首页 > 解决方案 > EDI 解串器不能以不同的格式工作

问题描述

EASI    2.0 01  105687859   01  112088708   20100809    080953  EDT T   850 080908095349328 
01  850 00  1.0 SA  C0020287    10  20020207    122325  A123456 USD 34579   0005    707738  John Doe 314-999-1279   PP  BK  FT  P2      2.25    10  30  20021231    Net 60  20100809    20020331    FEDX    Alpha Philadelphia  John Smith  123 ABC Drive       Hebron  OH  43025   US  N   Deliver to Receiving Dock before 8:00 AM, call before delivery  Shrink Wrap cartons UKK PROMO001    92  212-345-678 
02  1   00999913060595  K112    54  7   36  EA  8.3600  372.96 
02  1   00884913060595  K112    54  7   36  EA  8.3600  372.96 
02  1   00884913060595  K112    54  7   36  EA  8.3600  372.96 
09  5   120              
EASX    080908095349328 01 

什么是 EDI 段组,因为我在反序列化时无法反序列化,因为它与 EDI 格式不完全匹配

我的反序列化功能是

 var grammar = CustomEDIGrammar.GetGrammar();
                    CAA850 interchange;

                    try
                    {
                        using (var stream = new StreamReader(tmpfilepath))
                        {
                            interchange = new EdiSerializer().Deserialize<CAA850>(stream, grammar);
                        }
                    }
                    catch(Exception ex)
                    {
                        var expmsg = ex;
                        throw;
                    }

