EDI.Net icon indicating copy to clipboard operation
EDI.Net copied to clipboard

Looking for already made PAXLST c# class any version

Open Sharkboy-j opened this issue 5 years ago • 7 comments

Maybe anybody has ready C# class for message in subject? Thank you Have some problems with creating model, sometimes segments parsing well, sometimes no.

Sharkboy-j avatar Oct 16 '18 13:10 Sharkboy-j

Hi Jeremy, can you share some code and a point to what went wrong. It may be easier to get you going than find something already made

cleftheris avatar Oct 16 '18 13:10 cleftheris

Hi Jeremy, can you share some code and a point to what went wrong. It may be easier to get you going than find something already made

here is my class

  public class PaxLst
    {
        #region header
        public UNB UNB { get; set; }

        public UNG UNG { get; set; }
        public UNH UNH { get; set; }
        public BGM BGM { get; set; }


        #endregion


    }

    #region header segments

    [EdiSegment, EdiPath("UNB")]
    public class UNB
    {
        [EdiValue("X(4)", Path = "UNB/0", Mandatory = true)]
        public string Identifier { get; set; } = "UNOA"; //Syntax identifier

        [EdiValue("9(1)", Path = "UNB/0/1", Mandatory = true)]
        public string Version { get; set; } = "4"; //Syntax version number

        /// <summary>
        /// Sender identification
        /// </summary>
        [EdiValue("X(35)", Path = "UNB/1/0", Mandatory = true)]
        public string SenderId { get; set; } = "UKSB";

        [EdiValue("X(4)", Path = "UNB/1/1", Mandatory = false)]
        public string PartnerIDCodeQualifier { get; set; }

        [EdiValue("X(14)", Path = "UNB/1/2", Mandatory = false)]
        public string ReverseRoutingAddress { get; set; }

        [EdiValue("X(35)", Path = "UNB/2/0", Mandatory = true)]
        public string RecipientId { get; set; } = "DLH";


        [EdiValue("X(4)", Path = "UNB/2/1", Mandatory = false)]
        public string ParterIDCode { get; set; }


        [EdiValue("X(14)", Path = "UNB/2/2", Mandatory = false)]
        public string RoutingAddress { get; set; }



        [EdiValue("9(6)", Path = "UNB/3/0", Format = "ddMMyy", Description = "Date of Preparation")]
        [EdiValue("9(4)", Path = "UNB/3/1", Format = "HHmm", Description = "Time or Prep")]
        public DateTime DateOfPreparation { get; set; } = DateTime.ParseExact("110103:0621", "yyMMdd:HHmm",
                                       System.Globalization.CultureInfo.InvariantCulture);

        [EdiValue("X(14)", Path = "UNB/4", Mandatory = true)]
        public string ControlRef { get; set; } = "D8L3H9";

        [EdiValue("9(1)", Path = "UNB/8", Mandatory = false)]
        public int AckRequest { get; set; }
    }


    [EdiSegment, EdiPath("UNG")]
    public class UNG
    {
        [EdiValue("9(6)", Path = "UNG/0/0", Mandatory = true)]
        public string FGI { get; set; } = "CUSRES";

        /// <summary>
        /// Application sender identification
        /// </summary>
        [EdiValue("X(35)", Path = "UNG/1/0", Mandatory = true)]
        public string ASI { get; set; } = "UKSB";

        [EdiValue("X(35)", Path = "UNG/2/0", Mandatory = true)]
        public string RecipientId2 { get; set; } = "DLH";




        [EdiValue("9(6)", Path = "UNG/3/0", Format = "ddMMyy", Description = "Date of Preparation")]
        [EdiValue("9(4)", Path = "UNG/3/1", Format = "HHmm", Description = "Time or Prep")]
        public DateTime DateOfPreparation2 { get; set; } = DateTime.ParseExact("110103:0621", "yyMMdd:HHmm",
                                 System.Globalization.CultureInfo.InvariantCulture);
        [EdiValue("X(14)", Path = "UNG/4", Mandatory = true)]
        public string ControlRef2 { get; set; } = "D8L3H9";

        [EdiValue("X(2)", Path = "UNG/5")]
        public string ControllingAgency2 { get; set; } = "UN";


        [EdiValue("X(3)", Path = "UNG/6")]
        public string Versions2 { get; set; } = "D";

        [EdiValue("X(3)", Path = "UNG/6/1")]
        public string ReleaseNumber2 { get; set; } = "05B";
    }


    [EdiSegment, EdiPath("UNH")]
    public class UNH
    {
        [EdiValue("X(14)", Path = "UNH/0/0")]
        public string MessageRef { get; set; } = "1";

        [EdiValue("X(6)", Path = "UNH/1/0")]
        public string MessageType { get; set; } = "CUSRES";

        [EdiValue("X(3)", Path = "UNH/1/1")]
        public string Versions { get; set; } = "D";

        [EdiValue("X(3)", Path = "UNH/1/2")]
        public string ReleaseNumber { get; set; } = "05B";

        [EdiValue("X(2)", Path = "UNH/1/3")]
        public string ControllingAgency { get; set; } = "UN";

        [EdiValue("X(6)", Path = "UNH/1/4")]
        public string AssociationAssignedCode { get; set; } = "IATA";

        [EdiValue("X(35)", Path = "UNH/2/0")]
        public string CommonAccessRef { get; set; }
    }

    [EdiSegment, EdiPath("BGM")]
    public class BGM
    {
        /// <summary>
        /// 962 Indicates response message
        /// 132 Unsolicited message
        /// 312 Acknowledgement message
        /// </summary>
        [EdiValue("9(2)", Path = "BGM/0/0")]
        public int MessageType2 { get; set; }

        [EdiValue("X(35)", Path = "BGM/1/0")]
        public string DocumentNumber { get; set; }

        [EdiValue("X(3)", Path = "BGM/2/0", Mandatory = false)]
        public string MessageFunction { get; set; }

        [EdiValue("X(3)", Path = "BGM/3/0")]
        public string ResponseType { get; set; }
    }
    #endregion

