You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
591 lines
20 KiB
C#
591 lines
20 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.MvcShipping.Models.MsOp_InternalTrade;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using HcUtility.Comm;
|
|
using System.Web.Mvc;//ContentResult
|
|
using DSWeb.TruckMng.Helper.Repository;//ModelObjectRepository
|
|
using DSWeb.MvcShipping.Helper;
|
|
using DSWeb.Areas.CommMng.DAL;//使用获取权限子句
|
|
using DSWeb.Areas.SysMng.DAL.SysTask;
|
|
using DSWeb.Common.DB;
|
|
using System.Linq;
|
|
using DSWeb.MvcShipping.DAL.MsOpSeaeDAL;
|
|
|
|
namespace DSWeb.Areas.MvcShipping.DAL.DJYORDER_CONTRACTNO
|
|
{
|
|
public class DJYORDER_CONTRACTNODAL
|
|
{
|
|
#region 大简云订舱 船公司合约 头表 查询
|
|
|
|
|
|
const string HeadSql = " SELECT * FROM DJYORDER_CONTRACTNO where 1=1 ";
|
|
|
|
|
|
public static List<DJYORDER_CONTRACTNO_md> GetDataList(int start, int limit, string sort, string condition, VW_user_md userinfo, ref int count)
|
|
{
|
|
//range
|
|
var rangestr = GetRangDAStr(userinfo);
|
|
|
|
//condition
|
|
var strCondition = condition;
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort); ;
|
|
|
|
var param = new BasicDataRefDAL.PagedQuaryParam();
|
|
param.strSql = HeadSql;
|
|
param.strCondition = strCondition;
|
|
param.rangestr = rangestr;
|
|
param.sortstring = sortstring;
|
|
param.defaultsortstr = "CREATETIME desc";
|
|
param.start = start;
|
|
param.limit = limit;
|
|
|
|
var strSql = BasicDataRefDAL.PagedQuaryStr(param);
|
|
|
|
count = BasicDataRefDAL.PagedCount(param);
|
|
|
|
return SetData(strSql);
|
|
|
|
}
|
|
|
|
public static string GetDataListStr(string condition, VW_user_md userinfo)
|
|
{
|
|
|
|
//range
|
|
|
|
var rangestr = GetRangDAStr(userinfo);
|
|
|
|
|
|
//condition
|
|
var strCondition = "";
|
|
|
|
var sortstring = "";
|
|
|
|
var param = new BasicDataRefDAL.PagedQuaryParam();
|
|
param.strSql = HeadSql;
|
|
param.strCondition = strCondition;
|
|
param.rangestr = rangestr;
|
|
param.sortstring = sortstring;
|
|
param.defaultsortstr = "ETA desc";
|
|
param.start = 0;
|
|
param.limit = 9999;
|
|
|
|
var strSql = BasicDataRefDAL.PagedQuaryStr(param);
|
|
|
|
return strSql.ToString();
|
|
|
|
}
|
|
|
|
private static List<DJYORDER_CONTRACTNO_md> SetData(System.Text.StringBuilder strSql)
|
|
{
|
|
var bodyList = new List<DJYORDER_CONTRACTNO_md>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
DJYORDER_CONTRACTNO_md data = new DJYORDER_CONTRACTNO_md();
|
|
#region Set DB data to Object
|
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
data.CARRIER = Convert.ToString(reader["CARRIER"]);
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
data.contractType = Convert.ToString(reader["contractType"]);
|
|
data.CONTACTTITLE = Convert.ToString(reader["CONTACTTITLE"]);
|
|
|
|
|
|
data.ShipperName = Convert.ToString(reader["ShipperName"]);
|
|
data.ShipperAddress = Convert.ToString(reader["ShipperAddress"]);
|
|
data.ShipperCountry = Convert.ToString(reader["ShipperCountry"]);
|
|
data.ShipperProvince = Convert.ToString(reader["ShipperProvince"]);
|
|
data.ShipperCity = Convert.ToString(reader["ShipperCity"]);
|
|
data.ShipperCounty = Convert.ToString(reader["ShipperCounty"]);
|
|
data.ShipperPostCode = Convert.ToString(reader["ShipperPostCode"]);
|
|
data.ShipperFirstName = Convert.ToString(reader["ShipperFirstName"]);
|
|
data.ShipperLastName = Convert.ToString(reader["ShipperLastName"]);
|
|
data.ShipperPhoneCountryCode = Convert.ToString(reader["ShipperPhoneCountryCode"]);
|
|
data.ShipperPhoneCode = Convert.ToString(reader["ShipperPhoneCode"]);
|
|
data.ShipperPhone = Convert.ToString(reader["ShipperPhone"]);
|
|
data.ShipperPhoneExtension = Convert.ToString(reader["ShipperPhoneExtension"]);
|
|
|
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
data.ORDER_CUSTCODE = Convert.ToString(reader["ORDER_CUSTCODE"]);
|
|
data.ORDER_CUSTNAME = Convert.ToString(reader["ORDER_CUSTNAME"]);
|
|
data.Shipper = Convert.ToString(reader["Shipper"]);
|
|
|
|
data.NamedAccount = Convert.ToString(reader["NamedAccount"]);
|
|
#endregion
|
|
|
|
bodyList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
return bodyList;
|
|
}
|
|
|
|
public static string GetRangDAStr(VW_user_md userinfo)
|
|
{
|
|
string str = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modDJYORDER_CONTRACTNO' and USERID='" + userinfo.USERID + "' and ISDELETE=0");
|
|
|
|
string visiblerange = "4";
|
|
string operaterange = "4";
|
|
string AUTHORITYID = "";
|
|
string VSSQL = "";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
VSSQL = Convert.ToString(reader["VSSQL"]);
|
|
break;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
if (visiblerange == "3" || visiblerange == "2"|| visiblerange == "5"|| visiblerange == "6") {
|
|
visiblerange = "1";
|
|
}
|
|
|
|
if (visiblerange == "4")
|
|
{
|
|
str = "1=2";
|
|
}
|
|
//else if (visiblerange == "3")
|
|
//{
|
|
|
|
// str = " (INPUTBY='" + userinfo.SHOWNAME + "' OR SALE='" + userinfo.SHOWNAME + "' )";
|
|
|
|
//}
|
|
//else if (visiblerange == "2")
|
|
//{
|
|
// str = $" (DEPT='{userinfo.deptgid}' or SALEDEPT='{userinfo.deptgid}') ";
|
|
|
|
//}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = $" UPPER(CORPID)='{userinfo.COMPANYID}' ";
|
|
}
|
|
else if (visiblerange == "5")
|
|
{
|
|
|
|
var userstr = new StringBuilder();
|
|
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userinfo.USERID + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
{
|
|
str = "";
|
|
while (reader.Read())
|
|
{
|
|
if (str == "")
|
|
{
|
|
str = $" (Corpid='{userinfo.COMPANYID}' ";
|
|
}
|
|
else
|
|
{
|
|
str = str + $" or Corpid='{userinfo.COMPANYID}' ";
|
|
};
|
|
}
|
|
str = str + ")";
|
|
reader.Close();
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
public static List<VW_DJYORDER_LASTConsignee_2_md> GetLASTConsignee(string ConsigneeName, string CARRIER = "")
|
|
{
|
|
var result = new List<VW_DJYORDER_LASTConsignee_2_md>();
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
result = cdc.VW_DJYORDER_LASTConsignee_2.Where(x=>x.CARRIER==CARRIER && x.ConsigneeName.Contains(ConsigneeName))
|
|
.OrderByDescending(x => x._count).ThenByDescending(x => x.CreateTime)
|
|
.ToList();
|
|
|
|
return result;
|
|
}
|
|
|
|
public static List<VW_DJYORDER_LASTNotifypart_2_md> GetLASTNotifypart(string NotifypartName,string CARRIER="")
|
|
{
|
|
var result = new List<VW_DJYORDER_LASTNotifypart_2_md>();
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
result = cdc.VW_DJYORDER_LASTNotifypart_2.Where(x => x.CARRIER == CARRIER && x.NotifypartName.Contains(NotifypartName))
|
|
.OrderByDescending(x => x._count).ThenByDescending(x => x.CreateTime)
|
|
.ToList();
|
|
|
|
return result;
|
|
}
|
|
|
|
public static List<VW_DJYORDER_LASTShipper_2_md> GetLASTShipper(string ShipperName, string CARRIER = "")
|
|
{
|
|
var result = new List<VW_DJYORDER_LASTShipper_2_md>();
|
|
|
|
var cdc = new CommonDataContext();
|
|
|
|
result = cdc.VW_DJYORDER_LASTShipper_2.Where(x => x.CARRIER == CARRIER && x.ShipperName.Contains(ShipperName))
|
|
.OrderByDescending(x => x._count).ThenByDescending(x => x.CreateTime)
|
|
.ToList();
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult DoSendDjyOrder_COSCO(string USERID, string BSNO, string str, string FileGidList = "")
|
|
{
|
|
|
|
var canmake = new DBResult();
|
|
var hp = 大简云订舱邮件Helper.GetOpseae_COSCO(BSNO, USERID, str, out canmake);
|
|
|
|
//20240423test
|
|
hp.SaveDjyOrder();
|
|
|
|
if (!canmake.Success)
|
|
{
|
|
return canmake;
|
|
}
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
//20240312 用formdata方式发送post请求
|
|
|
|
result = hp.SendFormdataPost(USERID);
|
|
|
|
if (!result.Success)
|
|
{
|
|
return result;
|
|
|
|
//20240423
|
|
//hp.SaveDjyOrder();
|
|
}
|
|
|
|
result = hp.SendEmail_Opseae(USERID, BSNO, FileGidList);
|
|
return result;
|
|
}
|
|
|
|
public static DBResult DoSendDjyOrder_EMC(string USERID, string BSNO, string str, string FileGidList = "")
|
|
{
|
|
|
|
var canmake = new DBResult();
|
|
var hp = 大简云订舱邮件Helper.GetOpseae_EMC(BSNO, USERID, str, out canmake);
|
|
|
|
//20240423test
|
|
hp.SaveDjyOrder();
|
|
|
|
if (!canmake.Success)
|
|
{
|
|
return canmake;
|
|
}
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
//result=hp.SendEmail_Opseae(USERID, BSNO, FileGidList);
|
|
//result.OK();
|
|
|
|
//20240429 增加判断 判断船名航次是否正确
|
|
//如不正确则弹出选框令用户自行选择 选框内容为吴广接口返回的船名航次列表
|
|
result = hp.CheckShipinfo_EMC(USERID);
|
|
|
|
hp.设置收货地_EMC(USERID);
|
|
|
|
if (!result.Success)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//20240312 用formdata方式发送post请求
|
|
|
|
result = hp.SendFormdataPost(USERID);
|
|
|
|
if (!result.Success)
|
|
{
|
|
return result;
|
|
|
|
//20240423
|
|
//hp.SaveDjyOrder();
|
|
}
|
|
|
|
result = hp.SendEmail_Opseae(USERID, BSNO, FileGidList);
|
|
return result;
|
|
}
|
|
|
|
public static DBResult DoSendDjyOrder_ONE(string USERID, string BSNO, string str, string FileGidList = "")
|
|
{
|
|
|
|
var canmake = new DBResult();
|
|
var hp = 大简云订舱邮件Helper.GetOpseae_ONE(BSNO, USERID, str, out canmake);
|
|
|
|
//20240423test
|
|
hp.SaveDjyOrder();
|
|
|
|
if (!canmake.Success)
|
|
{
|
|
return canmake;
|
|
}
|
|
|
|
|
|
var result = new DBResult();
|
|
|
|
//result=hp.SendEmail_Opseae(USERID, BSNO, FileGidList);
|
|
//result.OK();
|
|
|
|
//20240429 增加判断 判断船名航次是否正确
|
|
//如不正确则弹出选框令用户自行选择 选框内容为吴广接口返回的船名航次列表
|
|
result = hp.CheckShipinfo_ONE(USERID);
|
|
|
|
//hp.设置收货地_EMC(USERID);
|
|
|
|
if (!result.Success)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//20240312 用formdata方式发送post请求
|
|
|
|
result = hp.SendFormdataPost(USERID);
|
|
|
|
if (!result.Success)
|
|
{
|
|
return result;
|
|
|
|
//20240423
|
|
//hp.SaveDjyOrder();
|
|
}
|
|
|
|
result = hp.SendEmail_Opseae(USERID, BSNO, FileGidList);
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public class DJYORDER_ACCOUNTINFODAL
|
|
{
|
|
#region 大简云订舱 船公司账号密码 头表 查询
|
|
|
|
|
|
const string HeadSql = " SELECT * FROM DJYORDER_ACCOUNTINFO where 1=1 ";
|
|
|
|
|
|
public static List<DJYORDER_ACCOUNTINFO_md> GetDataList(int start, int limit, string sort, string condition, VW_user_md userinfo, ref int count)
|
|
{
|
|
//range
|
|
var rangestr = GetRangDAStr(userinfo);
|
|
|
|
//condition
|
|
var strCondition = condition;
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort); ;
|
|
|
|
var param = new BasicDataRefDAL.PagedQuaryParam();
|
|
param.strSql = HeadSql;
|
|
param.strCondition = strCondition;
|
|
param.rangestr = rangestr;
|
|
param.sortstring = sortstring;
|
|
param.defaultsortstr = "CREATETIME desc";
|
|
param.start = start;
|
|
param.limit = limit;
|
|
|
|
var strSql = BasicDataRefDAL.PagedQuaryStr(param);
|
|
|
|
count = BasicDataRefDAL.PagedCount(param);
|
|
|
|
return SetData(strSql);
|
|
|
|
}
|
|
|
|
public static string GetDataListStr(string condition, VW_user_md userinfo)
|
|
{
|
|
|
|
//range
|
|
|
|
var rangestr = GetRangDAStr(userinfo);
|
|
|
|
|
|
//condition
|
|
var strCondition = "";
|
|
|
|
var sortstring = "";
|
|
|
|
var param = new BasicDataRefDAL.PagedQuaryParam();
|
|
param.strSql = HeadSql;
|
|
param.strCondition = strCondition;
|
|
param.rangestr = rangestr;
|
|
param.sortstring = sortstring;
|
|
param.defaultsortstr = "CREATETIME desc";
|
|
param.start = 0;
|
|
param.limit = 9999;
|
|
|
|
var strSql = BasicDataRefDAL.PagedQuaryStr(param);
|
|
|
|
return strSql.ToString();
|
|
|
|
}
|
|
|
|
private static List<DJYORDER_ACCOUNTINFO_md> SetData(System.Text.StringBuilder strSql)
|
|
{
|
|
var bodyList = new List<DJYORDER_ACCOUNTINFO_md>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
DJYORDER_ACCOUNTINFO_md data = new DJYORDER_ACCOUNTINFO_md();
|
|
#region Set DB data to Object
|
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.CORPID = Convert.ToString(reader["CORPID"]);
|
|
data.CARRIER = Convert.ToString(reader["CARRIER"]);
|
|
data.ACCOUNT = Convert.ToString(reader["ACCOUNT"]);
|
|
data.ACCOUNTPSW = Convert.ToString(reader["ACCOUNTPSW"]);
|
|
|
|
data.BookingCONTACTTITLE = Convert.ToString(reader["BookingCONTACTTITLE"]);
|
|
|
|
data.BookingName = Convert.ToString(reader["BookingName"]);
|
|
data.BookingAddress = Convert.ToString(reader["BookingAddress"]);
|
|
data.BookingCountry = Convert.ToString(reader["BookingCountry"]);
|
|
data.BookingProvince = Convert.ToString(reader["BookingProvince"]);
|
|
data.BookingCity = Convert.ToString(reader["BookingCity"]);
|
|
data.BookingCounty = Convert.ToString(reader["BookingCounty"]);
|
|
data.BookingPostCode = Convert.ToString(reader["BookingPostCode"]);
|
|
data.BookingFirstName = Convert.ToString(reader["BookingFirstName"]);
|
|
data.BookingLastName = Convert.ToString(reader["BookingLastName"]);
|
|
data.BookingPhoneCountryCode = Convert.ToString(reader["BookingPhoneCountryCode"]);
|
|
data.BookingPhoneCode = Convert.ToString(reader["BookingPhoneCode"]);
|
|
data.BookingPhone = Convert.ToString(reader["BookingPhone"]);
|
|
data.BookingPhoneExtension = Convert.ToString(reader["BookingPhoneExtension"]);
|
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
#endregion
|
|
|
|
bodyList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
return bodyList;
|
|
}
|
|
|
|
public static string GetRangDAStr(VW_user_md userinfo)
|
|
{
|
|
string str = "";
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modDJYORDER_ACCOUNTINFO' and USERID='" + userinfo.USERID + "' and ISDELETE=0");
|
|
|
|
string visiblerange = "4";
|
|
string operaterange = "4";
|
|
string AUTHORITYID = "";
|
|
string VSSQL = "";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
|
|
while (reader.Read())
|
|
{
|
|
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
|
|
operaterange = Convert.ToString(reader["OPERATERANGE"]);
|
|
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
|
|
VSSQL = Convert.ToString(reader["VSSQL"]);
|
|
break;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
if (visiblerange == "3" || visiblerange == "2" || visiblerange == "5" || visiblerange == "6")
|
|
{
|
|
visiblerange = "1";
|
|
}
|
|
|
|
if (visiblerange == "4")
|
|
{
|
|
str = "1=2";
|
|
}
|
|
//else if (visiblerange == "3")
|
|
//{
|
|
|
|
// str = " (INPUTBY='" + userinfo.SHOWNAME + "' OR SALE='" + userinfo.SHOWNAME + "' )";
|
|
|
|
//}
|
|
//else if (visiblerange == "2")
|
|
//{
|
|
// str = $" (DEPT='{userinfo.deptgid}' or SALEDEPT='{userinfo.deptgid}') ";
|
|
|
|
//}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = $" UPPER(CORPID)='{userinfo.COMPANYID}' ";
|
|
}
|
|
else if (visiblerange == "5")
|
|
{
|
|
|
|
var userstr = new StringBuilder();
|
|
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userinfo.USERID + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
|
|
Database userdb = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
|
|
{
|
|
str = "";
|
|
while (reader.Read())
|
|
{
|
|
if (str == "")
|
|
{
|
|
str = $" (Corpid='{userinfo.COMPANYID}' ";
|
|
}
|
|
else
|
|
{
|
|
str = str + $" or Corpid='{userinfo.COMPANYID}' ";
|
|
};
|
|
}
|
|
str = str + ")";
|
|
reader.Close();
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|