-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple repeated elements within a single segment #272
Comments
This didn't seem right, but just trying things and at least doesn't have any errors. However, it serializes them into separate PFD segments (see below) [EdiSegment, EdiPath("PFD")]
public class PFD
{
[EdiValue(Path = "PFD/0/0")]
public string PFD_01A_SpecificSeat { get; set; }
[EdiValue(Path = "PFD/0/1")]
public string PFD_01B_FreeSeatingReference { get; set; }
[EdiValue(Path = "PFD/1/0")]
public string PFD_02A_NoSmokingIndicator { get; set; }
[EdiValue(Path = "PFD/1/1")]
public string PFD_02B_CabinClassDesignator { get; set; }
[EdiValue(Path = "PFD/1/2")]
public string PFD_02C_CabinClassNumber { get; set; }
[EdiValue(Path = "PFD/1/3")]
public string PFD_02D_FreeTextCabinClassZone { get; set; }
[EdiValue(Path = "PFD/1/4")]
public string PFD_02E_SegmentAirportOfDeparture { get; set; }
[EdiValue(Path = "PFD/1/5")]
public string PFD_02F_SegmentAirportOfArrival { get; set; }
[EdiValue(Path = "PFD/1/6")]
public string PFD_02G_EquipmentCode { get; set; }
[EdiValue(Path = "PFD/1/7")]
public string PFD_02H_SeatRequestFullfilledIndicator { get; set; }
[EdiValue(Path = "PFD/1/8")]
public string PFD_02I_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/1/9")]
public string PFD_02J_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/1/10")]
public string PFD_02K_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/1/11")]
public string PFD_02L_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/1/12")]
public string PFD_02M_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/2/0")]
public string PFD_07_PaxIdForBPPrint { get; set; }
[EdiValue(Path = "PFD/2/1")]
public string PFD_07_InfantIdForBPPrint { get; set; }
[EdiValue(Path = "PFD/3/0")]
public string PFD_08_IssueReissueBoardingPass { get; set; }
[EdiValue(Path = "PFD/4/0")]
public string PFD_09_BarcodeForBoardingPass { get; set; }
[EdiValue(Path = "PFD/5/0")]
public string PFD_10_PaxPriorityInformation { get; set; }
[EdiPath("PFD/6/0..*")]
public PFD_SeatDetail[] SeatDetails { get; set; }
[EdiPath("PFD/7/0..*")]
public PFD_SeatDefinition[] SeatDefinitions { get; set; }
}
[EdiElement]
public class PFD_SeatDetail
{
[EdiValue(Path = "PFD/*/0")]
public string PFD_11A_SpecificSeat { get; set; }
[EdiValue(Path = "PFD/*/1")]
public string PFD_11B_FreeSeatingReference { get; set; }
}
[EdiElement]
public class PFD_SeatDefinition
{
[EdiValue(Path = "PFD/*/0")]
public string PFD_12A_NoSmokingIndicator { get; set; }
[EdiValue(Path = "PFD/*/1")]
public string PFD_12B_CabinClassDesignator { get; set; }
[EdiValue(Path = "PFD/*/2")]
public string PFD_12C_CabinClassNumber { get; set; }
[EdiValue(Path = "PFD/*/3")]
public string PFD_12D_FreeTextCabinClassZone { get; set; }
[EdiValue(Path = "PFD/*/4")]
public string PFD_12E_SegmentAirportOfDeparture { get; set; }
[EdiValue(Path = "PFD/*/5")]
public string PFD_12F_SegmentAirportOfArrival { get; set; }
[EdiValue(Path = "PFD/*/6")]
public string PFD_12G_EquipmentCode { get; set; }
[EdiValue(Path = "PFD/*/7")]
public string PFD_12H_SeatRequestFullfilledIndicator { get; set; }
[EdiValue(Path = "PFD/*/8")]
public string PFD_12I_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/*/9")]
public string PFD_12J_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/*/10")]
public string PFD_12K_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/*/11")]
public string PFD_12L_SeatCharacteristics { get; set; }
[EdiValue(Path = "PFD/*/12")]
public string PFD_12M_SeatCharacteristics { get; set; }
} var interchange = new Interchange_PFD()
{
PFD = new PFD
{
PFD_01A_SpecificSeat = "12C",
PFD_02A_NoSmokingIndicator = "N",
PFD_02B_CabinClassDesignator = "M",
PFD_02C_CabinClassNumber = "3",
PFD_02E_SegmentAirportOfDeparture = "FRA",
PFD_02F_SegmentAirportOfArrival = "MEX",
PFD_02G_EquipmentCode = "744",
SeatCharacteristics = new PFD_SeatCharacteristic []
{
new PFD_SeatCharacteristic {
PFD_02I_SeatCharacteristics = "Y"
},
new PFD_SeatCharacteristic {
PFD_02I_SeatCharacteristics = "Z"
}
},
PFD_07_PaxIdForBPPrint = "12",
PFD_10_PaxPriorityInformation = "M/M",
SeatDetails = new PFD_SeatDetail[] {
new PFD_SeatDetail {
PFD_11A_SpecificSeat = "01X"
},
new PFD_SeatDetail {
PFD_11A_SpecificSeat = "02X"
}
},
SeatDefinitions = new PFD_SeatDefinition[] {
new PFD_SeatDefinition {
PFD_12A_NoSmokingIndicator = "A"
},
new PFD_SeatDefinition {
PFD_12A_NoSmokingIndicator = "B"
}
}
}
};
var output = new StringBuilder();
var grammar = EdiGrammar.NewEdiFact();
using (var writer = new EdiTextWriter(new StringWriter(output), grammar))
{
new EdiSerializer() { EnableCompression = true }.Serialize(writer, interchange);
Debug.Write(output);
} Serializes them into separate PFD segments instead of a single PFD segment. The goal is a single PFD segment.
|
Hi @nochancenine this is a nice test that you can add it to the tests project with an assertion. If you give it a try I can look at a pull request. On a quick note, probably you need to omit the PFD from your component values and add it to the segment itself. So I would make these attributes have the segmentName part as a wildcard But I have to give it a closer look to be sure. |
Hello, thank you I have tried the I have created a new pull request with a sample test here: |
Thanks for the pull request I will check it out as soon as possible. |
I'm working with a segment PFD that has multiple repeated elements within the segment and also repeated elements within repeated elements.
All the examples I have found seem to only have a single repeated element within a segment. I have other segments like that and they work.
The issue is specifically with multiple repeated elements in the same segment.
I have been trying many combinations trying to get these to serialize onto a single PFD segment, but it always seems to split them off into separate PFD segments.
Even if I need to do the Seat Characteristics as 5 individual
EdiValue
each (not repeated), there are still multiple repeated elements that I haven't been able to get to serialize into a single PFD segmentIs there a way to accomplish this or any workaround method to achieve it?
What I thought I should do is like this:
...
Then this:
But that results in
I have been trying different models, but here is a trimmed down one:
Again, the goal is to get these to serialize all into a single PFD segment
Is this possible by any means?
Thank you
The text was updated successfully, but these errors were encountered: