Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------------------------------
        private void BtnTestClick(object sender, EventArgs e)
        {
            var strOut = @"D:\Temp\X12\214\GLO\Out";
            var strErr = @"D:\Temp\X12\214\GLO\Err";
            var strPrs = @"D:\Temp\X12\214\GLO\Prs";
            var strFilename = @"D:\Temp\X12\214\GLO\Inp\XUS_214GLO_S00010208_OOP_FMA_201508261622479030.xml";

            var fileStatus = new FileAnalysis();
            var fileProcessor = new FileProcessor(this.cboInstance.Text);

            fileProcessor.Func_CWO_XUS_SHP_X12_214_GLO(strFilename, strOut, strPrs, strErr);

            if (fileProcessor.FileStatus.Status)
            {
                this.txtMessage.AppendText(strFilename + "\t Output:" + fileProcessor.FileStatus.FileOutName);
                //fileProcessor.FileStatus = fileProcessor.Func_File_SendToCargowise(
                //this.strAdpUrl,
                //fileProcessor.FileStatus.FileOutName,
                //this.strAdpRcp,
                //this.strAdpSnd,
                //this.strAdpPwd,
                //this.txt300GLOOut.Text);
            }
            else
            {
                this.txtMessage.AppendText(strFilename + "\t Output:" + fileProcessor.FileStatus.FileErrName + "\n");
                this.txtMessage.AppendText(fileProcessor.FileStatus.ExcpMessage);
            }
        }
 //-----------------------------------------------------------------------------------------------------
 public FileAnalysis Func_X12_810_GLO_CWO_XMS_CIV(
     string filename,
     string errorOut,
     string validOut,
     string processOut)
 {
     this.FileStatus = new FileAnalysis();
     try
     {
         if (File.Exists(filename))
         {
             int j;
             DateTime dteInvDate;
             var strBN = string.Empty;
             var strBM = string.Empty;
             var strPO = string.Empty;
             var edi810 = Interchange.LoadFrom(File.OpenRead(filename));
             var ediInt = new XmlInterchange();
             for (var g = 0; g < edi810.Groups.Count; g++)
             {
                 ediInt.Version = "1";
                 ediInt.InterchangeInfo = new InterchangeInfo
                 {
                     Date = DateTime.Now,
                     XmlType = XmlType.LightWeight,
                     EDIOrganisation =
                     {
                         EDICode = "WALINTJFK",
                         OwnerCode = "WALINTJFK"
                     },
                     Source =
                         new InterchangeInfoSource
                         {
                             EnterpriseCode
                                 = "WLT",
                             CompanyCode =
                                 "JFK",
                             OriginServer =
                                 "JFK",
                             LoginName =
                                 "jerry.mabasa",
                             LoginUserEmailAddress
                                 =
                                 "*****@*****.**"
                         },
                     Target = {BranchCode = "JFK"}
                 };
                 ediInt.Payload = new XmlInterchangePayload {Invoices = new Invoices()};
                 for (var m = 0; m < edi810.Groups[g].Messages.Count; m++)
                 {
                     if (edi810.Groups[g].Messages[m].Context.Tag != "810")
                     {
                         this.FileStatus.ExcpMessage = string.Concat("Invalid 810: ", Path.GetFileName(filename));
                     }
                     else
                     {
                         var ediMsg = edi810.Groups[g].Messages[m].DeserializeItem<M_810>();
                         var ediInvH = new InvoiceHeader {InvoiceNumber = ediMsg.S_BIG.D_76_2};
                         var decInvAmnt = new decimal(0);
                         decimal.TryParse(ediMsg.S_TDS.D_610_1, out decInvAmnt);
                         ediInvH.InvoiceAmount.Value = decInvAmnt/new decimal(100);
                         ediInvH.InvoiceAmount.CurrencyCode = ediMsg.S_CUR.D_100_2;
                         string[] strArrays =
                         {
                             ediMsg.S_BIG.D_373_1.Substring(4, 2), "/",
                             ediMsg.S_BIG.D_373_1.Substring(6, 2), "/",
                             ediMsg.S_BIG.D_373_1.Substring(0, 4)
                         };
                         if (DateTime.TryParse(string.Concat(strArrays), out dteInvDate))
                         {
                             ediInvH.InvoiceDate = dteInvDate;
                         }
                         ediInvH.Consignor = new Organisation();
                         ediInvH.Consignee = new Organisation();
                         var clsOrgBuy = new Organisation();
                         var clsOrgSel = new Organisation();
                         for (j = 0; j < ediMsg.G_N1.Count; j++)
                         {
                             if (ediMsg.G_N1[j].S_N1.D_98_1.ToString() == "SF")
                             {
                                 ediInvH.Consignor.EDICode = ediMsg.G_N1[j].S_N1.D_67_4;
                                 ediInvH.Consignor.OwnerCode = ediMsg.G_N1[j].S_N1.D_67_4;
                                 var clsCnrAdd = new OrganisationDetailAddress();
                                 if (ediMsg.G_N1[j].S_N3.Count != 0)
                                 {
                                     clsCnrAdd.AddressLine1 = ediMsg.G_N1[j].S_N3[0].D_166_1;
                                     clsCnrAdd.AddressLine2 = ediMsg.G_N1[j].S_N3[0].D_166_2;
                                 }
                                 if (ediMsg.G_N1[j].S_N4 != null)
                                 {
                                     clsCnrAdd.CityOrSuburb = ediMsg.G_N1[j].S_N4.D_19_1;
                                 }
                                 ediInvH.Consignee.OrganisationDetails.Addresses.Add(clsCnrAdd);
                                 clsOrgSel = ediInvH.Consignor;
                             }
                             if (ediMsg.G_N1[j].S_N1.D_98_1.ToString() == "ST")
                             {
                                 ediInvH.Consignee.EDICode = ediMsg.G_N1[j].S_N1.D_67_4;
                                 ediInvH.Consignee.OwnerCode = ediMsg.G_N1[j].S_N1.D_67_4;
                                 ediInvH.Consignee.OrganisationDetails.Name = ediMsg.G_N1[j].S_N1.D_93_2;
                                 var clsCneAdd = new OrganisationDetailAddress();
                                 if (ediMsg.G_N1[j].S_N3.Count != 0)
                                 {
                                     if (ediMsg.G_N1[j].S_N3[0].D_166_1 != null)
                                     {
                                         clsCneAdd.AddressLine1 = ediMsg.G_N1[j].S_N3[0].D_166_1;
                                     }
                                     if (ediMsg.G_N1[j].S_N3[0].D_166_2 != null)
                                     {
                                         clsCneAdd.AddressLine2 = ediMsg.G_N1[j].S_N3[0].D_166_2;
                                     }
                                 }
                                 if (ediMsg.G_N1[j].S_N4 != null)
                                 {
                                     clsCneAdd.CityOrSuburb = ediMsg.G_N1[j].S_N4.D_19_1;
                                 }
                                 ediInvH.Consignee.OrganisationDetails.Addresses.Add(clsCneAdd);
                             }
                             if (ediMsg.G_N1[j].S_N1.D_98_1.ToString() == "BT")
                             {
                                 clsOrgBuy.EDICode = ediMsg.G_N1[j].S_N1.D_67_4;
                                 clsOrgBuy.OwnerCode = ediMsg.G_N1[j].S_N1.D_67_4;
                                 var clsBuyAdd = new OrganisationDetailAddress();
                                 if (ediMsg.G_N1[j].S_N3.Count != 0)
                                 {
                                     if (ediMsg.G_N1[j].S_N3[0].D_166_1 != null)
                                     {
                                         clsBuyAdd.AddressLine1 = ediMsg.G_N1[j].S_N3[0].D_166_1;
                                     }
                                     if (ediMsg.G_N1[j].S_N3[0].D_166_2 != null)
                                     {
                                         clsBuyAdd.AddressLine2 = ediMsg.G_N1[j].S_N3[0].D_166_2;
                                     }
                                 }
                                 if (ediMsg.G_N1[j].S_N4 != null)
                                 {
                                     clsBuyAdd.CityOrSuburb = ediMsg.G_N1[j].S_N4.D_19_1;
                                 }
                             }
                             if (ediMsg.G_N1[j].S_REF_2.Count > 0)
                             {
                                 for (var h = 0; h < ediMsg.G_N1[j].S_REF_2.Count; h++)
                                 {
                                     if (ediMsg.G_N1[j].S_REF_2[h].D_128_1.ToString() == "BN")
                                     {
                                         if (ediMsg.G_N1[j].S_REF_2[h].D_127_2 != null)
                                         {
                                             strBN = ediMsg.G_N1[j].S_REF_2[h].D_127_2;
                                         }
                                     }
                                     if (ediMsg.G_N1[j].S_REF_2[h].D_128_1.ToString() == "BM")
                                     {
                                         if (ediMsg.G_N1[j].S_REF_2[h].D_127_2 != null)
                                         {
                                             strBM = ediMsg.G_N1[j].S_REF_2[h].D_127_2;
                                         }
                                     }
                                 }
                             }
                         }
                         ediInvH.IsGroupInvoice = TrueFalse.@false;
                         ediInvH.Incoterm = ediMsg.S_FOB.D_335_5.ToString();
                         var decVol = new decimal(0);
                         ediInvH.Volume.Value = decVol;
                         ediInvH.Volume.DimensionType = "M3";
                         var decWgt = new decimal(0);
                         decimal.TryParse(ediMsg.S_CTT.D_81_3, out decWgt);
                         ediInvH.Weight.Value = decWgt;
                         ediInvH.Weight.DimensionType = ediMsg.S_CTT.D_355_4.ToString();
                         ediInvH.StandAloneInvoiceDirection = "EXP";
                         var clsInvRef = new InvoiceReference {Type = ediMsg.S_CAD_2.D_128_7.ToString()};
                         if (clsInvRef.Type == "BM")
                         {
                             clsInvRef.Type = "MB";
                         }
                         clsInvRef.Value = ediMsg.S_CAD_2.D_127_8;
                         ediInvH.References.Add(clsInvRef);
                         var clsPORef = new InvoiceReference {Type = "PO", Value = ediMsg.S_BIG.D_324_4};
                         ediInvH.References.Add(clsPORef);
                         strPO = clsPORef.Value;
                         for (j = 0; j < ediMsg.G_IT1.Count; j++)
                         {
                             var clsInvLine = new InvoiceLine
                             {
                                 InvoiceLineNumber = ediMsg.G_IT1[j].S_IT1.D_350_1
                             };
                             var decInvQty = new decimal(0);
                             decimal.TryParse(ediMsg.G_IT1[j].S_IT1.D_358_2, out decInvQty);
                             clsInvLine.InvoiceQty.Value = decInvQty;
                             clsInvLine.InvoiceQty.DimensionType = ediMsg.G_IT1[j].S_IT1.D_355_3.ToString();
                             if (clsInvLine.InvoiceQty.DimensionType == "CA")
                             {
                                 clsInvLine.InvoiceQty.DimensionType = "CAS";
                             }
                             if (clsInvLine.InvoiceQty.DimensionType == "EA")
                             {
                                 clsInvLine.InvoiceQty.DimensionType = "PCS";
                             }
                             var decLinPrc = new decimal(0);
                             decimal.TryParse(ediMsg.G_IT1[j].S_IT1.D_212_4, out decLinPrc);
                             clsInvLine.LinePrice.Value = decLinPrc*decInvQty;
                             if (ediMsg.G_IT1[j].S_IT1.D_234_7 != null)
                             {
                                 clsInvLine.ProductNumber = ediMsg.G_IT1[j].S_IT1.D_234_7;
                             }
                             clsInvLine.ProductDescription = ediMsg.G_IT1[j].S_IT1.D_234_11;
                             var decCusQty = new decimal(0);
                             decimal.TryParse(ediMsg.G_IT1[j].S_IT1.D_358_2, out decCusQty);
                             clsInvLine.CustomsInvoiceQty.Value = decCusQty;
                             clsInvLine.CustomsInvoiceQty.DimensionType =
                                 ediMsg.G_IT1[j].S_IT1.D_355_3.ToString();
                             if (ediMsg.G_IT1[j].S_IT1.D_235_12.ToString() == "CH")
                             {
                                 clsInvLine.LineClassification.OriginOfGoods = ediMsg.G_IT1[j].S_IT1.D_234_13;
                             }
                             if (ediMsg.G_IT1[j].S_IT1.D_235_14.ToString() == "HD")
                             {
                                 clsInvLine.LineClassification.TariffCode.Type = "HTS";
                             }
                             clsInvLine.LineClassification.TariffCode.Value = ediMsg.G_IT1[j].S_IT1.D_234_15;
                             var decNetWgt = new decimal(0);
                             decimal.TryParse(ediMsg.G_IT1[j].S_PO4.D_384_6, out decNetWgt);
                             clsInvLine.NetWeight.Value = decNetWgt;
                             clsInvLine.NetWeight.DimensionType = ediMsg.G_IT1[j].S_PO4.D_355_7.ToString();
                             clsInvLine.CustomText1 = strBN;
                             clsInvLine.CustomText2 = strBM;
                             clsInvLine.CustomText3 = strPO;
                             var clsUSInv = new USInvoice
                             {
                                 Organisations =
                                 {
                                     Buyer = clsOrgBuy,
                                     Seller = clsOrgSel
                                 }
                             };
                             ediInvH.CountryPayload.USInvoice = new USInvoice();
                             ediInvH.CountryPayload.USInvoice = clsUSInv;
                             clsInvLine.OrderNumber = clsPORef.Value;
                             ediInvH.InvoiceLines.Add(clsInvLine);
                         }
                         ediInt.Payload.Invoices.InvoiceHeader.Add(ediInvH);
                     }
                 }
             }
             ediInt.Serialize();
             if (
                 File.Exists(
                     string.Concat(validOut, "\\810_JNJ_", Path.GetFileNameWithoutExtension(filename), ".xml")))
             {
                 File.Delete(
                     string.Concat(validOut, "\\810_JNJ_", Path.GetFileNameWithoutExtension(filename), ".xml"));
             }
             ediInt.SaveToFile(
                 string.Concat(validOut, "\\810_JNJ_", Path.GetFileNameWithoutExtension(filename), ".xml"));
             if (File.Exists(string.Concat(processOut, "\\", Path.GetFileName(filename))))
             {
                 File.Delete(string.Concat(processOut, "\\", Path.GetFileName(filename)));
             }
             File.Move(filename, string.Concat(processOut, "\\", Path.GetFileName(filename)));
         }
     }
     catch (Exception exception)
     {
         this.FileStatus.ExcpMessage = exception.Message;
     }
     return this.FileStatus;
 }
        //-----------------------------------------------------------------------------------------------------
        public FileAnalysis Func_CWO_XUS_SHP_X12_310_GLO(
            string filename,
            string fileOut,
            string filePrs,
            string fileErr)
        {
            this.FileStatus = new FileAnalysis();
            if (File.Exists(filename))
            {
                var controlNum = this.Func_SQL_GetControlNumber();
                var doc = new XmlDocument();
                doc.Load(filename);
                XmlNode root = doc.DocumentElement;
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("ns", "http://www.cargowise.com/Schemas/Universal/2011/11");
                var myInterchange = new MyINT(controlNum, "12", "3023254180", "ZZ", "FMXJ310", true);
                var myGroup = myInterchange.CreateGroup(controlNum, "IO", "3023254180", "FMXJ310");
                var myMessage = new X12_4010_310(controlNum);
                var statusCode = this.Func_XML_GetResultString(doc, nsmgr, @"//ns:ActionPurpose/ns:Code");
                if (statusCode == "INV")
                {
                    var invTerms = this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:ShipmentCollection/ns:Shipment/ns:PaymentMethod/ns:Code");
                    var invCode = new X12_ID_146();
                    invCode = invTerms == "PPD" ? X12_ID_146.PP : X12_ID_146.CC;
                    var invAmnt = this.Func_XML_GetResultString(doc, nsmgr, @"//ns:LocalTotal");
                    invAmnt = invAmnt.Substring(0, invAmnt.Length - 2).Replace(".", string.Empty);
                    myMessage.Add_B3(
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:Number"),
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:TransactionInfo/ns:Description"),
                        invCode,
                        this.Func_XML_GetResultDate(doc, nsmgr, @"//ns:TransactionDate"),
                        invAmnt,
                        "WINA",
                        this.Func_XML_GetResultDate(doc, nsmgr, @"//ns:DueDate"));
                    myMessage.Add_B2A(X12_ID_353.Item00, X12_ID_346.BN);
                    var refList =
                        doc.SelectNodes(
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type/ns:Code",
                            nsmgr);
                    if (refList != null && refList.Count > 0)
                    {
                        foreach (XmlNode refItem in refList)
                        {
                            switch (refItem.InnerText)
                            {
                                case "LID":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.OL,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='LID']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='LID']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;

                                case "BKG":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.MB,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='BKG']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='BKG']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;

                                case "UCR":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.SI,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='UCR']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='UCR']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;

                                case "CON":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.TS,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='CON']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='CON']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;

                                case "OAG":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.FN,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='OAG']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='OAG']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;
                            }
                        }
                    }

                    myMessage.Add_N9(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.BN,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:Shipment/ns:WayBillNumber"), "");

                    myMessage.Add_N9(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.FN,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:Shipment/ns:DataContext/ns:DataSourceCollection/ns:DataSource[ns:Type='ForwardingShipment']/ns:Key"),
                        "");

                    myMessage.Add_N9(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.X9,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:WayBillNumber"), "");

                    myMessage.Add_N9(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.IV,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:Number"), "");

                    myMessage.Add_N9(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_128.VR,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:DataProvider"), "");

                    var ordList =
                        doc.SelectNodes(
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:LocalProcessing/ns:OrderNumberCollection/ns:OrderNumber",
                            nsmgr);

                    if (ordList != null && ordList.Count > 0)
                    {
                        int intCnt = 1;

                        foreach (XmlNode ordItem in ordList)
                        {
                            myMessage.Add_N9(
                                EdiFabric.Definitions.X12_004010_310.X12_ID_128.PO,
                                this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:LocalProcessing/ns:OrderNumberCollection/ns:OrderNumber[" +
                                    intCnt.ToString() +
                                    "]/ns:OrderReference"), "");

                            intCnt += 1;
                        }
                    }

                    var transLeg = this.Func_XML_GetResultCount(
                        doc,
                        nsmgr,
                        @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg");
                    for (var i = 1; i <= transLeg; i++)
                    {
                        myMessage.Add_V1(
                            this.Func_XML_GetResultString(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=" + i
                                + "]/ns:VesselName"),
                            this.Func_XML_GetResultString(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=" + i
                                + "]/ns:VoyageFlightNo"),
                            this.Func_XML_GetResultString(
                                doc,
                                nsmgr,
                                @"//SubShipment/TransportLegCollection/TransportLeg[LegOrder=" + i
                                +
                                "]/Carrier/RegistrationNumberCollection/RegistrationNumber/Type[Code='CCC']/parent::RegistrationNumber/Value"));
                    }
                    var dtmR4R = new List<S_DTM>();
                    var estR = new S_DTM
                    {
                        D_374_1 = X12_ID_374.Item139,
                        D_373_2 =
                            this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:DateCollection/ns:Date[ns:Type='Departure']/ns:Value/parent::ns:Date[ns:IsEstimate='true']/ns:Value"),
                        D_337_3 =
                            this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:DateCollection/ns:Date[ns:Type='Departure']/ns:Value/parent::ns:Date[ns:IsEstimate='true']/ns:Value"),
                        D_623_4 = EdiFabric.Definitions.X12_004010_310.X12_ID_623.LT,
                        D_623_4Specified = true
                    };

                    if (estR.D_373_2 != string.Empty && estR.D_337_3 != string.Empty)
                    {
                        dtmR4R.Add(estR);
                    }

                    var actR = new S_DTM
                    {
                        D_374_1 = X12_ID_374.Item140,
                        D_373_2 =
                            this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:ActualDeparture"),
                        D_337_3 =
                            this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:ActualDeparture"),
                        D_623_4 = EdiFabric.Definitions.X12_004010_310.X12_ID_623.LT,
                        D_623_4Specified = true
                    };
                    if (actR.D_373_2 != string.Empty && actR.D_337_3 != string.Empty)
                    {
                        dtmR4R.Add(actR);
                    }

                    myMessage.Add_R4(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_115.R,
                        EdiFabric.Definitions.X12_004010_310.X12_ID_309.UN,
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:SubShipment/ns:PortOfOrigin/ns:Code"),
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:SubShipment/ns:PortOfOrigin/ns:Name"),
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:SubShipment/ns:PortOfOrigin/ns:Code")
                            .Substring(0, 2),
                        dtmR4R);

                    var dtmR4E = new List<S_DTM>();
                    var estE = new S_DTM
                    {
                        D_374_1 = X12_ID_374.Item139,
                        D_373_2 =
                            this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:DateCollection/ns:Date[ns:Type='Arrival']/ns:Value/parent::ns:Date[ns:IsEstimate='true']/ns:Value"),
                        D_337_3 =
                            this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:DateCollection/ns:Date[ns:Type='Arrival']/ns:Value/parent::ns:Date[ns:IsEstimate='true']/ns:Value"),
                        D_623_4 = EdiFabric.Definitions.X12_004010_310.X12_ID_623.LT,
                        D_623_4Specified = true
                    };
                    if (estE.D_373_2 != string.Empty && estE.D_337_3 != string.Empty)
                    {
                        dtmR4E.Add(estE);
                    }

                    var actE = new S_DTM
                    {
                        D_374_1 = X12_ID_374.Item140,
                        D_373_2 =
                            this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                + transLeg + "]/ns:ActualArrival"),
                        D_337_3 =
                            this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                + transLeg + "]/ns:ActualArrival"),
                        D_623_4 = EdiFabric.Definitions.X12_004010_310.X12_ID_623.LT,
                        D_623_4Specified = true
                    };
                    if (actE.D_373_2 != string.Empty && actE.D_337_3 != string.Empty)
                    {
                        dtmR4E.Add(actE);
                    }

                    myMessage.Add_R4(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_115.E,
                        EdiFabric.Definitions.X12_004010_310.X12_ID_309.UN,
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:SubShipment/ns:PortOfDestination/ns:Code"),
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:SubShipment/ns:PortOfDestination/ns:Name"),
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:SubShipment/ns:PortOfDestination/ns:Code")
                            .Substring(0, 2),
                        dtmR4E);

                    var dtmR4L = new List<S_DTM>();
                    var estL = new S_DTM
                    {
                        D_374_1 = X12_ID_374.Item139,
                        D_373_2 =
                            this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:EstimatedDeparture"),
                        D_337_3 =
                            this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:EstimatedDeparture"),
                        D_623_4 = EdiFabric.Definitions.X12_004010_310.X12_ID_623.LT,
                        D_623_4Specified = true
                    };
                    if (estL.D_373_2 != string.Empty && estL.D_337_3 != string.Empty)
                    {
                        dtmR4L.Add(estL);
                    }

                    var actL = new S_DTM
                    {
                        D_374_1 = X12_ID_374.Item140,
                        D_373_2 =
                            this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                + transLeg + "]/ns:ActualDeparture"),
                        D_337_3 =
                            this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                + transLeg + "]/ns:ActualDeparture"),
                        D_623_4 = EdiFabric.Definitions.X12_004010_310.X12_ID_623.LT,
                        D_623_4Specified = true
                    };
                    if (actL.D_373_2 != string.Empty && actL.D_337_3 != string.Empty)
                    {
                        dtmR4L.Add(actL);
                    }

                    myMessage.Add_R4(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_115.L,
                        EdiFabric.Definitions.X12_004010_310.X12_ID_309.UN,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Code"),
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Name"),
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Code")
                            .Substring(0, 2),
                        dtmR4L);

                    var dtmR4D = new List<S_DTM>();
                    var estD = new S_DTM
                    {
                        D_374_1 = X12_ID_374.Item139,
                        D_373_2 =
                            this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                + transLeg + "]/ns:EstimatedArrival"),
                        D_337_3 =
                            this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                + transLeg + "]/ns:EstimatedArrival"),
                        D_623_4 = EdiFabric.Definitions.X12_004010_310.X12_ID_623.LT,
                        D_623_4Specified = true
                    };
                    if (estD.D_373_2 != string.Empty && estD.D_337_3 != string.Empty)
                    {
                        dtmR4D.Add(estD);
                    }

                    var actD = new S_DTM
                    {
                        D_374_1 = X12_ID_374.Item140,
                        D_337_3 =
                            this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                + transLeg + "]/ns:ActualArrival"),
                        D_373_2 =
                            this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                + transLeg + "]/ns:ActualArrival"),
                        D_623_4 = EdiFabric.Definitions.X12_004010_310.X12_ID_623.LT,
                        D_623_4Specified = true
                    };
                    if (actD.D_373_2 != string.Empty && actD.D_337_3 != string.Empty)
                    {
                        dtmR4D.Add(actD);
                    }

                    myMessage.Add_R4(
                        EdiFabric.Definitions.X12_004010_310.X12_ID_115.D,
                        EdiFabric.Definitions.X12_004010_310.X12_ID_309.UN,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                            + transLeg + "]/ns:PortOfDischarge/ns:Code"),
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                            + transLeg + "]/ns:PortOfDischarge/ns:Name"),
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                            + transLeg + "]/ns:PortOfDischarge/ns:Code").Substring(0, 2),
                        dtmR4D);

                    myMessage.Add_LX(doc, nsmgr);
                    myMessage.Add_L3(
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:ShipmentCollection/ns:Shipment/ns:DocumentedWeight"),
                        invAmnt,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:ShipmentCollection/ns:Shipment/ns:DocumentedVolume"),
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:ShipmentCollection/ns:Shipment/ns:DocumentedChargeable"));
                    myGroup.AddMessage(myMessage.m310);
                    myInterchange.SaveEdi(
                        string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                    //this.FileStatus.HasError =
                    //    Func_File_Validate(
                    //        string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                    if (!this.FileStatus.HasError)
                    {
                        this.Func_SQL_SubmitControlNumber(
                            controlNum,
                            "310GLO",
                            string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                        Func_File_Move(filename, string.Concat(filePrs, "\\", Path.GetFileName(filename)));
                        this.FileStatus.Created = true;
                        this.FileStatus.Status = true;
                        this.FileStatus.FileOutName = string.Concat(
                            fileOut,
                            "\\",
                            Path.GetFileNameWithoutExtension(filename),
                            ".edi");
                    }
                    else
                    {
                        Func_File_Move(
                            string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"),
                            string.Concat(fileErr, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                        Func_File_Move(filename, string.Concat(fileErr, "\\", Path.GetFileName(filename)));
                        this.FileStatus.Created = false;
                        this.FileStatus.Status = false;
                        this.FileStatus.FileErrName = string.Concat(fileOut, "\\", Path.GetFileName(filename));
                    }
                }
            }
            return this.FileStatus;
        }
        //-----------------------------------------------------------------------------------------------------
        public FileAnalysis Func_CWO_XUS_SHP_X12_301_GLO(
            string filename,
            string fileOut,
            string filePrs,
            string fileErr,
            X12_ID_558 codeX12Id558)
        {
            this.FileStatus = new FileAnalysis();
            if (File.Exists(filename))
            {
                var controlNum = this.Func_SQL_GetControlNumber();
                var doc = new XmlDocument();
                doc.Load(filename);
                XmlNode root = doc.DocumentElement;
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("ns", "http://www.cargowise.com/Schemas/Universal/2011/11");
                var bookingConfirmed =
                    DateTime.Parse(
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:EventType[ns:Code='ATC']/parent::ns:DataContext/ns:TriggerDate"));
                var myInterchange = new MyINT(controlNum, "12", "3023254180", "ZZ", "FMXJ301", true);
                var myGroup = myInterchange.CreateGroup(controlNum, "RO", "3023254180", "FMXJ301");
                var myMessage = new X12_4010_301(
                    controlNum,
                    this.Func_XML_GetResultString(doc, nsmgr, @"//ns:SubShipment/ns:WayBillNumber"),
                    bookingConfirmed);
                var svl =
                    this.Func_SQL_TranslateCWOTariffServiceLevel(
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:ServiceLevel/ns:Code")).Trim();
                var SvcLvl = X12_ID_375.Item1A;
                if (svl.Any())
                {
                    switch (svl)
                    {
                        case "DD":
                        {
                            SvcLvl = X12_ID_375.DD;
                        }
                            break;

                        case "DP":
                        {
                            SvcLvl = X12_ID_375.DP;
                        }
                            break;

                        case "PD":
                        {
                            SvcLvl = X12_ID_375.PD;
                        }
                            break;

                        case "PP":
                        {
                            SvcLvl = X12_ID_375.PP;
                        }
                            break;
                    }
                }
                myMessage.Add_Y3(
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"/ns:UniversalInterchange/ns:Body/ns:UniversalShipment/ns:Shipment/ns:BookingConfirmationReference"),
                    this.Func_XML_GetResultDate(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:DateCollection/ns:Date[ns:Type='Departure'][ns:IsEstimate='true']/ns:Value"),
                    this.Func_XML_GetResultDate(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:DateCollection/ns:Date[ns:Type='Arrival'][ns:IsEstimate='true']/ns:Value"),
                    this.Func_XML_GetResultDate(
                        doc,
                        nsmgr,
                        @"/ns:UniversalInterchange/ns:Body/ns:UniversalShipment/ns:Shipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder='1']/ns:FCLCutOff"),
                    this.Func_XML_GetResultTime(
                        doc,
                        nsmgr,
                        @"/ns:UniversalInterchange/ns:Body/ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container/ns:DepartureSlotDateTime"),
                    SvcLvl,
                    "WINA",
                    string.Empty,
                    string.Empty,
                    X12_ID_91.O,
                    X12_ID_623.LT);
                myMessage.Add_Y4(
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"/ns:UniversalInterchange/ns:Body/ns:UniversalShipment/ns:Shipment/ns:BookingConfirmationReference"),
                    this.Func_XML_GetResultDate(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:LocalProcessing/ns:EstimatedPickup"),
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:ContainerCollection/ns:Container/ns:ContainerType/ns:ISOCode"),
                    int.Parse(
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:ContainerCount")));
                var refList =
                    doc.SelectNodes(
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type/ns:Code",
                        nsmgr);
                if (refList != null && refList.Count > 0)
                {
                    foreach (XmlNode refItem in refList)
                    {
                        switch (refItem.InnerText)
                        {
                            case "LID":
                            {
                                myMessage.Add_N9(
                                    X12_ID_128.OL,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='LID']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='LID']/parent::ns:AdditionalReference/ns:ContextInformation"));
                            }
                                break;

                            case "BKG":
                            {
                                myMessage.Add_N9(
                                    X12_ID_128.MB,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='BKG']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='BKG']/parent::ns:AdditionalReference/ns:ContextInformation"));
                            }
                                break;

                            case "UCR":
                            {
                                myMessage.Add_N9(
                                    X12_ID_128.SI,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='UCR']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='UCR']/parent::ns:AdditionalReference/ns:ContextInformation"));
                            }
                                break;

                            case "CON":
                            {
                                myMessage.Add_N9(
                                    X12_ID_128.TS,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='CON']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='CON']/parent::ns:AdditionalReference/ns:ContextInformation"));
                            }
                                break;

                            case "OAG":
                            {
                                myMessage.Add_N9(
                                    X12_ID_128.FN,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='OAG']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='OAG']/parent::ns:AdditionalReference/ns:ContextInformation"));
                            }
                                break;
                        }
                    }
                }
                myMessage.Add_R4(
                    X12_ID_115.R,
                    X12_ID_309.UN,
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:PortOfOrigin/ns:Code"),
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:PortOfOrigin/ns:Name"),
                    string.Empty,
                    string.Empty);
                myMessage.Add_R4(
                    X12_ID_115.L,
                    X12_ID_309.UN,
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:PortOfLoading/ns:Code"),
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:PortOfLoading/ns:Name"),
                    string.Empty,
                    string.Empty);
                myMessage.Add_R4(
                    X12_ID_115.D,
                    X12_ID_309.UN,
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:PortOfDischarge/ns:Code"),
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:PortOfDischarge/ns:Name"),
                    string.Empty,
                    string.Empty);
                myMessage.Add_R4(
                    X12_ID_115.E,
                    X12_ID_309.UN,
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:PortOfDestination/ns:Code"),
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:PortOfDestination/ns:Name"),
                    string.Empty,
                    string.Empty);
                myMessage.Add_LX("1");
                myMessage.Add_V1(
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"/ns:UniversalInterchange/ns:Body/ns:UniversalShipment/ns:Shipment/ns:VesselName"),
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"/ns:UniversalInterchange/ns:Body/ns:UniversalShipment/ns:Shipment/ns:VoyageFlightNo"),
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:Carrier/ns:RegistrationNumberCollection/ns:RegistrationNumber/ns:Type[ns:Code='CCC']/parent::ns:RegistrationNumber/ns:Value"),
                    X12_ID_854.GC);
                myGroup.AddMessage(myMessage.m301);
                myInterchange.SaveEdi(string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                this.FileStatus.HasError =
                    Func_File_Validate(string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                if (!this.FileStatus.HasError)
                {
                    this.Func_SQL_SubmitControlNumber(
                        controlNum,
                        "301GLO",
                        string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                    Func_File_Move(filename, string.Concat(filePrs, "\\", Path.GetFileName(filename)));
                    this.FileStatus.Created = true;
                    this.FileStatus.Status = true;
                    this.FileStatus.FileOutName = string.Concat(
                        fileOut,
                        "\\",
                        Path.GetFileNameWithoutExtension(filename),
                        ".edi");
                }
                else
                {
                    Func_File_Move(
                        string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"),
                        string.Concat(fileErr, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                    Func_File_Move(filename, string.Concat(fileErr, "\\", Path.GetFileName(filename)));
                    this.FileStatus.Created = false;
                    this.FileStatus.Status = false;
                    this.FileStatus.FileErrName = string.Concat(fileOut, "\\", Path.GetFileName(filename));
                }
            }
            return this.FileStatus;
        }
        //-----------------------------------------------------------------------------------------------------
        public FileAnalysis Func_X12_300_GLO_CWO_XUS_SHP_01(
            string filename,
            string errorOut,
            string validOut,
            string processOut = "")
        {
            this.FileStatus = new FileAnalysis();
            if (File.Exists(filename))
            {
                var ediInt = Interchange.LoadFrom(File.OpenRead(filename));
                var xmlInt = new UniversalInterchange();
                if (ediInt.Groups != null)
                {
                    for (var g = 0; g < ediInt.Groups.Count; g++)
                    {
                        xmlInt.Header = new UniversalInterchangeHeader
                        {
                            SenderID = ediInt.Groups[g].Gs.D_142_2,
                            RecipientID = ediInt.Groups[g].Gs.D_124_3
                        };
                        xmlInt.Body = new UniversalInterchangeBody
                        {
                            UniversalShipment =
                                new UniversalShipmentData {version = "1.1"}
                        };
                        for (var m = 0; m < ediInt.Groups[g].Messages.Count; m++)
                        {
                            if (ediInt.Groups[g].Messages[m].Context.Tag == "300")
                            {
                                try
                                {
                                    var objMsg = ediInt.Groups[g].Messages[m].DeserializeItem<M_300>();
                                    var objShp = new Shipment
                                    {
                                        AdditionalTerms = string.Empty,
                                        AgentsReference = string.Empty,
                                        AWBServiceLevel =
                                            new CodeDescriptionPair
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        CartageWaybillNumber = string.Empty,
                                        CFSReference = string.Empty,
                                        FirstBuyerContact = string.Empty,
                                        Folio = string.Empty,
                                        OwnerRef = string.Empty,
                                        QuoteNumber = string.Empty,
                                        SecondBuyerContact = string.Empty,
                                        VesselName = string.Empty,
                                        VoyageFlightNo = string.Empty,
                                        WarehouseLocation = string.Empty,
                                        DataContext =
                                            new DataContext
                                            {
                                                DataSourceCollection =
                                                    new List<DataSource>
                                                    {
                                                        new DataSource
                                                        {
                                                            Type
                                                                =
                                                                "ForwardingBooking",
                                                            Key
                                                                =
                                                                string
                                                                    .Empty
                                                        }
                                                    },
                                                DataTargetCollection =
                                                    new List<DataTarget>
                                                    {
                                                        new DataTarget
                                                        {
                                                            Type
                                                                =
                                                                "ForwardingBooking"
                                                        }
                                                    },
                                                ActionPurpose =
                                                    new CodeDescriptionPair
                                                    {
                                                        Code
                                                            =
                                                            "APP",
                                                        Description
                                                            =
                                                            "As Per Payload"
                                                    },
                                                Company =
                                                    new Company
                                                    {
                                                        Code = "JFK",
                                                        Country =
                                                            new Country
                                                            {
                                                                Code
                                                                    =
                                                                    "US",
                                                                Name
                                                                    =
                                                                    "United States"
                                                            },
                                                        Name =
                                                            "Walker International Transportation LLC"
                                                    },
                                                DataProvider = "X12300GLO",
                                                EnterpriseID = "WLT",
                                                EventBranch =
                                                    new Branch
                                                    {
                                                        Code = "JFK",
                                                        Name =
                                                            "USJFK - Valley Stream, NY"
                                                    },
                                                EventDepartment =
                                                    new Department
                                                    {
                                                        Code =
                                                            "FES",
                                                        Name =
                                                            "Forwarding Export Sea"
                                                    },
                                                EventType =
                                                    new CodeDescriptionPair
                                                    {
                                                        Code
                                                            =
                                                            "ADD"
                                                    },
                                                EventUser =
                                                    new Staff
                                                    {
                                                        Code = "JSM",
                                                        Name =
                                                            "Jerry S. Mabasa"
                                                    },
                                                ServerID = "JNJ",
                                                CodesMappedToTarget = true,
                                                CodesMappedToTargetSpecified =
                                                    true
                                            },
                                        ActualChargeable = 0M,
                                        ActualChargeableSpecified = true,
                                        BookingConfirmationReference = string.Empty,
                                        IsBooking = true,
                                        IsBookingSpecified = true,
                                        ContainerCount = 0,
                                        ContainerCountSpecified = true,
                                        ContainerMode = new ContainerMode(),
                                        FreightRate = 0M,
                                        FreightRateSpecified = true,
                                        FreightRateCurrency =
                                            new Currency
                                            {
                                                Code = "USD",
                                                Description = "United States Dollar"
                                            },
                                        GoodsDescription = string.Empty,
                                        GoodsValue = 0M,
                                        GoodsValueCurrency =
                                            new Currency
                                            {
                                                Code = "USD",
                                                Description = "United States Dollar"
                                            },
                                        HBLAWBChargesDisplay =
                                            new CodeDescriptionPair
                                            {
                                                Code = "SHW",
                                                Description =
                                                    "Show Collect Charges"
                                            },
                                        InsuranceValue = 0M,
                                        InsuranceValueCurrency =
                                            new Currency
                                            {
                                                Code = "USD",
                                                Description = "United States Dollar"
                                            },
                                        InterimReceiptNumber = string.Empty,
                                        IsDirectBooking = false,
                                        IsForwardRegistered = false,
                                        IsNeutralMaster = new IsNeutralMaster {Value = false},
                                        JobCosting =
                                            new ShipmentJobCosting
                                            {
                                                Branch =
                                                    new Branch
                                                    {
                                                        Code =
                                                            "JFK",
                                                        Name =
                                                            "USJFK - Valley Stream, NY"
                                                    },
                                                Currency =
                                                    new Currency
                                                    {
                                                        Code
                                                            =
                                                            "USD",
                                                        Description
                                                            =
                                                            "United States Dollar"
                                                    },
                                                Department =
                                                    new Department
                                                    {
                                                        Code
                                                            =
                                                            "FES",
                                                        Name
                                                            =
                                                            "Forwarding Export Sea"
                                                    },
                                                HomeBranch =
                                                    new Branch
                                                    {
                                                        Code =
                                                            "JFK",
                                                        Name =
                                                            "USJFK - Valley Stream, NY"
                                                    },
                                                OperationsStaff =
                                                    new Staff
                                                    {
                                                        Code =
                                                            "JSM"
                                                    },
                                                AccrualNotRecognized = 0M,
                                                AccrualNotRecognizedSpecified
                                                    = true,
                                                AccrualRecognized = 0M,
                                                AccrualRecognizedSpecified
                                                    = true,
                                                AgentRevenue = 0M,
                                                AgentRevenueSpecified =
                                                    true,
                                                LocalClientRevenue = 0M,
                                                LocalClientRevenueSpecified
                                                    = true,
                                                OtherDebtorRevenue = 0M,
                                                OtherDebtorRevenueSpecified
                                                    = true,
                                                SalesStaff =
                                                    new Staff
                                                    {
                                                        Code =
                                                            "JSM",
                                                        Name =
                                                            "Jerry S. Mabasa"
                                                    },
                                                TotalAccrual = 0M,
                                                TotalAccrualSpecified =
                                                    true,
                                                TotalCost = 0M,
                                                TotalCostSpecified = true,
                                                TotalJobProfit = 0M,
                                                TotalJobProfitSpecified =
                                                    true,
                                                TotalRevenue = 0M,
                                                TotalRevenueSpecified =
                                                    true,
                                                TotalWIP = 0M,
                                                TotalWIPSpecified = true,
                                                WIPNotRecognized = 0M,
                                                WIPNotRecognizedSpecified
                                                    = true,
                                                WIPRecognized = 0M,
                                                WIPRecognizedSpecified =
                                                    true,
                                                ChargeLineCollection =
                                                    new List
                                                        <
                                                            ShipmentJobCostingChargeLine
                                                            >()
                                            },
                                        OuterPacks = 0,
                                        OuterPacksSpecified = true,
                                        OuterPacksPackageType =
                                            new PackageType
                                            {
                                                Code = "PCS",
                                                Description = "Pieces"
                                            },
                                        PackingOrder = 0,
                                        ReleaseType =
                                            new CodeDescriptionPair
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        ServiceLevel =
                                            new ServiceLevel
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        ShipmentIncoTerm =
                                            new IncoTerm
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        ShippedOnBoard =
                                            new CodeDescriptionPair
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        TotalVolume = 0M,
                                        TotalVolumeSpecified = true,
                                        TotalVolumeUnit =
                                            new UnitOfVolume
                                            {
                                                Code = "M3",
                                                Description = "Cubic Meters"
                                            },
                                        TotalWeight = 0M,
                                        TotalWeightUnit =
                                            new UnitOfWeight
                                            {
                                                Code = "KG",
                                                Description = "Kilograms"
                                            },
                                        TotalWeightSpecified = true,
                                        TransportMode =
                                            new CodeDescriptionPair
                                            {
                                                Code = "SEA",
                                                Description =
                                                    "Sea Freight"
                                            },
                                        WayBillNumber = string.Empty,
                                        WayBillType =
                                            new WayBillType
                                            {
                                                Code = "HWB",
                                                Description = "House Waybill"
                                            },
                                        LocalProcessing =
                                            new ShipmentLocalProcessing
                                            {
                                                DeliveryRequiredBy =
                                                    string.Empty,
                                                EstimatedDelivery =
                                                    string.Empty,
                                                EstimatedPickup =
                                                    string.Empty,
                                                FCLDeliveryEquipmentNeeded
                                                    =
                                                    new CodeDescriptionPair
                                                    {
                                                        Code
                                                            =
                                                            "WUP",
                                                        Description
                                                            =
                                                            "Wait for Pack/Unpack"
                                                    },
                                                FCLPickupEquipmentNeeded
                                                    =
                                                    new CodeDescriptionPair
                                                    {
                                                        Code
                                                            =
                                                            "WUP",
                                                        Description
                                                            =
                                                            "Wait for Pack/Unpack"
                                                    },
                                                InsuranceRequired =
                                                    false,
                                                PickupRequiredBy =
                                                    string.Empty,
                                                OrderNumberCollection
                                                    =
                                                    new List
                                                        <
                                                            ShipmentLocalProcessingOrderNumber
                                                            >()
                                            },
                                        ContainerCollection = new ShipmentContainerCollection(),
                                        DateCollection = new List<Date>(),
                                        OrganizationAddressCollection =
                                            new List<OrganizationAddress>(),
                                        NoteCollection = new List<Note>()
                                    };
                                    if (objMsg.S_Y1.D_375_8Specified)
                                    {
                                        objShp.ServiceLevel.Code =
                                            this.Func_SQL_TranslateX12TariffServiceLevel(objMsg.S_Y1.D_375_8.ToString());
                                    }
                                    if ((objMsg.S_B1.D_145_2 != null) || (objMsg.S_B1.D_145_2 != string.Empty))
                                    {
                                        objShp.WayBillNumber = objMsg.S_B1.D_145_2;
                                        objShp.DataContext.DataSourceCollection[0].Key = objMsg.S_B1.D_145_2;
                                    }
                                    var cntCount = 0;
                                    for (var y = 0; y < objMsg.G_Y2.Count; y++)
                                    {
                                        int value;
                                        int.TryParse(objMsg.G_Y2[y].S_Y2.D_95_1, out value);
                                        cntCount += value;
                                    }
                                    objShp.ContainerCount = cntCount;
                                    if (objShp.ContainerCount > 0)
                                    {
                                        objShp.ContainerMode.Code = "FCL";
                                        objShp.ContainerMode.Description = "Full Container Load";
                                    }
                                    else
                                    {
                                        objShp.ContainerMode.Code = "LCL";
                                        objShp.ContainerMode.Description = "Less Container Load";
                                    }
                                    int cntPgk;
                                    int.TryParse(objMsg.G_LX[0].S_L0.D_80_8, out cntPgk);
                                    objShp.OuterPacks = cntPgk;
                                    if (objMsg.G_LX[0].S_L0.D_211_14Specified)
                                    {
                                        objShp.OuterPacksPackageType.Code = objMsg.G_LX[0].S_L0.D_211_14.ToString();
                                        objShp.OuterPacksSpecified = true;
                                    }
                                    else
                                    {
                                        objShp.OuterPacksPackageType.Code = string.Empty;
                                        objShp.OuterPacksSpecified = false;
                                    }
                                    for (var r = 0; r < objMsg.G_R4.Count; r++)
                                    {
                                        switch (objMsg.G_R4[r].S_R4.D_115_1)
                                        {
                                            case EdiFabric.Definitions.X12_004010_300.X12_ID_115.D:
                                            {
                                                objShp.PortOfDischarge = new UNLOCO();
                                                if (objMsg.G_R4[r].S_R4.D_309_2Specified)
                                                {
                                                    if (objMsg.G_R4[r].S_R4.D_309_2
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_309.AC)
                                                    {
                                                        objShp.PortOfDischarge.Code =
                                                            this.Func_SQL_GetPortCodeFromCityName(
                                                                objMsg.G_R4[r].S_R4.D_310_3,
                                                                objMsg.G_R4[r].S_R4.D_156_8,
                                                                objMsg.G_R4[r].S_R4.D_26_5);
                                                        objShp.PortOfDischarge.Name =
                                                            this.Func_SQL_GetPortNameFromCityName(
                                                                objMsg.G_R4[r].S_R4.D_310_3,
                                                                objMsg.G_R4[r].S_R4.D_156_8,
                                                                objMsg.G_R4[r].S_R4.D_26_5);
                                                    }
                                                }
                                                if (objMsg.G_R4[r].S_R4.D_309_2Specified)
                                                {
                                                    if (objMsg.G_R4[r].S_R4.D_309_2
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_309.UN)
                                                    {
                                                        objShp.PortOfDischarge.Code =
                                                            objMsg.G_R4[r].S_R4.D_310_3.Replace(" ", string.Empty);
                                                        objShp.PortOfDischarge.Name = objMsg.G_R4[r].S_R4.D_114_4;
                                                    }
                                                }
                                                foreach (var t in objMsg.G_R4[r].S_DTM)
                                                {
                                                    if (t.D_374_1
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_374.Item371)
                                                    {
                                                        var arv = new Date
                                                        {
                                                            Type = DateType.Arrival,
                                                            Value =
                                                                this.Func_CON_ToISODate_STR(
                                                                    t.D_373_2,
                                                                    t.D_337_3),
                                                            IsEstimate = true,
                                                            IsEstimateSpecified = true
                                                        };
                                                        objShp.DateCollection.Add(arv);
                                                    }
                                                }
                                            }
                                                break;

                                            case EdiFabric.Definitions.X12_004010_300.X12_ID_115.J:
                                            case EdiFabric.Definitions.X12_004010_300.X12_ID_115.L:
                                            {
                                                objShp.PortOfLoading = new UNLOCO();
                                                if (objMsg.G_R4[r].S_R4.D_309_2Specified)
                                                {
                                                    if (objMsg.G_R4[r].S_R4.D_309_2
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_309.AC)
                                                    {
                                                        objShp.PortOfLoading.Code =
                                                            this.Func_SQL_GetPortCodeFromCityName(
                                                                objMsg.G_R4[r].S_R4.D_310_3,
                                                                objMsg.G_R4[r].S_R4.D_156_8,
                                                                objMsg.G_R4[r].S_R4.D_26_5);
                                                        objShp.PortOfLoading.Name =
                                                            this.Func_SQL_GetPortNameFromCityName(
                                                                objMsg.G_R4[r].S_R4.D_310_3,
                                                                objMsg.G_R4[r].S_R4.D_156_8,
                                                                objMsg.G_R4[r].S_R4.D_26_5);
                                                    }
                                                }
                                                if (objMsg.G_R4[r].S_R4.D_309_2Specified)
                                                {
                                                    if (objMsg.G_R4[r].S_R4.D_309_2
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_309.UN)
                                                    {
                                                        objShp.PortOfLoading.Code =
                                                            objMsg.G_R4[r].S_R4.D_310_3.Replace(" ", string.Empty);
                                                        objShp.PortOfLoading.Name = objMsg.G_R4[r].S_R4.D_114_4;
                                                    }
                                                }
                                                foreach (var t in objMsg.G_R4[r].S_DTM)
                                                {
                                                    if (t.D_374_1
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_374.Item010)
                                                    {
                                                        var dep = new Date
                                                        {
                                                            Type = DateType.Departure,
                                                            Value =
                                                                this.Func_CON_ToISODate_STR(
                                                                    t.D_373_2,
                                                                    t.D_337_3),
                                                            IsEstimate = true,
                                                            IsEstimateSpecified = true
                                                        };
                                                        objShp.DateCollection.Add(dep);
                                                    }
                                                }
                                            }
                                                break;

                                            case EdiFabric.Definitions.X12_004010_300.X12_ID_115.R:
                                            {
                                                objShp.PortOfOrigin = new UNLOCO();
                                                if (objMsg.G_R4[r].S_R4.D_309_2Specified)
                                                {
                                                    if (objMsg.G_R4[r].S_R4.D_309_2
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_309.AC)
                                                    {
                                                        objShp.PortOfOrigin.Code =
                                                            this.Func_SQL_GetPortCodeFromCityName(
                                                                objMsg.G_R4[r].S_R4.D_310_3,
                                                                objMsg.G_R4[r].S_R4.D_156_8,
                                                                objMsg.G_R4[r].S_R4.D_26_5);
                                                        objShp.PortOfOrigin.Name =
                                                            this.Func_SQL_GetPortNameFromCityName(
                                                                objMsg.G_R4[r].S_R4.D_310_3,
                                                                objMsg.G_R4[r].S_R4.D_156_8,
                                                                objMsg.G_R4[r].S_R4.D_26_5);
                                                    }
                                                }
                                                if (objMsg.G_R4[r].S_R4.D_309_2Specified)
                                                {
                                                    if (objMsg.G_R4[r].S_R4.D_309_2
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_309.UN)
                                                    {
                                                        objShp.PortOfOrigin.Code =
                                                            objMsg.G_R4[r].S_R4.D_310_3.Replace(" ", string.Empty);
                                                        objShp.PortOfOrigin.Name = objMsg.G_R4[r].S_R4.D_114_4;
                                                    }
                                                }
                                                foreach (var t in objMsg.G_R4[r].S_DTM)
                                                {
                                                    if (t.D_374_1
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_374.Item118)
                                                    {
                                                        objShp.LocalProcessing.EstimatedPickup =
                                                            this.Func_CON_ToISODate_STR(t.D_373_2, t.D_337_3);
                                                        objShp.LocalProcessing.PickupRequiredBy =
                                                            this.Func_CON_ToISODate_STR(t.D_373_2, t.D_337_3);
                                                        var pic = new Date
                                                        {
                                                            Type = DateType.Pickup,
                                                            Value =
                                                                this.Func_CON_ToISODate_STR(
                                                                    t.D_373_2,
                                                                    t.D_337_3),
                                                            IsEstimate = true,
                                                            IsEstimateSpecified = true
                                                        };
                                                        objShp.DateCollection.Add(pic);
                                                    }
                                                }
                                            }
                                                break;

                                            case EdiFabric.Definitions.X12_004010_300.X12_ID_115.E:
                                            {
                                                objShp.PortOfDestination = new UNLOCO();
                                                if (objMsg.G_R4[r].S_R4.D_309_2Specified)
                                                {
                                                    if (objMsg.G_R4[r].S_R4.D_309_2
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_309.AC)
                                                    {
                                                        objShp.PortOfDestination.Code =
                                                            this.Func_SQL_GetPortCodeFromCityName(
                                                                objMsg.G_R4[r].S_R4.D_310_3,
                                                                objMsg.G_R4[r].S_R4.D_156_8,
                                                                objMsg.G_R4[r].S_R4.D_26_5);
                                                        objShp.PortOfDestination.Name =
                                                            this.Func_SQL_GetPortNameFromCityName(
                                                                objMsg.G_R4[r].S_R4.D_310_3,
                                                                objMsg.G_R4[r].S_R4.D_156_8,
                                                                objMsg.G_R4[r].S_R4.D_26_5);
                                                    }
                                                }
                                                if (objMsg.G_R4[r].S_R4.D_309_2Specified)
                                                {
                                                    if (objMsg.G_R4[r].S_R4.D_309_2
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_309.UN)
                                                    {
                                                        objShp.PortOfDestination.Code =
                                                            objMsg.G_R4[r].S_R4.D_310_3.Replace(" ", string.Empty);
                                                        objShp.PortOfDestination.Name = objMsg.G_R4[r].S_R4.D_114_4;
                                                    }
                                                }
                                                foreach (var t in objMsg.G_R4[r].S_DTM)
                                                {
                                                    if (t.D_374_1
                                                        == EdiFabric.Definitions.X12_004010_300.X12_ID_374.Item074)
                                                    {
                                                        objShp.LocalProcessing.DeliveryRequiredBy =
                                                            this.Func_CON_ToISODate_STR(t.D_373_2, t.D_337_3);
                                                        objShp.LocalProcessing.EstimatedDelivery =
                                                            this.Func_CON_ToISODate_STR(t.D_373_2, t.D_337_3);
                                                        var dlv = new Date
                                                        {
                                                            Type = DateType.Delivery,
                                                            Value =
                                                                this.Func_CON_ToISODate_STR(
                                                                    t.D_373_2,
                                                                    t.D_337_3),
                                                            IsEstimate = true,
                                                            IsEstimateSpecified = true
                                                        };
                                                        objShp.DateCollection.Add(dlv);
                                                        var dlvR = new Date
                                                        {
                                                            Type = DateType.DeliveryRequiredBy,
                                                            Value =
                                                                this.Func_CON_ToISODate_STR(
                                                                    t.D_373_2,
                                                                    t.D_337_3),
                                                            IsEstimate = true,
                                                            IsEstimateSpecified = true
                                                        };
                                                        objShp.DateCollection.Add(dlvR);
                                                    }
                                                }
                                            }
                                                break;
                                        }
                                    }
                                    for (var n9 = 0; n9 < objMsg.S_N9.Count; n9++)
                                    {
                                        var str = objMsg.S_N9[n9].D_128_1.ToString();
                                        if (str != string.Empty)
                                        {
                                            switch (str)
                                            {
                                                case "PO":
                                                {
                                                    var objRef = new ShipmentLocalProcessingOrderNumber
                                                    {
                                                        OrderReference
                                                            =
                                                            objMsg
                                                                .S_N9
                                                                //-----------------------------------------------------------------------------------------------------
                                                                [n9]
                                                                .D_127_2
                                                    };
                                                    objShp.LocalProcessing.OrderNumberCollection.Add(objRef);
                                                }
                                                    break;

                                                case "BN":
                                                {
                                                    var objRef =
                                                        new ShipmentAdditionalReferenceCollectionAdditionalReference
                                                        {
                                                            Type
                                                                =
                                                            {
                                                                Code
                                                                    =
                                                                    "BKG"
                                                            },
                                                            ReferenceNumber
                                                                =
                                                                objMsg
                                                                    .S_N9
                                                                    [
                                                                        n9
                                                                    ]
                                                                    .D_127_2
                                                        };
                                                    objShp.AdditionalReferenceCollection.AdditionalReference.Add(
                                                        objRef);
                                                }
                                                    break;

                                                case "SI":
                                                {
                                                    var objRef =
                                                        new ShipmentAdditionalReferenceCollectionAdditionalReference
                                                        {
                                                            Type
                                                                =
                                                            {
                                                                Code
                                                                    =
                                                                    "UCR"
                                                            },
                                                            ReferenceNumber
                                                                =
                                                                objMsg
                                                                    .S_N9
                                                                    [
                                                                        n9
                                                                    ]
                                                                    .D_127_2
                                                        };
                                                    objShp.AdditionalReferenceCollection.AdditionalReference.Add(
                                                        objRef);
                                                }
                                                    break;

                                                case "TS":
                                                {
                                                    var objRef =
                                                        new ShipmentAdditionalReferenceCollectionAdditionalReference
                                                        {
                                                            Type
                                                                =
                                                            {
                                                                Code
                                                                    =
                                                                    "CON"
                                                            },
                                                            ReferenceNumber
                                                                =
                                                                objMsg
                                                                    .S_N9
                                                                    [
                                                                        n9
                                                                    ]
                                                                    .D_127_2
                                                        };
                                                    objShp.AdditionalReferenceCollection.AdditionalReference.Add(
                                                        objRef);
                                                }
                                                    break;

                                                case "OL":
                                                {
                                                    var objRef =
                                                        new ShipmentAdditionalReferenceCollectionAdditionalReference
                                                        {
                                                            Type
                                                                =
                                                            {
                                                                Code
                                                                    =
                                                                    "LID"
                                                            },
                                                            ReferenceNumber
                                                                =
                                                                objMsg
                                                                    .S_N9
                                                                    [
                                                                        n9
                                                                    ]
                                                                    .D_127_2,
                                                            ContextInformation
                                                                =
                                                                objMsg
                                                                    .S_N9
                                                                    [
                                                                        n9
                                                                    ]
                                                                    .D_369_3
                                                        };
                                                    objShp.AdditionalReferenceCollection.AdditionalReference.Add(
                                                        objRef);
                                                }
                                                    break;

                                                case "MB":
                                                {
                                                    var objRef =
                                                        new ShipmentAdditionalReferenceCollectionAdditionalReference
                                                        {
                                                            Type
                                                                =
                                                            {
                                                                Code
                                                                    =
                                                                    "BKG"
                                                            },
                                                            ReferenceNumber
                                                                =
                                                                objMsg
                                                                    .S_N9
                                                                    [
                                                                        n9
                                                                    ]
                                                                    .D_127_2,
                                                            ContextInformation
                                                                =
                                                                objMsg
                                                                    .S_N9
                                                                    [
                                                                        n9
                                                                    ]
                                                                    .D_369_3
                                                        };
                                                    objShp.AdditionalReferenceCollection.AdditionalReference.Add(
                                                        objRef);
                                                }
                                                    break;
                                            }
                                        }
                                    }
                                    for (var cc = 0; cc < objMsg.G_Y2.Count; cc++)
                                    {
                                        var objCnt = new ShipmentContainerCollectionContainer
                                        {
                                            AirVentFlow = 0,
                                            Commodity =
                                                new Commodity
                                                {
                                                    Code
                                                        =
                                                        string
                                                            .Empty,
                                                    Description
                                                        =
                                                        string
                                                            .Empty
                                                },
                                            ContainerType =
                                                new ShipmentContainerCollectionContainerContainerType
                                                {
                                                    Code
                                                        =
                                                        objMsg
                                                            .G_Y2
                                                            [
                                                                cc
                                                            ]
                                                            .S_Y2
                                                            .D_24_4,
                                                    Category
                                                        =
                                                        new ShipmentContainerCollectionContainerContainerTypeCategory
                                                        {
                                                            Code
                                                                =
                                                                string
                                                                    .Empty,
                                                            Description
                                                                =
                                                                string
                                                                    .Empty
                                                        },
                                                    Description
                                                        =
                                                        string
                                                            .Empty,
                                                    ISOCode
                                                        =
                                                        string
                                                            .Empty
                                                },
                                            DepartureEstimatedPickup
                                                = string.Empty,
                                            DepartureSlotDateTime =
                                                string.Empty,
                                            DepartureSlotReference =
                                                string.Empty,
                                            EmptyRequired =
                                                string.Empty,
                                            FCL_LCL_AIR =
                                                new ContainerMode
                                                {
                                                    Code
                                                        =
                                                        Enum
                                                            .GetName
                                                            (
                                                                typeof
                                                                    (
                                                                    X12_ID_102
                                                                    ),
                                                                objMsg
                                                                    .G_Y2
                                                                    [
                                                                        cc
                                                                    ]
                                                                    .S_Y2
                                                                    .D_91_5)
                                                },
                                            ReleaseNum =
                                                string.Empty,
                                            SetPointTemp = 0M,
                                            TempRecorderSerialNo =
                                                string.Empty
                                        };
                                        int intCnt;
                                        int.TryParse(objMsg.G_Y2[cc].S_Y2.D_95_1, out intCnt);
                                        objCnt.ContainerCount = intCnt;
                                        objShp.ContainerCollection.Container.Add(objCnt);
                                    }
                                    objShp.ContainerCollection.Content = CollectionContent.Complete;
                                    objShp.ContainerCollection.ContentSpecified = true;
                                    for (var n1 = 0; n1 < objMsg.G_N1.Count; n1++)
                                    {
                                        var objAdd = new OrganizationAddress();
                                        var str = objMsg.G_N1[n1].S_N1.D_98_1.ToString();
                                        switch (str)
                                        {
                                            case "BT":
                                            {
                                                objAdd.AddressType = "LocalClient";
                                            }
                                                break;

                                            case "SH":
                                            {
                                                objAdd.AddressType = "ConsignorDocumentaryAddress";
                                            }
                                                break;

                                            case "AB":
                                            case "SF":
                                            {
                                                objAdd.AddressType = "ConsignorPickupDeliveryAddress";
                                            }
                                                break;

                                            case "AE":
                                            {
                                                objAdd.AddressType = "ConsigneePickupDeliveryAddress";
                                            }
                                                break;

                                            case "ST":
                                            {
                                                objAdd.AddressType = "ConsigneePickupDeliveryAddress";
                                            }
                                                break;

                                            case "CN":
                                            {
                                                objAdd.AddressType = "ConsigneeDocumentaryAddress";
                                            }
                                                break;
                                        }
                                        if (objAdd.AddressType != string.Empty)
                                        {
                                            if (objMsg.G_N1[n1].S_N1 != null)
                                            {
                                                if (objMsg.G_N1[n1].S_N1.D_67_4 != null)
                                                {
                                                    objAdd.OrganizationCode = objMsg.G_N1[n1].S_N1.D_67_4;
                                                }
                                                if (objMsg.G_N1[n1].S_N1.D_93_2 != null)
                                                {
                                                    objAdd.CompanyName = objMsg.G_N1[n1].S_N1.D_93_2;
                                                }
                                            }
                                            if (objMsg.G_N1[n1].S_N3.Count >= 1)
                                            {
                                                if (objMsg.G_N1[n1].S_N3[0].D_166_1 != null)
                                                {
                                                    objAdd.Address1 = objMsg.G_N1[n1].S_N3[0].D_166_1;
                                                }
                                            }
                                            if (objMsg.G_N1[n1].S_N3.Count >= 2)
                                            {
                                                if (objMsg.G_N1[n1].S_N3[1].D_166_2 != null)
                                                {
                                                    objAdd.Address2 = objMsg.G_N1[n1].S_N3[1].D_166_2;
                                                }
                                            }
                                            objAdd.City = objMsg.G_N1[n1].S_N4.D_19_1;
                                            if (objMsg.G_N1[n1].S_N4 != null)
                                            {
                                                if (objMsg.G_N1[n1].S_N4.D_19_1 != null)
                                                {
                                                    objAdd.City = objMsg.G_N1[n1].S_N4.D_19_1;
                                                }
                                                if (objMsg.G_N1[n1].S_N4.D_156_2 != null)
                                                {
                                                    objAdd.State = objMsg.G_N1[n1].S_N4.D_156_2;
                                                }
                                                if (objMsg.G_N1[n1].S_N4 != null)
                                                {
                                                    if (objMsg.G_N1[n1].S_N4.D_156_2 != null)
                                                    {
                                                        if ((objMsg.G_N1[n1].S_N4.D_19_1 != null)
                                                            && (objMsg.G_N1[n1].S_N4.D_156_2 != null)
                                                            && (objMsg.G_N1[n1].S_N4.D_26_4 != null))
                                                        {
                                                            objAdd.State =
                                                                this.Func_SQL_GetPortStateFromCityName(
                                                                    objMsg.G_N1[n1].S_N4.D_19_1,
                                                                    objMsg.G_N1[n1].S_N4.D_156_2,
                                                                    objMsg.G_N1[n1].S_N4.D_26_4) ?? string.Empty;
                                                        }
                                                    }
                                                }
                                                if (objMsg.G_N1[n1].S_N4.D_116_3 != null)
                                                {
                                                    objAdd.Postcode = objMsg.G_N1[n1].S_N4.D_116_3;
                                                }
                                                if (objMsg.G_N1[n1].S_N4.D_26_4 != null)
                                                {
                                                    objAdd.Country.Code = objMsg.G_N1[n1].S_N4.D_26_4;
                                                }
                                            }
                                            for (var g61 = 0; g61 < objMsg.G_N1[n1].S_G61_2.Count; g61++)
                                            {
                                                if (objMsg.G_N1[n1].S_G61_2[g61].D_93_2 != null)
                                                {
                                                    objAdd.Contact = objMsg.G_N1[n1].S_G61_2[g61].D_93_2;
                                                }
                                                if (objMsg.G_N1[n1].S_G61_2[g61].D_365_3Specified)
                                                {
                                                    if (objMsg.G_N1[n1].S_G61_2[g61].D_365_3 == X12_ID_365.TE)
                                                    {
                                                        objAdd.Phone = objMsg.G_N1[n1].S_G61_2[g61].D_364_4;
                                                    }
                                                    if (objMsg.G_N1[n1].S_G61_2[g61].D_365_3 == X12_ID_365.EM)
                                                    {
                                                        objAdd.Email = objMsg.G_N1[n1].S_G61_2[g61].D_364_4;
                                                    }
                                                }
                                            }
                                            objShp.OrganizationAddressCollection.Add(objAdd);
                                        }
                                    }
                                    var CNE = false;
                                    foreach (var org in objShp.OrganizationAddressCollection)
                                    {
                                        if (org.AddressType == "ConsigneeDocumentaryAddress")
                                        {
                                            CNE = true;
                                        }
                                    }
                                    if (CNE == false)
                                    {
                                        for (var o = 0; o < objShp.OrganizationAddressCollection.Count; o++)
                                        {
                                            if (objShp.OrganizationAddressCollection[o].AddressType
                                                == "ConsigneePickupDeliveryAddress")
                                            {
                                                var objAdd = new OrganizationAddress
                                                {
                                                    AddressType =
                                                        "ConsigneeDocumentaryAddress",
                                                    OrganizationCode =
                                                        objShp
                                                            .OrganizationAddressCollection
                                                            [o].OrganizationCode,
                                                    CompanyName =
                                                        objShp
                                                            .OrganizationAddressCollection
                                                            [o].CompanyName,
                                                    Address1 =
                                                        objShp
                                                            .OrganizationAddressCollection
                                                            [o].Address1,
                                                    Address2 =
                                                        objShp
                                                            .OrganizationAddressCollection
                                                            [o].Address2,
                                                    City =
                                                        objShp
                                                            .OrganizationAddressCollection
                                                            [o].City,
                                                    State =
                                                        objShp
                                                            .OrganizationAddressCollection
                                                            [o].State,
                                                    Postcode =
                                                        objShp
                                                            .OrganizationAddressCollection
                                                            [o].Postcode,
                                                    Country =
                                                        objShp
                                                            .OrganizationAddressCollection
                                                            [o].Country
                                                };
                                                objShp.OrganizationAddressCollection.Add(objAdd);
                                            }
                                        }
                                    }
                                    if (objMsg.G_LX[0].S_L1 != null)
                                    {
                                        var decAmnt = 0M;
                                        var chgLine = new ShipmentJobCostingChargeLine
                                        {
                                            Branch =
                                                new Branch
                                                {
                                                    Code = "JFK",
                                                    Name =
                                                        "USJFK - Valley Stream, NY"
                                                },
                                            ChargeCode =
                                                new ChargeCode
                                                {
                                                    Code =
                                                        objMsg
                                                            .G_LX
                                                            [0
                                                            ]
                                                            .S_L1
                                                            .D_150_8
                                                            .ToString
                                                            (),
                                                    Description
                                                        =
                                                        objMsg
                                                            .G_LX
                                                            [0
                                                            ]
                                                            .S_L1
                                                            .D_150_8
                                                            .ToString
                                                            ()
                                                },
                                            ChargeCodeGroup =
                                                new CodeDescriptionPair
                                                {
                                                    Code
                                                        =
                                                        "FRT",
                                                    Description
                                                        =
                                                        "Freight"
                                                },
                                            CostApportionmentConsolNumber
                                                = new EntityReference(),
                                            CostGSTVATID = new TaxID(),
                                            CostIsPosted = false,
                                            CostLocalAmount = 0M,
                                            CostLocalAmountSpecified =
                                                true,
                                            CostOSAmount = 0M,
                                            CostOSAmountSpecified = true,
                                            CostOSCurrency =
                                                new Currency
                                                {
                                                    Code =
                                                        "USD",
                                                    Description
                                                        =
                                                        "United States Dollar"
                                                },
                                            CostOSGSTVATAmount = 0M,
                                            CostOSGSTVATAmountSpecified =
                                                true,
                                            Creditor =
                                                new OrganizationReference
                                                    (),
                                            Debtor =
                                                new OrganizationReference
                                                {
                                                    Key
                                                        =
                                                        "Organization",
                                                    Type
                                                        =
                                                        "GLOX12300"
                                                },
                                            Department =
                                                new Department
                                                {
                                                    Code =
                                                        "FES",
                                                    Name =
                                                        "Forwarding Export Sea"
                                                },
                                            Description =
                                                objMsg.G_LX[0].S_L1
                                                    .D_150_8.ToString(),
                                            ExternalDebtorCode = "JJSLC",
                                            SellInvoiceType = "FIN",
                                            SellIsPosted = false,
                                            SellLocalAmount = 0M,
                                            SellLocalAmountSpecified =
                                                true,
                                            SellOSAmount = 0M,
                                            SellOSCurrency =
                                                new Currency
                                                {
                                                    Code =
                                                        "USD",
                                                    Description
                                                        =
                                                        "United States Dollar"
                                                },
                                            SellOSGSTVATAmount = 0M,
                                            SellOSGSTVATAmountSpecified =
                                                true,
                                            DisplaySequence = 1
                                        };
                                        decimal.TryParse(objMsg.G_LX[0].S_L1.D_58_4, out decAmnt);
                                        chgLine.SellLocalAmount = decAmnt;
                                        objShp.JobCosting.ChargeLineCollection.Add(chgLine);
                                    }
                                    for (var k1 = 0; k1 < objMsg.S_K1.Count; k1++)
                                    {
                                        var note = new Note
                                        {
                                            IsCustomDescription = true,
                                            Description = "Imported Notes",
                                            NoteText =
                                                objMsg.S_K1[k1].D_61_1 + Environment.NewLine
                                                + objMsg.S_K1[k1].D_61_2
                                        };
                                        objShp.NoteCollection.Add(note);
                                    }

                                    var ediList = this.Func_EDI_GetOriginalMessage(filename, '*', '~');
                                    if (ediList.Count > 0)
                                    {
                                        var ediNote = new Note
                                        {
                                            IsCustomDescription = true,
                                            Description = "Original EDI Message"
                                        };
                                        foreach (var item in ediList)
                                        {
                                            if (ediNote.NoteText == string.Empty)
                                            {
                                                ediNote.NoteText = item;
                                            }
                                            else
                                            {
                                                ediNote.NoteText = ediNote.NoteText + Environment.NewLine + item;
                                            }
                                        }
                                        objShp.NoteCollection.Add(ediNote);
                                    }
                                    xmlInt.Body.UniversalShipment.Shipment = objShp;
                                }
                                catch (Exception exc)
                                {
                                    Debug.Print(exc.Message);
                                    throw;
                                }
                            }
                        }
                        xmlInt.Serialize();
                        xmlInt.SaveToFile(
                            string.Concat(validOut, "\\300_GLO_", Path.GetFileNameWithoutExtension(filename), ".xml"));
                        this.FileStatus.FileOutName = string.Concat(
                            validOut,
                            "\\300_GLO_",
                            Path.GetFileNameWithoutExtension(filename),
                            ".xml");
                        this.FileStatus.Status = true;
                        Func_File_Move(filename, string.Concat(processOut, "\\", Path.GetFileName(filename)));
                    }
                }
            }
            else
            {
                this.FileStatus.ExcpMessage = "Cannot Find: " + filename;
            }
            return this.FileStatus;
        }
        public FileAnalysis Func_CWO_XUS_SHP_X12_214_GLO(
            string filename,
            string fileOut,
            string filePrs,
            string fileErr)
        {
            this.FileStatus = new FileAnalysis();
            if (File.Exists(filename))
            {
                var controlNum = this.Func_SQL_GetControlNumber();
                var doc = new XmlDocument();
                doc.Load(filename);
                XmlNode root = doc.DocumentElement;
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("ns", "http://www.cargowise.com/Schemas/Universal/2011/11");
                var myInterchange = new MyINT(controlNum, "12", "3023254180", "ZZ", "FMXJ214", true);
                var myGroup = myInterchange.CreateGroup(controlNum, "QM", "3023254180", "FMXJ214");
                var myMessage = new X12_4010_214(controlNum);
                var statusCode = this.Func_XML_GetResultString(doc, nsmgr, @"//ns:ActionPurpose/ns:Code");
                if (statusCode != string.Empty)
                {
                    myMessage.Add_B10(
                        this.Func_XML_GetResultString(doc, nsmgr,
                            @"//ns:Shipment/ns:DataContext/ns:DataSourceCollection/ns:DataSource[ns:Type='ForwardingShipment']/ns:Key"),
                        this.Func_XML_GetResultString(doc, nsmgr, @"//ns:SubShipmentCollection/ns:SubShipment/ns:WayBillNumber"),
                        "WINA"
                        );

                    switch (statusCode)
                    {
                        case "AAP":
                        {
                        }
                            break;

                        case "ABD":
                        {
                        }
                            break;

                        case "X3P":
                        {
                            myMessage.Add_LX("1", X12_ID_1650.X3, X12_ID_1651.NS, X12_ID_1652.AA, X12_ID_1651.NS,
                                this.Func_XML_GetResultDate(doc, nsmgr,
                                    @"//ns:LocalProcessing/ns:PickupCartageCompleted"),
                                this.Func_XML_GetResultTime(doc, nsmgr,
                                    @"//ns:LocalProcessing/ns:PickupCartageCompleted"),
                                EdiFabric.Definitions.X12_004010_214.X12_ID_623.LT,
                                this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:OrganizationAddressCollection/ns:OrganizationAddress[ns:AddressType='ConsignorPickupDeliveryAddress']/ns:City"),
                                this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:OrganizationAddressCollection/ns:OrganizationAddress[ns:AddressType='ConsignorPickupDeliveryAddress']/ns:State"),
                                this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:OrganizationAddressCollection/ns:OrganizationAddress[ns:AddressType='ConsignorPickupDeliveryAddress']/ns:Country/ns:Code")
                                );
                        }
                            break;

                        case "AFP":
                        {
                            myMessage.Add_LX("1", X12_ID_1650.AF, X12_ID_1651.NS, X12_ID_1652.AA, X12_ID_1651.NS,
                                this.Func_XML_GetResultDate(doc, nsmgr,
                                    @"//ns:LocalProcessing/ns:PickupCartageCompleted"),
                                this.Func_XML_GetResultTime(doc, nsmgr,
                                    @"//ns:LocalProcessing/ns:PickupCartageCompleted"),
                                EdiFabric.Definitions.X12_004010_214.X12_ID_623.LT,
                                this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:OrganizationAddressCollection/ns:OrganizationAddress[ns:AddressType='ConsignorPickupDeliveryAddress']/ns:City"),
                                this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:OrganizationAddressCollection/ns:OrganizationAddress[ns:AddressType='ConsignorPickupDeliveryAddress']/ns:State"),
                                this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:OrganizationAddressCollection/ns:OrganizationAddress[ns:AddressType='ConsignorPickupDeliveryAddress']/ns:Country/ns:Code")
                                );
                        }
                            break;

                        case "X1D":
                        {
                        }
                            break;

                        case "D1D":
                        {
                        }
                            break;

                        case "AGP":
                        {
                        }
                            break;

                        case "OOP":
                        {
                                myMessage.Add_LX("1", X12_ID_1650.OO, X12_ID_1651.NS, X12_ID_1652.AA, X12_ID_1651.NS,
                                this.Func_XML_GetResultDate(doc, nsmgr,
                                    @"//ns:TriggerDate"),
                                this.Func_XML_GetResultTime(doc, nsmgr,
                                    @"//ns:TriggerDate"),
                                EdiFabric.Definitions.X12_004010_214.X12_ID_623.LT,
                                Func_SQL_GetCityNameFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code"))
                                    .Substring(0, 29)
                                    .Trim(),
                                Func_SQL_GetStateCodeFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code")),
                                Func_SQL_GetCountryCodeFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code"))
                                );
                            }
                            break;

                        case "P1P":
                        {
                            myMessage.Add_LX("1", X12_ID_1650.P1, X12_ID_1651.NS, X12_ID_1652.AA, X12_ID_1651.NS,
                                this.Func_XML_GetResultDate(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:ActualDeparture"),
                                this.Func_XML_GetResultTime(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:ActualDeparture"),
                                EdiFabric.Definitions.X12_004010_214.X12_ID_623.LT,
                                Func_SQL_GetCityNameFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code"))
                                    .Substring(0, 29)
                                    .Trim(),
                                Func_SQL_GetStateCodeFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code")),
                                Func_SQL_GetCountryCodeFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code"))
                                );
                        }
                            break;

                        case "X4D":
                        {
                            myMessage.Add_LX("1", X12_ID_1650.X4, X12_ID_1651.NS, X12_ID_1652.AA, X12_ID_1651.NS,
                                this.Func_XML_GetResultDate(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:ActualArrival"),
                                this.Func_XML_GetResultTime(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:ActualArrival"),
                                EdiFabric.Definitions.X12_004010_214.X12_ID_623.LT,
                                Func_SQL_GetCityNameFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfDischarge/ns:Code"))
                                    .Substring(0, 29)
                                    .Trim(),
                                Func_SQL_GetStateCodeFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfDischarge/ns:Code")),
                                Func_SQL_GetCountryCodeFromPortCode(this.Func_XML_GetResultString(doc, nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfDischarge/ns:Code"))
                                );
                        }
                            break;

                        case "X9D":
                        {
                        }
                            break;
                    }

                    myGroup.AddMessage(myMessage.m214);
                    myInterchange.SaveEdi(@"D:\Temp\X12\214\GLO\Out\" + Path.GetFileNameWithoutExtension(filename) +
                                          ".edi");
                }
            }
            return FileStatus;
        }
        //-----------------------------------------------------------------------------------------------------
        public FileAnalysis Func_X12_300_GLO_CWO_XUS_SHP(
            string filename,
            string errorOut,
            string validOut,
            string processOut = "")
        {
            this.FileStatus = new FileAnalysis();
            if (File.Exists(filename))
            {
                var ediInt = Interchange.LoadFrom(File.OpenRead(filename));
                var xmlInt = new UniversalInterchange();
                if (ediInt.Groups != null)
                {
                    for (var g = 0; g < ediInt.Groups.Count; g++)
                    {
                        xmlInt.Header = new UniversalInterchangeHeader
                        {
                            SenderID = ediInt.Groups[g].Gs.D_142_2,
                            RecipientID = ediInt.Groups[g].Gs.D_124_3
                        };
                        xmlInt.Body = new UniversalInterchangeBody
                        {
                            UniversalShipment =
                                new UniversalShipmentData {version = "1.1"}
                        };
                        for (var m = 0; m < ediInt.Groups[g].Messages.Count; m++)
                        {
                            if (ediInt.Groups[g].Messages[m].Context.Tag == "300")
                            {
                                try
                                {
                                    var xmlMsg = ediInt.Serialize();
                                    var objMsg = ediInt.Groups[g].Messages[m].DeserializeItem<M_300>();
                                    var xmlDoc = new XmlDocument();
                                    xmlDoc.LoadXml(xmlMsg.ToString());
                                    var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
                                    nsmgr.AddNamespace("ns", "www.edifabric.com/x12");
                                    var objShp = new Shipment
                                    {
                                        AdditionalTerms = string.Empty,
                                        AgentsReference = string.Empty,
                                        AWBServiceLevel =
                                            new CodeDescriptionPair
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        CartageWaybillNumber = string.Empty,
                                        CFSReference = string.Empty,
                                        FirstBuyerContact = string.Empty,
                                        Folio = string.Empty,
                                        OwnerRef = string.Empty,
                                        QuoteNumber = string.Empty,
                                        SecondBuyerContact = string.Empty,
                                        VesselName = string.Empty,
                                        VoyageFlightNo = string.Empty,
                                        WarehouseLocation = string.Empty,
                                        DataContext =
                                            new DataContext
                                            {
                                                DataSourceCollection =
                                                    new List<DataSource>
                                                    {
                                                        new DataSource
                                                        {
                                                            Type
                                                                =
                                                                "ForwardingBooking",
                                                            Key
                                                                =
                                                                string
                                                                    .Empty
                                                        }
                                                    },
                                                DataTargetCollection =
                                                    new List<DataTarget>
                                                    {
                                                        new DataTarget
                                                        {
                                                            Type
                                                                =
                                                                "ForwardingBooking"
                                                        }
                                                    },
                                                ActionPurpose =
                                                    new CodeDescriptionPair
                                                    {
                                                        Code
                                                            =
                                                            "APP",
                                                        Description
                                                            =
                                                            "As Per Payload"
                                                    },
                                                Company =
                                                    new Company
                                                    {
                                                        Code = "JFK",
                                                        Country =
                                                            new Country
                                                            {
                                                                Code
                                                                    =
                                                                    "US",
                                                                Name
                                                                    =
                                                                    "United States"
                                                            },
                                                        Name =
                                                            "Walker International Transportation LLC"
                                                    },
                                                DataProvider = "X12300GLO",
                                                EnterpriseID = "WLT",
                                                EventBranch =
                                                    new Branch
                                                    {
                                                        Code = "JFK",
                                                        Name =
                                                            "USJFK - Valley Stream, NY"
                                                    },
                                                EventDepartment =
                                                    new Department
                                                    {
                                                        Code =
                                                            "FES",
                                                        Name =
                                                            "Forwarding Export Sea"
                                                    },
                                                EventType =
                                                    new CodeDescriptionPair
                                                    {
                                                        Code
                                                            =
                                                            "ADD"
                                                    },
                                                EventUser =
                                                    new Staff
                                                    {
                                                        Code = "JSM",
                                                        Name =
                                                            "Jerry S. Mabasa"
                                                    },
                                                ServerID = "JNJ",
                                                CodesMappedToTarget = true,
                                                CodesMappedToTargetSpecified =
                                                    true
                                            },
                                        ActualChargeable = 0M,
                                        ActualChargeableSpecified = true,
                                        BookingConfirmationReference = string.Empty,
                                        IsBooking = true,
                                        IsBookingSpecified = true,
                                        ContainerCount = 0,
                                        ContainerCountSpecified = true,
                                        ContainerMode = new ContainerMode(),
                                        FreightRate = 0M,
                                        FreightRateSpecified = true,
                                        FreightRateCurrency =
                                            new Currency
                                            {
                                                Code = "USD",
                                                Description = "United States Dollar"
                                            },
                                        GoodsDescription = string.Empty,
                                        GoodsValue = 0M,
                                        GoodsValueCurrency =
                                            new Currency
                                            {
                                                Code = "USD",
                                                Description = "United States Dollar"
                                            },
                                        HBLAWBChargesDisplay =
                                            new CodeDescriptionPair
                                            {
                                                Code = "SHW",
                                                Description =
                                                    "Show Collect Charges"
                                            },
                                        InsuranceValue = 0M,
                                        InsuranceValueCurrency =
                                            new Currency
                                            {
                                                Code = "USD",
                                                Description = "United States Dollar"
                                            },
                                        InterimReceiptNumber = string.Empty,
                                        IsDirectBooking = false,
                                        IsForwardRegistered = false,
                                        IsNeutralMaster = new IsNeutralMaster {Value = false},
                                        JobCosting =
                                            new ShipmentJobCosting
                                            {
                                                Branch =
                                                    new Branch
                                                    {
                                                        Code =
                                                            "JFK",
                                                        Name =
                                                            "USJFK - Valley Stream, NY"
                                                    },
                                                Currency =
                                                    new Currency
                                                    {
                                                        Code
                                                            =
                                                            "USD",
                                                        Description
                                                            =
                                                            "United States Dollar"
                                                    },
                                                Department =
                                                    new Department
                                                    {
                                                        Code
                                                            =
                                                            "FES",
                                                        Name
                                                            =
                                                            "Forwarding Export Sea"
                                                    },
                                                HomeBranch =
                                                    new Branch
                                                    {
                                                        Code =
                                                            "JFK",
                                                        Name =
                                                            "USJFK - Valley Stream, NY"
                                                    },
                                                OperationsStaff =
                                                    new Staff
                                                    {
                                                        Code =
                                                            "JSM"
                                                    },
                                                AccrualNotRecognized = 0M,
                                                AccrualNotRecognizedSpecified
                                                    = true,
                                                AccrualRecognized = 0M,
                                                AccrualRecognizedSpecified
                                                    = true,
                                                AgentRevenue = 0M,
                                                AgentRevenueSpecified =
                                                    true,
                                                LocalClientRevenue = 0M,
                                                LocalClientRevenueSpecified
                                                    = true,
                                                OtherDebtorRevenue = 0M,
                                                OtherDebtorRevenueSpecified
                                                    = true,
                                                SalesStaff =
                                                    new Staff
                                                    {
                                                        Code =
                                                            "JSM",
                                                        Name =
                                                            "Jerry S. Mabasa"
                                                    },
                                                TotalAccrual = 0M,
                                                TotalAccrualSpecified =
                                                    true,
                                                TotalCost = 0M,
                                                TotalCostSpecified = true,
                                                TotalJobProfit = 0M,
                                                TotalJobProfitSpecified =
                                                    true,
                                                TotalRevenue = 0M,
                                                TotalRevenueSpecified =
                                                    true,
                                                TotalWIP = 0M,
                                                TotalWIPSpecified = true,
                                                WIPNotRecognized = 0M,
                                                WIPNotRecognizedSpecified
                                                    = true,
                                                WIPRecognized = 0M,
                                                WIPRecognizedSpecified =
                                                    true,
                                                ChargeLineCollection =
                                                    new List
                                                        <
                                                            ShipmentJobCostingChargeLine
                                                            >()
                                            },
                                        OuterPacks = 0,
                                        OuterPacksSpecified = true,
                                        OuterPacksPackageType =
                                            new PackageType
                                            {
                                                Code = "PCS",
                                                Description = "Pieces"
                                            },
                                        PackingOrder = 0,
                                        ReleaseType =
                                            new CodeDescriptionPair
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        ServiceLevel =
                                            new ServiceLevel
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        ShipmentIncoTerm =
                                            new IncoTerm
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        ShippedOnBoard =
                                            new CodeDescriptionPair
                                            {
                                                Code = string.Empty,
                                                Description = string.Empty
                                            },
                                        TotalVolume = 0M,
                                        TotalVolumeSpecified = true,
                                        TotalVolumeUnit =
                                            new UnitOfVolume
                                            {
                                                Code = "M3",
                                                Description = "Cubic Meters"
                                            },
                                        TotalWeight = 0M,
                                        TotalWeightUnit =
                                            new UnitOfWeight
                                            {
                                                Code = "KG",
                                                Description = "Kilograms"
                                            },
                                        TotalWeightSpecified = true,
                                        TransportMode =
                                            new CodeDescriptionPair
                                            {
                                                Code = "SEA",
                                                Description =
                                                    "Sea Freight"
                                            },
                                        WayBillNumber = string.Empty,
                                        WayBillType =
                                            new WayBillType
                                            {
                                                Code = "HWB",
                                                Description = "House Waybill"
                                            },
                                        LocalProcessing =
                                            new ShipmentLocalProcessing
                                            {
                                                DeliveryRequiredBy =
                                                    string.Empty,
                                                EstimatedDelivery =
                                                    string.Empty,
                                                EstimatedPickup =
                                                    string.Empty,
                                                FCLDeliveryEquipmentNeeded
                                                    =
                                                    new CodeDescriptionPair
                                                    {
                                                        Code
                                                            =
                                                            string
                                                                .Empty,
                                                        Description
                                                            =
                                                            string
                                                                .Empty
                                                    },
                                                FCLPickupEquipmentNeeded
                                                    =
                                                    new CodeDescriptionPair
                                                    {
                                                        Code
                                                            =
                                                            string
                                                                .Empty,
                                                        Description
                                                            =
                                                            string
                                                                .Empty
                                                    },
                                                InsuranceRequired =
                                                    false,
                                                PickupRequiredBy =
                                                    string.Empty,
                                                OrderNumberCollection
                                                    =
                                                    new List
                                                        <
                                                            ShipmentLocalProcessingOrderNumber
                                                            >()
                                            },
                                        ContainerCollection = new ShipmentContainerCollection(),
                                        PackingLineCollection = new List<PackingLine>(),
                                        DateCollection = new List<Date>(),
                                        OrganizationAddressCollection =
                                            new List<OrganizationAddress>(),
                                        NoteCollection = new List<Note>()
                                    };

                                    objShp.WayBillNumber = this.Func_XML_GetResultString(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:S_B1/ns:D_145_2");

                                    objShp.CFSReference = this.Func_XML_GetResultString(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:S_B1/ns:D_145_2");

                                    objShp.OwnerRef = objShp.WayBillNumber;

                                    objShp.BookingConfirmationReference = this.Func_XML_GetResultString(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:S_N9[ns:D_128_1='MB']/ns:D_127_2");

                                    var orgLOC = new OrganizationAddress
                                    {
                                        AddressType = "LocalClient",
                                        OrganizationCode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/ns:D_67_4"),
                                        CompanyName =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/ns:D_93_2"),
                                        Address1 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N3/ns:D_166_1"),
                                        Address2 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N3/ns:D_166_2"),
                                        City =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                        Postcode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N4/ns:D_116_3"),
                                        State =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                        Country =
                                            new Country
                                            {
                                                Code =
                                                    Func_SQL_ConvertCountryISO3ToISO2
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            },
                                        Contact =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='BT']/parent::ns:G_N1_2/ns:S_G61_2[1]/ns:D_93_2"),
                                        Email =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='BT']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='EM']/ns:D_364_4"),
                                        Phone =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='BT']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='TE']/ns:D_364_4"),
                                        Port =
                                            new UNLOCO
                                            {
                                                Code =
                                                    this
                                                        .Func_SQL_GetPortCodeFromCityName
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='BT']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            }
                                    };

                                    objShp.OrganizationAddressCollection.Add(orgLOC);

                                    var orgCNR = new OrganizationAddress
                                    {
                                        AddressType = "ConsignorDocumentaryAddress",
                                        OrganizationCode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/ns:D_67_4"),
                                        CompanyName =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/ns:D_93_2"),
                                        Address1 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N3/ns:D_166_1"),
                                        Address2 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N3/ns:D_166_2"),
                                        City =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                        Postcode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N4/ns:D_116_3"),
                                        State =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                        Country =
                                            new Country
                                            {
                                                Code =
                                                    Func_SQL_ConvertCountryISO3ToISO2
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            },
                                        Contact =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='SH']/parent::ns:G_N1_2/ns:S_G61_2[1]/ns:D_93_2"),
                                        Email =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='SH']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='EM']/ns:D_364_4"),
                                        Phone =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='SH']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='TE']/ns:D_364_4"),
                                        Port =
                                            new UNLOCO
                                            {
                                                Code =
                                                    this
                                                        .Func_SQL_GetPortCodeFromCityName
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SH']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            }
                                    };

                                    objShp.OrganizationAddressCollection.Add(orgCNR);

                                    //objShp.PortOfOrigin = new UNLOCO
                                    //{
                                    //    Code = this
                                    //       .Func_SQL_GetPortCodeFromCityName
                                    //       (
                                    //           this
                                    //       .Func_XML_GetResultString
                                    //       (
                                    //           xmlDoc,
                                    //           nsmgr,
                                    //           @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='R']/ns:D_310_3"),
                                    //           this
                                    //       .Func_XML_GetResultString
                                    //       (
                                    //           xmlDoc,
                                    //           nsmgr,
                                    //           @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='R']/ns:D_156_8"),
                                    //           this
                                    //       .Func_XML_GetResultString
                                    //       (
                                    //           xmlDoc,
                                    //           nsmgr,
                                    //           @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='R']/ns:D_26_5"))
                                    //};

                                    var orgCNRPck = new OrganizationAddress
                                    {
                                        AddressType =
                                            "ConsignorPickupDeliveryAddress",
                                        OrganizationCode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/ns:D_67_4"),
                                        CompanyName =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/ns:D_93_2"),
                                        Address1 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N3/ns:D_166_1"),
                                        Address2 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N3/ns:D_166_2"),
                                        City =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                        Postcode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N4/ns:D_116_3"),
                                        State =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                        Country =
                                            new Country
                                            {
                                                Code =
                                                    Func_SQL_ConvertCountryISO3ToISO2
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            },
                                        Contact =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='SF']/parent::ns:G_N1_2/ns:S_G61_2[1]/ns:D_93_2"),
                                        Email =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='SF']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='EM']/ns:D_364_4"),
                                        Phone =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='SF']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='TE']/ns:D_364_4"),
                                        Port =
                                            new UNLOCO
                                            {
                                                Code =
                                                    this
                                                        .Func_SQL_GetPortCodeFromCityName
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='SF']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            }
                                    };
                                    objShp.OrganizationAddressCollection.Add(orgCNRPck);

                                    var orgCNE = new OrganizationAddress
                                    {
                                        AddressType = "ConsigneeDocumentaryAddress",
                                        OrganizationCode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/ns:D_67_4"),
                                        CompanyName =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/ns:D_93_2"),
                                        Address1 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N3/ns:D_166_1"),
                                        Address2 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N3/ns:D_166_2"),
                                        City =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                        Postcode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N4/ns:D_116_3"),
                                        State =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                        Country =
                                            new Country
                                            {
                                                Code =
                                                    Func_SQL_ConvertCountryISO3ToISO2
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            },
                                        Contact =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='CN']/parent::ns:G_N1_2/ns:S_G61_2[1]/ns:D_93_2"),
                                        Email =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='CN']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='EM']/ns:D_364_4"),
                                        Phone =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='CN']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='TE']/ns:D_364_4"),
                                        Port =
                                            new UNLOCO
                                            {
                                                Code =
                                                    this
                                                        .Func_SQL_GetPortCodeFromCityName
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='CN']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            }
                                    };
                                    objShp.OrganizationAddressCollection.Add(orgCNE);

                                    //objShp.PortOfDischarge = new UNLOCO
                                    //{
                                    //    Code =
                                    //        this
                                    //        .Func_SQL_GetPortCodeFromCityName
                                    //        (
                                    //     this
                                    //        .Func_XML_GetResultString
                                    //        (
                                    //     xmlDoc,
                                    //     nsmgr,
                                    //     @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_N4_2/ns:D_19_1"),
                                    //     this
                                    //        .Func_XML_GetResultString
                                    //        (
                                    //     xmlDoc,
                                    //     nsmgr,
                                    //     @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_N4_2/ns:D_156_2"),
                                    //     this
                                    //        .Func_XML_GetResultString
                                    //        (
                                    //     xmlDoc,
                                    //     nsmgr,
                                    //     @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_N4_2/ns:D_26_4"))
                                    //};

                                    //objShp.PortOfDestination = new UNLOCO
                                    //{
                                    //    Code =
                                    //        this
                                    //        .Func_SQL_GetPortCodeFromCityName
                                    //        (
                                    //     this
                                    //        .Func_XML_GetResultString
                                    //        (
                                    //     xmlDoc,
                                    //     nsmgr,
                                    //     @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_N4_2/ns:D_19_1"),
                                    //     this
                                    //        .Func_XML_GetResultString
                                    //        (
                                    //     xmlDoc,
                                    //     nsmgr,
                                    //     @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_N4_2/ns:D_156_2"),
                                    //     this
                                    //        .Func_XML_GetResultString
                                    //        (
                                    //     xmlDoc,
                                    //     nsmgr,
                                    //     @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_N4_2/ns:D_26_4"))
                                    //};

                                    var orgCNEDlv = new OrganizationAddress
                                    {
                                        AddressType =
                                            "ConsigneePickupDeliveryAddress",
                                        OrganizationCode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/ns:D_67_4"),
                                        CompanyName =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/ns:D_93_2"),
                                        Address1 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N3/ns:D_166_1"),
                                        Address2 =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N3/ns:D_166_2"),
                                        City =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                        Postcode =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N4/ns:D_116_3"),
                                        State =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                        Country =
                                            new Country
                                            {
                                                Code =
                                                    Func_SQL_ConvertCountryISO3ToISO2
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            },
                                        Contact =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_G61_2[1]/ns:D_93_2"),
                                        Email =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='EM']/ns:D_364_4"),
                                        Phone =
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_204/ns:G_S5/ns:G_N1_2/ns:S_N1_2[ns:D_98_1='ST']/parent::ns:G_N1_2/ns:S_G61_2[ns:D_365_3='TE']/ns:D_364_4"),
                                        Port =
                                            new UNLOCO
                                            {
                                                Code =
                                                    this
                                                        .Func_SQL_GetPortCodeFromCityName
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N4/ns:D_19_1"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N4/ns:D_156_2"),
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_N1/ns:S_N1[ns:D_98_1='ST']/parent::ns:G_N1/ns:S_N4/ns:D_26_4")),
                                                Name = ""
                                            }
                                    };

                                    objShp.OrganizationAddressCollection.Add(orgCNEDlv);

                                    objShp.ServiceLevel.Code =
                                        this.Func_SQL_TranslateX12TariffServiceLevel(
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:S_Y1/ns:D_375_8"));

                                    if (this.Func_XML_GetResultString(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='R']/ns:D_309_2") == "AC")
                                    {
                                        objShp.PortOfOrigin = new UNLOCO
                                        {
                                            Code =
                                                this.Func_SQL_GetPortCodeFromCityName(
                                                    this.Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='R']/ns:D_310_3"),
                                                    this.Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='R']/ns:D_156_8"),
                                                    this.Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='R']/ns:D_26_5"))
                                        };
                                    }
                                    else
                                    {
                                        objShp.PortOfOrigin = new UNLOCO
                                        {
                                            Code =
                                                this.Func_XML_GetResultString(
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='R']/ns:D_310_3")
                                        };
                                    }

                                    if (this.Func_XML_GetResultString(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='L']/ns:D_309_2") == "AC")
                                    {
                                        objShp.PortOfLoading = new UNLOCO
                                        {
                                            Code =
                                                this.Func_SQL_GetPortCodeFromCityName(
                                                    this.Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='L']/ns:D_310_3"),
                                                    this.Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='L']/ns:D_156_8"),
                                                    this.Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='L']/ns:D_26_5"))
                                        };
                                    }
                                    else
                                    {
                                        objShp.PortOfLoading = new UNLOCO
                                        {
                                            Code =
                                                this.Func_XML_GetResultString(
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='L']/ns:D_310_3")
                                        };
                                    }

                                    if (this.Func_XML_GetResultString(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='D']/ns:D_309_2") == "AC")
                                    {
                                        objShp.PortOfDischarge = new UNLOCO
                                        {
                                            Code =
                                                this
                                                    .Func_SQL_GetPortCodeFromCityName(
                                                        this.Func_XML_GetResultString(
                                                            xmlDoc,
                                                            nsmgr,
                                                            @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='D']/ns:D_310_3"),
                                                        this.Func_XML_GetResultString(
                                                            xmlDoc,
                                                            nsmgr,
                                                            @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='D']/ns:D_156_8"),
                                                        this.Func_XML_GetResultString(
                                                            xmlDoc,
                                                            nsmgr,
                                                            @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='D']/ns:D_26_5"))
                                        };
                                    }
                                    else
                                    {
                                        objShp.PortOfDischarge = new UNLOCO
                                        {
                                            Code =
                                                this.Func_XML_GetResultString(
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='D']/ns:D_310_3")
                                        };
                                    }

                                    if (this.Func_XML_GetResultString(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='E']/ns:D_309_2") == "AC")
                                    {
                                        objShp.PortOfDestination = new UNLOCO
                                        {
                                            Code =
                                                this
                                                    .Func_SQL_GetPortCodeFromCityName(
                                                        this.Func_XML_GetResultString(
                                                            xmlDoc,
                                                            nsmgr,
                                                            @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='E']/ns:D_310_3"),
                                                        this.Func_XML_GetResultString(
                                                            xmlDoc,
                                                            nsmgr,
                                                            @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='E']/ns:D_156_8"),
                                                        this.Func_XML_GetResultString(
                                                            xmlDoc,
                                                            nsmgr,
                                                            @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='E']/ns:D_26_5"))
                                        };
                                    }
                                    else
                                    {
                                        objShp.PortOfDestination = new UNLOCO
                                        {
                                            Code =
                                                this.Func_XML_GetResultString(
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:G_R4/ns:S_R4[ns:D_115_1='E']/ns:D_310_3")
                                        };
                                    }

                                    if (string.IsNullOrEmpty(objShp.PortOfDestination.Code))
                                    {
                                        objShp.PortOfDestination = objShp.PortOfDischarge;
                                    }

                                    objShp.TotalWeight = this.Func_XML_GetResultIntNumber(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:G_LX/ns:S_L0/ns:D_81_4");
                                    objShp.TotalWeightUnit = new UnitOfWeight
                                    {
                                        Code =
                                            this
                                                .Func_SQL_TranslateX12_Weight_UoM(
                                                    this.Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_LX/ns:S_L0/ns:D_188_11"))
                                    };
                                    objShp.TotalWeightSpecified = true;

                                    objShp.DocumentedWeight = objShp.TotalWeight;
                                    objShp.DocumentedWeightSpecified = true;

                                    objShp.ManifestedWeight = objShp.TotalWeight;
                                    objShp.ManifestedWeightSpecified = true;

                                    objShp.TotalVolume = this.Func_XML_GetResultIntNumber(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:G_LX/ns:S_L0/ns:D_183_6");
                                    objShp.TotalVolumeUnit = new UnitOfVolume
                                    {
                                        Code =
                                            this
                                                .Func_SQL_TranslateX12_Volume_UoM(
                                                    this.Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_LX/ns:S_L0/ns:D_184_7"))
                                    };
                                    objShp.TotalVolumeSpecified = true;

                                    objShp.DocumentedVolume = objShp.TotalVolume;
                                    objShp.DocumentedVolumeSpecified = true;

                                    objShp.ManifestedVolume = objShp.TotalVolume;
                                    objShp.ManifestedVolumeSpecified = true;

                                    objShp.OuterPacks = this.Func_XML_GetResultIntNumber(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:G_LX/ns:S_L0/ns:D_80_8");
                                    objShp.OuterPacksPackageType = new PackageType
                                    {
                                        Code =
                                            Func_SQL_GetCWOPackageForm(
                                                this
                                                    .Func_XML_GetResultString(
                                                        xmlDoc,
                                                        nsmgr,
                                                        @"//ns:M_300/ns:G_LX/ns:S_L0/ns:D_211_9"))
                                    };
                                    objShp.OuterPacksSpecified = true;

                                    var packLine = new PackingLine
                                    {
                                        PackQty = objShp.OuterPacks,
                                        PackType =
                                            new PackageType
                                            {
                                                Code =
                                                    objShp
                                                        .OuterPacksPackageType
                                                        .Code,
                                                Description =
                                                    objShp
                                                        .OuterPacksPackageType
                                                        .Description
                                            },
                                        Weight = objShp.TotalWeight,
                                        WeightUnit = objShp.TotalWeightUnit,
                                        WeightSpecified = true,
                                        Volume = objShp.TotalVolume,
                                        VolumeUnit = objShp.TotalVolumeUnit,
                                        VolumeSpecified = true
                                    };
                                    objShp.PackingLineCollection.Add(packLine);

                                    var cntData = new ShipmentContainerCollectionContainer
                                    {
                                        AirVentFlow = 0,
                                        Commodity =
                                            new Commodity
                                            {
                                                Code
                                                    =
                                                    string
                                                        .Empty,
                                                Description
                                                    =
                                                    string
                                                        .Empty
                                            },
                                        ContainerType =
                                            new ShipmentContainerCollectionContainerContainerType
                                            {
                                                ISOCode
                                                    =
                                                    this
                                                        .Func_XML_GetResultString
                                                        (
                                                            xmlDoc,
                                                            nsmgr,
                                                            @"//ns:M_300/ns:G_Y2/ns:S_Y2/ns:D_24_4"),
                                                Code
                                                    =
                                                    Func_SQL_GetCWOContainerType
                                                        (
                                                            this
                                                                .Func_XML_GetResultString
                                                                (
                                                                    xmlDoc,
                                                                    nsmgr,
                                                                    @"//ns:M_300/ns:G_Y2/ns:S_Y2/ns:D_24_4"))
                                            }
                                    };
                                    cntData.ContainerCount = this.Func_XML_GetResultIntNumber(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:G_Y2/ns:S_Y2/ns:D_95_1");

                                    objShp.ContainerCollection.Container.Add(cntData);

                                    objShp.LocalProcessing.EstimatedPickup =
                                        this.Func_CON_ToISODate_ISO(
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_R4/ns:S_DTM[ns:D_374_1='118']/ns:D_373_2"),
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_R4/ns:S_DTM[ns:D_374_1='118']/ns:D_337_3"));
                                    objShp.LocalProcessing.PickupRequiredBy = objShp.LocalProcessing.EstimatedPickup;
                                    //this.Func_CON_ToISODate_ISO(
                                    //    this.Func_XML_GetResultString(
                                    //        xmlDoc,
                                    //        nsmgr,
                                    //        @"//ns:M_204/ns:G_S5/ns:S_G62_2[ns:D_176_3='K']/ns:D_373_2"),
                                    //    this.Func_XML_GetResultString(
                                    //        xmlDoc,
                                    //        nsmgr,
                                    //        @"//ns:M_204/ns:G_S5/ns:S_G62_2[ns:D_176_3='K']/ns:D_337_4"));
                                    objShp.LocalProcessing.EstimatedDelivery =
                                        this.Func_CON_ToISODate_ISO(
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_R4/ns:S_DTM[ns:D_374_1='371']/ns:D_373_2"),
                                            this.Func_XML_GetResultString(
                                                xmlDoc,
                                                nsmgr,
                                                @"//ns:M_300/ns:G_R4/ns:S_DTM[ns:D_374_1='371']/ns:D_337_3"));
                                    objShp.LocalProcessing.DeliveryRequiredBy = objShp.LocalProcessing.EstimatedDelivery;
                                    //this.Func_CON_ToISODate_ISO(
                                    //    this.Func_XML_GetResultString(
                                    //        xmlDoc,
                                    //        nsmgr,
                                    //        @"//ns:M_204/ns:G_S5/ns:S_G62_2[ns:D_176_3='L']/ns:D_373_2"),
                                    //    this.Func_XML_GetResultString(
                                    //        xmlDoc,
                                    //        nsmgr,
                                    //        @"//ns:M_204/ns:G_S5/ns:S_G62_2[ns:D_176_3='L']/ns:D_337_4"));

                                    var dteETD = new Date
                                    {
                                        Type = DateType.Departure,
                                        IsEstimate = true,
                                        IsEstimateSpecified = true,
                                        Value =
                                            this.Func_CON_ToISODate_ISO(
                                                this.Func_XML_GetResultString(
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:G_R4/ns:S_DTM[ns:D_374_1='010']/ns:D_373_2"),
                                                this.Func_XML_GetResultString(
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:G_R4/ns:S_DTM[ns:D_374_1='010']/ns:D_337_3"))
                                    };

                                    objShp.DateCollection.Add(dteETD);

                                    var dteETA = new Date
                                    {
                                        Type = DateType.Arrival,
                                        IsEstimate = true,
                                        IsEstimateSpecified = true,
                                        Value =
                                            this.Func_CON_ToISODate_ISO(
                                                this.Func_XML_GetResultString(
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:G_R4/ns:S_DTM[ns:D_374_1='371']/ns:D_373_2"),
                                                this.Func_XML_GetResultString(
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:G_R4/ns:S_DTM[ns:D_374_1='371']/ns:D_337_3"))
                                    };

                                    objShp.DateCollection.Add(dteETA);

                                    var dteBkd = new Date
                                    {
                                        Type = DateType.BookingConfirmed,
                                        IsEstimate = false,
                                        IsEstimateSpecified = true,
                                        Value =
                                            this.Func_CON_ToISODate_ISO(
                                                ediInt.Groups[g].Gs.D_29_4,
                                                ediInt.Groups[g].Gs.D_30_5)
                                        //this.Func_CON_ToISODate_ISO(this.Func_XML_GetResultString(xmlDoc, nsmgr, @"//ns:M_204/ns:S_G62/ns:D_373_2"), this.Func_XML_GetResultString(xmlDoc, nsmgr, @"//ns:M_204///ns:S_G62/ns:D_337_4"))
                                    };

                                    objShp.DateCollection.Add(dteBkd);

                                    var ordRef = new ShipmentLocalProcessingOrderNumber();
                                    ordRef.OrderReference = this.Func_XML_GetResultString(
                                        xmlDoc,
                                        nsmgr,
                                        @"//ns:M_300/ns:S_N9[ns:D_128_1='PO']/ns:D_127_2");

                                    objShp.LocalProcessing.OrderNumberCollection.Add(ordRef);

                                    var ucrRef = new ShipmentAdditionalReferenceCollectionAdditionalReference
                                    {
                                        Type =
                                        {
                                            Code
                                                =
                                                "UCR"
                                        },
                                        ReferenceNumber
                                            =
                                            this
                                                .Func_XML_GetResultString
                                                (
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:S_N9[ns:D_128_1='SI']/ns:D_127_2")
                                    };

                                    if (!string.IsNullOrEmpty(ucrRef.ReferenceNumber))
                                    {
                                        objShp.AdditionalReferenceCollection.AdditionalReference.Add(ucrRef);
                                    }

                                    var oagRef = new ShipmentAdditionalReferenceCollectionAdditionalReference
                                    {
                                        Type =
                                        {
                                            Code
                                                =
                                                "OAG"
                                        },
                                        ReferenceNumber
                                            =
                                            this
                                                .Func_XML_GetResultString
                                                (
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:S_N9[ns:D_128_1='CG']/ns:D_127_2")
                                    };

                                    if (!string.IsNullOrEmpty(oagRef.ReferenceNumber))
                                    {
                                        objShp.AdditionalReferenceCollection.AdditionalReference.Add(oagRef);
                                    }

                                    var bkgRefBn = new ShipmentAdditionalReferenceCollectionAdditionalReference
                                    {
                                        Type
                                            =
                                        {
                                            Code
                                                =
                                                "BKG"
                                        },
                                        ReferenceNumber
                                            =
                                            this
                                                .Func_XML_GetResultString
                                                (
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:S_N9[ns:D_128_1='BN']/ns:D_127_2")
                                    };

                                    if (!string.IsNullOrEmpty(bkgRefBn.ReferenceNumber))
                                    {
                                        objShp.AdditionalReferenceCollection.AdditionalReference.Add(bkgRefBn);
                                    }

                                    var bkgRefMb = new ShipmentAdditionalReferenceCollectionAdditionalReference
                                    {
                                        Type
                                            =
                                        {
                                            Code
                                                =
                                                "BKG"
                                        },
                                        ReferenceNumber
                                            =
                                            this
                                                .Func_XML_GetResultString
                                                (
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:S_N9[ns:D_128_1='MB']/ns:D_127_2")
                                    };

                                    if (!string.IsNullOrEmpty(bkgRefMb.ReferenceNumber))
                                    {
                                        objShp.AdditionalReferenceCollection.AdditionalReference.Add(bkgRefMb);
                                    }

                                    var bkgCon = new ShipmentAdditionalReferenceCollectionAdditionalReference
                                    {
                                        Type =
                                        {
                                            Code
                                                =
                                                "CON"
                                        },
                                        ReferenceNumber
                                            =
                                            this
                                                .Func_XML_GetResultString
                                                (
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:S_N9[ns:D_128_1='TS']/ns:D_127_2")
                                    };

                                    if (!string.IsNullOrEmpty(bkgCon.ReferenceNumber))
                                    {
                                        objShp.AdditionalReferenceCollection.AdditionalReference.Add(bkgCon);
                                    }

                                    var bkgLid = new ShipmentAdditionalReferenceCollectionAdditionalReference
                                    {
                                        Type =
                                        {
                                            Code
                                                =
                                                "LID"
                                        },
                                        ReferenceNumber
                                            =
                                            this
                                                .Func_XML_GetResultString
                                                (
                                                    xmlDoc,
                                                    nsmgr,
                                                    @"//ns:M_300/ns:S_N9[ns:D_128_1='OL']/ns:D_127_2")
                                    };

                                    if (!string.IsNullOrEmpty(bkgLid.ReferenceNumber))
                                    {
                                        objShp.AdditionalReferenceCollection.AdditionalReference.Add(bkgLid);
                                    }

                                    var ediList = this.Func_EDI_GetOriginalMessage(filename, '*', '~');
                                    if (ediList.Count > 0)
                                    {
                                        var ediNote = new Note
                                        {
                                            IsCustomDescription = true,
                                            Description = "Original EDI Message"
                                        };
                                        foreach (var item in ediList)
                                        {
                                            if (ediNote.NoteText == string.Empty)
                                            {
                                                ediNote.NoteText = item;
                                            }
                                            else
                                            {
                                                ediNote.NoteText = ediNote.NoteText + Environment.NewLine + item;
                                            }
                                        }
                                        objShp.NoteCollection.Add(ediNote);
                                    }

                                    //var ediAdd = new Note
                                    //{
                                    //    IsCustomDescription = true,
                                    //    Description = "Must Respond By"
                                    //};

                                    //ediAdd.NoteText = "Must Respond By: " + Func_CON_ToISODate_DTM(this.Func_XML_GetResultString(xmlDoc, nsmgr, @"//ns:M_204/ns:S_G62/ns:D_373_2 "), this.Func_XML_GetResultString(xmlDoc, nsmgr, @"//ns:M_204/ns:S_G62/ns:D_337_4"));

                                    //objShp.NoteCollection.Add(ediAdd);

                                    xmlInt.Body.UniversalShipment.Shipment = objShp;
                                }
                                catch (Exception exc)
                                {
                                    Debug.Print(exc.Message);
                                    throw;
                                }
                            }
                        }
                        xmlInt.Serialize();
                        xmlInt.SaveToFile(
                            string.Concat(validOut, "\\300_GLO_", Path.GetFileNameWithoutExtension(filename), ".xml"));
                        this.FileStatus.FileOutName = string.Concat(
                            validOut,
                            "\\300_GLO_",
                            Path.GetFileNameWithoutExtension(filename),
                            ".xml");
                        this.FileStatus.Status = true;
                        Func_File_Move(filename, string.Concat(processOut, "\\", Path.GetFileName(filename)));
                    }
                }
            }
            else
            {
                this.FileStatus.ExcpMessage = "Cannot Find: " + filename;
            }
            return this.FileStatus;
        }
 //-----------------------------------------------------------------------------------------------------
 public FileAnalysis Func_SPX_XMS(string strFilename, string strOutLoc)
 {
     this.FileStatus = new FileAnalysis();
     if (File.Exists(strFilename))
     {
         var xdWrap = XDocument.Load("XML/UniversalInterchangeWrapper.xml");
         var xdNaAp = XDocument.Load(strFilename);
         XNamespace xnWrap = "http://www.cargowise.com/Schemas/Universal/2011/11";
         var xpNav = xdWrap.CreateNavigator();
         var xnNSM = new XmlNamespaceManager(xpNav.NameTable);
         xnNSM.AddNamespace("cw", "http://www.cargowise.com/Schemas/Universal/2011/11");
         XElement node;
         node = xdWrap.XPathSelectElement("/cw:UniversalInterchange/cw:Body", xnNSM);
         node.Add(xdNaAp.Root);
         Func_File_Move(strFilename, string.Concat(strOutLoc, "\\", Path.GetFileName(strFilename)));
         if (strFilename.Contains("SPARX_SHP_XML_EVT_"))
         {
             strFilename = strFilename.Replace("SPARX_SHP_XML_EVT_", "SPARX_SHP_XUE_EVT_");
         }
         else
         {
             strFilename = strFilename.Replace("SPARX_SHP_XML_APP_", "SPARX_SHP_XUS_APP_");
         }
         xdWrap.Save(strFilename);
         this.FileStatus.Status = true;
         this.FileStatus.FileOutName = strFilename;
     }
     else
     {
         this.FileStatus.Status = false;
     }
     return this.FileStatus;
 }
 //-----------------------------------------------------------------------------------------------------
 public FileAnalysis Func_SPX_SendToCargowise(
     string strURL,
     string strFilename,
     string strRcp,
     string strSnd,
     string strPwd,
     string strOutLoc)
 {
     this.FileStatus = new FileAnalysis();
     try
     {
         cargowiseService.SendMessage(strURL, strFilename, strRcp, strSnd, strPwd);
         try
         {
             Func_File_Move(strFilename, strOutLoc + "\\" + Path.GetFileName(strFilename));
         }
         catch (Exception exp)
         {
             this.FileStatus.ExcpMessage = exp.Message;
         }
     }
     catch (Exception exp)
     {
         this.FileStatus.ExcpMessage = exp.Message;
     }
     return this.FileStatus;
 }
 //-----------------------------------------------------------------------------------------------------
 public FileAnalysis Func_File_Validate(
     string filename,
     string errorOut,
     string validOut,
     string type,
     char dataSep,
     char lineSep)
 {
     this.FileStatus = new FileAnalysis();
     if (File.Exists(filename))
     {
         try
         {
             this.FileStatus.HasError = Func_File_Validate(filename);
             this.FileStatus.HasCWError = Func_File_Validate_StatusAndFilename(filename);
             if (this.FileStatus.HasError && (this.FileStatus.HasCWError == false))
             {
                 if (!filename.Contains(type))
                 {
                     var ediObject = Interchange.LoadFrom(File.OpenRead(filename));
                     if (ediObject.Groups != null)
                     {
                         foreach (var g in ediObject.Groups)
                         {
                             foreach (var m in g.Messages)
                             {
                                 var brokenRules = (List<string>) m.Validate();
                                 if (brokenRules.Count > 0)
                                 {
                                     this.FileStatus.HasError = true;
                                     this.FileStatus.Errors = Func_X12_AssignErrors(brokenRules);
                                     this.FileStatus.Fixable = Func_X12_Eval_ErrorCodes(
                                         this.FileStatus.Errors,
                                         type);
                                     this.FileStatus.HasCWError = Func_File_Validate_StatusAndFilename(filename);
                                     if (this.FileStatus.Fixable && (!filename.Contains(type))
                                         && (this.FileStatus.HasCWError == false))
                                     {
                                         var errContext = new InterchangeContext
                                         {
                                             DataElementSeparator =
                                                 dataSep.ToString(),
                                             SegmentTerminator =
                                                 lineSep.ToString()
                                         };
                                         var errContent = Func_X12_Eval_Segments(
                                             filename,
                                             ediObject.ToEdi(errContext),
                                             type,
                                             dataSep,
                                             lineSep);
                                         if (
                                             File.Exists(
                                                 string.Concat(
                                                     Path.GetDirectoryName(filename),
                                                     "\\",
                                                     Path.GetFileNameWithoutExtension(filename),
                                                     "_",
                                                     type,
                                                     ".txt")))
                                         {
                                             File.Delete(
                                                 string.Concat(
                                                     Path.GetDirectoryName(filename),
                                                     "\\",
                                                     Path.GetFileNameWithoutExtension(filename),
                                                     "_",
                                                     type,
                                                     ".txt"));
                                         }
                                         TextWriter errWriter =
                                             File.CreateText(
                                                 string.Concat(
                                                     Path.GetDirectoryName(filename),
                                                     "\\",
                                                     Path.GetFileNameWithoutExtension(filename),
                                                     "_",
                                                     type,
                                                     ".txt"));
                                         try
                                         {
                                             errWriter.Write(string.Concat(errContent));
                                         }
                                         finally
                                         {
                                             ((IDisposable) errWriter).Dispose();
                                         }
                                         this.FileStatus.HasError =
                                             Func_File_Validate(
                                                 string.Concat(
                                                     Path.GetDirectoryName(filename),
                                                     "\\",
                                                     Path.GetFileNameWithoutExtension(filename),
                                                     "_",
                                                     type,
                                                     ".txt"));
                                         if (this.FileStatus.HasError)
                                         {
                                             Func_File_Move(
                                                 filename,
                                                 string.Concat(errorOut, "\\", Path.GetFileName(filename)));
                                             this.FileStatus.FileErrName = string.Concat(
                                                 errorOut,
                                                 "\\",
                                                 Path.GetFileName(filename));
                                             this.FileStatus.ExcpMessage = "Cannot Recover From EDI Errors: "
                                                                           + filename;
                                             this.FileStatus.Status = false;
                                             if (
                                                 File.Exists(
                                                     string.Concat(
                                                         Path.GetDirectoryName(filename),
                                                         "\\",
                                                         Path.GetFileNameWithoutExtension(filename),
                                                         "_",
                                                         type,
                                                         ".txt")))
                                             {
                                                 File.Delete(
                                                     string.Concat(
                                                         Path.GetDirectoryName(filename),
                                                         "\\",
                                                         Path.GetFileNameWithoutExtension(filename),
                                                         "_",
                                                         type,
                                                         ".txt"));
                                             }
                                             return this.FileStatus;
                                         }
                                         this.FileStatus.FileOutName =
                                             string.Concat(
                                                 Path.GetDirectoryName(filename),
                                                 "\\",
                                                 Path.GetFileNameWithoutExtension(filename),
                                                 "_",
                                                 type,
                                                 ".txt");
                                         this.FileStatus.Status = true;
                                         this.FileStatus.Created = true;
                                         if (File.Exists(filename))
                                         {
                                             File.Delete(filename);
                                         }
                                         return this.FileStatus;
                                     }
                                     Func_File_Move(
                                         filename,
                                         string.Concat(errorOut, "\\", Path.GetFileName(filename)));
                                     this.FileStatus.FileErrName = string.Concat(
                                         errorOut,
                                         "\\",
                                         Path.GetFileName(filename));
                                     this.FileStatus.ExcpMessage = "Cannot Recover From EDI Errors: " + filename;
                                     this.FileStatus.Status = false;
                                     return this.FileStatus;
                                 }
                                 var valContext = new InterchangeContext
                                 {
                                     DataElementSeparator =
                                         dataSep.ToString(),
                                     SegmentTerminator =
                                         lineSep.ToString()
                                 };
                                 var valContent = Func_X12_Eval_Segments(
                                     filename,
                                     ediObject.ToEdi(valContext),
                                     type,
                                     dataSep,
                                     lineSep);
                                 if (Func_Data_ListIsEqual(valContent, ediObject.ToEdi(valContext)))
                                 {
                                     Func_File_Move(
                                         filename,
                                         string.Concat(validOut, "\\", Path.GetFileName(filename)));
                                     this.FileStatus.FileErrName = string.Concat(
                                         validOut,
                                         "\\",
                                         Path.GetFileName(filename));
                                     this.FileStatus.Created = true;
                                     this.FileStatus.Status = true;
                                     return this.FileStatus;
                                 }
                                 if (
                                     File.Exists(
                                         string.Concat(
                                             Path.GetDirectoryName(filename),
                                             "\\",
                                             Path.GetFileNameWithoutExtension(filename),
                                             "_",
                                             type,
                                             ".txt")))
                                 {
                                     File.Delete(
                                         string.Concat(
                                             Path.GetDirectoryName(filename),
                                             "\\",
                                             Path.GetFileNameWithoutExtension(filename),
                                             "_",
                                             type,
                                             ".txt"));
                                 }
                                 TextWriter valWriter =
                                     File.CreateText(
                                         string.Concat(
                                             Path.GetDirectoryName(filename),
                                             "\\",
                                             Path.GetFileNameWithoutExtension(filename),
                                             "_",
                                             type,
                                             ".txt"));
                                 try
                                 {
                                     valWriter.Write(string.Concat(valContent));
                                 }
                                 finally
                                 {
                                     ((IDisposable) valWriter).Dispose();
                                 }
                                 Func_File_Move(
                                     filename,
                                     string.Concat(validOut, "\\", Path.GetFileName(filename)));
                                 this.FileStatus.FileErrName = string.Concat(
                                     validOut,
                                     "\\",
                                     Path.GetFileName(filename));
                                 this.FileStatus.Created = true;
                                 this.FileStatus.Status = true;
                                 return this.FileStatus;
                             }
                         }
                     }
                 }
                 else
                 {
                     Func_File_Move(filename, string.Concat(errorOut, "\\", Path.GetFileName(filename)));
                     this.FileStatus.FileErrName = string.Concat(errorOut, "\\", Path.GetFileName(filename));
                     this.FileStatus.ExcpMessage = "Cannot Recover From EDI Errors";
                     this.FileStatus.Status = false;
                     this.FileStatus.Created = false;
                     return this.FileStatus;
                 }
             }
             else
             {
                 if (this.FileStatus.HasCWError)
                 {
                     Func_File_Move(filename, string.Concat(errorOut, "\\", Path.GetFileName(filename)));
                     this.FileStatus.FileErrName = string.Concat(errorOut, "\\", Path.GetFileName(filename));
                     this.FileStatus.Status = false;
                     this.FileStatus.Created = false;
                     return this.FileStatus;
                 }
                 Func_File_Move(filename, string.Concat(validOut, "\\", Path.GetFileName(filename)));
                 this.FileStatus.FileErrName = string.Concat(validOut, "\\", Path.GetFileName(filename));
                 this.FileStatus.Created = true;
                 this.FileStatus.Status = true;
                 return this.FileStatus;
             }
         }
         catch (ParserException parEx)
         {
             Func_File_Move(filename, string.Concat(errorOut, "\\", Path.GetFileName(filename)));
             this.FileStatus.FileErrName = string.Concat(errorOut, "\\", Path.GetFileName(filename));
             this.FileStatus.ExcpMessage = parEx.Message;
             this.FileStatus.Status = false;
             this.FileStatus.Created = false;
             return this.FileStatus;
         }
         catch (NullReferenceException nulEx)
         {
             Func_File_Move(filename, string.Concat(errorOut, "\\", Path.GetFileName(filename)));
             this.FileStatus.FileErrName = string.Concat(errorOut, "\\", Path.GetFileName(filename));
             this.FileStatus.ExcpMessage = nulEx.Message;
             this.FileStatus.Status = false;
             this.FileStatus.Created = false;
             return this.FileStatus;
         }
     }
     else
     {
         this.FileStatus.ExcpMessage = "Could Not Find: " + filename;
         this.FileStatus.Status = false;
         this.FileStatus.Created = false;
         return this.FileStatus;
     }
     return this.FileStatus;
 }
        //-----------------------------------------------------------------------------------------------------
        public FileAnalysis Func_CWO_XUS_SHP_X12_990_GLO(
            string filename,
            string fileOut,
            string filePrs,
            string fileErr)
        {
            this.FileStatus = new FileAnalysis();
            if (File.Exists(filename))
            {
                var controlNum = this.Func_SQL_GetControlNumber();
                var doc = new XmlDocument();
                doc.Load(filename);
                XmlNode root = doc.DocumentElement;
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("ns", "http://www.cargowise.com/Schemas/Universal/2011/11");
                var myInterchange = new MyINT(controlNum, "12", "3023254180", "ZZ", "FMXJ990", true);
                var myGroup = myInterchange.CreateGroup(controlNum, "GF", "3023254180", "FMXJ990");
                var myMessage = new X12_4010_990(controlNum);
                myMessage.Add_B1_A(
                    "WINA",
                    this.Func_XML_GetResultString(
                        doc,
                        nsmgr,
                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:WayBillNumber"),
                    DateTime.Now);
                myMessage.Add_N9(this.Func_XML_GetResultString(doc, nsmgr,
                    @"//ns:Shipment/ns:DataContext/ns:DataSourceCollection/ns:DataSource[ns:Type='ForwardingShipment']/ns:Key"));
                myGroup.AddMessage(myMessage.m990);

                myInterchange.SaveEdi(string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                this.FileStatus.HasError =
                    Func_File_Validate(string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                if (!this.FileStatus.HasError)
                {
                    this.Func_SQL_SubmitControlNumber(
                        controlNum,
                        "990GLO",
                        string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                    Func_File_Move(filename, string.Concat(filePrs, "\\", Path.GetFileName(filename)));
                    this.FileStatus.Created = true;
                    this.FileStatus.Status = true;
                    this.FileStatus.FileOutName = string.Concat(
                        fileOut,
                        "\\",
                        Path.GetFileNameWithoutExtension(filename),
                        ".edi");
                }
                else
                {
                    Func_File_Move(
                        string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"),
                        string.Concat(fileErr, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                    Func_File_Move(filename, string.Concat(fileErr, "\\", Path.GetFileName(filename)));
                    this.FileStatus.Created = false;
                    this.FileStatus.Status = false;
                    this.FileStatus.FileErrName = string.Concat(fileOut, "\\", Path.GetFileName(filename));
                }
            }
            return this.FileStatus;
        }
        //-----------------------------------------------------------------------------------------------------
        public FileAnalysis Func_CWO_XUS_SHP_X12_315_GLO(
            string filename,
            string fileOut,
            string filePrs,
            string fileErr)
        {
            this.FileStatus = new FileAnalysis();
            if (File.Exists(filename))
            {
                var controlNum = this.Func_SQL_GetControlNumber();
                var doc = new XmlDocument();
                doc.Load(filename);
                XmlNode root = doc.DocumentElement;
                var nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("ns", "http://www.cargowise.com/Schemas/Universal/2011/11");
                var myInterchange = new MyINT(controlNum, "12", "3023254180", "ZZ", "FMXJ315", true);
                var myGroup = myInterchange.CreateGroup(controlNum, "QO", "3023254180", "FMXJ315");
                var myMessage = new X12_4010_315(controlNum);
                var statusCode = this.Func_XML_GetResultString(doc, nsmgr, @"//ns:ActionPurpose/ns:Code");
                if (statusCode != string.Empty)
                {
                    switch (statusCode)
                    {
                        case "LEO":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));
                            var dateEvt = this.Func_XML_GetResultDate(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:ContainerCollection/ns:Container/ns:ContainerParkEmptyPickupGateOut");
                            var timeEvt = this.Func_XML_GetResultTime(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:ContainerCollection/ns:Container/ns:ContainerParkEmptyPickupGateOut");
                            var containerNum = this.Func_XML_GetResultString(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:ContainerCollection/ns:Container/ns:ContainerNumber");
                            var contPre = containerNum.Substring(0, 4);
                            var contSuf = containerNum.Substring(4, 7);
                            var contChk = containerNum.Substring(10, 1);
                            var contType = this.Func_XML_GetResultString(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:ContainerCollection/ns:Container/ns:ContainerType/ns:ISOCode");
                            var portCode = this.Func_XML_GetResultString(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code");
                            myMessage.Add_B4(
                                b403,
                                dateEvt,
                                timeEvt,
                                contPre,
                                contSuf,
                                b409,
                                contType,
                                portCode,
                                EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                contChk);
                        }
                            break;

                        case "ILR":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:FCLWharfGateIn");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:FCLWharfGateIn");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "AEL":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:FCLOnBoardVessel");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:FCLOnBoardVessel");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "CLL":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1][ns:TransportMode='Sea']/ns:EstimatedDeparture");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1][ns:TransportMode='Sea']/ns:EstimatedDeparture");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "VDL":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1][ns:TransportMode='Sea']/ns:ActualDeparture");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1][ns:TransportMode='Sea']/ns:ActualDeparture");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg/ns:PortOfLoading/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "ELD":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            var legCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:TransportMode='Sea']");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "][ns:TransportMode='Sea']/ns:EstimatedArrival");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "][ns:TransportMode='Sea']/ns:EstimatedArrival");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "]/ns:PortOfDischarge/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "VAD":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            var legCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:TransportMode='Sea']");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "][ns:TransportMode='Sea']/ns:ActualArrival");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "][ns:TransportMode='Sea']/ns:ActualArrival");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "]/ns:PortOfDischarge/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "UVD":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            var legCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:TransportMode='Sea']");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:FCLUnloadFromVessel");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:FCLUnloadFromVessel");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "]/ns:PortOfDischarge/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "OLD":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            var legCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:TransportMode='Sea']");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:FCLWharfGateOut");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:FCLWharfGateOut");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "]/ns:PortOfDischarge/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "AGM":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:LocalProcessing/ns:EstimatedDelivery");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:LocalProcessing/ns:EstimatedDelivery");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:PortOfDestination/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "DEM":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:LocalProcessing/ns:DeliveryCartageCompleted");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:LocalProcessing/ns:DeliveryCartageCompleted");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:PortOfDestination/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        case "TOS":
                        {
                            var b403 =
                                this.Func_EDI_ConvertStatusCode(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B403"));
                            var b409 =
                                this.Func_EDI_ConvertContainerStatus(
                                    this.Func_SQL_GetStatusCode(statusCode, "315GLO", "B409"));

                            var cntCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container");

                            var legCount = this.Func_XML_GetResultCount(
                                doc,
                                nsmgr,
                                @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:TransportMode='Sea']");

                            if (cntCount > 0)
                            {
                                var dateEvt = this.Func_XML_GetResultDate(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerParkEmptyReturnGateIn");

                                var timeEvt = this.Func_XML_GetResultTime(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerParkEmptyReturnGateIn");

                                var containerNum = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerNumber");
                                var contPre = containerNum.Substring(0, 4);
                                var contSuf = containerNum.Substring(4, 7);
                                var contChk = containerNum.Substring(10, 1);

                                var contType = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:UniversalShipment/ns:Shipment/ns:ContainerCollection/ns:Container[ns:Link=1]/ns:ContainerType/ns:ISOCode");

                                var portCode = this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                    + legCount + "]/ns:PortOfDischarge/ns:Code");

                                myMessage.Add_B4(
                                    b403,
                                    dateEvt,
                                    timeEvt,
                                    contPre,
                                    contSuf,
                                    b409,
                                    contType,
                                    portCode,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    contChk);
                            }
                        }
                            break;

                        default:
                        {
                            break;
                        }
                    }

                    var refList =
                        doc.SelectNodes(
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type/ns:Code",
                            nsmgr);

                    myMessage.Add_N9(EdiFabric.Definitions.X12_004010_315.X12_ID_128.ZZ, "WINA", "");

                    if (refList != null && refList.Count > 0)
                    {
                        foreach (XmlNode refItem in refList)
                        {
                            switch (refItem.InnerText)
                            {
                                case "LID":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_315.X12_ID_128.OL,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='LID']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='LID']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;

                                case "BKG":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_315.X12_ID_128.MB,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='BKG']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='BKG']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;

                                case "UCR":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_315.X12_ID_128.SI,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='UCR']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='UCR']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;

                                case "CON":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_315.X12_ID_128.TS,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='CON']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='CON']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;

                                case "OAG":
                                {
                                    myMessage.Add_N9(
                                        EdiFabric.Definitions.X12_004010_315.X12_ID_128.FN,
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='OAG']/parent::ns:AdditionalReference/ns:ReferenceNumber"),
                                        this.Func_XML_GetResultString(
                                            doc,
                                            nsmgr,
                                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:AdditionalReferenceCollection/ns:AdditionalReference/ns:Type[ns:Code='OAG']/parent::ns:AdditionalReference/ns:ContextInformation"));
                                }
                                    break;
                            }
                        }
                    }

                    myMessage.Add_N9(
                        EdiFabric.Definitions.X12_004010_315.X12_ID_128.BN,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:Shipment/ns:WayBillNumber"), "");

                    myMessage.Add_N9(
                        EdiFabric.Definitions.X12_004010_315.X12_ID_128.FN,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:Shipment/ns:DataContext/ns:DataSourceCollection/ns:DataSource[ns:Type='ForwardingShipment']/ns:Key"),
                        "");

                    myMessage.Add_N9(
                        EdiFabric.Definitions.X12_004010_315.X12_ID_128.X9,
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:WayBillNumber"), "");

                    var ordList =
                        doc.SelectNodes(
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:LocalProcessing/ns:OrderNumberCollection/ns:OrderNumber",
                            nsmgr);

                    if (ordList != null && ordList.Count > 0)
                    {
                        int intCnt = 1;

                        foreach (XmlNode ordItem in ordList)
                        {
                            myMessage.Add_N9(
                                EdiFabric.Definitions.X12_004010_315.X12_ID_128.PO,
                                this.Func_XML_GetResultString(
                                    doc,
                                    nsmgr,
                                    @"//ns:SubShipmentCollection/ns:SubShipment/ns:LocalProcessing/ns:OrderNumberCollection/ns:OrderNumber[" +
                                    intCnt.ToString() +
                                    "]/ns:OrderReference"), "");

                            intCnt += 1;
                        }
                    }

                    myMessage.Add_Q2(
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegType='Main']/ns:VoyageFlightNo"),
                        this.Func_XML_GetResultString(
                            doc,
                            nsmgr,
                            @"//ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegType='Main']/ns:VesselName"));

                    if (statusCode != string.Empty)
                    {
                        var tranCount = this.Func_XML_GetResultCount(
                            doc,
                            nsmgr,
                            @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg");

                        switch (statusCode)
                        {
                            case "LEO":
                            {
                                myMessage.Add_R4(
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_115.L,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Code"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Name"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Code")
                                        .Substring(0, 2));
                            }
                                break;

                            case "VDL":
                            {
                                myMessage.Add_R4(
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_115.L,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Code"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Name"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Code")
                                        .Substring(0, 2));
                            }
                                break;

                            case "OLD":
                            {
                                myMessage.Add_R4(
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_115.D,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                        + tranCount + "]/ns:PortOfDischarge/ns:Code"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                        + tranCount + "]/ns:PortOfDischarge/ns:Name"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                        + tranCount + "]/ns:PortOfDischarge/ns:Code").Substring(0, 2));
                            }
                                break;

                            case "DEM":
                            {
                                myMessage.Add_R4(
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_115.M,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfDestination/ns:Code"),
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfDestination/ns:Name"),
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfDestination/ns:Code")
                                        .Substring(0, 2));
                            }
                                break;

                            default:
                            {
                                myMessage.Add_R4(
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_115.R,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfOrigin/ns:Code"),
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfOrigin/ns:Name"),
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfOrigin/ns:Code")
                                        .Substring(0, 2));
                                myMessage.Add_R4(
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_115.M,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfDestination/ns:Code"),
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfDestination/ns:Name"),
                                    this.Func_XML_GetResultString(doc, nsmgr,
                                        @"//ns:SubShipment/ns:PortOfDestination/ns:Code")
                                        .Substring(0, 2));
                                //var tranCount = this.Func_XML_GetResultCount(
                                //    doc,
                                //    nsmgr,
                                //    @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg");
                                myMessage.Add_R4(
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_115.L,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Code"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Name"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder=1]/ns:PortOfLoading/ns:Code")
                                        .Substring(0, 2));
                                myMessage.Add_R4(
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_115.D,
                                    EdiFabric.Definitions.X12_004010_315.X12_ID_309.UN,
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                        + tranCount + "]/ns:PortOfDischarge/ns:Code"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                        + tranCount + "]/ns:PortOfDischarge/ns:Name"),
                                    this.Func_XML_GetResultString(
                                        doc,
                                        nsmgr,
                                        @"//ns:SubShipmentCollection/ns:SubShipment/ns:TransportLegCollection/ns:TransportLeg[ns:LegOrder="
                                        + tranCount + "]/ns:PortOfDischarge/ns:Code").Substring(0, 2));
                            }
                                break;
                        }
                    }

                    myGroup.AddMessage(myMessage.m315);
                    myInterchange.SaveEdi(string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename),
                        ".edi"));
                    this.FileStatus.HasError =
                        Func_File_Validate(string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename),
                            ".edi"));
                    if (!this.FileStatus.HasError)
                    {
                        this.Func_SQL_SubmitControlNumber(
                            controlNum,
                            "315GLO",
                            string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                        Func_File_Move(filename, string.Concat(filePrs, "\\", Path.GetFileName(filename)));
                        this.FileStatus.Created = true;
                        this.FileStatus.Status = true;
                        this.FileStatus.FileOutName = string.Concat(
                            fileOut,
                            "\\",
                            Path.GetFileNameWithoutExtension(filename),
                            ".edi");
                    }
                    else
                    {
                        Func_File_Move(
                            string.Concat(fileOut, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"),
                            string.Concat(fileErr, "\\", Path.GetFileNameWithoutExtension(filename), ".edi"));
                        Func_File_Move(filename, string.Concat(fileErr, "\\", Path.GetFileName(filename)));
                        this.FileStatus.Created = false;
                        this.FileStatus.Status = false;
                        this.FileStatus.FileErrName = string.Concat(fileOut, "\\", Path.GetFileName(filename));
                    }
                }
            }
            return this.FileStatus;
        }