//-----------------------------------------------------------------------------------------------------
        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 static bool LoadFromFile(string fileName, out ShipmentJobCostingChargeLine obj)
 {
     Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 public static bool Deserialize(string input, out ShipmentJobCostingChargeLine obj)
 {
     Exception exception = null;
     return Deserialize(input, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an ShipmentJobCostingChargeLine object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output ShipmentJobCostingChargeLine object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out ShipmentJobCostingChargeLine obj, out Exception exception)
 {
     exception = null;
     obj = default(ShipmentJobCostingChargeLine);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 /// <summary>
 /// Deserializes workflow markup into an ShipmentJobCostingChargeLine object
 /// </summary>
 /// <param name="input">string workflow markup to deserialize</param>
 /// <param name="obj">Output ShipmentJobCostingChargeLine object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this Serializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string input, out ShipmentJobCostingChargeLine obj, out Exception exception)
 {
     exception = null;
     obj = default(ShipmentJobCostingChargeLine);
     try
     {
         obj = Deserialize(input);
         return true;
     }
     catch (Exception ex)
     {
         exception = ex;
         return false;
     }
 }