and here is example of message

UNA:*.? $
UNB*UNOA:4*SDT:ZZ*NLDAPIKM:ZZ*180828:0629*1808280629**APIS$
UNG*PAXLST*BELAVIA:ZZ*NLDAPIKM:ZZ*180828:0629*1808280629*UN*D:05B$UNH*1808280629*PAXLST:D:05B:UN:IATA*B2867*06$
BGM*745$
NAD*MS***SABRE CENTRAL$
COM*800-727-6827:TE*817-264-7656:FX$
TDT*20*B2867$
LOC*125*MSQ$
DTM*189:1808280930:201$
LOC*87*AMS$
DTM*232:1808281110:201$
NAD*FL***ROOSEVELT:MIRANDA LENA$
ATT*2**F$
DTM*329:030406$
LOC*22*AMS$
LOC*178*ALA$
LOC*179*AMS$
NAT*2*NLD$
RFF*AVF:RIBHBQ$
RFF*SEA:21F$
DOC*P:110:111*NUP94LCH7$
DTM*36:230620$
LOC*91*NLD$
RFF*AVF:OWPYBS$
RFF*SEA:14C$DOC*P:110:111*NYB15BRR7$
DTM*36:280209$
LOC*91*NLD$
CNT*42:141$
UNT*159*1808280629$
UNE*1*1808280629$
UNZ*1*1808280629$

i have no idea why UNG wont pars

Sharkboy-j avatar Oct 16 '18 14:10 Sharkboy-j

Hi Jeremy,

From what you have shared it seems to me that you are not making use of the edi EdiMessage and EdiGroup attributes. Although most mappings if not all are possible with EdiSegment and EdiSegmentGroup the message and group hierarchy is a special one. So in order to get the header and footer segments mapped correctly you will need a container class for PaxLstGroup and PaxLstMessage

cleftheris avatar Oct 17 '18 06:10 cleftheris

Hi Jeremy,

From what you have shared it seems to me that you are not making use of the edi EdiMessage and EdiGroup attributes. Although most mappings if not all are possible with EdiSegment and EdiSegmentGroup the message and group hierarchy is a special one. So in order to get the header and footer segments mapped correctly you will need a container class for PaxLstGroup and PaxLstMessage

Hello again. Ty for reply. Can you explain when i should to use EdiMessage, EdiSegment, EdiGroup etc. ...

Sharkboy-j avatar Oct 17 '18 10:10 Sharkboy-j

Take a look at my answer to a similar question here https://github.com/indice-co/EDI.Net/issues/14#issuecomment-244056179

cleftheris avatar Oct 17 '18 10:10 cleftheris

Take a look at my answer to a similar question here #14 (comment)

Did i get it rigth?

UNA:*.?
+---$UNB				Interchange Header [EdiElement]
| +---$UNG				Functional Group Header [EdiGroup]
| | +---$UNH			Message Header [EdiMessage]
| | | +---$BGM			????
| | | |
| | | | +---
| | | | |	$NAD
| | | | |	$COM
| | | | |	$TDT
| | | | |	$LOC
| | | | |	$DTM
| | | | |	$LOC
| | | | |	$DTM
| | | | |
| | | | |		$NAD
| | | | |		$ATT
| | | | |		$DTM
| | | | |		$MEA
| | | | |		$FTX
| | | | |		$LOC
| | | | |		$LOC
| | | | |		$LOC
| | | | |		$NAT
| | | | |		$RFF
| | | | |		$RFF
| | | | |		$DOC
| | | | |		$DTM
| | | | |		$LOC
| | | | |	
| | | | |		$NAD
| | | | |		$ATT
| | | | |		$DTM
| | | | |		$MEA
| | | | |		$FTX
| | | | |		$LOC
| | | | |		$LOC
| | | | |		$LOC
| | | | |		$NAT
| | | | |		$RFF
| | | | |		$RFF
| | | | |		$DOC
| | | | |		$DTM
| | | | |		$LOC
| | | | +---					
| | | +---$CNT			????
| | +---$UNT			Message Trailer [EdiMessage]
| +---$UNE				Functional Group Header	[EdiGroup]
+---$UNZ				Interchange Trailer [EdiElement]

Sharkboy-j avatar Oct 17 '18 11:10 Sharkboy-j

Correct as far as the outer part is concerned, anything in between UNH and UNT is considered to be the message content and its structure is specific to the transmission, "PAXLST" in your case. Take a look at the sample code we got in the tests project that handles the IFCSUM transmission https://github.com/indice-co/EDI.Net/blob/master/test/indice.Edi.Tests/Models/EDIFact_D01B_IFCSUM.cs it is not complete but it is enough to see how it is put together.

One addition to that. In your case you also got the message group so you will need an extra container for your classes. So the messages should be contained inside a class marked with [EdiGroup] that is not present in the exaple I have shown but it is shown in this one here https://github.com/indice-co/EDI.Net/blob/f896b4796746c011cbd2c89ecb3250f62dc7782e/test/indice.Edi.Tests/Models/X12_214.cs

cleftheris avatar Oct 17 '18 11:10 cleftheris