|
|
using CustomsCargoSystem.Data;
|
|
|
using CustomsCargoSystem.Helper;
|
|
|
using CustomsCargoSystem.MessageQueue;
|
|
|
using CustomsCargoSystem.Model;
|
|
|
using CustomsCargoSystem.Parser;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Configuration;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.ServiceProcess;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Threading;
|
|
|
using System.Xml;
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
namespace CustomsCargoSystem.ExchangeDataStorageService
|
|
|
{
|
|
|
public class MainService : ServiceBase
|
|
|
{
|
|
|
private IContainer components = null;
|
|
|
|
|
|
[DllImport("kernel32.dll")]
|
|
|
public static extern IntPtr _lopen(string lpPathName, int iReadWrite);
|
|
|
|
|
|
[DllImport("kernel32.dll")]
|
|
|
public static extern bool CloseHandle(IntPtr hObject);
|
|
|
|
|
|
public const int OF_READWRITE = 2;
|
|
|
public const int OF_SHARE_DENY_NONE = 0x40;
|
|
|
public readonly IntPtr HFILE_ERROR = new IntPtr(-1);
|
|
|
|
|
|
|
|
|
public string ConnectionString
|
|
|
{
|
|
|
get;
|
|
|
set;
|
|
|
}
|
|
|
|
|
|
public string QmName
|
|
|
{
|
|
|
get;
|
|
|
set;
|
|
|
}
|
|
|
|
|
|
public string QueueInName
|
|
|
{
|
|
|
get;
|
|
|
set;
|
|
|
}
|
|
|
|
|
|
public string Channel
|
|
|
{
|
|
|
get;
|
|
|
set;
|
|
|
}
|
|
|
|
|
|
public string ConnName
|
|
|
{
|
|
|
get;
|
|
|
set;
|
|
|
}
|
|
|
|
|
|
public string IMFMsgPath
|
|
|
{
|
|
|
get;
|
|
|
set;
|
|
|
}
|
|
|
|
|
|
public Thread ServiceThread
|
|
|
{
|
|
|
get;
|
|
|
set;
|
|
|
}
|
|
|
|
|
|
public bool IsThreadNeedRun
|
|
|
{
|
|
|
get;
|
|
|
set;
|
|
|
}
|
|
|
|
|
|
public MainService()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
IsThreadNeedRun = true;
|
|
|
ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
|
|
|
QmName = ConfigurationManager.AppSettings["qmName"];
|
|
|
QueueInName = ConfigurationManager.AppSettings["queueInName"];
|
|
|
Channel = ConfigurationManager.AppSettings["Channel"];
|
|
|
ConnName = ConfigurationManager.AppSettings["ConnName"];
|
|
|
IMFMsgPath = ConfigurationManager.AppSettings["IMFMsgPath"];
|
|
|
}
|
|
|
|
|
|
protected override void OnStart(string[] args)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Log.WriteLog("9systemlog", "订阅服务开启");
|
|
|
IsThreadNeedRun = true;
|
|
|
ServiceThread = new Thread(StartServiceThread_IMF);
|
|
|
ServiceThread.Start();
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("9systemlog", ex.ToString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public bool CheckFileCanRead(string filePath)
|
|
|
{
|
|
|
string vFileName = filePath;
|
|
|
|
|
|
//文件不存在
|
|
|
if (!File.Exists(vFileName))
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
IntPtr vHandle = _lopen(vFileName, OF_READWRITE | OF_SHARE_DENY_NONE);
|
|
|
//文件不可读取
|
|
|
if (vHandle == HFILE_ERROR)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
CloseHandle(vHandle);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
public void StartServiceThread(object obj)
|
|
|
{
|
|
|
string connectionString = ConnectionString;
|
|
|
while (IsThreadNeedRun)
|
|
|
{
|
|
|
string text = MessageQueueManager.ReadMessage(QmName, QueueInName, Channel, ConnName);
|
|
|
if (!string.IsNullOrWhiteSpace(text))
|
|
|
{
|
|
|
Log.WriteMessage("999All", DateTime.Now.ToString("yyyyMMddHHmmss"), text);
|
|
|
try
|
|
|
{
|
|
|
if (text.Contains("FWB/"))
|
|
|
{
|
|
|
Log.WriteMessage("1fwboriginal", DateTime.Now.ToString("yyyyMMddHHmmssfff"), text);
|
|
|
if (!text.Contains("<Msg>"))
|
|
|
{
|
|
|
ProcessXmlDocumentFWB(text);
|
|
|
}
|
|
|
}
|
|
|
else if (text.Contains("FFM/") && text.Contains("CGO"))
|
|
|
{
|
|
|
Log.WriteMessage("2ffmoriginal", DateTime.Now.ToString("yyyyMMddHHmmssfff"), text);
|
|
|
if (!text.Contains("<Msg>"))
|
|
|
{
|
|
|
BookingFFMINFO(text);
|
|
|
}
|
|
|
}
|
|
|
else if (text.Contains("FHL/"))
|
|
|
{
|
|
|
Log.WriteMessage("3fhloriginal", DateTime.Now.ToString("yyyyMMddHHmmssfff"), text);
|
|
|
if (!text.Contains("<Msg>"))
|
|
|
{
|
|
|
ProcessXmlDocumentFHL(text);
|
|
|
}
|
|
|
}
|
|
|
else if (text.Contains("<TYPE>ICUSTOMS</TYPE>") && (text.Contains("FSU_FOH") || text.Contains("FZE_FOH") || text.Contains("FSU_DEP") || text.Contains("FZE_DEP") || text.Contains("FSU_RCF") || text.Contains("FZE_RCF") || text.Contains("<STYP>PFFM</STYP>")))
|
|
|
{
|
|
|
XmlDocument xmlDocument = new XmlDocument();
|
|
|
xmlDocument.LoadXml(text);
|
|
|
ProcessXmlDocument_New(xmlDocument);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("9systemlog", ex.ToString());
|
|
|
}
|
|
|
Thread.Sleep(200);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void StartServiceThread_IMF(object obj)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string connectionString = ConnectionString;
|
|
|
while (IsThreadNeedRun)
|
|
|
{
|
|
|
string text = "";
|
|
|
string[] files = Directory.GetFiles(IMFMsgPath, "*.txt");
|
|
|
for (int i = 0; i < files.Length; i++)
|
|
|
{
|
|
|
if (!CheckFileCanRead(files[i]))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
text = File.ReadAllText(files[i]);
|
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
|
{
|
|
|
if (File.Exists(files[i]))
|
|
|
{
|
|
|
File.Delete(files[i]);
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
Log.WriteMessage("999All", DateTime.Now.ToString("yyyyMMddHHmmss"), text);
|
|
|
if (!text.Contains("<META>"))
|
|
|
{
|
|
|
if (File.Exists(files[i]))
|
|
|
{
|
|
|
File.Delete(files[i]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
XmlDocument xmlDocument = new XmlDocument();
|
|
|
xmlDocument.LoadXml(File.ReadAllText(files[i]));
|
|
|
if (text.Contains("<STYP>IFWB</STYP>") && text.Contains("FWB/"))
|
|
|
{
|
|
|
Log.WriteMessage("1fwboriginal", DateTime.Now.ToString("yyyyMMddHHmmssfff"), text);
|
|
|
XmlNode xmlNode = xmlDocument.SelectSingleNode("/MSG/FWB");
|
|
|
if (xmlNode != null)
|
|
|
{
|
|
|
ProcessXmlDocumentFWB(xmlNode.InnerText);
|
|
|
}
|
|
|
}
|
|
|
else if (text.Contains("<STYP>FFM</STYP>") && text.Contains("FFM/") && text.Contains("CGO"))
|
|
|
{
|
|
|
Log.WriteMessage("2ffmoriginal", DateTime.Now.ToString("yyyyMMddHHmmssfff"), text);
|
|
|
XmlNode xmlNode = xmlDocument.SelectSingleNode("/MSG/FFM");
|
|
|
if (xmlNode != null)
|
|
|
{
|
|
|
BookingFFMINFO(xmlNode.InnerText);
|
|
|
}
|
|
|
}
|
|
|
else if (text.Contains("<STYP>IFHL</STYP>") && text.Contains("FHL/"))
|
|
|
{
|
|
|
Log.WriteMessage("3fhloriginal", DateTime.Now.ToString("yyyyMMddHHmmssfff"), text);
|
|
|
XmlNode xmlNode = xmlDocument.SelectSingleNode("/MSG/FHL");
|
|
|
if (xmlNode != null)
|
|
|
{
|
|
|
ProcessXmlDocumentFHL(xmlNode.InnerText);
|
|
|
}
|
|
|
}
|
|
|
else if (text.Contains("<TYPE>DFME</TYPE>") && (text.Contains("<STYP>UFOH</STYP>") || text.Contains("<STYP>EFOH</STYP>") || text.Contains("<STYP>UDEP</STYP>") || text.Contains("<STYP>EDEP</STYP>") || text.Contains("<STYP>URCF</STYP>") || text.Contains("<STYP>ERCF</STYP>") || text.Contains("<STYP>PFFM</STYP>")))
|
|
|
{
|
|
|
ProcessXmlDocument_New(xmlDocument);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("9systemlog", ex.ToString());
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
if (File.Exists(files[i]))
|
|
|
{
|
|
|
File.Delete(files[i]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(500);
|
|
|
}
|
|
|
}catch(IOException e){
|
|
|
Log.WriteLog("9systemlog", e.ToString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected override void OnStop()
|
|
|
{
|
|
|
IsThreadNeedRun = false;
|
|
|
try
|
|
|
{
|
|
|
ServiceThread.Abort();
|
|
|
ServiceThread = null;
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
throw;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public bool ProcessXmlDocument(XmlDocument xmlDoc)
|
|
|
{
|
|
|
string text = "";
|
|
|
int num = 0;
|
|
|
string connectionString = ConnectionString;
|
|
|
try
|
|
|
{
|
|
|
XmlNode xmlNode = xmlDoc.SelectSingleNode("/MSG/META/TYPE");
|
|
|
XmlNode xmlNode2 = xmlDoc.SelectSingleNode("/MSG/META/STYP");
|
|
|
if (xmlNode == null || xmlNode2 == null)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
string innerText = xmlNode.InnerText;
|
|
|
string innerText2 = xmlNode2.InnerText;
|
|
|
if (innerText != "ICUSTOMS")
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
if ("FSU_FOH" == innerText2)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.ArrivedMaster arrivedMaster = CustomsCargoSystem.Parser.ArrivedMaster.Parse(xmlDoc);
|
|
|
text = arrivedMaster.WAYBILLNOMASTER;
|
|
|
Log.WriteMessage("FSU_FOH", arrivedMaster.WAYBILLNOMASTER, xmlDoc.InnerXml);
|
|
|
string masterid = "";
|
|
|
num = CustomsCargoSystem.Data.ArrivedMaster.Save(connectionString, arrivedMaster, out masterid);
|
|
|
if (num > 0 && !string.IsNullOrEmpty(masterid))
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.ArrivedSecondary> source = CustomsCargoSystem.Data.ArrivedSecondary.exist_arrivedmasteride(connectionString, arrivedMaster.WAYBILLNOMASTER);
|
|
|
if (source.Count() > 0)
|
|
|
{
|
|
|
CustomsCargoSystem.Data.ArrivedSecondary.UpdateArrivedSecondary_arrivedmasterid(connectionString, arrivedMaster.WAYBILLNOMASTER, masterid, arrivedMaster.CUSTOMSCODE);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ("FZE_FOH" == innerText2)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.ArrivedSecondary arrivedSecondary = CustomsCargoSystem.Parser.ArrivedSecondary.Parse(xmlDoc);
|
|
|
Log.WriteMessage("FZE_FOH", arrivedSecondary.WAYBILLNOMASTER, xmlDoc.InnerXml);
|
|
|
num = CustomsCargoSystem.Data.ArrivedSecondary.Save(connectionString, arrivedSecondary);
|
|
|
}
|
|
|
if ("FSU_DEP" == innerText2)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.TallyMaster tallyMaster = CustomsCargoSystem.Parser.TallyMaster.Parse(xmlDoc, "FSU_DEP");
|
|
|
text = tallyMaster.WAYBILLNOMASTER;
|
|
|
Log.WriteMessage("FSU_DEP", tallyMaster.WAYBILLNOMASTER, xmlDoc.InnerXml);
|
|
|
string masterid = "";
|
|
|
num = CustomsCargoSystem.Data.TallyMaster.Save(connectionString, tallyMaster, out masterid);
|
|
|
if (num > 0)
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallySecondary> source2 = CustomsCargoSystem.Data.TallySecondary.tallymasteridisnull(connectionString, tallyMaster.WAYBILLNOMASTER);
|
|
|
if (source2.Count() > 0 && !string.IsNullOrEmpty(masterid))
|
|
|
{
|
|
|
CustomsCargoSystem.Data.TallySecondary.update_tallysecondary_tallymasterid(connectionString, tallyMaster.WAYBILLNOMASTER, masterid);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ("FZE_DEP" == innerText2)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.TallySecondary tallySecondary = CustomsCargoSystem.Parser.TallySecondary.Parse(xmlDoc, "FZE_DEP");
|
|
|
text = tallySecondary.WAYBILLNOSECONDARY;
|
|
|
Log.WriteMessage("FZE_DEP", tallySecondary.WAYBILLNOMASTER, xmlDoc.InnerXml);
|
|
|
num = CustomsCargoSystem.Data.TallySecondary.Save(connectionString, tallySecondary);
|
|
|
}
|
|
|
if ("FSU_RCF" == innerText2)
|
|
|
{
|
|
|
Log.WriteMessage("FSU_RCF", DateTime.Now.ToString("yyyyMMddHHmmss"), xmlDoc.InnerXml);
|
|
|
CustomsCargoSystem.Model.TallyMaster tallyMaster = CustomsCargoSystem.Parser.TallyMaster.Parse(xmlDoc, "FSU_RCF");
|
|
|
text = tallyMaster.WAYBILLNOMASTER;
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallyMaster> source3 = CustomsCargoSystem.Data.TallyMaster.TallyMasterIsExist(connectionString, text, tallyMaster.FLIGHTNO, tallyMaster.FLIGHTDATE.ToString("yyyy-MM-dd"));
|
|
|
List<CustomsCargoSystem.Model.OriginManifestMaster> source4 = CustomsCargoSystem.Data.OriginManifestMaster.GetFlightOgi(connectionString, tallyMaster.FLIGHTNO, tallyMaster.FLIGHTDATE).ToList();
|
|
|
if (source4.Count() > 0)
|
|
|
{
|
|
|
tallyMaster.ORIGINATINGSTATION = source4.FirstOrDefault().OriginatingStation;
|
|
|
}
|
|
|
if (source3.Count() == 0)
|
|
|
{
|
|
|
string masterid = "";
|
|
|
num = CustomsCargoSystem.Data.TallyMaster.Save(connectionString, tallyMaster, out masterid);
|
|
|
if (num > 0)
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallySecondary> source2 = CustomsCargoSystem.Data.TallySecondary.tallymasteridisnull(connectionString, tallyMaster.WAYBILLNOMASTER);
|
|
|
if (source2.Count() > 0 && !string.IsNullOrEmpty(masterid))
|
|
|
{
|
|
|
CustomsCargoSystem.Data.TallySecondary.update_tallysecondary_tallymasterid(connectionString, tallyMaster.WAYBILLNOMASTER, masterid);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ("FZE_RCF" == innerText2)
|
|
|
{
|
|
|
Log.WriteMessage("FZE_RCF", DateTime.Now.ToString("yyyyMMddHHmmss"), xmlDoc.InnerXml);
|
|
|
CustomsCargoSystem.Model.TallySecondary tallySecondary = CustomsCargoSystem.Parser.TallySecondary.Parse(xmlDoc, "FZE_RCF");
|
|
|
text = tallySecondary.WAYBILLNOMASTER;
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallySecondary> source5 = CustomsCargoSystem.Data.TallySecondary.TallySecondaryIsExist(connectionString, text, tallySecondary.WAYBILLNOSECONDARY);
|
|
|
if (source5.Count() == 0)
|
|
|
{
|
|
|
num = CustomsCargoSystem.Data.TallySecondary.Save(connectionString, tallySecondary);
|
|
|
}
|
|
|
}
|
|
|
if ("PFFM" == innerText2)
|
|
|
{
|
|
|
List<DEPARTURESLOADING> list = departuresloading.Parse(xmlDoc);
|
|
|
Log.WriteMessage("PFFM", DateTime.Now.ToString("yyyyMMddHHmmssfff"), xmlDoc.InnerXml);
|
|
|
foreach (DEPARTURESLOADING item in list)
|
|
|
{
|
|
|
text = item.waybillno;
|
|
|
num = departuresloading_service.Save(connectionString, item);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("4xml_error", ex.ToString() + "\r\n\r\n" + xmlDoc.InnerText);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public bool ProcessXmlDocument_New(XmlDocument xmlDoc)
|
|
|
{
|
|
|
string text = "";
|
|
|
int num = 0;
|
|
|
string connectionString = ConnectionString;
|
|
|
try
|
|
|
{
|
|
|
XmlNode xmlNode = xmlDoc.SelectSingleNode("/MSG/META/TYPE");
|
|
|
XmlNode xmlNode2 = xmlDoc.SelectSingleNode("/MSG/META/STYP");
|
|
|
if (xmlNode == null || xmlNode2 == null)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
string innerText = xmlNode.InnerText;
|
|
|
string innerText2 = xmlNode2.InnerText;
|
|
|
if (innerText != "DFME")
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
if ("UFOH" == innerText2)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.ArrivedMaster arrivedMaster = CustomsCargoSystem.Parser.ArrivedMaster.Parse(xmlDoc);
|
|
|
text = arrivedMaster.WAYBILLNOMASTER;
|
|
|
Log.WriteMessage("FSU_FOH", arrivedMaster.WAYBILLNOMASTER, xmlDoc.InnerXml);
|
|
|
string masterid = "";
|
|
|
num = CustomsCargoSystem.Data.ArrivedMaster.Save(connectionString, arrivedMaster, out masterid);
|
|
|
if (num > 0 && !string.IsNullOrEmpty(masterid))
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.ArrivedSecondary> source = CustomsCargoSystem.Data.ArrivedSecondary.exist_arrivedmasteride(connectionString, arrivedMaster.WAYBILLNOMASTER);
|
|
|
if (source.Count() > 0)
|
|
|
{
|
|
|
CustomsCargoSystem.Data.ArrivedSecondary.UpdateArrivedSecondary_arrivedmasterid(connectionString, arrivedMaster.WAYBILLNOMASTER, masterid, arrivedMaster.CUSTOMSCODE);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ("EFOH" == innerText2)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.ArrivedSecondary arrivedSecondary = CustomsCargoSystem.Parser.ArrivedSecondary.Parse(xmlDoc);
|
|
|
Log.WriteMessage("FZE_FOH", arrivedSecondary.WAYBILLNOMASTER, xmlDoc.InnerXml);
|
|
|
num = CustomsCargoSystem.Data.ArrivedSecondary.Save(connectionString, arrivedSecondary);
|
|
|
}
|
|
|
if ("UDEP" == innerText2)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.TallyMaster tallyMaster = CustomsCargoSystem.Parser.TallyMaster.Parse(xmlDoc, "FSU_DEP");
|
|
|
text = tallyMaster.WAYBILLNOMASTER;
|
|
|
Log.WriteMessage("FSU_DEP", tallyMaster.WAYBILLNOMASTER, xmlDoc.InnerXml);
|
|
|
string masterid = "";
|
|
|
num = CustomsCargoSystem.Data.TallyMaster.Save(connectionString, tallyMaster, out masterid);
|
|
|
if (num > 0)
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallySecondary> source2 = CustomsCargoSystem.Data.TallySecondary.tallymasteridisnull(connectionString, tallyMaster.WAYBILLNOMASTER);
|
|
|
if (source2.Count() > 0 && !string.IsNullOrEmpty(masterid))
|
|
|
{
|
|
|
CustomsCargoSystem.Data.TallySecondary.update_tallysecondary_tallymasterid(connectionString, tallyMaster.WAYBILLNOMASTER, masterid);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ("EDEP" == innerText2)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.TallySecondary tallySecondary = CustomsCargoSystem.Parser.TallySecondary.Parse(xmlDoc, "FZE_DEP");
|
|
|
text = tallySecondary.WAYBILLNOSECONDARY;
|
|
|
Log.WriteMessage("FZE_DEP", tallySecondary.WAYBILLNOMASTER, xmlDoc.InnerXml);
|
|
|
num = CustomsCargoSystem.Data.TallySecondary.Save(connectionString, tallySecondary);
|
|
|
}
|
|
|
if ("URCF" == innerText2)
|
|
|
{
|
|
|
Log.WriteMessage("FSU_RCF", DateTime.Now.ToString("yyyyMMddHHmmss"), xmlDoc.InnerXml);
|
|
|
CustomsCargoSystem.Model.TallyMaster tallyMaster = CustomsCargoSystem.Parser.TallyMaster.Parse(xmlDoc, "FSU_RCF");
|
|
|
text = tallyMaster.WAYBILLNOMASTER;
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallyMaster> source3 = CustomsCargoSystem.Data.TallyMaster.TallyMasterIsExist(connectionString, text, tallyMaster.FLIGHTNO, tallyMaster.FLIGHTDATE.ToString("yyyy-MM-dd"));
|
|
|
List<CustomsCargoSystem.Model.OriginManifestMaster> source4 = CustomsCargoSystem.Data.OriginManifestMaster.GetFlightOgi(connectionString, tallyMaster.FLIGHTNO, tallyMaster.FLIGHTDATE).ToList();
|
|
|
if (source4.Count() > 0)
|
|
|
{
|
|
|
tallyMaster.ORIGINATINGSTATION = source4.FirstOrDefault().OriginatingStation;
|
|
|
}
|
|
|
if (source3.Count() == 0)
|
|
|
{
|
|
|
string masterid = "";
|
|
|
num = CustomsCargoSystem.Data.TallyMaster.Save(connectionString, tallyMaster, out masterid);
|
|
|
if (num > 0)
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallySecondary> source2 = CustomsCargoSystem.Data.TallySecondary.tallymasteridisnull(connectionString, tallyMaster.WAYBILLNOMASTER);
|
|
|
if (source2.Count() > 0 && !string.IsNullOrEmpty(masterid))
|
|
|
{
|
|
|
CustomsCargoSystem.Data.TallySecondary.update_tallysecondary_tallymasterid(connectionString, tallyMaster.WAYBILLNOMASTER, masterid);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (source3.Count() > 0)
|
|
|
{
|
|
|
tallyMaster.AUTOID = source3.FirstOrDefault().AUTOID;
|
|
|
CustomsCargoSystem.Data.TallyMaster.Update(connectionString, tallyMaster);
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallySecondary> source2 = CustomsCargoSystem.Data.TallySecondary.tallymasteridisnull(connectionString, tallyMaster.WAYBILLNOMASTER);
|
|
|
if (source2.Count() > 0 && !string.IsNullOrEmpty(tallyMaster.AUTOID))
|
|
|
{
|
|
|
CustomsCargoSystem.Data.TallySecondary.update_tallysecondary_tallymasterid(connectionString, tallyMaster.WAYBILLNOMASTER, tallyMaster.AUTOID);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if ("ERCF" == innerText2)
|
|
|
{
|
|
|
Log.WriteMessage("FZE_RCF", DateTime.Now.ToString("yyyyMMddHHmmss"), xmlDoc.InnerXml);
|
|
|
CustomsCargoSystem.Model.TallySecondary tallySecondary = CustomsCargoSystem.Parser.TallySecondary.Parse(xmlDoc, "FZE_RCF");
|
|
|
text = tallySecondary.WAYBILLNOMASTER;
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallyMaster> byWayBillNoMaster = CustomsCargoSystem.Data.TallyMaster.GetByWayBillNoMaster(connectionString, text);
|
|
|
if (byWayBillNoMaster != null && byWayBillNoMaster.Count() > 0)
|
|
|
{
|
|
|
tallySecondary.TALLYMASTERID = byWayBillNoMaster.FirstOrDefault().AUTOID;
|
|
|
}
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallySecondary> source5 = CustomsCargoSystem.Data.TallySecondary.TallySecondaryIsExist(connectionString, text, tallySecondary.WAYBILLNOSECONDARY);
|
|
|
if (source5.Count() == 0)
|
|
|
{
|
|
|
num = CustomsCargoSystem.Data.TallySecondary.Save(connectionString, tallySecondary);
|
|
|
}
|
|
|
else if (source5.Count() > 0)
|
|
|
{
|
|
|
tallySecondary.AUTOID = source5.FirstOrDefault().AUTOID;
|
|
|
CustomsCargoSystem.Data.TallySecondary.Update(connectionString, tallySecondary);
|
|
|
}
|
|
|
}
|
|
|
if ("PFFM" == innerText2)
|
|
|
{
|
|
|
List<DEPARTURESLOADING> list = departuresloading.Parse(xmlDoc);
|
|
|
Log.WriteMessage("PFFM", DateTime.Now.ToString("yyyyMMddHHmmssfff"), xmlDoc.InnerXml);
|
|
|
foreach (DEPARTURESLOADING item in list)
|
|
|
{
|
|
|
text = item.waybillno;
|
|
|
num = departuresloading_service.Save(connectionString, item);
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("4xml_error", ex.ToString() + "\r\n\r\n" + xmlDoc.InnerText);
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static bool ProcessXmlDocumentFWB(string FWB)
|
|
|
{
|
|
|
bool result = false;
|
|
|
string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
|
|
|
string text = string.Empty;
|
|
|
string text2 = string.Empty;
|
|
|
string cARRIER = string.Empty;
|
|
|
string aRRIVALSTATION = string.Empty;
|
|
|
string cARRIER2 = string.Empty;
|
|
|
string aRRIVALSTATION2 = string.Empty;
|
|
|
string cARRIER3 = string.Empty;
|
|
|
string text3 = string.Empty;
|
|
|
string text4 = string.Empty;
|
|
|
string text5 = string.Empty;
|
|
|
string text6 = string.Empty;
|
|
|
string text7 = string.Empty;
|
|
|
string text8 = "0";
|
|
|
string text9 = "0";
|
|
|
string value = "";
|
|
|
string text10 = "";
|
|
|
string text11 = "";
|
|
|
string iSTRANSFER = "-1";
|
|
|
string text12 = "";
|
|
|
string text13 = "";
|
|
|
string shipper_phone = "";
|
|
|
string shipper_fax = "";
|
|
|
string text14 = "";
|
|
|
string text15 = "";
|
|
|
string text16 = "";
|
|
|
string consignee_fax = "";
|
|
|
string text17 = "";
|
|
|
string text18 = "";
|
|
|
try
|
|
|
{
|
|
|
string[] source = FWB.Split('\n');
|
|
|
source = source.Where((string p) => !string.IsNullOrEmpty(p.Trim())).ToArray();
|
|
|
if (source.Length > 0)
|
|
|
{
|
|
|
for (int i = 0; i < source.Length; i++)
|
|
|
{
|
|
|
string text19 = source[i].Trim();
|
|
|
if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3) && !string.IsNullOrEmpty(text5) && !string.IsNullOrEmpty(text7) && !string.IsNullOrEmpty(text8) && !string.IsNullOrEmpty(text10) && !string.IsNullOrEmpty(text11) && !string.IsNullOrEmpty(text12) && !string.IsNullOrEmpty(text14) && !string.IsNullOrEmpty(text17) && !string.IsNullOrEmpty(text18))
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(text19))
|
|
|
{
|
|
|
if (text19.Contains("FWB/") && string.IsNullOrEmpty(value))
|
|
|
{
|
|
|
value = text19;
|
|
|
}
|
|
|
if (text19.Length > 12 && Regex.IsMatch(text19.Substring(0, 12), "^(\\d{3}-)?\\d{8}$"))
|
|
|
{
|
|
|
text = text19.Substring(0, 12);
|
|
|
if (text8 == "0" || text9 == "0")
|
|
|
{
|
|
|
string text20 = text19.Split('/')[1];
|
|
|
text20 = text20.Substring(1, text20.Length - 1);
|
|
|
if (text20.Contains("K"))
|
|
|
{
|
|
|
text8 = text20.Substring(0, text20.IndexOf("K"));
|
|
|
text9 = text20.Substring(text20.IndexOf("K") + 1, text20.Length - text20.IndexOf("K") - 1);
|
|
|
Regex regex = new Regex("[a-zA-Z]+");
|
|
|
Match match = regex.Match(text9);
|
|
|
if (match.Success)
|
|
|
{
|
|
|
text9 = text9.Substring(0, text9.IndexOf(match.Value));
|
|
|
}
|
|
|
}
|
|
|
if (text20.Contains("L"))
|
|
|
{
|
|
|
text8 = text20.Substring(0, text20.IndexOf("L"));
|
|
|
text9 = text20.Substring(text20.IndexOf("L") + 1, text20.Length - text20.IndexOf("L") - 1);
|
|
|
Regex regex = new Regex("[a-zA-Z]+");
|
|
|
Match match = regex.Match(text9);
|
|
|
if (match.Success)
|
|
|
{
|
|
|
text9 = text9.Substring(0, text9.IndexOf(match.Value));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (text19.Length > 2)
|
|
|
{
|
|
|
if (text19.Substring(0, 3) == "SHP" && string.IsNullOrEmpty(text3) && string.IsNullOrEmpty(text4))
|
|
|
{
|
|
|
text3 = source[i + 1].Trim().Substring(1);
|
|
|
text4 = source[i + 2].Trim().Substring(1);
|
|
|
string text21 = source[i + 4].Trim().Substring(1);
|
|
|
if (!string.IsNullOrEmpty(text21) && text21.Length >= 2)
|
|
|
{
|
|
|
string[] array = text21.Split('/');
|
|
|
if (array[0].Length == 2)
|
|
|
{
|
|
|
text13 = array[0];
|
|
|
}
|
|
|
if (array.Length >= 3)
|
|
|
{
|
|
|
if (array[2] == "TE")
|
|
|
{
|
|
|
shipper_phone = array[3];
|
|
|
}
|
|
|
if (array.Length >= 5 && array[4] == "FX")
|
|
|
{
|
|
|
shipper_fax = array[5];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text12) && text19.Contains("/SHP/T/"))
|
|
|
{
|
|
|
string[] array2 = text19.Split('/');
|
|
|
text12 = array2[array2.Length - 1];
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text14) && text19.Contains("/CNE/T/"))
|
|
|
{
|
|
|
string[] array2 = text19.Split('/');
|
|
|
text14 = array2[array2.Length - 1];
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text17) && (text19.Contains("/CNE/CP/") || text19.Contains("/CNE/ST/") || text19.Contains("/CNE/KC/")))
|
|
|
{
|
|
|
string[] array2 = text19.Split('/');
|
|
|
text17 = array2[array2.Length - 1];
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text18) && (text19.Contains("/CNE/CT/") || text19.Contains("/CNE/U/")))
|
|
|
{
|
|
|
string[] array2 = text19.Split('/');
|
|
|
text18 = array2[array2.Length - 1];
|
|
|
}
|
|
|
}
|
|
|
if (text19.Length > 2 && text19.Substring(0, 3) == "CNE" && string.IsNullOrEmpty(text5) && string.IsNullOrEmpty(text6))
|
|
|
{
|
|
|
text5 = source[i + 1].Trim().Substring(1);
|
|
|
text6 = source[i + 2].Trim().Substring(1);
|
|
|
string text21 = source[i + 4].Trim().Substring(1);
|
|
|
if (!string.IsNullOrEmpty(text21) && text21.Length >= 2)
|
|
|
{
|
|
|
string[] array = text21.Split('/');
|
|
|
if (array[0].Length == 2)
|
|
|
{
|
|
|
text15 = array[0];
|
|
|
}
|
|
|
if (array.Length >= 3)
|
|
|
{
|
|
|
if (array[2] == "TE")
|
|
|
{
|
|
|
text16 = array[3];
|
|
|
}
|
|
|
if (array.Length >= 5 && array[4] == "FX")
|
|
|
{
|
|
|
consignee_fax = array[5];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (text19.Length > 3)
|
|
|
{
|
|
|
if (text19.Substring(0, 3) == "RTG")
|
|
|
{
|
|
|
string[] array3 = text19.Split('/');
|
|
|
if (array3 != null)
|
|
|
{
|
|
|
if (array3.Length == 4)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(array3[1]) && array3[1].Length > 3)
|
|
|
{
|
|
|
text2 = array3[1].Substring(0, 3);
|
|
|
cARRIER = array3[1].Substring(3, array3[1].Length - 3);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(array3[2]) && array3[2].Length > 3)
|
|
|
{
|
|
|
aRRIVALSTATION = array3[2].Substring(0, 3);
|
|
|
cARRIER2 = array3[2].Substring(3, array3[2].Length - 3);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(array3[3]) && array3[3].Length > 3)
|
|
|
{
|
|
|
aRRIVALSTATION2 = array3[3].Substring(0, 3);
|
|
|
cARRIER3 = array3[3].Substring(3, array3[3].Length - 3);
|
|
|
}
|
|
|
}
|
|
|
if (array3.Length == 3)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(array3[1]) && array3[1].Length > 3)
|
|
|
{
|
|
|
text2 = array3[1].Substring(0, 3);
|
|
|
cARRIER = array3[1].Substring(3, array3[1].Length - 3);
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(array3[2]) && array3[2].Length > 3)
|
|
|
{
|
|
|
aRRIVALSTATION = array3[2].Substring(0, 3);
|
|
|
cARRIER2 = array3[2].Substring(3, array3[2].Length - 3);
|
|
|
}
|
|
|
}
|
|
|
if (array3.Length == 2 && !string.IsNullOrEmpty(array3[1]) && array3[1].Length > 3)
|
|
|
{
|
|
|
text2 = array3[1].Substring(0, 3);
|
|
|
cARRIER = array3[1].Substring(3, array3[1].Length - 3);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (text19.Substring(0, 3) == "CVD")
|
|
|
{
|
|
|
string[] array3 = text19.Split('/');
|
|
|
if (array3 != null)
|
|
|
{
|
|
|
text7 = array3[3];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (text19.Contains("/NG/") && string.IsNullOrEmpty(text10) && text19.Substring(0, 4) == "/NG/")
|
|
|
{
|
|
|
text10 = text19.Replace("/NG/", "");
|
|
|
}
|
|
|
else if (text19.Contains("/NC/") && string.IsNullOrEmpty(text10) && text19.Substring(0, 4) == "/NC/")
|
|
|
{
|
|
|
text10 = text19.Replace("/NC/", "");
|
|
|
}
|
|
|
else if (text19.Contains("SPH/") && string.IsNullOrEmpty(text11))
|
|
|
{
|
|
|
text11 = text19.Replace("SPH/", "");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (text7.Contains("C"))
|
|
|
{
|
|
|
text7 = "CC";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text7))
|
|
|
{
|
|
|
text7 = "PP";
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(text12) && !string.IsNullOrEmpty(text13))
|
|
|
{
|
|
|
bool flag = false;
|
|
|
List<t_bas_enterprise> list = CustomsCargoSystem.Data.OriginManifestMaster.get_t_bas_enterprise(connectionString, text13).ToList();
|
|
|
string text22 = "";
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
foreach (t_bas_enterprise item in list)
|
|
|
{
|
|
|
if (text12.Contains(item.enterprise_code))
|
|
|
{
|
|
|
flag = true;
|
|
|
text22 = item.enterprise_code;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (flag)
|
|
|
{
|
|
|
string value2 = "+";
|
|
|
text12 = text12.Insert(text12.LastIndexOf(text22) + text22.Length, value2);
|
|
|
}
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(text14) && !string.IsNullOrEmpty(text15))
|
|
|
{
|
|
|
bool flag = false;
|
|
|
List<t_bas_enterprise> list = CustomsCargoSystem.Data.OriginManifestMaster.get_t_bas_enterprise(connectionString, text15).ToList();
|
|
|
string text22 = "";
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
foreach (t_bas_enterprise item2 in list)
|
|
|
{
|
|
|
if (text14.Contains(item2.enterprise_code))
|
|
|
{
|
|
|
flag = true;
|
|
|
text22 = item2.enterprise_code;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (flag)
|
|
|
{
|
|
|
string value2 = "+";
|
|
|
text14 = text14.Insert(text14.LastIndexOf(text22) + text22.Length, value2);
|
|
|
}
|
|
|
}
|
|
|
fwb_info fwb_info = new fwb_info();
|
|
|
fwb_info.AUTOID = Guid.NewGuid().ToString();
|
|
|
fwb_info.WAYBILLNOMASTER = text;
|
|
|
fwb_info.TOTALPIECE = text8;
|
|
|
fwb_info.TOTALWEIGHT = text9;
|
|
|
fwb_info.CARRIER1 = cARRIER;
|
|
|
fwb_info.ARRIVALSTATION1 = text2;
|
|
|
fwb_info.CARRIER2 = cARRIER2;
|
|
|
fwb_info.ARRIVALSTATION2 = aRRIVALSTATION;
|
|
|
fwb_info.CARRIER3 = cARRIER3;
|
|
|
fwb_info.ARRIVALSTATION3 = aRRIVALSTATION2;
|
|
|
fwb_info.SHIPPERNAME = text3;
|
|
|
fwb_info.SHIPPERADDRESS = text4;
|
|
|
fwb_info.CONSIGNEENAME = text5;
|
|
|
fwb_info.CONSIGNEEADDRESS = text6;
|
|
|
fwb_info.PAYMODE = text7;
|
|
|
fwb_info.CREATEDATE = DateTime.Now;
|
|
|
fwb_info.PRODUCTNAME = text10;
|
|
|
fwb_info.SPECIALGOODSCODE = text11;
|
|
|
fwb_info.ISTRANSFER = iSTRANSFER;
|
|
|
fwb_info.shipper_code = text12;
|
|
|
fwb_info.shipper_countrycode = text13;
|
|
|
fwb_info.shipper_phone = shipper_phone;
|
|
|
fwb_info.shipper_fax = shipper_fax;
|
|
|
if (string.IsNullOrEmpty(text18) && !string.IsNullOrEmpty(text16))
|
|
|
{
|
|
|
text18 = text16;
|
|
|
}
|
|
|
else if (string.IsNullOrEmpty(text16) && !string.IsNullOrEmpty(text18))
|
|
|
{
|
|
|
text16 = text18;
|
|
|
}
|
|
|
fwb_info.consignee_code = text14;
|
|
|
fwb_info.consignee_countrycode = text15;
|
|
|
fwb_info.consignee_phone = text16;
|
|
|
fwb_info.consignee_fax = consignee_fax;
|
|
|
fwb_info.specific_consigneename = text17;
|
|
|
fwb_info.specific_consignee_phone = text18;
|
|
|
if (!string.IsNullOrEmpty(fwb_info.WAYBILLNOMASTER) && CustomsCargoSystem.Data.OriginManifestMaster.InsertFwbInfo(connectionString, fwb_info) > 0)
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.OriginManifestMaster> originManifestMasterFromWayBillNoMaster = CustomsCargoSystem.Data.OriginManifestMaster.GetOriginManifestMasterFromWayBillNoMaster(connectionString, fwb_info.WAYBILLNOMASTER);
|
|
|
if (originManifestMasterFromWayBillNoMaster.Count() > 0)
|
|
|
{
|
|
|
CustomsCargoSystem.Data.OriginManifestMaster.UpdateFWB(connectionString, fwb_info);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("1fwb_error", ex.ToString() + "\r\n\r\n" + FWB);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static bool ProcessXmlDocumentFHL(string FHL)
|
|
|
{
|
|
|
bool result = false;
|
|
|
string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
|
|
|
string wayBillNoMaster = "";
|
|
|
string wayBillNoSecondary = "";
|
|
|
string text = "0";
|
|
|
string text2 = "0";
|
|
|
string specialGoodsCode = "";
|
|
|
string productName = "";
|
|
|
string shipperName = "";
|
|
|
string shipperAddress = "";
|
|
|
string consigneeName = "";
|
|
|
string consigneeAddress = "";
|
|
|
string value = "";
|
|
|
string text3 = "";
|
|
|
string cUSTOMSSTATUS = "-1";
|
|
|
string originatingstation_bill = "";
|
|
|
string destinationstation_bill = "";
|
|
|
string text4 = "";
|
|
|
string text5 = "";
|
|
|
string shipper_phone = "";
|
|
|
string shipper_fax = "";
|
|
|
string text6 = "";
|
|
|
string text7 = "";
|
|
|
string text8 = "";
|
|
|
string consignee_fax = "";
|
|
|
string text9 = "";
|
|
|
string text10 = "";
|
|
|
try
|
|
|
{
|
|
|
string text11 = FHL.Trim();
|
|
|
string[] source = (from x in text11.Split(Environment.NewLine.ToCharArray())
|
|
|
where x.Length > 0
|
|
|
select x).ToArray();
|
|
|
source = source.Where((string p) => !string.IsNullOrEmpty(p.Trim())).ToArray();
|
|
|
if (source.Length > 0)
|
|
|
{
|
|
|
for (int i = 0; i < source.Length; i++)
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(source[i]))
|
|
|
{
|
|
|
if (source[i].ToString().Contains("FHL/") && string.IsNullOrEmpty(value))
|
|
|
{
|
|
|
value = source[i].ToString();
|
|
|
}
|
|
|
string text12 = source[i];
|
|
|
if (string.IsNullOrEmpty(text4) && text12.Contains("/SHP/T/"))
|
|
|
{
|
|
|
string[] array = text12.Split('/');
|
|
|
text4 = array[array.Length - 1];
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text6) && text12.Contains("/CNE/T/"))
|
|
|
{
|
|
|
string[] array = text12.Split('/');
|
|
|
text6 = array[array.Length - 1];
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text9) && (text12.Contains("/CNE/CP/") || text12.Contains("/CNE/ST/") || text12.Contains("/CNE/KC/")))
|
|
|
{
|
|
|
string[] array = text12.Split('/');
|
|
|
text9 = array[array.Length - 1];
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text10) && (text12.Contains("/CNE/CT/") || text12.Contains("/CNE/U/")))
|
|
|
{
|
|
|
string[] array = text12.Split('/');
|
|
|
text10 = array[array.Length - 1];
|
|
|
}
|
|
|
string[] source2 = new string[6]
|
|
|
{
|
|
|
"2",
|
|
|
"3",
|
|
|
"4",
|
|
|
"02",
|
|
|
"03",
|
|
|
"04"
|
|
|
};
|
|
|
string[][] source3 = source.Select((string x) => (from y in x.Split('/') select y.Trim(' ')).ToArray()).ToArray();
|
|
|
string[] array2 = source3.First((string[] y) => y[0] == "FHL");
|
|
|
string[] array3 = (from x in source[i].Split('/') select x.Trim(' ')).ToArray();
|
|
|
if (array3[0] == "MBI")
|
|
|
{
|
|
|
wayBillNoMaster = array3[1].Substring(0, 12);
|
|
|
}
|
|
|
else if (array3[0] == "HBS")
|
|
|
{
|
|
|
wayBillNoSecondary = array3[1];
|
|
|
text = array3[3];
|
|
|
text2 = array3[4].Substring(1);
|
|
|
if (array3.Length >= 6)
|
|
|
{
|
|
|
productName = array3[6];
|
|
|
}
|
|
|
if (array3.Length <= 6)
|
|
|
{
|
|
|
}
|
|
|
}
|
|
|
else if (array3[0] == "SHP")
|
|
|
{
|
|
|
if (array2 != null && source2.Contains(array2[1]) && array3.Length > 1)
|
|
|
{
|
|
|
shipperName = array3[1];
|
|
|
string[] array4 = (from x in source[i + 1].Split('/')
|
|
|
select x.Trim(' ')).ToArray();
|
|
|
shipperAddress = array4[1];
|
|
|
string text13 = source[i + 3].Trim().Substring(1);
|
|
|
if (!string.IsNullOrEmpty(text13) && text13.Length >= 2)
|
|
|
{
|
|
|
string[] array5 = text13.Split('/');
|
|
|
if (array5 != null && array5[0].Length == 2)
|
|
|
{
|
|
|
text5 = array5[0];
|
|
|
}
|
|
|
if (array5.Length >= 3)
|
|
|
{
|
|
|
if (array5[2] == "TE")
|
|
|
{
|
|
|
shipper_phone = array5[3];
|
|
|
}
|
|
|
if (array5[2] == "FX")
|
|
|
{
|
|
|
shipper_fax = array5[3];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
string[] array6 = (from x in source[i + 1].Split('/')
|
|
|
select x.Trim(' ')).ToArray();
|
|
|
shipperName = array6[1];
|
|
|
string[] array4 = (from x in source[i + 2].Split('/')
|
|
|
select x.Trim(' ')).ToArray();
|
|
|
shipperAddress = array4[1];
|
|
|
string text13 = source[i + 4].Trim().Substring(1);
|
|
|
if (!string.IsNullOrEmpty(text13) && text13.Length >= 3)
|
|
|
{
|
|
|
string[] array5 = text13.Split('/');
|
|
|
if (array5 != null && array5[0].Length == 2)
|
|
|
{
|
|
|
text5 = array5[0];
|
|
|
}
|
|
|
if (array5.Length >= 3)
|
|
|
{
|
|
|
if (array5[2] == "TE")
|
|
|
{
|
|
|
shipper_phone = array5[3];
|
|
|
}
|
|
|
if (array5[2] == "FX")
|
|
|
{
|
|
|
shipper_fax = array5[3];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (array3[0] == "CNE")
|
|
|
{
|
|
|
if (array2 != null && source2.Contains(array2[1]) && array3.Length > 1)
|
|
|
{
|
|
|
consigneeName = array3[1];
|
|
|
string[] array4 = (from x in source[i + 1].Split('/') select x.Trim(' ')).ToArray();
|
|
|
consigneeAddress = array4[1];
|
|
|
string text13 = source[i + 3].Trim().Substring(1);
|
|
|
if (!string.IsNullOrEmpty(text13) && text13.Length >= 2)
|
|
|
{
|
|
|
string[] array5 = text13.Split('/');
|
|
|
if (array5 != null && array5[0].Length == 2)
|
|
|
{
|
|
|
text7 = array5[0];
|
|
|
}
|
|
|
if (array5.Length >= 3)
|
|
|
{
|
|
|
if (array5[2] == "TE")
|
|
|
{
|
|
|
text8 = array5[3];
|
|
|
}
|
|
|
if (array5[2] == "FX")
|
|
|
{
|
|
|
consignee_fax = array5[3];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (i + 1 < source.Length)
|
|
|
{
|
|
|
string[] array6 = (from x in source[i + 1].Split('/')
|
|
|
select x.Trim(' ')).ToArray();
|
|
|
consigneeName = array6[1];
|
|
|
}
|
|
|
if (i + 2 < source.Length)
|
|
|
{
|
|
|
string[] array4 = (from x in source[i + 2].Split('/') select x.Trim(' ')).ToArray();
|
|
|
consigneeAddress = array4[1];
|
|
|
}
|
|
|
string text13 = source[(i + 3 >= source.Length) ? (source.Length - 1) : (i + 3)].Trim().Substring(1);
|
|
|
if (!string.IsNullOrEmpty(text13) && text13.Length >= 3)
|
|
|
{
|
|
|
string[] array5 = text13.Split('/');
|
|
|
if (array5 != null && array5[0].Length == 2)
|
|
|
{
|
|
|
text7 = array5[0];
|
|
|
}
|
|
|
if (array5.Length >= 3)
|
|
|
{
|
|
|
if (array5[2] == "TE")
|
|
|
{
|
|
|
text8 = array5[3];
|
|
|
}
|
|
|
if (array5[2] == "FX")
|
|
|
{
|
|
|
consignee_fax = array5[3];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (array3[0] == "CVD" && string.IsNullOrEmpty(text3))
|
|
|
{
|
|
|
text3 = source[i].Split('/')[2];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (text3.Contains("C"))
|
|
|
{
|
|
|
text3 = "CC";
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text3))
|
|
|
{
|
|
|
text3 = "PP";
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(text4) && !string.IsNullOrEmpty(text5))
|
|
|
{
|
|
|
bool flag = false;
|
|
|
List<t_bas_enterprise> list = CustomsCargoSystem.Data.OriginManifestMaster.get_t_bas_enterprise(connectionString, text5).ToList();
|
|
|
string text14 = "";
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
foreach (t_bas_enterprise item in list)
|
|
|
{
|
|
|
if (text4.Contains(item.enterprise_code))
|
|
|
{
|
|
|
flag = true;
|
|
|
text14 = item.enterprise_code;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (flag)
|
|
|
{
|
|
|
string value2 = "+";
|
|
|
text4 = text4.Insert(text4.LastIndexOf(text14) + text14.Length, value2);
|
|
|
}
|
|
|
}
|
|
|
if (!string.IsNullOrEmpty(text6) && !string.IsNullOrEmpty(text7))
|
|
|
{
|
|
|
bool flag = false;
|
|
|
List<t_bas_enterprise> list = CustomsCargoSystem.Data.OriginManifestMaster.get_t_bas_enterprise(connectionString, text7).ToList();
|
|
|
string text14 = "";
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
foreach (t_bas_enterprise item2 in list)
|
|
|
{
|
|
|
if (text6.Contains(item2.enterprise_code))
|
|
|
{
|
|
|
flag = true;
|
|
|
text14 = item2.enterprise_code;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (flag)
|
|
|
{
|
|
|
string value2 = "+";
|
|
|
text6 = text6.Insert(text6.LastIndexOf(text14) + text14.Length, value2);
|
|
|
}
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text10) && !string.IsNullOrEmpty(text8))
|
|
|
{
|
|
|
text10 = text8;
|
|
|
}
|
|
|
else if (string.IsNullOrEmpty(text8) && !string.IsNullOrEmpty(text10))
|
|
|
{
|
|
|
text8 = text10;
|
|
|
}
|
|
|
IEnumerable<CustomsCargoSystem.Model.OriginManifestMaster> originManifestMasterFromWayBillNoMaster = CustomsCargoSystem.Data.OriginManifestMaster.GetOriginManifestMasterFromWayBillNoMaster(connectionString, wayBillNoMaster);
|
|
|
if (originManifestMasterFromWayBillNoMaster.Count() > 0)
|
|
|
{
|
|
|
CustomsCargoSystem.Model.OriginManifestMaster originManifestMaster = originManifestMasterFromWayBillNoMaster.ToList().FirstOrDefault();
|
|
|
if (originManifestMaster != null)
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.OriginManifestSecondary> originManifestSecondaryTureOrFalse = CustomsCargoSystem.Data.OriginManifestMaster.GetOriginManifestSecondaryTureOrFalse(connectionString, wayBillNoMaster, wayBillNoSecondary);
|
|
|
string customsCode = originManifestMaster.CustomsCode;
|
|
|
cUSTOMSSTATUS = originManifestMaster.CustomsStatus;
|
|
|
CustomsCargoSystem.Model.OriginManifestSecondary originManifestSecondary = new CustomsCargoSystem.Model.OriginManifestSecondary();
|
|
|
originManifestSecondary.AutoID = Guid.NewGuid().ToString();
|
|
|
originManifestSecondary.WayBillNoMaster = wayBillNoMaster;
|
|
|
originManifestSecondary.WayBillNoSecondary = wayBillNoSecondary;
|
|
|
originManifestSecondary.Weight = text2;
|
|
|
originManifestSecondary.Piece = text;
|
|
|
originManifestSecondary.ManifestPiece = text;
|
|
|
originManifestSecondary.ManifestWeight = text2;
|
|
|
originManifestSecondary.ProductName = productName;
|
|
|
originManifestSecondary.PayMode = text3;
|
|
|
originManifestSecondary.SpecialGoodsCode = specialGoodsCode;
|
|
|
originManifestSecondary.CustomsCode = customsCode;
|
|
|
originManifestSecondary.ShipperName = shipperName;
|
|
|
originManifestSecondary.ShipperAddress = shipperAddress;
|
|
|
originManifestSecondary.ConsigneeName = consigneeName;
|
|
|
originManifestSecondary.ConsigneeAddress = consigneeAddress;
|
|
|
originManifestSecondary.CreateDate = DateTime.Now;
|
|
|
originManifestSecondary.ORIGINMANIFESTMASTERAUTOID = originManifestMaster.AutoID;
|
|
|
originManifestSecondary.CUSTOMSSTATUS = cUSTOMSSTATUS;
|
|
|
originManifestSecondary.STATUS = "01";
|
|
|
originManifestSecondary.originatingstation_bill = originatingstation_bill;
|
|
|
originManifestSecondary.destinationstation_bill = destinationstation_bill;
|
|
|
originManifestSecondary.shipper_code = text4;
|
|
|
originManifestSecondary.shipper_countrycode = text5;
|
|
|
originManifestSecondary.shipper_phone = shipper_phone;
|
|
|
originManifestSecondary.shipper_fax = shipper_fax;
|
|
|
originManifestSecondary.consignee_code = text6;
|
|
|
originManifestSecondary.consignee_countrycode = text7;
|
|
|
originManifestSecondary.consignee_phone = text8;
|
|
|
originManifestSecondary.consignee_fax = consignee_fax;
|
|
|
originManifestSecondary.specific_consigneename = text9;
|
|
|
originManifestSecondary.specific_consignee_phone = text10;
|
|
|
if (originManifestSecondaryTureOrFalse.Count() == 0)
|
|
|
{
|
|
|
if (CustomsCargoSystem.Data.OriginManifestMaster.InsertFHL(connectionString, originManifestSecondary) > 0)
|
|
|
{
|
|
|
result = true;
|
|
|
}
|
|
|
}
|
|
|
else if (originManifestSecondaryTureOrFalse.ToList().FirstOrDefault().STATUS == "01" || originManifestSecondaryTureOrFalse.ToList().FirstOrDefault().STATUS == "17")
|
|
|
{
|
|
|
originManifestSecondary.AutoID = originManifestSecondaryTureOrFalse.ToList().FirstOrDefault().AutoID;
|
|
|
if (CustomsCargoSystem.Data.OriginManifestMaster.UpdateFHL(connectionString, originManifestSecondary) > 0)
|
|
|
{
|
|
|
result = true;
|
|
|
}
|
|
|
}
|
|
|
InitTallySecondary(originManifestSecondary);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
IEnumerable<CustomsCargoSystem.Model.OriginManifestSecondary> originManifestSecondaryTureOrFalse = CustomsCargoSystem.Data.OriginManifestMaster.GetOriginManifestSecondaryTureOrFalse(connectionString, wayBillNoMaster, wayBillNoSecondary);
|
|
|
CustomsCargoSystem.Model.OriginManifestSecondary originManifestSecondary = new CustomsCargoSystem.Model.OriginManifestSecondary();
|
|
|
originManifestSecondary.AutoID = Guid.NewGuid().ToString();
|
|
|
originManifestSecondary.WayBillNoMaster = wayBillNoMaster;
|
|
|
originManifestSecondary.WayBillNoSecondary = wayBillNoSecondary;
|
|
|
originManifestSecondary.Weight = text2;
|
|
|
originManifestSecondary.Piece = text;
|
|
|
originManifestSecondary.ManifestPiece = text;
|
|
|
originManifestSecondary.ManifestWeight = text2;
|
|
|
originManifestSecondary.ProductName = productName;
|
|
|
originManifestSecondary.PayMode = text3;
|
|
|
originManifestSecondary.SpecialGoodsCode = specialGoodsCode;
|
|
|
originManifestSecondary.CustomsCode = "4604";
|
|
|
originManifestSecondary.ShipperName = shipperName;
|
|
|
originManifestSecondary.ShipperAddress = shipperAddress;
|
|
|
originManifestSecondary.ConsigneeName = consigneeName;
|
|
|
originManifestSecondary.ConsigneeAddress = consigneeAddress;
|
|
|
originManifestSecondary.CreateDate = DateTime.Now;
|
|
|
originManifestSecondary.ORIGINMANIFESTMASTERAUTOID = "0";
|
|
|
originManifestSecondary.CUSTOMSSTATUS = cUSTOMSSTATUS;
|
|
|
originManifestSecondary.STATUS = "01";
|
|
|
originManifestSecondary.originatingstation_bill = originatingstation_bill;
|
|
|
originManifestSecondary.destinationstation_bill = destinationstation_bill;
|
|
|
originManifestSecondary.shipper_code = text4;
|
|
|
originManifestSecondary.shipper_countrycode = text5;
|
|
|
originManifestSecondary.shipper_phone = shipper_phone;
|
|
|
originManifestSecondary.shipper_fax = shipper_fax;
|
|
|
originManifestSecondary.consignee_code = text6;
|
|
|
originManifestSecondary.consignee_countrycode = text7;
|
|
|
originManifestSecondary.consignee_phone = text8;
|
|
|
originManifestSecondary.consignee_fax = consignee_fax;
|
|
|
originManifestSecondary.specific_consigneename = text9;
|
|
|
originManifestSecondary.specific_consignee_phone = text10;
|
|
|
if (originManifestSecondaryTureOrFalse.Count() == 0)
|
|
|
{
|
|
|
if (CustomsCargoSystem.Data.OriginManifestMaster.InsertFHL(connectionString, originManifestSecondary) > 0)
|
|
|
{
|
|
|
result = true;
|
|
|
}
|
|
|
}
|
|
|
else if (originManifestSecondaryTureOrFalse.ToList().FirstOrDefault().STATUS == "01" || originManifestSecondaryTureOrFalse.ToList().FirstOrDefault().STATUS == "17")
|
|
|
{
|
|
|
originManifestSecondary.AutoID = originManifestSecondaryTureOrFalse.ToList().FirstOrDefault().AutoID;
|
|
|
if (CustomsCargoSystem.Data.OriginManifestMaster.UpdateFHL(connectionString, originManifestSecondary) > 0)
|
|
|
{
|
|
|
result = true;
|
|
|
}
|
|
|
}
|
|
|
InitTallySecondary(originManifestSecondary);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("3fhl_error", ex.ToString() + "\r\n\r\n" + FHL);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static bool BookingFFMINFO(string FFM)
|
|
|
{
|
|
|
string text = "";
|
|
|
string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
|
|
|
string text2 = "";
|
|
|
string text3 = "";
|
|
|
string text4 = "";
|
|
|
string destinationstation = "";
|
|
|
string text5 = "";
|
|
|
string text6 = string.Empty;
|
|
|
string islast = string.Empty;
|
|
|
ffm_info ffm_info = new ffm_info();
|
|
|
try
|
|
|
{
|
|
|
string text7 = FFM.Trim();
|
|
|
string[] source = text7.Split(new char[2]
|
|
|
{
|
|
|
'\t',
|
|
|
'\n'
|
|
|
}, StringSplitOptions.None);
|
|
|
text7 = source.Aggregate((string str1, string str2) => str1 + str2);
|
|
|
string[] source2 = text7.Split('\r');
|
|
|
source2 = source2.Where((string p) => !string.IsNullOrEmpty(p.Trim())).ToArray();
|
|
|
string item = source2.Where((string p) => p.Contains("FFM/")).ToList().FirstOrDefault()
|
|
|
.ToString();
|
|
|
int count = source2.ToList().IndexOf(item);
|
|
|
List<string> list = source2.ToList();
|
|
|
list.RemoveRange(0, count);
|
|
|
if (list.Count > 0)
|
|
|
{
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
{
|
|
|
text2 = list[i].Trim();
|
|
|
if (string.IsNullOrEmpty(text3) && string.IsNullOrEmpty(text4) && text2.Contains("/") && text2.Split('/').Length >= 4)
|
|
|
{
|
|
|
string pattern = "^\\d*$";
|
|
|
if (Regex.IsMatch(text2.Split('/')[0], pattern))
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(text6))
|
|
|
{
|
|
|
text6 = int.Parse(text2.Split('/')[0]).ToString();
|
|
|
}
|
|
|
text3 = ((text2.Split('/')[1] == null) ? "" : text2.Split('/')[1]);
|
|
|
text4 = ((text2.Split('/')[2] == null) ? "" : text2.Split('/')[2]);
|
|
|
if (text4.Length > 5)
|
|
|
{
|
|
|
text4 = text4.Substring(0, 5);
|
|
|
}
|
|
|
text5 = text2.Split('/')[3];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (text5 != "CGO")
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
for (int num = list.Count - 1; num > 0; num--)
|
|
|
{
|
|
|
if (list[num] != null && (list[num].Trim() == "LAST" || list[num].Trim() == "CONT"))
|
|
|
{
|
|
|
islast = list[num].Trim();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
islast = string.Empty;
|
|
|
}
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
{
|
|
|
text2 = list[i].Trim();
|
|
|
if (text2.Length > 12 && Regex.IsMatch(text2.Substring(0, 12), "^(\\d{3}-)?\\d{8}$"))
|
|
|
{
|
|
|
for (int num2 = i - 1; num2 > 0; num2--)
|
|
|
{
|
|
|
string text8 = list[num2].Trim();
|
|
|
if (!string.IsNullOrEmpty(text8) && text8.Length >= 3 && text8.Length <= 40 && (text8.Length == 3 || text8.Substring(0, 3) == "CGO"))
|
|
|
{
|
|
|
destinationstation = text8.Substring(0, 3);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
int num3 = 0;
|
|
|
text = text2.Substring(0, 12);
|
|
|
ffm_info = CustomsCargoSystem.Parser.OriginManifestMaster.Parse_ffm_info(text2, text3, text4, text5, destinationstation);
|
|
|
ffm_info.reportorder = text6;
|
|
|
ffm_info.islast = islast;
|
|
|
if (ffm_info != null && !string.IsNullOrEmpty(ffm_info.waybillnomaster) && !string.IsNullOrEmpty(ffm_info.flightno) && !string.IsNullOrEmpty(ffm_info.reportorder) && !string.IsNullOrEmpty(ffm_info.islast))
|
|
|
{
|
|
|
var _theflightdate = ffm_info.flightdate;
|
|
|
bool flag = 1 == 0;
|
|
|
int num4 = (int)ffm_info.flightdate.DayOfWeek;
|
|
|
if (num4 == 0)
|
|
|
{
|
|
|
num4 = 7;
|
|
|
}
|
|
|
IEnumerable<FlightSettingModel> flightPlan = CustomsCargoSystem.Data.OriginManifestMaster.GetFlightPlan(connectionString, ffm_info.flightno, ffm_info.originatingstation, num4.ToString());
|
|
|
if (flightPlan.Count() > 0)
|
|
|
{
|
|
|
FlightSettingModel flightSettingModel = flightPlan.FirstOrDefault();
|
|
|
if (flightSettingModel != null)
|
|
|
{
|
|
|
ffm_info.flightdate = ffm_info.flightdate.AddDays(flightSettingModel.crossdatys);
|
|
|
}
|
|
|
}
|
|
|
string text9 = "";
|
|
|
for (int num2 = i - 1; num2 > 0; num2--)
|
|
|
{
|
|
|
string text10 = list[num2].Trim();
|
|
|
if (!string.IsNullOrEmpty(text10) && text10.Length > 4 && text10.Substring(0, 4) == "ULD/")
|
|
|
{
|
|
|
text9 = text10.Split('/')[1];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (string.IsNullOrEmpty(text9))
|
|
|
{
|
|
|
text9 = "BUG0625";
|
|
|
}
|
|
|
ffm_info.pallet = text9;
|
|
|
ffm_info.dealstatus = "0";
|
|
|
num3 = CustomsCargoSystem.Data.OriginManifestMaster.insert_ffminfo(connectionString, ffm_info);
|
|
|
}
|
|
|
if (num3 > 0)
|
|
|
{
|
|
|
Log.ffminfo_log("sucess_ffminfo", ffm_info.flightno + ".txt", string.Format("{0}舱单信息航班号:{1}航班日期:{2},主单号:{3}入库成功。" + Environment.NewLine, DateTime.Now, ffm_info.flightno, ffm_info.flightdate, ffm_info.waybillnomaster));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("2ffm_error", ex.ToString() + "\r\n\r\n" + FFM);
|
|
|
Log.ffminfo_log("failed_ffminfo", ffm_info.flightno + ".txt", string.Format("{0}舱单信息航班号:{1}航班日期:{2},主单号:{3}入库成功。" + Environment.NewLine, DateTime.Now, ffm_info.flightno, ffm_info.flightdate, ffm_info.waybillnomaster));
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private static void InitTallySecondary(CustomsCargoSystem.Model.OriginManifestSecondary model)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
|
|
|
CustomsCargoSystem.Model.TallySecondary tallySecondary = new CustomsCargoSystem.Model.TallySecondary();
|
|
|
tallySecondary.AUTOID = Guid.NewGuid().ToString("N");
|
|
|
tallySecondary.WAYBILLNOMASTER = model.WayBillNoMaster;
|
|
|
tallySecondary.WAYBILLNOSECONDARY = model.WayBillNoSecondary;
|
|
|
tallySecondary.PIECE = model.ManifestPiece;
|
|
|
tallySecondary.WEIGHT = model.ManifestWeight;
|
|
|
tallySecondary.TALLYPIECE = "0";
|
|
|
tallySecondary.TALLYWEIGHT = "0";
|
|
|
tallySecondary.CUSTOMSCODE = model.CustomsCode;
|
|
|
tallySecondary.PRODUCTNAME = model.ProductName;
|
|
|
tallySecondary.CREATEDATE = DateTime.Now;
|
|
|
tallySecondary.status = "00";
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallyMaster> byWayBillNoMaster = CustomsCargoSystem.Data.TallyMaster.GetByWayBillNoMaster(connectionString, model.WayBillNoMaster);
|
|
|
if (byWayBillNoMaster != null && byWayBillNoMaster.Count() > 0)
|
|
|
{
|
|
|
tallySecondary.TALLYMASTERID = byWayBillNoMaster.FirstOrDefault().AUTOID;
|
|
|
}
|
|
|
IEnumerable<CustomsCargoSystem.Model.TallySecondary> source = CustomsCargoSystem.Data.TallySecondary.TallySecondaryIsExist(connectionString, tallySecondary.WAYBILLNOMASTER, tallySecondary.WAYBILLNOSECONDARY);
|
|
|
if (source.Count() == 0)
|
|
|
{
|
|
|
CustomsCargoSystem.Data.TallySecondary.Insert(connectionString, tallySecondary);
|
|
|
}
|
|
|
else if (source.FirstOrDefault().status == "00")
|
|
|
{
|
|
|
CustomsCargoSystem.Data.TallySecondary.Update(connectionString, tallySecondary);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Log.WriteLog("4xml_error", "生成理货分单出错,错误:" + ex.ToString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
{
|
|
|
if (disposing && components != null)
|
|
|
{
|
|
|
components.Dispose();
|
|
|
}
|
|
|
base.Dispose(disposing);
|
|
|
}
|
|
|
|
|
|
private void InitializeComponent()
|
|
|
{
|
|
|
components = new Container();
|
|
|
base.ServiceName = "货运系统数据交换协议数据入库服务";
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|