我的 CAA850 课程是

    {
        [EdiSegment]
        class CAA850
        {
    
    
            // ISA
            #region EASI and 01
            [EdiValue("9(2)", Path = "EASI/0", Description = "EASI01 - Version Number")]
            public string VersionNumber { get; set; }
    
            [EdiValue("9(3)", Path = "EASI/1", Description = "EASI02 - Sender Qualifier")]
            public string SenderQualifier { get; set; }
    
            [EdiValue("9(2)", Path = "EASI/2", Description = "EASI03 - Sender ID")]
            public string SenderID { get; set; }
    
            [EdiValue("X(3)", Path = "EASI/3", Description = "EASI04 - Receiver Qualifier")]
            public string ReceiverQualifier { get; set; }
    
            [EdiValue("9(2)", Path = "EASI/4", Description = "EASI05 - Receiver Id")]
            public string ReceiverId { get; set; }
    
            [EdiValue("X(22)", Path = "EASI/5", Description = "EASI06 - File Creation Time")]
            public string FileCreationDate { get; set; }
    
            [EdiValue("X(30)", Path = "EASI/6", Description = "EASI07 - File Creation Time")]
            public string FileCreationTime { get; set; }
    
            [EdiValue("9(2)", Path = "EASI/7", Description = "EASI08 - Time Zone")]
            public string TimeZone { get; set; }
    
            [EdiValue("X(15)", Path = "EASI/8", Description = "EASI09 - Production Or Test")]
            public string ProductionorTest { get; set; }
    
            [EdiValue("9(3)", Path = "EASI/9", Description = "EASI10 - Transaction Type")]
    
            public string TransactionType { get; set; }
    
            [EdiValue("9(4)", Path = "EASI/10", Description = "EASI11 - Interchange ID")]
            public string InterchangeID { get; set; }
    
            public RecordType01 RecordType01s { get; set; }
    
            public List<RecordType02> RecordType02s { get; set; }
    
            public RecordType09 RecordType09s { get; set; }
    
            public EASX Easx { get; set; }
    
            [EdiSegment]
            public class RecordType01
            {
    
    
                [EdiValue("9(4)", Path = "01/0", Description = "010 - Transaction Type")]
                public string TransactionType { get; set; }
    
                [EdiValue("9(2)", Path = "01/1", Description = "011 - Transaction Set Purpose")]
                public string TransactionSetPurpose { get; set; }
    
                [EdiValue("X(3)", Path = "01/2", Description = "012 - Version Number")]
                public string VersionNumber { get; set; }
    
                [EdiValue("9(4)", Path = "01/3", Description = "013 - Purchase Order Type Code")]
                public string PurchaseOrderTypeCode { get; set; }
    
    
                [EdiValue("9(4)", Path = "01/4", Description = "014 - Purchase Order Type Code")]
                public string PurchaseOrderNumber { get; set; }
    
                [EdiValue("9(4)", Path = "01/5", Description = "015 - Release Number")]
                public string ReleaseNumber { get; set; }
    
                [EdiValue("9(4)", Path = "01/6", Description = "016 - Purchase Order Date")]
                public string PurchaseOrderDate { get; set; }
    
                [EdiValue("9(4)", Path = "01/7", Description = "017 - Purchase Order Time")]
                public string PurchaseOrderTime { get; set; }
    
                [EdiValue("9(4)", Path = "01/8", Description = "018 - Contract Number")]
                public string ContractNumber { get; set; }
    
                [EdiValue("9(4)", Path = "01/9", Description = "019 -Currency Code")]
                public string CurrencyCode { get; set; }
    
                [EdiValue("9(4)", Path = "01/10", Description = "0120 - Purchase Account ID")]
                public string PurchaseAccountID { get; set; }
    
                [EdiValue("9(4)", Path = "01/11", Description = "0121 - Store ID")]
                public string StoreID { get; set; }
    
                [EdiValue("9(4)", Path = "01/12", Description = "0122 - Vendor ID")]
                public string VendorID { get; set; }
    
                [EdiValue("9(4)", Path = "01/13", Description = "0123 - Contact Name And Numer")]
                public string ContactNameAndNumer { get; set; }
    
                [EdiValue("9(4)", Path = "01/14", Description = "0124 - FOB Payment Instructions")]
                public string FOBPaymentInstructions { get; set; }
    
                [EdiValue("9(4)", Path = "01/15", Description = "0125 - Sales Requirement Code Shipment")]
                public string SalesRequirementCodeShipment { get; set; }
    
                [EdiValue("9(4)", Path = "01/16", Description = "0126 - Sales Requirement Code TruckLoad")]
                public string SalesRequirementCodeTruckLoad { get; set; }
    
                [EdiValue("9(4)", Path = "01/17", Description = "0127 - Sales Requirement Code Ship Date")]
                public string SalesRequirementCodeShipDate { get; set; }
    
                [EdiValue("9(4)", Path = "01/18", Description = "0128 - Sales Requirement Code Consigmentor Ship Blind")]
                public string SalesRequirementCodeConsigmentorShipBlind { get; set; }
    
                [EdiValue("9(4)", Path = "01/19", Description = "0129 - Payment Terms Discount Offered")]
                public string PaymentTermsDiscountOffered { get; set; }
    
                [EdiValue("9(4)", Path = "01/20", Description = "0130 - Payment Terms DiscountDays")]
                public string PaymentTermsDiscountDays { get; set; }
    
                [EdiValue("9(4)", Path = "01/21", Description = "0131 - Payment Due In Number of Days Without Discount")]
                public string PaymentDueInNumberofDaysWithoutDiscount { get; set; }
    
                [EdiValue("9(4)", Path = "01/22", Description = "0132 - Specific Payment Date")]
                public string SpecificPaymentDate { get; set; }
    
                [EdiValue("9(4)", Path = "01/23", Description = "0133 - Literal Of Payment Terms")]
                public string LiteralOfPaymentTerms { get; set; }
    
                [EdiValue("9(4)", Path = "01/24", Description = "0134 - Requested Ship Date")]
                public string RequestedShipDate { get; set; }
    
                [EdiValue("9(4)", Path = "01/25", Description = "0135 -Cancel Date")]
                public string CancelDate { get; set; }
    
                [EdiValue("9(4)", Path = "01/26", Description = "0136 - Carrier Routing Details")]
                public string CarrierRoutingDetails { get; set; }
    
                [EdiValue("9(4)", Path = "01/27", Description = "0137 - Deliver To Company Name")]
                public string DeliverToCompanyName { get; set; }
    
    
                [EdiValue("9(4)", Path = "01/28", Description = "0138 - Deliver To Contact Name")]
                public string DeliverToContactName { get; set; }
    
                [EdiValue("9(4)", Path = "01/29", Description = "0139 - Deliver To Address Line1")]
                public string DeliverToAddressLine1 { get; set; }
    
                [EdiValue("9(4)", Path = "01/30", Description = "0140 -Deliver To Address Line2")]
                public string DeliverToAddressLine2 { get; set; }
    
                [EdiValue("9(4)", Path = "01/31", Description = "0141 - Deliver To City Name")]
                public string DeliverToCityName { get; set; }
    
                [EdiValue("9(4)", Path = "01/32", Description = "0142 - Deliver To State Code")]
                public string DeliverToStateCode { get; set; }
    
                [EdiValue("9(4)", Path = "01/33", Description = "0143 - Deliver To Postal Code")]
                public string DeliverToPostalCode { get; set; }
    
                [EdiValue("9(4)", Path = "01/34", Description = "0144 - Deliver To Country Code")]
                public string DeliverToCountryCode { get; set; }
    
                [EdiValue("9(4)", Path = "01/35", Description = "0145 - Drop Ship Code")]
                public string DropShipCode { get; set; }
    
                [EdiValue("9(4)", Path = "01/36", Description = "0146 - Special lDelivery Instructions")]
                public string SpecialDeliveryInstructions { get; set; }
    
                [EdiValue("9(4)", Path = "01/37", Description = "0147 - Special Order Instructions")]
                public string SpecialOrderInstructions { get; set; }
    
                [EdiValue("9(4)", Path = "01/38", Description = "0148 - Deliver To Country Province Town Territory")]
                public string DeliverToCountryProvinceTownTerritory { get; set; }
    
                [EdiValue("9(4)", Path = "01/39", Description = "0149 - Promotional Code")]
                public string PromotionalCode { get; set; }
    
    
                [EdiValue("9(4)", Path = "01/40", Description = "0150 - Delivery Service Level")]
                public string DeliveryServiceLevel { get; set; }
    
                [EdiValue("9(4)", Path = "01/41", Description = "0151 - Deliver To Receivers Phone Number")]
                public string DeliverToReceiversPhoneNumber { get; set; }
    
    
            }
    
            [EdiSegment]
            public class RecordType02
            {
    
    
                [EdiValue("9(4)", Path = "02/0", Description = "020 - Line Item Number")]
                public string LineItemNumber { get; set; }
    
                [EdiValue("9(4)", Path = "02/1", Description = "021 - ItemIdentification GTIN")]
                public string ItemIdentificationGTIN { get; set; }
    
                [EdiValue("9(4)", Path = "02/2", Description = "022 - Master Style")]
                public string MasterStyle { get; set; }
    
                [EdiValue("9(4)", Path = "02/3", Description = "023 - Color Code")]
                public string ColorCode { get; set; }
    
                [EdiValue("9(4)", Path = "02/4", Description = "024 - Size Code")]
                public string SizeCode { get; set; }
    
                [EdiValue("9(4)", Path = "02/5", Description = "025 - Quantity Ordered")]
                public string QuantityOrdered { get; set; }
    
                [EdiValue("9(4)", Path = "02/6", Description = "026 - Unit or Basis for Measurement Code")]
                public string UnitorBasisforMeasurementCode { get; set; }
    
                [EdiValue("9(4)", Path = "02/7", Description = "027 - Purchase Unit Price")]
                public string PurchaseUnitPrice { get; set; }
    
                [EdiValue("9(4)", Path = "02/8", Description = "028 - Total Monetary Amount of Line Item")]
                public string TotalMonetaryAmountofLineItem { get; set; }
            }
    
            [EdiSegment]
            public class RecordType09
            {
    
    
                [EdiValue("9(4)", Path = "09/0", Description = "029 - Record Count")]
                public string RecordCount { get; set; }
    
                [EdiValue("9(4)", Path = "09/1", Description = "030 - Total Quantity Ordered")]
                public string TotalQuantityOrdered { get; set; }
    
                [EdiValue("9(4)", Path = "09/2", Description = "031 - Total Monetary Value")]
                public string TotalMonetaryValue { get; set; }
    
                [EdiValue("9(4)", Path = "09/3", Description = "032 - Total Monetary Value of Other Charges")]
                public string TotalMonetaryValueofOtherCharges { get; set; }
    
                [EdiValue("9(4)", Path = "09/4", Description = "033 - Number of Cases")]
                public string NumberofCases { get; set; }
    
                [EdiValue("9(4)", Path = "09/5", Description = "034 - Purchase Order Total Amount")]
                public string PurchaseOrderTotalAmount { get; set; }
    
    
            }
            [EdiSegment]
            public class EASX
            {
              
    
                [EdiValue("9(4)", Path = "EASX/0", Description = "EASX0 - Interchange ID")]
                public string InterchangeID { get; set; }
    
                [EdiValue("9(4)", Path = "EASX/1", Description = "EASX1 - Number Of Documents")]
                public string NumberOfDocuments { get; set; }
            }
    
            #endregion
    
            #region Edi Enumerations
    
            #endregion
        }
    }

哪个类段哪个类组可以帮助,因为它在反序列化时不完全对应 EDI 格式,它是上面空白中给出的形式的不同形式。这就是为什么我必须在反序列化时给出段名称,但是我该如何放置和放置什么。

标签: c#asp.net-mvcalgorithmasp.net-coreedi

解决方案


推荐阅读