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.
DS7/Job_JieFeng_FTP/DataSave.cs

2239 lines
74 KiB
C#

3 years ago
using HcUtility.Core;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Xml;
namespace Job_JieFeng_FTP
{
[JsonObject]
public class FTP_SeaeOrderMC //op_seaeorder
{
#region private Fields
private string _BSNO = string.Empty;
private string _ORSTATUS = string.Empty;
private string _BSDATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
private string _MBLNO = string.Empty;
private string _CUSTOMERNAME = string.Empty;
private string _SHIPPER = string.Empty;
private string _CONSIGNEE = string.Empty;
private string _NOTIFYPARTY = string.Empty;
private string _CARRIER = string.Empty;
private string _VESSEL = string.Empty;
private string _VOYNO = string.Empty;
private string _ETD = string.Empty;
private string _PlACERECEIPT = string.Empty;
private string _PORTLOADID = string.Empty;
private string _PORTLOAD = string.Empty;
private string _PORTDISCHARGEID = string.Empty;
private string _PORTDISCHARGE = string.Empty;
private string _PLACEDELIVERYID = string.Empty;
private string _PLACEDELIVERY = string.Empty;
private string _DESTINATIONID = string.Empty;
private string _DESTINATION = string.Empty;
private string _NOBILL = string.Empty;
private string _ISSUETYPE = string.Empty;
private string _ISSUEDATE = string.Empty;
private string _ISSUEPLACE = string.Empty;
private string _BLFRT = string.Empty;
private string _PREPARDAT = string.Empty;
private string _PAYABLEAT = string.Empty;
private string _SERVICE = string.Empty;
private string _MARKS = string.Empty;
private string _NOPKGS = string.Empty;
private string _DESCRIPTION = string.Empty;
private string _GOODSNAME = string.Empty;
private string _GROSSWEIGHT = string.Empty;
private string _MEASUREMENT = string.Empty;
private string _PKGS = "0";
private string _KINDPKGS = string.Empty;
private string _KGS = "0";
private string _CBM = "0";
private string _TOTALNO = string.Empty;
private string _CNTRTOTAL = string.Empty;
private string _INPUTBY = string.Empty;
private string _INVNO = string.Empty;
private string _CARGOID = string.Empty;
private string _DCLASS = string.Empty;
private string _DUNNO = string.Empty;
private string _REEFERF = string.Empty;
private string _TEMPID = string.Empty;
private string _TEMPSET = string.Empty;
private string _TEMPMAX = string.Empty;
private string _TEMPMIN = string.Empty;
private string _CUSTOMSNUM = "0";
private string _REMARK = string.Empty;
private string _DPAGE = string.Empty;
private string _DLABEL = string.Empty;
private string _LANE = string.Empty;
private string _SERVICECONTRACTNO = string.Empty;
#endregion
#region R&W
[ModelDB(MDBType = ModelDBOprationType.All, IsPrimary = true)]
public string BSNO
{
get { return _BSNO; }
set { _BSNO = value; }
}
[ModelDB]
public string ORSTATUS
{
get { return _ORSTATUS; }
set { _ORSTATUS = value; }
}
[ModelDB]
public string BSDATE
{
get { return _BSDATE; }
set { _BSDATE = value; }
}
[ModelDB]
public string MBLNO
{
get { return _MBLNO; }
set { _MBLNO = value; }
}
[ModelDB]
public string CUSTOMERNAME
{
get { return _CUSTOMERNAME; }
set { _CUSTOMERNAME = value; }
}
[ModelDB]
public string SHIPPER
{
get { return _SHIPPER; }
set { _SHIPPER = value; }
}
[ModelDB]
public string CONSIGNEE
{
get { return _CONSIGNEE; }
set { _CONSIGNEE = value; }
}
[ModelDB]
public string NOTIFYPARTY
{
get { return _NOTIFYPARTY; }
set { _NOTIFYPARTY = value; }
}
[ModelDB]
public string CARRIER
{
get { return _CARRIER; }
set { _CARRIER = value; }
}
[ModelDB]
public string VESSEL
{
get { return _VESSEL; }
set { _VESSEL = value; }
}
[ModelDB]
public string VOYNO
{
get { return _VOYNO; }
set { _VOYNO = value; }
}
[ModelDB]
public string ETD
{
get { return _ETD; }
set { _ETD = value; }
}
[ModelDB]
public string PlACERECEIPT
{
get { return _PlACERECEIPT; }
set { _PlACERECEIPT = value; }
}
[ModelDB]
public string PORTLOADID
{
get { return _PORTLOADID; }
set { _PORTLOADID = value; }
}
[ModelDB]
public string PORTLOAD
{
get { return _PORTLOAD; }
set { _PORTLOAD = value; }
}
[ModelDB]
public string PORTDISCHARGEID
{
get { return _PORTDISCHARGEID; }
set { _PORTDISCHARGEID = value; }
}
[ModelDB]
public string PORTDISCHARGE
{
get { return _PORTDISCHARGE; }
set { _PORTDISCHARGE = value; }
}
[ModelDB]
public string PLACEDELIVERYID
{
get { return _PLACEDELIVERYID; }
set { _PLACEDELIVERYID = value; }
}
[ModelDB]
public string PLACEDELIVERY
{
get { return _PLACEDELIVERY; }
set { _PLACEDELIVERY = value; }
}
[ModelDB]
public string DESTINATIONID
{
get { return _DESTINATIONID; }
set { _DESTINATIONID = value; }
}
[ModelDB]
public string DESTINATION
{
get { return _DESTINATION; }
set { _DESTINATION = value; }
}
[ModelDB]
public string NOBILL
{
get { return _NOBILL; }
set { _NOBILL = value; }
}
[ModelDB]
public string ISSUETYPE
{
get { return _ISSUETYPE; }
set { _ISSUETYPE = value; }
}
[ModelDB]
public string ISSUEDATE
{
get { return _ISSUEDATE; }
set { _ISSUEDATE = value; }
}
[ModelDB]
public string ISSUEPLACE
{
get { return _ISSUEPLACE; }
set { _ISSUEPLACE = value; }
}
[ModelDB]
public string BLFRT
{
get { return _BLFRT; }
set { _BLFRT = value; }
}
[ModelDB]
public string PREPARDAT
{
get { return _PREPARDAT; }
set { _PREPARDAT = value; }
}
[ModelDB]
public string PAYABLEAT
{
get { return _PAYABLEAT; }
set { _PAYABLEAT = value; }
}
[ModelDB]
public string SERVICE
{
get { return _SERVICE; }
set { _SERVICE = value; }
}
[ModelDB]
public string MARKS
{
get { return _MARKS; }
set { _MARKS = value; }
}
[ModelDB]
public string NOPKGS
{
get { return _NOPKGS; }
set { _NOPKGS = value; }
}
[ModelDB]
public string DESCRIPTION
{
get { return _DESCRIPTION; }
set { _DESCRIPTION = value; }
}
[ModelDB]
public string GOODSNAME
{
get { return _GOODSNAME; }
set { _GOODSNAME = value; }
}
[ModelDB]
public string GROSSWEIGHT
{
get { return _GROSSWEIGHT; }
set { _GROSSWEIGHT = value; }
}
[ModelDB]
public string MEASUREMENT
{
get { return _MEASUREMENT; }
set { _MEASUREMENT = value; }
}
[ModelDB]
public string PKGS
{
get { return _PKGS; }
set { _PKGS = value; }
}
[ModelDB]
public string KINDPKGS
{
get { return _KINDPKGS; }
set { _KINDPKGS = value; }
}
[ModelDB]
public string KGS
{
get { return _KGS; }
set { _KGS = value; }
}
[ModelDB]
public string CBM
{
get { return _CBM; }
set { _CBM = value; }
}
[ModelDB]
public string TOTALNO
{
get { return _TOTALNO; }
set { _TOTALNO = value; }
}
[ModelDB]
public string CNTRTOTAL
{
get { return _CNTRTOTAL; }
set { _CNTRTOTAL = value; }
}
[ModelDB]
public string INPUTBY
{
get { return _INPUTBY; }
set { _INPUTBY = value; }
}
[ModelDB]
public string INVNO
{
get { return _INVNO; }
set { _INVNO = value; }
}
[ModelDB]
public string CARGOID
{
get { return _CARGOID; }
set { _CARGOID = value; }
}
[ModelDB]
public string DCLASS
{
get { return _DCLASS; }
set { _DCLASS = value; }
}
[ModelDB]
public string DUNNO
{
get { return _DUNNO; }
set { _DUNNO = value; }
}
[ModelDB]
public string REEFERF
{
get { return _REEFERF; }
set { _REEFERF = value; }
}
[ModelDB]
public string TEMPID
{
get { return _TEMPID; }
set { _TEMPID = value; }
}
[ModelDB]
public string TEMPSET
{
get { return _TEMPSET; }
set { _TEMPSET = value; }
}
[ModelDB]
public string TEMPMAX
{
get { return _TEMPMAX; }
set { _TEMPMAX = value; }
}
[ModelDB]
public string TEMPMIN
{
get { return _TEMPMIN; }
set { _TEMPMIN = value; }
}
[ModelDB]
public string CUSTOMSNUM
{
get { return _CUSTOMSNUM; }
set { _CUSTOMSNUM = value; }
}
[ModelDB]
public string REMARK
{
get { return _REMARK; }
set { _REMARK = value; }
}
[ModelDB]
public string DPAGE
{
get { return _DPAGE; }
set { _DPAGE = value; }
}
[ModelDB]
public string DLABEL
{
get { return _DLABEL; }
set { _DLABEL = value; }
}
[ModelDB]
public string LANE
{
get { return _LANE; }
set { _LANE = value; }
}
[ModelDB]
public string SERVICECONTRACTNO
{
get { return _SERVICECONTRACTNO; }
set { _SERVICECONTRACTNO = value; }
}
public string CUSTATTN { get; set; }
public string CUSTTEL { get; set; }
public string 退 { get { return "'EDI订舱退舱'"; } }
public string { get { return "'EDI订舱修改'"; } }
public string { get { return "'EDI订舱'"; } }
#endregion
#region 简易分解XML
private XmlDocument _root { get; set; }
XmlNode root { get { return XmlReader.GetFirstChildNodeByName(_root, "v4:Order", nsp); } }
XmlNode DataArea
{
get
{
return XmlReader.GetFirstChildNodeByName(root, "DataArea", nsp);
}
}
#region 增删标记
XmlNode Action
{
get
{
return XmlReader.GetFirstChildNodeByName(DataArea, "Action", nsp);
}
}
public string {
get {
XmlNode ActionCode = XmlReader.GetFirstChildNodeByName(Action, "ActionCode", nsp);
return XmlReader.ReadNodeText(ActionCode);
}
}
public string str
{
get
{
if ( == "9") return "";
if ( == "5") return "";
if ( == "1") return "【退舱】\r\n";
return "";
}
}
public string
{
get
{
if ( == "9") return $"(case when exists (select 1 from t_op_task where 提单号='{CUSTNO}' and [任务类型]={退舱任务类型}) then {修改任务类型} else {新增任务类型} end)";
if ( == "5") return $"{修改任务类型}";
if ( == "1") return "'EDI订舱退舱'";
return "";
}
}
#endregion
#region 联系人联系方式
XmlNode MessageContact
{
get
{
return XmlReader.GetFirstChildNodeByName(DataArea, "MessageContact", nsp);
}
}
XmlNode SimsID
{
get
{
return XmlReader.GetFirstChildNodeByName(MessageContact, "SimsID", nsp);
}
}
string {
get
{
return XmlReader.ReadNodeText(SimsID);
}
}
string
{
get
{
var ContactCommunicationList = XmlReader.GetChildNodesByName(MessageContact, "ContactCommunication");
foreach (XmlNode item in ContactCommunicationList) {
string Type = XmlReader.ReadFirstChildNodeTextByName(item, "Type");
if (Type == "TE") {
return XmlReader.ReadFirstChildNodeTextByName(item, "CommID");
}
}
return "";
}
}
string
{
get
{
var ContactCommunicationList = XmlReader.GetChildNodesByName(MessageContact, "ContactCommunication");
foreach (XmlNode item in ContactCommunicationList)
{
string Type = XmlReader.ReadFirstChildNodeTextByName(item, "Type");
if (Type == "EM")
{
return XmlReader.ReadFirstChildNodeTextByName(item, "CommID");
}
}
return "";
}
}
#endregion
private XmlNode OrderDescription
{
get
{
return XmlReader.GetFirstChildNodeByName(DataArea, "OrderDescription");
}
}
#region 付费方式
private XmlNode TransportConditions
{
get
{
return XmlReader.GetFirstChildNodeByName(OrderDescription, "TransportConditions");
}
}
private XmlNode PaymentTerm
{
get
{
return XmlReader.GetFirstChildNodeByName(TransportConditions, "PaymentTerm");
}
}
private string _PaymentTerm()
{
return XmlReader.ReadNodeText( XmlReader.GetFirstChildNodeByName(TransportConditions, "PaymentTerm")).ToUpper();
}
private string {
get {
if (_PaymentTerm() == "CC") return "FREIGHT COLLECT";
if (_PaymentTerm() == "PP") return "FREIGHT PREPAID";
return "";
}
}
private string {
get
{
if (_PaymentTerm() == "CC") {
return ();
}
if (_PaymentTerm() == "PP") {
return ();
}
return "";
}
}
#endregion
public XmlNode Identification { get { return XmlReader.GetFirstChildNodeByName(OrderDescription, "Identification"); } }
public XmlNode UniqueOrderNumber { get { return XmlReader.GetFirstChildNodeByName(Identification, "UniqueOrderNumber"); } }
public XmlNode OrderReason { get { return XmlReader.GetFirstChildNodeByName(Identification, "OrderReason"); } }
public string legCounter { get { return XmlReader.ReadAttrValue(UniqueOrderNumber, "legCounter"); } }
public string CUSTNO { get { return XmlReader.ReadNodeText(UniqueOrderNumber); } }
public string BLTYPE{ get { return XmlReader.ReadNodeText(OrderReason); } }
private XmlNodeList PartnerList
{
get
{
return XmlReader.GetChildNodesByName(OrderDescription, "Partner");
}
}
#region 相关外围公司:委托单位 发货人 收货人 通知人
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Partner", "roleCode", "OY", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Partner", "roleCode", "CZ", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Partner", "roleCode", "CN", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Partner", "roleCode", "N1", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Partner", "roleCode", "CA", nsp);
}
}
public static string getMBLNO(XmlNode OrderDescription, XmlNamespaceManager nsp)
{
var MBLNO = XmlReader.getNodeByAttr(OrderDescription, "MasterNumber", "agencyID", "CA", nsp);
if (MBLNO != null)
return XmlReader.ReadNodeText(MBLNO);
else return "";
}
private string companyname(XmlNode comp)
{
var result = "";
try
{
var Address = XmlReader.GetFirstChildNodeByName(comp, "Address", nsp);
if (Address == null) return "";
var AddressDetails = XmlReader.GetChildNodesByName(Address, "AddressDetails", nsp);
foreach (XmlNode item in AddressDetails)
{
var AddressDetailShared = XmlReader.GetFirstChildNodeByName(item, "AddressDetailShared", nsp);
var Language = XmlReader.ReadFirstChildNodeTextByName(AddressDetailShared, "Language", nsp);
if (Language == "en")
{
var PrintPreview = XmlReader.GetChildNodesByName(AddressDetailShared, "PrintPreview", nsp);
foreach (XmlNode pp in PrintPreview)
{
if (result != "") result += "\r\n";
result += XmlReader.ReadFirstChildNodeTextByName(pp, "PrintLine", nsp);
}
return result;
}
//if (Language == "zhCN")
//{
// var Name = XmlReader.GetFirstChildNodeByName(AddressDetailShared, "Name", nsp);
// result = XmlReader.ReadFirstChildNodeTextByName(Name, "Name", nsp);
// return result;
//}
}
}
catch{
return result;
}
return result;
}
private string companyshortname(XmlNode comp)
{
var result = "";
var Address = XmlReader.GetFirstChildNodeByName(comp, "Address", nsp);
if (Address == null) return "";
var AddressDetails = XmlReader.GetChildNodesByName(Address, "AddressDetails", nsp);
foreach (XmlNode item in AddressDetails)
{
var AddressDetailShared = XmlReader.GetFirstChildNodeByName(item, "AddressDetailShared", nsp);
var Language = XmlReader.ReadFirstChildNodeTextByName(AddressDetailShared, "Language", nsp);
if (Language == "en")
{
var Name = XmlReader.GetFirstChildNodeByName(AddressDetailShared, "Name", nsp);
result = XmlReader.ReadFirstChildNodeTextByName(Name, "Name", nsp);
return result;
}
//if (Language == "zhCN")
//{
// var Name = XmlReader.GetFirstChildNodeByName(AddressDetailShared, "Name", nsp);
// result = XmlReader.ReadFirstChildNodeTextByName(Name, "Name", nsp);
// return result;
//}
}
return result;
}
#endregion
#region 航程 分段的航行路径
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Legs", "legCounter", legCounter, nsp);
}
}
private XmlNodeList {
get
{
return XmlReader.GetChildNodesByName(OrderDescription, "Legs", nsp);
}
}
private Int32 {
get { return .Count; }
}
private string get(XmlNode ) {
var vessel = XmlReader.getNodeByAttr(, "TransportMeansName", "type", "VesselName", nsp);
return XmlReader.ReadNodeText(vessel);
}
private string get(XmlNode )
{
return XmlReader.ReadFirstChildNodeTextByName(, "ConveyanceNumber");
}
private string getContractNo() {
var Carrier = XmlReader.GetFirstChildNodeByName(, "Carrier", nsp);
var ContractNumber = XmlReader.getNodeByAttr(Carrier, "ReferenceID", "referenceQualifier", "ContractNumber", nsp);
return XmlReader.ReadNodeText(ContractNumber);
}
#endregion
#region 地点
private XmlNodeList
{
get
{
return XmlReader.GetChildNodesByName(OrderDescription, "Locations", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Locations", "type", "DES", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Locations", "type", "DEP", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Locations", "type", "POR", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Locations", "type", "FDEL", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Locations", "type", "CY/O", nsp);
}
}
private XmlNode
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "Locations", "type", "CY/D", nsp);
}
}
private string (XmlNode ) {
if ( == null) return "";
return XmlReader.ReadFirstChildNodeTextByName(, "LocationName");
}
private string ID(XmlNode )
{
if ( == null) return "";
var idnode = XmlReader.getNodeByAttr(, "LocationID", "codeType", "UNLOCODE", nsp);
return XmlReader.ReadNodeText(idnode);
}
#endregion
#region 日期
//private XmlNodeList 所有日期
//{
// get
// {
// return XmlReader.GetChildNodesByName(OrderDescription, "DateTimes", nsp);
// }
//}
private XmlNode node
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "DateTimes", "type", "133", nsp);
}
}
private XmlNode node
{
get
{
return XmlReader.getNodeByAttr(OrderDescription, "DateTimes", "type", "132", nsp);
}
}
private string {
get {
var datestr = XmlReader.ReadFirstChildNodeTextByName(node, "Date");
return datestr.Substring(0, 10);
}
}
private string
{
get
{
var datestr = XmlReader.ReadFirstChildNodeTextByName(node, "Date");
return datestr.Substring(0, 10);
}
}
#endregion
private string
{
get
{
//运输条款表 条款list = new 运输条款表();
var result = "";
var _node= XmlReader.GetFirstChildNodeByName(OrderDescription, "ServiceRequest", nsp);
if (_node == null) { } else {
var = XmlReader.ReadFirstChildNodeTextByName(_node, "ServiceType");
var = "";
if (dic.TryGetValue(, out ))
{
result = ;
}
if (result == "") result = ;
}
return result;
}
}
private string
{
get
{
var result = "正本";
var _node = XmlReader.GetFirstChildNodeByName(OrderDescription, "ServiceRequest", nsp);
if (_node != null)
{
var node = XmlReader.GetFirstChildNodeByName(_node, "MoreServiceInfo");
if (node!= null){
var _r = XmlReader.ReadFirstChildNodeTextByName(node, "Text");
if (_r == "EXPRESS") {
result = "Seaway";
}
}
}
return result;
}
}
private string getRemark
{
get
{
var result = "";
var _remark = XmlReader.getNodeByAttr(, "AdditionalInformation", "type", "SIN", nsp);
if (_remark == null) return "";
var strarray = XmlReader.ReadChildNodeTexts(_remark);
foreach (string textline in strarray) {
if (result != "") result += "\r\n";
result += textline;
}
return result;
}
}
#region 集装箱信息 PackageOutToIn
private XmlNodeList
{
get
{
return XmlReader.GetChildNodesByName(OrderDescription, "PackageOutToIn", nsp);
}
}
private string getMarks() {
var result = "";
var mllist = new List<string>();
foreach (XmlNode PackageOutToIn in ) {
//var NextInnerPackage = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "NextInnerPackage", nsp);
var MarksAndLabels = XmlReader.GetChildNodesByName(PackageOutToIn, "MarksAndLabels", nsp);
var Trans = "";
var TransportEquipment = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "TransportEquipment", nsp);
if (TransportEquipment != null)
{
var TM = XmlReader.GetFirstChildNodeByName(TransportEquipment, "MarksAndLabels", nsp);
Trans = XmlReader.getmlstr(TM);
}
foreach (XmlNode ml in MarksAndLabels) {
var nml = XmlReader.getmlstr(ml);
if (nml == Trans)
{
}
else {
if (mllist.IndexOf(nml) >= 0)
{
}
else
{
mllist.Add(nml);
}
}
}
}
if (mllist.Count > 0) {
foreach (var nm in mllist) {
if (result != "")
{
result += "\r\n";
}
result += nm;
}
}
return result;
}
//直接获得pkgs信息
private string getKINDPKGS_0(List<PKGSEDI_MB> mpkglist)
{
var result = "";
var mllist = new List<string>();
foreach (XmlNode ctn in )
{
var _pkgs = FTP_SeaeOrderMC.getKINDPKGS_0(ctn, nsp,mpkglist);
if (mllist.IndexOf(_pkgs) >= 0)
{
}
else
{
if(!string.IsNullOrWhiteSpace( _pkgs))
mllist.Add(_pkgs);
}
}
if (mllist.Count >= 0)
{
foreach (var nm in mllist)
{
if (result != "") result += ",";
result += nm;
}
}
return result;
}
//private static string getPKGSByEDICODE(string EDICODE) {
// if (mpkglist.Exists(o => o.EDICODE == EDICODE))
// {
// var pkgs = PKGSEDI.FindAll(o => o.EDICODE == EDICODE);
// return pkgs[0].PKGS;
// }
// return "";
//}
private bool haveDangerous()
{
foreach (XmlNode ctn in )
{
var NextInnerPackages = XmlReader.GetChildNodesByName(ctn, "NextInnerPackage", nsp);
foreach (XmlNode NextInnerPackage in NextInnerPackages)
{
var Goods = XmlReader.GetChildNodesByName(NextInnerPackage, "Goods", nsp);
foreach (XmlNode good in Goods)
{
var DngrsGoods = XmlReader.GetFirstChildNodeByName(good, "DngrsGoods", nsp);
if (DngrsGoods != null) return true;
}
}
}
return false;
}
private bool haveFrozen()
{
foreach (XmlNode ctn in )
{
var NextInnerPackages = XmlReader.GetChildNodesByName(ctn, "NextInnerPackage", nsp);
foreach (XmlNode NextInnerPackage in NextInnerPackages)
{
var PackageDetails = XmlReader.GetChildNodesByName(NextInnerPackage, "PackageDetails", nsp);
foreach (XmlNode PackageDetail in PackageDetails)
{
var Measures = XmlReader.GetChildNodesByName(PackageDetail, "Measures", nsp);
foreach (XmlNode item in Measures)
{
if (XmlReader.ReadAttrValue(item, "type") == "TemperatureMax")
{
return true;
}
}
}
}
}
return false;
}
public static string getKINDPKGS_0(XmlNode PackageOutToIn, XmlNamespaceManager nsp, List<PKGSEDI_MB> mpkglist)
{
var result = "";
try
{
var NextInnerPackage = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "NextInnerPackage", nsp);
var PackageDetails = XmlReader.GetFirstChildNodeByName(NextInnerPackage, "PackageDetails", nsp);
var Package = XmlReader.GetFirstChildNodeByName(PackageDetails, "Package", nsp);
var _pkgs = XmlReader.ReadChildNodeTextsByName(Package, "PackageTypeCode", nsp);
result = _pkgs[0];
if (!string.IsNullOrEmpty(result)) {
var PKGS = mpkglist.Find(e => e.EDICODE == result);
if (PKGS != null) {
result = PKGS.PKGS;
}
}
return result;
}
catch {
return "";
}
}
public static string getPKGS(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var result = "0";
var NextInnerPackage = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "NextInnerPackage", nsp);
if (NextInnerPackage != null)
{
var PackageDetails = XmlReader.GetFirstChildNodeByName(NextInnerPackage, "PackageDetails", nsp);
if (PackageDetails != null)
{
var Measures = XmlReader.getNodeByAttr(PackageDetails, "Measures", "type", "NoUnits", nsp);
if (Measures == null) return "0";
result = XmlReader.ReadChildNodeTextsByName(Measures, "MeasureValue", nsp)[0];
}
}
return result;
}
public static string getKGS(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var result = "0";
var NextInnerPackage = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "NextInnerPackage", nsp);
if (NextInnerPackage != null)
{
var PackageDetails = XmlReader.GetFirstChildNodeByName(NextInnerPackage, "PackageDetails", nsp);
if (PackageDetails != null)
{
var Measures = XmlReader.getNodeByAttr(PackageDetails, "Measures", "type", "G", nsp);
if (Measures == null) return "0";
result = XmlReader.ReadChildNodeTextsByName(Measures, "MeasureValue", nsp)[0];
}
}
return result;
}
public static string getCBM(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var result = "0";
var NextInnerPackage = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "NextInnerPackage", nsp);
if (NextInnerPackage != null)
{
var PackageDetails = XmlReader.GetFirstChildNodeByName(NextInnerPackage, "PackageDetails", nsp);
if (PackageDetails != null)
{
var Measures = XmlReader.getNodeByAttr(PackageDetails, "Measures", "type", "ABJ", nsp);
//if (Measures == null) Measures = XmlReader.getNodeByAttr(PackageDetails, "Measures", "type", "AAL", nsp);//AAL是净重
if (Measures == null) return "0";
result = XmlReader.ReadChildNodeTextsByName(Measures, "MeasureValue", nsp)[0];
}
}
return result;
}
public static string getCNTRNO(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var CNTRNO = XmlReader.getNodeByAttr(PackageOutToIn, "PackageID", "identificationSystem", "PackageNumber", nsp);
if (CNTRNO != null)
return XmlReader.ReadNodeText(CNTRNO);
else return "";
}
public static string getSEALNO(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var SEALNO = XmlReader.getNodeByAttr(PackageOutToIn, "PackageID", "identificationSystem", "Seal", nsp);
if (SEALNO != null)
return XmlReader.ReadNodeText(SEALNO);
else return "";
}
public static string getMarks(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var result = "";
XmlNode PackageDetails = null;
var NextInnerPackage = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "NextInnerPackage", nsp);
if (NextInnerPackage != null)
PackageDetails = XmlReader.GetFirstChildNodeByName(NextInnerPackage, "PackageDetails", nsp);
else PackageDetails = PackageOutToIn;
var MarksAndLabels = XmlReader.GetChildNodesByName(PackageDetails, "MarksAndLabels", nsp);
var desList = new NoRepeatStrList();
desList._add(XmlReader.getmlstr(MarksAndLabels));
return desList.getstr();
}
public static string getGoodsname(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var result = "";
var Goods = XmlReader.GetChildNodesByName(PackageOutToIn, "Goods", nsp);
var gslist = new NoRepeatStrList();
foreach (XmlNode Good in Goods)
{
var GoodsDescription = XmlReader.GetFirstChildNodeByName(Good, "GoodsDescription", nsp);
if (GoodsDescription == null) continue;
gslist._add( XmlReader.ReadFirstChildNodeTextByName(GoodsDescription, "Text", nsp));
}
if (gslist.Count > 0) {
result = gslist.getstr();
}
return result;
}
public static string getGoodsDescription(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var result = "";
XmlNode PackageDetails = null;
var NextInnerPackage = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "NextInnerPackage", nsp);
if (NextInnerPackage != null)
PackageDetails = XmlReader.GetFirstChildNodeByName(NextInnerPackage, "PackageDetails", nsp);
else PackageDetails = PackageOutToIn;
var Goods = XmlReader.GetChildNodesByName(PackageDetails, "Goods", nsp);
var desList = new NoRepeatStrList();
foreach (XmlNode Good in Goods)
{
var GoodsDescription = XmlReader.GetChildNodesByName(Good, "GoodsDescription", nsp);
desList._add(XmlReader.getmlstr(GoodsDescription));
}
return desList.getstr();
}
public static string getHSCODE(XmlNode PackageOutToIn, XmlNamespaceManager nsp)
{
var result = "";
var GoodsList = XmlReader.GetChildNodesByName(PackageOutToIn, "Goods", nsp);
foreach (XmlNode Goods in GoodsList)
{
var Product = XmlReader.GetFirstChildNodeByName(Goods, "Product", nsp);
if (Product == null) continue;
var hscodenod = XmlReader.getNodeByAttr(Product, "ProductID", "numberingSystem", "HS", nsp);
if (hscodenod == null) continue;
result = XmlReader.ReadNodeText(hscodenod);
}
return result;
}
#endregion
#region 总货物信息 TotalMeasures
private XmlNodeList
{
get
{
return XmlReader.GetChildNodesByName(OrderDescription, "TotalMeasures", nsp);
}
}
private XmlNode getgoodsinfo(string type) {
foreach (XmlNode item in )
{
var _type = XmlReader.ReadAttrValue(item, "type");
if (type== _type && (XmlReader.ReadFirstChildNodeTextByName(item, "TypeClassification",nsp)== "Ordered")) {
return item;
}
}
return null;
}
private string getgoodsinfostr(string type)
{
var node = getgoodsinfo(type);
if (node == null) { return "0"; }
else
{
return XmlReader.ReadFirstChildNodeTextByName(node, "MeasureValue", nsp);
}
}
private string
{
get {
var result = "";
result = getgoodsinfostr("NoUnits");
return result;
}
}
private string
{
get
{
var result = "";
result = getgoodsinfostr("ABJ");
return result;
}
}
private string
{
get
{
var result = "";
result = getgoodsinfostr("G");
return result;
}
}
private XmlNodeList
{
get
{
return XmlReader.GetChildNodesByName(OrderDescription, "PackageOutToIn", nsp);
}
}
private XmlNodeList getGoods(XmlNode PackageOutToIn) {
return XmlReader.GetChildNodesByName(PackageOutToIn, "Goods", nsp);
}
private string
{
get
{
var result = "";
var _markslist = new NoRepeatStrList();
foreach (XmlNode ctn in )
{
var goodsdescription = FTP_SeaeOrderMC.getMarks(ctn, nsp);
_markslist._add(goodsdescription);
}
result = _markslist.getstr();
return result;
}
}
private string {
get {
var result = "";
var namelist = new NoRepeatStrList();
//var hscodelist = new NoRepeatStrList();
foreach (XmlNode item in ) {
var pm = FTP_SeaeOrderMC.getGoodsname(item, nsp);
//var hscode = getHSCODE(item,nsp);
namelist._add(pm);
//hscodelist._add(hscode);
}
result = namelist.getstr();
//if (hscodelist.Count > 0) {
// result += "\r\nHSCODE:" + hscodelist.getstr();
//}
return result;
}
}
private string {
get
{
var result = "";
var _descriptionlist = new NoRepeatStrList();
var hscodelist = new NoRepeatStrList();
foreach (XmlNode ctn in )
{
var goodsdescription = FTP_SeaeOrderMC.getGoodsDescription(ctn, nsp);
_descriptionlist._add(goodsdescription);
var hscode = getHSCODE(ctn, nsp);
hscodelist._add(hscode);
}
result= _descriptionlist.getstr();
if (hscodelist.Count > 0)
{
result += "\r\nHSCODE:" + hscodelist.getstr();
}
return result;
}
}
#endregion
#region CARGOID 普通S 冷冻R 危险D 超限O
private string getCARGOID() {
string result = "S";
if (haveDangerous()) {
result = "D";
return result;
}
if (haveFrozen())
{
result = "R";
return result;
}
return result;
}
#endregion
#region 危险品信息 DCLASS
//多个危险品 取不重复的所有
private List<XmlNode> Nodes()
{
var result = new List<XmlNode>();
foreach (XmlNode ctn in )
{
var Goods = XmlReader.GetFirstChildNodeByName(ctn, "Goods", nsp);
var DngrsGoods = XmlReader.GetFirstChildNodeByName(Goods, "DngrsGoods", nsp);
if (DngrsGoods != null) {
result.Add(DngrsGoods);
}
}
return result;
}
private string Total() {
var result = "";
var codelist = new List<string>();
if (Nodes() != null)
{
foreach (XmlNode item in Nodes())
{
var DngrsCode = XmlReader.ReadFirstChildNodeTextByName(item, "DngrsCode", nsp);
if (codelist.IndexOf(DngrsCode) < 0)
{
codelist.Add(DngrsCode);
}
}
foreach (var code in codelist)
{
if (result != "") result += ",";
result += code;
}
}
return result;
}
private string Total()
{
var result = "";
var codelist = new List<string>();
if (Nodes() != null)
{
foreach (XmlNode item in Nodes())
{
var DngrsNumberUN = XmlReader.ReadFirstChildNodeTextByName(item, "DngrsNumberUN", nsp);
if (codelist.IndexOf(DngrsNumberUN) < 0)
{
codelist.Add(DngrsNumberUN);
}
}
foreach (var code in codelist)
{
if (result != "") result += ",";
result += code;
}
}
return result;
}
private string () {
var result = "";
var codelist = new List<string>();
if (Nodes() != null)
{
var list = new NoRepeatStrList();
foreach (XmlNode item in Nodes())
{
XmlNode node = null;
node = XmlReader.GetFirstChildNodeByName(item, "Contact");
if (node != null) node= XmlReader.GetFirstChildNodeByName(node, "Name");
if (node != null) node = XmlReader.GetFirstChildNodeByName(node, "Name");
if (node != null) list._add(XmlReader.ReadNodeText(node).Trim());
}
result = list.getstr();
}
return result;
}
private string ()
{
var result = "";
var codelist = new List<string>();
if (Nodes() != null)
{
var list = new NoRepeatStrList();
foreach (XmlNode item in Nodes())
{
XmlNode ContactCommunication = null;
var Contact = XmlReader.GetFirstChildNodeByName(item, "Contact");
if (Contact != null) ContactCommunication = XmlReader.GetFirstChildNodeByName(Contact, "ContactCommunication");
if (ContactCommunication != null && XmlReader.ReadFirstChildNodeTextByName(ContactCommunication, "Type") == "AL") {
list._add(XmlReader.ReadFirstChildNodeTextByName(ContactCommunication, "CommID").Trim());
}
}
result = list.getstr();
}
return result;
}
#endregion
#region 温度信息 DCLASS
private string ()
{
decimal TMin = 0.0M;
foreach (XmlNode ctn in )
{
var NextInnerPackage = XmlReader.GetFirstChildNodeByName(ctn, "NextInnerPackage", nsp);
var PackageDetails = XmlReader.GetFirstChildNodeByName(NextInnerPackage, "PackageDetails", nsp);
var Measures = XmlReader.GetChildNodesByName(PackageDetails, "Measures", nsp);
if (Measures != null)
foreach (XmlNode item in Measures)
{
if (XmlReader.ReadAttrValue(item, "type") == "TemperatureMin")
{
var MeasureValue = XmlReader.ReadFirstChildNodeTextByName(item, "MeasureValue", nsp);
decimal currT = 0.0M;
try
{
currT = Convert.ToDecimal(MeasureValue);
}
catch {
currT = 0.0M;
}
if (TMin == 0.0M || ((TMin != 0.0M) && (currT < TMin))) {
TMin = currT;
}
}
}
}
return TMin.ToString();
}
private string ()
{
decimal TMax = 0.0M;
foreach (XmlNode ctn in )
{
var NextInnerPackage = XmlReader.GetFirstChildNodeByName(ctn, "NextInnerPackage", nsp);
var PackageDetails = XmlReader.GetFirstChildNodeByName(NextInnerPackage, "PackageDetails", nsp);
var Measures = XmlReader.GetChildNodesByName(PackageDetails, "Measures", nsp);
if (Measures != null)
foreach (XmlNode item in Measures)
{
if (XmlReader.ReadAttrValue(item, "type") == "TemperatureMax")
{
var MeasureValue = XmlReader.ReadFirstChildNodeTextByName(item, "MeasureValue", nsp);
decimal currT = 0.0M;
try
{
currT = Convert.ToDecimal(MeasureValue);
}
catch
{
currT = 0.0M;
}
if (TMax == 0.0M || ((TMax != 0.0M) && (currT > TMax)))
{
TMax = currT;
}
}
}
}
return TMax.ToString();
}
#endregion
#endregion
public List<FTP_SeaeOrder_CtnMC> CtnList= new List<FTP_SeaeOrder_CtnMC>();
XmlNamespaceManager nsp { get; set; }
dic { get; set; }
public FTP_SeaeOrderMC(XmlDocument xmlobj,List<CARRIER> carrierList, _dic, List<PKGSEDI_MB> pkglist, List<PKGSEDI_MB> ctncodelist, out string msg)
{
//填充数据
BSNO = Guid.NewGuid().ToString();
CtnList = new List<FTP_SeaeOrder_CtnMC>();
msg = "1";
_root = xmlobj;
try
{
nsp = new XmlNamespaceManager(_root.NameTable); //导入命名空间
nsp.AddNamespace("v4", "http://www.schenker.com/SGI/v4");
nsp.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
msg = "2";
dic = _dic;
msg = "3";
#region 委托单位 发货人 收货人 通知人 船公司
//var 委托单位 = XmlReader.getNodeByAttr(OrderDescription, "Partner", "roleCode", "CZ", nsp);
CUSTOMERNAME = "全球青岛公司";
SHIPPER = companyname();
CONSIGNEE = companyname();
NOTIFYPARTY = companyname();
msg = "4";
var _carrier = companyshortname();
CARRIER = "";
if (carrierList.Exists(o => o.enname == _carrier))
{
CARRIER = carrierList.Find(o => o.enname == _carrier).edicode;
}
msg = "5";
MBLNO = getMBLNO(OrderDescription, nsp);
#endregion
#region 船名 航次
//取一程船名
if ( > 1)
{
VESSEL = get();
VOYNO = get();
}
else
{
VESSEL = get([0]);
VOYNO = get([0]);
}
msg = "6";
#endregion
ETD = ;
msg = "7";
#region 港
PORTLOAD = "QINGDAO,CHINA";//地点名称(起运港);
PORTLOADID = "CNTAO";// 地点ID(起运港);
PLACEDELIVERY = ();
PLACEDELIVERYID = ID();
if (string.IsNullOrWhiteSpace(PLACEDELIVERY))
{
PLACEDELIVERY = ();
}
if (string.IsNullOrWhiteSpace(PLACEDELIVERYID))
{
PLACEDELIVERYID = ID();
}
if (string.IsNullOrWhiteSpace(PLACEDELIVERY))
{
PLACEDELIVERY = PORTLOAD;
}
if (string.IsNullOrWhiteSpace(PLACEDELIVERYID))
{
PLACEDELIVERYID = PORTLOADID;
}
PORTDISCHARGE = ();
PORTDISCHARGEID = ID();
if ( == null)
{
DESTINATION = ();
DESTINATIONID = ID();
}
else
{
DESTINATION = ();
DESTINATIONID = ID();
}
if (string.IsNullOrWhiteSpace(NOTIFYPARTY))
{
NOTIFYPARTY = CONSIGNEE;
}
msg = "8";
#endregion
SERVICE = ;
MARKS = ;
GOODSNAME = ;
DESCRIPTION = ;
msg = "9";
GROSSWEIGHT = ;
msg = "9.1";
MEASUREMENT = ;
msg = "9.2";
PKGS = ;
msg = "9.3";
KINDPKGS = getKINDPKGS_0(pkglist);
msg = "10";
KGS = ;
CBM = ;
msg = "11";
CARGOID = getCARGOID();
if (CARGOID == "D")
{
DCLASS = Total();
DUNNO = Total();
}
msg = "12";
if (CARGOID == "R")
{
TEMPMIN = ();
TEMPMAX = ();
}
msg = "13";
SERVICECONTRACTNO = getContractNo();
msg = "14";
REMARK = getRemark;
if (CARGOID == "D")
{
//危险品的联系人和联系方式放海运出口业务备注
REMARK += "\r\n危险品联系人" + ();
REMARK += "\r\n危险品联系人电话" + ();
}
msg = "15";
BLFRT = ;
msg = "16";
if (_PaymentTerm() == "CC") PAYABLEAT = ;
if (_PaymentTerm() == "PP") PREPARDAT = ;
msg = "17";
CUSTATTN = ;
CUSTTEL = + " " + ;
msg = "18";
if (CARRIER == "")
{
REMARK = companyshortname() + "\r\n" + REMARK;
}
msg = "19";
ISSUETYPE = ;
msg = "20";
CtnList.Clear();
msg = "21";
foreach (XmlNode ctn in )
{
var _ctn = new FTP_SeaeOrder_CtnMC(ctn, this, nsp, pkglist,ctncodelist);
}
msg = "over";
}
catch (Exception ex) {
msg = msg + "_" + ex.Message;
}
}
public string getFieldstr() {
return "insert into op_seaeorder (BSNO,ORSTATUS,BSDATE,MBLNO,CUSTOMERNAME,SHIPPER,CONSIGNEE,NOTIFYPARTY,CARRIER,VESSEL,VOYNO,ETD,PlACERECEIPT,PORTLOADID,PORTLOAD,PORTDISCHARGEID,PORTDISCHARGE,PLACEDELIVERYID,PLACEDELIVERY,DESTINATIONID,DESTINATION,NOBILL,ISSUETYPE,ISSUEDATE,ISSUEPLACE,BLFRT,PREPARDAT,PAYABLEAT,SERVICE,MARKS,NOPKGS,DESCRIPTION,GOODSNAME,GROSSWEIGHT,MEASUREMENT,PKGS,KINDPKGS,KGS,CBM,TOTALNO,CNTRTOTAL,INPUTBY,INVNO,CARGOID,DCLASS,DUNNO,REEFERF,TEMPID,TEMPSET,TEMPMAX,TEMPMIN,CUSTOMSNUM,REMARK,DPAGE,DLABEL,LANE,SERVICECONTRACTNO,CUSTNO,CUSTATTN,CUSTTEL,BLTYPE) ";
}
public string getvaluestr() {
var valuesstr = $" values ('{BSNO.Replace("'", "''")}'," +//BSNO
$"'{ORSTATUS.Replace("'", "''")}'," + //ORSTATUS
$"'{BSDATE.Replace("'", "''")}'," + //BSDATE
$"'{MBLNO.Replace("'", "''")}'," + //MBLNO
$"'{CUSTOMERNAME.Replace("'", "''")}'," + //CUSTOMERNAME
$"'{SHIPPER.Replace("'", "''")}'," + //SHIPPER
$"'{CONSIGNEE.Replace("'", "''")}'," + //CONSIGNEE
$"'{NOTIFYPARTY.Replace("'", "''")}'," + //NOTIFYPARTY
$"'{CARRIER.Replace("'", "''")}'," + //CARRIER
$"'{VESSEL.Replace("'", "''")}'," + //VESSEL
$"'{VOYNO.Replace("'", "''")}'," + //VOYNO
$"'{ETD.Replace("'", "''")}'," + //ETD
$"'{PlACERECEIPT.Replace("'", "''")}'," + //PlACERECEIPT
$"'{PORTLOADID.Replace("'", "''")}'," + //PORTLOADID
$"'{PORTLOAD.Replace("'", "''")}'," + //PORTLOAD
$"'{PORTDISCHARGEID.Replace("'", "''")}'," + //PORTDISCHARGEID
$"'{PORTDISCHARGE.Replace("'", "''")}'," + //PORTDISCHARGE
$"'{PLACEDELIVERYID.Replace("'", "''")}'," + //PLACEDELIVERYID
$"'{PLACEDELIVERY.Replace("'", "''")}'," + //PLACEDELIVERY
$"'{DESTINATIONID.Replace("'", "''")}'," + //DESTINATIONID
$"'{DESTINATION.Replace("'", "''")}'," + //DESTINATION
$"'{NOBILL.Replace("'", "''")}'," + //NOBILL
$"'{ISSUETYPE.Replace("'", "''")}'," + //ISSUETYPE
$"'{ISSUEDATE.Replace("'", "''")}'," + //ISSUEDATE
$"'{ISSUEPLACE.Replace("'", "''")}'," + //ISSUEPLACE
$"'{BLFRT.Replace("'", "''")}'," + //BLFRT
$"'{PREPARDAT.Replace("'", "''")}'," + //PREPARDAT
$"'{PAYABLEAT.Replace("'", "''")}'," + //PAYABLEAT
$"'{SERVICE.Replace("'", "''")}'," + //SERVICE
$"'{MARKS.Replace("'", "''")}'," + //MARKS
$"'{NOPKGS.Replace("'", "''")}'," + //NOPKGS
$"'{DESCRIPTION.Replace("'", "''")}'," + //DESCRIPTION
$"'{GOODSNAME.Replace("'", "''")}'," + //GOODSNAME
$"'{GROSSWEIGHT.Replace("'", "''")}'," + //GROSSWEIGHT
$"'{MEASUREMENT.Replace("'", "''")}'," + //MEASUREMENT
$"'{PKGS.Replace("'", "''")}'," + //PKGS
$"'{KINDPKGS.Replace("'", "''")}'," + //KINDPKGS
$"'{KGS.Replace("'", "''")}'," + //KGS
$"'{CBM.Replace("'", "''")}'," + //CBM
$"'{TOTALNO.Replace("'", "''")}'," + //TOTALNO
$"'{CNTRTOTAL.Replace("'", "''")}'," + //CNTRTOTAL
$"'{INPUTBY.Replace("'", "''")}'," + //INPUTBY
$"'{INVNO.Replace("'", "''")}'," + //INVNO
$"'{CARGOID.Replace("'", "''")}'," + //CARGOID
$"'{DCLASS.Replace("'", "''")}'," + //DCLASS
$"'{DUNNO.Replace("'", "''")}'," + //DUNNO
$"'{REEFERF.Replace("'", "''")}'," + //REEFERF
$"'{TEMPID.Replace("'", "''")}'," + //TEMPID
$"'{TEMPSET.Replace("'", "''")}'," + //TEMPSET
$"'{TEMPMAX.Replace("'", "''")}'," + //TEMPMAX
$"'{TEMPMIN.Replace("'", "''")}'," + //TEMPMIN
$"'{CUSTOMSNUM.Replace("'", "''")}'," + //CUSTOMSNUM
$"'{REMARK.Replace("'", "''")}'," + //REMARK
$"'{DPAGE.Replace("'", "''")}'," + //DPAGE
$"'{DLABEL.Replace("'", "''")}'," + //DLABEL
$"'{LANE.Replace("'", "''")}'," + //LANE
$"'{SERVICECONTRACTNO.Replace("'", "''")}'," + //SERVICECONTRACTNO
$"'{CUSTNO.Replace("'", "''")}'," + //CUSTNO
$"'{CUSTATTN.Replace("'", "''")}'," + //CUSTATTN
$"'{CUSTTEL.Replace("'", "''")}'," + //CUSTTEL
$"'{BLTYPE.Replace("'", "''")}'" + //CUSTTEL
$")";
return valuesstr;
}
}
[JsonObject]
public class FTP_SeaeOrder_CtnMC
{
#region private Fields
private string _CTN_ID = string.Empty;
private string _ORDNO = string.Empty;
private string _CTNALL = string.Empty;
private string _CTNNUM = string.Empty;
private string _REMARK = string.Empty;
private string _KINDPKGS = string.Empty;
private string _PKGS = "0";
private string _KGS = "0";
private string _CBM = "0";
private string _GOODSNAME = string.Empty;
private string _HSCODE = string.Empty;
#endregion
#region R&W
[ModelDB(MDBType = ModelDBOprationType.All, IsPrimary = true)]
public string CTN_ID
{
get { return _CTN_ID; }
set { _CTN_ID = value; }
}
[ModelDB]
public string ORDNO
{
get { return _ORDNO; }
set { _ORDNO = value; }
}
[ModelDB]
public string CTNALL
{
get { return _CTNALL; }
set { _CTNALL = value; }
}
[ModelDB]
public string CTNNUM
{
get { return _CTNNUM; }
set { _CTNNUM = value; }
}
[ModelDB]
public string REMARK
{
get { return _REMARK; }
set { _REMARK = value; }
}
public string KINDPKGS
{
get { return _KINDPKGS; }
set { _KINDPKGS = value; }
}
public string PKGS
{
get { return _PKGS; }
set { _PKGS = value; }
}
public string KGS
{
get { return _KGS; }
set { _KGS = value; }
}
public string CBM
{
get { return _CBM; }
set { _CBM = value; }
}
public string GOODSNAME
{
get { return _GOODSNAME; }
set { _GOODSNAME = value; }
}
public string HSCODE
{
get { return _HSCODE; }
set { _HSCODE = value; }
}
public string CNTRNO { get; set; }
public string SEALNO { get; set; }
#endregion
public FTP_SeaeOrder_CtnMC(XmlNode PackageOutToIn, FTP_SeaeOrderMC head, XmlNamespaceManager nsp, List<PKGSEDI_MB> mpkglist, List<PKGSEDI_MB> ctncodelist)
{
//填充数据
CTN_ID = Guid.NewGuid().ToString();
ORDNO = head.BSNO;
var TransportEquipment = XmlReader.GetFirstChildNodeByName(PackageOutToIn, "TransportEquipment", nsp);
var xiangxing = XmlReader.GetFirstChildNodeByName(TransportEquipment, "MarksAndLabels", nsp);
CTNALL = XmlReader.ReadFirstChildNodeTextByName(xiangxing,"Text",nsp);
if (!string.IsNullOrEmpty(CTNALL))
{
var PKGS = ctncodelist.Find(e => e.EDICODE == CTNALL);
if (PKGS != null)
{
CTNALL = PKGS.PKGS;
}
}
CTNNUM = "1";
KINDPKGS = FTP_SeaeOrderMC.getKINDPKGS_0(PackageOutToIn,nsp, mpkglist);
PKGS = FTP_SeaeOrderMC.getPKGS(PackageOutToIn, nsp);
KGS = FTP_SeaeOrderMC.getKGS(PackageOutToIn, nsp);
CBM = FTP_SeaeOrderMC.getCBM(PackageOutToIn, nsp);
GOODSNAME = FTP_SeaeOrderMC.getGoodsDescription(PackageOutToIn, nsp);
HSCODE = FTP_SeaeOrderMC.getHSCODE(PackageOutToIn, nsp);
CNTRNO = FTP_SeaeOrderMC.getCNTRNO(PackageOutToIn,nsp);
SEALNO = FTP_SeaeOrderMC.getSEALNO(PackageOutToIn,nsp);
if (string.IsNullOrWhiteSpace(HSCODE)) {
GOODSNAME = "HS CODE:" + HSCODE + "\r\n" + GOODSNAME;
}
head.CtnList.Add(this);
}
public string getFieldstr() {
return "insert into op_seaeorderctn (CTN_ID,ORDNO,CTNALL,CTNNUM,REMARK,KINDPKGS,PKGS,KGS,CBM,GOODSNAME,HSCODE,CNTRNO,SEALNO) ";
}
public string getvaluestr()
{
var valuesstr = $" values ('{CTN_ID.Replace("'", "''")}'," +//
$"'{ORDNO.Replace("'", "''")}'," + //ORDNO
$"'{CTNALL.Replace("'", "''")}'," + //CTNALL
$"'{CTNNUM.Replace("'", "''")}'," + //CTNNUM
$"'{REMARK.Replace("'", "''")}'," + //REMARK
$"'{KINDPKGS.Replace("'", "''")}'," + //KINDPKGS
$"'{PKGS.Replace("'", "''")}'," + //PKGS
$"'{KGS.Replace("'", "''")}'," + //KGS
$"'{CBM.Replace("'", "''")}'," + //CBM
$"'{GOODSNAME.Replace("'", "''")}'," + //GOODSNAME
$"'{HSCODE.Replace("'", "''")}'," + //HSCODE
$"'{CNTRNO.Replace("'", "''")}'," + //CNTRNO
$"'{SEALNO.Replace("'", "''")}'" + //SEALNO
$")";
return valuesstr;
}
}
public class DBWork
{
public static int Save(string connStr, FTP_SeaeOrderMC head) {
var sqlstr = getSaveSql(connStr,head);
return ExecSql(connStr, sqlstr);
}
public static string getSaveSql(string connStr, FTP_SeaeOrderMC head) {
var insertstr = head.getFieldstr();
var valuestr = head.getvaluestr();
var headStr = insertstr + valuestr;
var ctnStr = "";
foreach (var ctn in head.CtnList)
{
var insertstr_ctn = ctn.getFieldstr();
var valuestr_ctn = ctn.getvaluestr();
ctnStr += insertstr_ctn + valuestr_ctn + " ";
}
//向一个指定表中写入一些数据
var tastStr = "";
if (head.BLTYPE != "WaybillInstructions")
{
var = Get(connStr, head);
var = "0";
if ( == "")
{
= "1";
}
tastStr = $" INSERT INTO [t_op_task] ([任务编号],[上级任务号],[任务类型],[任务来源],[任务状态],[任务说明],[发起人],[录入日期],[任务开始时间],[完成方式],[完成时间],[KPI值],[提单号],[文件编号],[邮件编号],[电子档案路径],[是否公共],[任务相关人员],[SEA编号]) select newid(),null,{head.任务类型增删标记},'FTP','未开始','{head.增删标记str}辛克订舱:{head.PORTDISCHARGE};{head.DESTINATION}','DEMO-SA',GETDATE(),GETDATE(),'手动',NULL,0,'{head.CUSTNO}',null,null,null,{是否公共},'{任务相关人员}','{head.BSNO}' ";
}
var sqlstr = headStr + " " + ctnStr + tastStr;
return sqlstr;
}
public static int ExecSql(string connStr, string SqlStr)
{
SqlConnection SCON = null;//连接对象
SqlCommand SCom = new SqlCommand();//命令对象
SCON = new SqlConnection(connStr);
SCON.Open();
SCom.CommandText = SqlStr;
SCom.Connection = SCON;
SCom.CommandType = CommandType.Text;
int num = SCom.ExecuteNonQuery();
SCON.Close();
return num;
}
public static DataTable QuerySql(string connStr, string condition)
{
SqlConnection conn = new SqlConnection(connStr);
SqlDataAdapter dataAdapter = new SqlDataAdapter(condition, conn);
DataTable tQuery = new DataTable();
dataAdapter.Fill(tQuery);
return tQuery;
}
public static List<PKGSEDI_MB> GetPKGSList(string connStr)
{
var result = new List<PKGSEDI_MB>();
var sqlQuery = " select * from t_code_package ";
DataTable tQuery = QuerySql(connStr, sqlQuery);
if (tQuery.Rows.Count >= 0)
{
foreach (DataRow row in tQuery.Rows)
{
PKGSEDI_MB item = new PKGSEDI_MB();
item.EDICODE = row["EDI代码"].ToString().Trim();
item.PKGS = row["代码"].ToString();
result.Add(item);
}
}
return result;
}
public static List<PKGSEDI_MB> GetCtnCodeList(string connStr)
{
var result = new List<PKGSEDI_MB>();
var sqlQuery = " select * from t_code_ctn ";
DataTable tQuery = QuerySql(connStr, sqlQuery);
if (tQuery.Rows.Count >= 0)
{
foreach (DataRow row in tQuery.Rows)
{
PKGSEDI_MB item = new PKGSEDI_MB();
item.EDICODE = row["EDI代码辛克"].ToString().Trim();
item.PKGS = row["表现形式"].ToString();
result.Add(item);
}
}
return result;
}
public static string GetMailStmp(string connStr,string StmpID="")
{
var result ="";
var sqlQuery = " select * from Mail_Send_Smtp ";
if (StmpID != "") sqlQuery = sqlQuery+" WHERE GID='"+ StmpID + "'";
DataTable tQuery = QuerySql(connStr, sqlQuery);
if (tQuery.Rows.Count >= 0)
{
result=tQuery.Rows[0]["GID"].ToString();
}
return result;
}
public static int SaveMail(string connStr,string sendto,string title,string body,string smtpid)
{
var sqlstr = $" INSERT INTO [Mail_Send] ([GID],[SendTo],[Title],[Body],[SendStatus],[TryCount],[CreateTime],[SmtpConfig],[Sender],[ShowName]) select newid(),'{sendto}','{title}','{body.Replace("'","''")}','Create',0,GETDATE(),'{smtpid}','','' ";
return ExecSql(connStr, sqlstr);
}
/// <summary>
/// 返回带单引号的用逗号隔开的人员姓名
/// </summary>
/// <param name="connStr"></param>
/// <param name="head"></param>
/// <returns></returns>
public static string Get(string connStr, FTP_SeaeOrderMC head)
{
if (head.CARRIER == "") return "";
var result = "";
var sqlQuery = $" select 姓名 from t_sys_employee where 辛克代码 like'%{head.CARRIER}%' ";
DataTable tQuery = QuerySql(connStr, sqlQuery);
if (tQuery.Rows.Count >= 0)
{
foreach (DataRow row in tQuery.Rows)
{
if (result != "") result += ",";
result += row["姓名"].ToString();
}
}
return result;
}
public static string Get(string connStr, FTP_SeaeOrderMC head)
{
if (head.CARRIER == "") return "";
var result = "";
var sqlQuery = $" select 邮箱 from t_sys_employee where 辛克代码 like'%{head.CARRIER}%' ";
DataTable tQuery = QuerySql(connStr, sqlQuery);
if (tQuery.Rows.Count >= 0)
{
foreach (DataRow row in tQuery.Rows)
{
if (result != "") result += ",";
result += row["邮箱"].ToString();
}
}
return result;
}
public static int DealDel(string connStr, FTP_SeaeOrderMC head) {
var sqlstr = getDealDelSql(connStr, head);
return ExecSql(connStr, sqlstr);
}
public static string getDealDelSql(string connStr, FTP_SeaeOrderMC head) {
var tastStr = $" delete from [t_op_task] where [任务状态]='未开始' and [提单号]='{head.CUSTNO}' ";
tastStr += " del ";
tastStr += " update [t_op_task] set [任务说明]='【已退舱!】 '+[任务说明] where [任务状态]<>'未开始' and [提单号]='"+head.CUSTNO+"' ";
return tastStr;
}
}
[JsonObject]//箱型表
public class PKGSEDI_MB
{
public string EDICODE { get; set; }
public string PKGS { get; set; }
}
}