EDI.Net
EDI.Net copied to clipboard
Avoid ambiguities between segments
Hi,
I have structure:
List<NUM> NUMs
(Condition type: I, status: TOT)
NUM:
Number
- NUM/0/0
Type
- NUM/0/1
Status
- NUM/1/0
Additional
- NUM segment with NUM/0/0 and NUM/0/1
DUM
- segment to avoid ambiguities between NUM
DEC
- DEC/0/0
List<Info> Infos
(Condition code: A,B,C,D)
Info:
Code
- PTS/0/0
InfoNumber
- NUM segment with NUM/0/0 and NUM/0/1 (Condition type: R)
DEC
- DEC/0/0 and DEC/0/1
Text
- TXF/0/0
SDI+TT'
NUM+123456789:I+TOT'
NUM+123454554:I'
DUM+'
DEC+2'
PTS+A+'
NUM+123456788:R'
DEC+2:C'
TXF+TEXT'
PTS+C'
NUM+123456777:R'
DEC+1:C'
TXF+TEXT'
NUM+123456789:I+TOT'
DUM+'
DEC+2'
PTS+A+'
NUM+123456838:R'
DEC+2:D'
TXF+TEXT'
SPR+ETD'
But is not work, it is my code. It extract group from num to num. My code:
[EdiCondition("I", Path = "NUM/0/1")]
public List<NUM> NUMs { get; set; }
[EdiSegmentGroup("NUM", SequenceEnd = "SPR")]
public class NUM
{
[EdiValue("X(35)", Path = "NUM/0", Mandatory = true)]
public string Number { get; set; }
[EdiValue("X(3)", Path = "NUM/0/1", Mandatory = true)]
public string Type { get; set; }
[EdiValue("X(3)", Path = "NUM/1", Mandatory = true)]
public string Status { get; set; }
public DUM DUM { get; set; }
public DEC DEC { get; set; }
[EdiCondition("A", Path = "PTS/1/0")]
[EdiCondition("B", Path = "PTS/1/0")]
[EdiCondition("C", Path = "PTS/1/0")]
[EdiAny]
public List<Info> Infos { get; set; }
}
[EdiSegmentGroup("PTS")]
public class Info
{
[EdiValue("X(3)", Path = "PTS/1/0")]
public string Code { get; set; }
[EdiValue("X(3)", Path = "PTS/2/0")]
public string CodeT { get; set; }
[EdiCondition("J", Path = "NUM/0/1")]
public NumberDetails Details { get; set; }
public DEC DEC { get; set; }
[EdiCondition("4", Path = "TXF/0/0")]
public string Text { get; set; }
}
[EdiSegment, EdiPath("DEC")]
public class DEC
{
[EdiValue("X(6)", Path = "DEC/0/0", Mandatory = true)]
public string Number { get; set; }
[EdiValue("X(3)", Path = "DEC/0/1")]
public string Status { get; set; }
}
How to parse it, i missed Details in Info. Because i cut data in List<NUM> SegmentGroup
I have to get list of NUM with 2 object. NUM[0].Infos with 2 object NUM[1].Infos with 1 object
Ok I cannot help without a complete class model and a sample. But if I had to guess by the structure indentation above you are better of defining your SegmentGroup explicitly by providing all direct possible children. For example instead of providing a sequence end you should define NUM and Info with something along the lines:
[EdiSegmentGroup("NUM", "DUM", "DEC", "PTS")]
public class NUM
{
[EdiValue("X(35)", Path = "NUM/0", Mandatory = true)]
public string Number { get; set; }
[EdiValue("X(3)", Path = "NUM/0/1", Mandatory = true)]
public string Type { get; set; }
[EdiValue("X(3)", Path = "NUM/1", Mandatory = true)]
public string Status { get; set; }
public DUM DUM { get; set; }
public DEC DEC { get; set; }
public List<Info> Infos { get; set; }
}
[EdiSegmentGroup("PTS", "NUM", "TXF")]
public class Info
{
[EdiValue("X(3)", Path = "PTS/1/0")]
public string Code { get; set; }
[EdiValue("X(3)", Path = "PTS/2/0")]
public string CodeT { get; set; }
public NUM Details { get; set; }
[EdiValue("X(4)", Path = "TXF/0/0")]
public string Text { get; set; }
}
This will help avoid any mixup for cyclic references.
If this does not help you have to provide me with more info as well as the transmission type.
in class NUM, I can meet a segment twice, but I have to use into NUM other
Have you resolved this issue? If yes please tell me so I can mark it as closed.
No,
Because in class NUM, i can meet again Segment NUM. And i get only last NUM 1st is mandatory 2nd is not mandatory, but when exist i have to get