-
Notifications
You must be signed in to change notification settings - Fork 169
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
Not able to serialize and deserialize SMPRES message correctly. #219
Comments
UNA:+.? ' |
Hi @dvddo and thanks for your interest in EDI.Net. Can you elaborate on what is the the input data, your classes/models and output? As a side note I would suggest when when you are working on an opensource project to prefer forking instead of re-uploading the project to github. There are numerous reasons you can google some or them but mainly it looks better in the eyes of the maintainer. |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using indice.Edi.Serialization;
namespace indice.Edi.Tests.Models
{
public class Edifact_SeatMap
{
public Message Msg { get; set; }
[EdiMessage]
public class Message
{
public CBD CabinDetails { get; set; }
public List<ROD> RowDetails { get; set; }
}
/// <summary>
/// Row Details
/// </summary>
[EdiSegment, EdiPath("ROD")]
public class ROD
{
[EdiValue(Path = "*/0")]
public string SeatRowNumber { get; set; }
[EdiPath("*/1")]
public ROD_RowCharacteristicsDetails RowCharacteristicsDetails { get; set; }
//public List<ROD_SeatOccupationDetails> SeatOccupationDetails { get; set; }
}
/// <summary>
/// C049
/// </summary>
[EdiElement]
public class ROD_RowCharacteristicsDetails
{
[EdiValue(Path = "*/1/0")]
public string RowCharacteristic { get; set; }
[EdiValue(Path = "*/1/1")]
public string RowCharacteristic1 { get; set; }
[EdiValue(Path = "*/1/2")]
public string RowCharacteristic2 { get; set; }
[EdiValue(Path = "*/1/3")]
public string RowCharacteristic3 { get; set; }
[EdiValue(Path = "*/1/4")]
public string RowCharacteristic4 { get; set; }
[EdiValue(Path = "*/1/5")]
public string RowCharacteristic5 { get; set; }
[EdiValue(Path = "*/1/6")]
public string RowCharacteristic6 { get; set; }
[EdiValue(Path = "*/1/7")]
public string RowCharacteristic7 { get; set; }
[EdiValue(Path = "*/1/8")]
public string RowCharacteristic8 { get; set; }
}
/// <summary>
/// C051
/// </summary>
[EdiElement]
public class ROD_SeatOccupationDetails
{
[EdiValue(Path = "*/*/0")]
public string SeatColumn { get; set; }
[EdiValue(Path = "*/*/1")]
public string SeatOccupation { get; set; }
[EdiValue(Path = "*/*/2")]
public string SeatCharacteristicCoded { get; set; }
[EdiValue(Path = "*/*/3")]
public string SeatCharacteristicCoded1 { get; set; }
[EdiValue(Path = "*/*/4")]
public string SeatCharacteristicCoded2 { get; set; }
[EdiValue(Path = "*/*/5")]
public string SeatCharacteristicCoded3 { get; set; }
[EdiValue(Path = "*/*/6")]
public string SeatCharacteristicCoded4 { get; set; }
[EdiValue(Path = "*/*/7")]
public string SeatCharacteristicCoded5 { get; set; }
[EdiValue(Path = "*/*/8")]
public string SeatCharacteristicCoded6 { get; set; }
//there are 30 more record
}
//CabinDetails
/// <summary>
/// Cabin Details
/// </summary>
[EdiSegment, EdiPath("CBD")]
public class CBD
{
[EdiPath("*/0")]
public CBD_CabinClassDesignation CabinClassDesignation { get; set; }
[EdiPath("*/1")]
public CBD_CabinClassSeatRowRangeDetails CabinClassSeatRowRangeDetails { get; set; }
[EdiValue(Path = "*/2")]
public string CabinClassLocation { get; set; }
[EdiPath("*/3")]
public CBD_SmokingAreaSeatRowRangeDetails SmokingAreaSeatRowRangeDetails { get; set; }
[EdiValue(Path = "*/4")]
public string SeatOccupationDefaultIndicator { get; set; }
[EdiPath("*/5")]
public CBD_OverwingSeatRowRange OverwingSeatRowRange { get; set; }
//public List<CBD_CabinWidthAndColumnDetails> CabinWidthAndColumnDetails { get; set; }
}
/// <summary>
/// C342
/// </summary>
[EdiElement]
public class CBD_CabinClassDesignation
{
[EdiValue(Path = "*/0/0")]
public string CabinClassDesignator { get; set; }
[EdiValue(Path = "*/0/1")]
public string CharacteristicIdentification { get; set; }
[EdiValue(Path = "*/0/2")]
public string CabinClassOfServiceCoded { get; set; }
[EdiValue(Path = "*/0/3")]
public string CabinCompartmentDesignator { get; set; }
}
/// <summary>
/// C052
/// </summary>
[EdiElement]
public class CBD_CabinClassSeatRowRangeDetails
{
[EdiValue(Path = "*/1/0")]
public string CabinClassDesignator { get; set; }
[EdiValue(Path = "*/1/1")]
public string CharacteristicIdentification { get; set; }
}
/// <summary>
/// C053
/// </summary>
[EdiElement]
public class CBD_SmokingAreaSeatRowRangeDetails
{
[EdiValue(Path = "*/3/0")]
public string SeatRowNumber { get; set; }
[EdiValue(Path = "*/3/1")]
public string SeatRowNumber1 { get; set; }
}
/// <summary>
/// C058
/// </summary>
[EdiElement]
public class CBD_OverwingSeatRowRange
{
[EdiValue(Path = "*/5/0")]
public string SeatRowNumber { get; set; }
[EdiValue(Path = "*/5/1")]
public string SeatRowNumber1 { get; set; }
}
/// <summary>
/// C054
/// </summary>
[EdiElement]
public class CBD_CabinWidthAndColumnDetails
{
[EdiValue(Path = "*/*/0")]
public string SeatColumn { get; set; }
[EdiValue(Path = "*/*/1")]
public string ColumnDescription { get; set; }
[EdiValue(Path = "*/*/2")]
public string ColumnDescription1 { get; set; }
}
}
} |
Thanks for the advice. My test file is SeatMapTest.cs. |
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using indice.Edi.Tests.Models;
using Xunit;
namespace indice.Edi.Tests
{
public class SeatMapTest
{
[Fact, Trait(Traits.Tag, "EDIFact"), Trait(Traits.Issue, "#999")]
public void EmptySegment_Withought_A_segmentname_separator_should_parse() {
var grammar = EdiGrammar.NewEdiFact();
var interchange = default(Edifact_SeatMap);
using (var stream = Helpers.GetResourceStream("edifact.Issue.SeatMap.edi")) {
interchange = new EdiSerializer().Deserialize<Edifact_SeatMap>(new StreamReader(stream), grammar);
}
Assert.NotNull(interchange);
}
}
} |
in a different project using model above i get incorrect deserialize edi UNA:+.? ' |
in my other project my model look like this public UNB Header { get; set; }
public SMPRES SeatMap { get; set; }
public UNZ Footer { get; set; }
[EdiMessage]
public class SMPRES
{
public UNH MessageHeader { get; set; }
public MSG MessageType { get; set; }
public List<TVL_SG> Legs { get; set; }
public UNT MessageFooter { get; set; }
}
[EdiSegmentGroup("TVL", "EQI", "CBD", "ROD_SG")]
public class TVL_SG : TVL
{
public EQI EquipmentInformation { get; set; }
public CBD CabinDetails { get; set; }
public List<ROD_SG> RowDetails { get; set; }
}
[EdiSegmentGroup("ROD")]
public class ROD_SG : ROD
{
} |
/// <summary>
/// MESSAGE TYPE IDENTIFICATION
/// </summary>
[EdiSegment, EdiPath("MSG")]
public class MSG
{
[EdiValue(Path = "*/0/0")]
public string BusinessFunctionCoded { get; set; }
[EdiValue(Path = "*/0/1")]
public string MessageFunctionCoded { get; set; }
[EdiValue(Path = "*/0/2")]
public string CodeListQualifier { get; set; }
[EdiValue(Path = "*/0/3")]
public string CodeListResponsibleAgencyCoded { get; set; }
[EdiValue(Path = "*/1/0")]
public string ResponseTypeCoded { get; set; }
}
/// <summary>
/// MESSAGE TYPE IDENTIFICATION
/// </summary>
[EdiSegment, EdiPath("UNB")]
public class UNB
{
#region Interchange Header
[EdiValue(Path = "*/0/0")]
public string SyntaxIdentifier { get; set; }
[EdiValue(Path = "*/0/1")]
public string SyntaxVersionNumber { get; set; }
[EdiValue(Path = "*/1/0")]
public string SenderIdentification { get; set; }
[EdiValue(Path = "*/1/1")]
public string SenderPartnerIdentificationCodeQualifier { get; set; }
[EdiValue(Path = "*/1/2")]
public string AddressForReverseRouting { get; set; }
[EdiValue(Path = "*/2/0")]
public string RecipientIdentification { get; set; }
[EdiValue(Path = "*/2/1")]
public string RecipientPartnerIdentificationCodeQualifier { get; set; }
[EdiValue(Path = "*/2/2")]
public string RoutingAddress { get; set; }
[EdiValue(Path = "*/3/0")]
public string DateOfPreparation { get; set; }
[EdiValue(Path = "*/3/1")]
public string TimeOfPreparation { get; set; }
[EdiValue(Path = "*/4")]
public string InterchangeControlReference { get; set; }
[EdiValue(Path = "*/7")]
public string ProcessingPriorityCode { get; set; }
#endregion Interchange Header
}
/// <summary>
/// MESSAGE TYPE IDENTIFICATION
/// </summary>
[EdiSegment, EdiPath("UNH")]
public class UNH
{
#region Message Header Info
[EdiValue(Path = "*/0")]
public string MessageReferenceNumber { get; set; }
[EdiValue(Path = "*/1/0")]
public string MessageType { get; set; }
[EdiValue(Path = "*/1/1")]
public string MessageTypeVersionNumber { get; set; }
[EdiValue(Path = "*/1/2")]
public string MessageTypeReleaseNumber { get; set; }
[EdiValue(Path = "*/1/3")]
public string ControllingAgency { get; set; }
[EdiValue(Path = "*/2/0")]
public string CommonAccessReference { get; set; }
#endregion Message Header Info
}
/// <summary>
/// departure date/time, origin, destination, operating airline code, flight
/// number, and operation suffix.
/// </summary>
[EdiSegment, EdiPath("TVL")]
public class TVL
{
[EdiValue("9(6)", Path = "*/0/0", Format = "ddMMyy", Description = "Date")]
public string FirstDate { get; set; }
[EdiValue("9(4)", Path = "*/0/1", Format = "HHmm", Description = "Time")]
public string FirstTime { get; set; }
private DateTime? _Arrival;
[EdiValue("9(6)", Path = "*/0/2", Format = "ddMMyy", Description = "Date")]
public string SecodnDate { get; set; }
[EdiValue("9(4)", Path = "*/0/3", Format = "HHmm", Description = "Time")]
public string SecondTime { get; set; }
[EdiValue("X(3)", Path = "*/1/0")]
public string OriginAirport { get; set; }
[EdiValue("X(3)", Path = "*/2/0")]
public string DestinationAirport { get; set; }
[EdiValue("X(3)", Path = "*/3/0")]
public string OperatingAirlineCode { get; set; }
[EdiValue("X(10)", Path = "*/4/0")]
public string FlightNumber { get; set; }
[EdiValue("X(1)", Path = "*/4/1")]
public string BookingCode { get; set; }
[EdiValue("X(1)", Path = "*/7/0")]
public string ProcessingIndicatorCoded { get; set; }
}
/// <summary>
/// C048
/// </summary>
[EdiElement]
public class EQI_ConfigurationDetails
{
[EdiValue(Path = "*/0/0")]
public string CabinClassDesignator { get; set; }
[EdiValue(Path = "*/0/1")]
public string Seats_NumberOfSeats { get; set; }
[EdiValue(Path = "*/0/2")]
public string CharacteristicIdentification { get; set; }
[EdiValue(Path = "*/0/3")]
public string CharacteristicIdentification1 { get; set; }
[EdiValue(Path = "*/0/4")]
public string CharacteristicIdentification2 { get; set; }
[EdiValue(Path = "*/0/5")]
public string CharacteristicIdentification3 { get; set; }
[EdiValue(Path = "*/0/6")]
public string CharacteristicIdentification4 { get; set; }
// There are 24 more CharacteristicIdentification
}
/// <summary>
/// Row Details
/// </summary>
[EdiSegment, EdiPath("ROD")]
public class ROD
{
[EdiValue(Path = "*/0")]
public string SeatRowNumber { get; set; }
[EdiPath("*/1")]
public ROD_RowCharacteristicsDetails RowCharacteristicsDetails { get; set; }
// public List<ROD_SeatOccupationDetails> SeatOccupationDetails { get; set; }
}
/// <summary>
/// C049
/// </summary>
[EdiElement]
public class ROD_RowCharacteristicsDetails
{
[EdiValue(Path = "*/1/0")]
public string RowCharacteristic { get; set; }
[EdiValue(Path = "*/1/1")]
public string RowCharacteristic1 { get; set; }
[EdiValue(Path = "*/1/2")]
public string RowCharacteristic2 { get; set; }
[EdiValue(Path = "*/1/3")]
public string RowCharacteristic3 { get; set; }
[EdiValue(Path = "*/1/4")]
public string RowCharacteristic4 { get; set; }
[EdiValue(Path = "*/1/5")]
public string RowCharacteristic5 { get; set; }
[EdiValue(Path = "*/1/6")]
public string RowCharacteristic6 { get; set; }
[EdiValue(Path = "*/1/7")]
public string RowCharacteristic7 { get; set; }
[EdiValue(Path = "*/1/8")]
public string RowCharacteristic8 { get; set; }
}
/// <summary>
/// C051
/// </summary>
[EdiElement]
public class ROD_SeatOccupationDetails
{
[EdiValue(Path = "*/*/0")]
public string SeatColumn { get; set; }
[EdiValue(Path = "*/*/1")]
public string SeatOccupation { get; set; }
[EdiValue(Path = "*/*/2")]
public string SeatCharacteristicCoded { get; set; }
[EdiValue(Path = "*/*/3")]
public string SeatCharacteristicCoded1 { get; set; }
[EdiValue(Path = "*/*/4")]
public string SeatCharacteristicCoded2 { get; set; }
[EdiValue(Path = "*/*/5")]
public string SeatCharacteristicCoded3 { get; set; }
[EdiValue(Path = "*/*/6")]
public string SeatCharacteristicCoded4 { get; set; }
[EdiValue(Path = "*/*/7")]
public string SeatCharacteristicCoded5 { get; set; }
[EdiValue(Path = "*/*/8")]
public string SeatCharacteristicCoded6 { get; set; }
//there are 30 more record
}
//CabinDetails
/// <summary>
/// Cabin Details
/// </summary>
[EdiSegment, EdiPath("CBD")]
public class CBD
{
[EdiPath("*/0")]
public CBD_CabinClassDesignation CabinClassDesignation { get; set; }
[EdiPath("*/1")]
public CBD_CabinClassSeatRowRangeDetails CabinClassSeatRowRangeDetails { get; set; }
[EdiValue(Path = "*/2")]
public string CabinClassLocation { get; set; }
[EdiPath("*/3")]
public CBD_SmokingAreaSeatRowRangeDetails SmokingAreaSeatRowRangeDetails { get; set; }
[EdiValue(Path = "*/4")]
public string SeatOccupationDefaultIndicator { get; set; }
[EdiPath("*/5")]
public CBD_OverwingSeatRowRange OverwingSeatRowRange { get; set; }
//public List<CBD_CabinWidthAndColumnDetails> CabinWidthAndColumnDetails { get; set; }
}
/// <summary>
/// C342
/// </summary>
[EdiElement]
public class CBD_CabinClassDesignation
{
[EdiValue(Path = "*/0/0")]
public string CabinClassDesignator { get; set; }
[EdiValue(Path = "*/0/1")]
public string CharacteristicIdentification { get; set; }
[EdiValue(Path = "*/0/2")]
public string CabinClassOfServiceCoded { get; set; }
[EdiValue(Path = "*/0/3")]
public string CabinCompartmentDesignator { get; set; }
}
/// <summary>
/// C052
/// </summary>
[EdiElement]
public class CBD_CabinClassSeatRowRangeDetails
{
[EdiValue(Path = "*/1/0")]
public string CabinClassDesignator { get; set; }
[EdiValue(Path = "*/1/1")]
public string CharacteristicIdentification { get; set; }
}
/// <summary>
/// C053
/// </summary>
[EdiElement]
public class CBD_SmokingAreaSeatRowRangeDetails
{
[EdiValue(Path = "*/3/0")]
public string SeatRowNumber { get; set; }
[EdiValue(Path = "*/3/1")]
public string SeatRowNumber1 { get; set; }
}
/// <summary>
/// C058
/// </summary>
[EdiElement]
public class CBD_OverwingSeatRowRange
{
[EdiValue(Path = "*/5/0")]
public string SeatRowNumber { get; set; }
[EdiValue(Path = "*/5/1")]
public string SeatRowNumber1 { get; set; }
}
/// <summary>
/// C054
/// </summary>
[EdiElement]
public class CBD_CabinWidthAndColumnDetails
{
[EdiValue(Path = "*/*/0")]
public string SeatColumn { get; set; }
[EdiValue(Path = "*/*/1")]
public string ColumnDescription { get; set; }
[EdiValue(Path = "*/*/2")]
public string ColumnDescription1 { get; set; }
}
[EdiSegment, EdiPath("UNT")]
public class UNT
{
// 0074 : NOMBRE DE SEGMENTS DANS LE MESSAGE
[EdiValue(Path = "*/0/0", Mandatory = true)]
public int NumberOfSegmentsInAMessage { get; set; }
// 0062 : NUMÉRO DE RÉFÉRENCE DU MESSAGE
[EdiValue("X(14)", Path = "*/1/0", Mandatory = true)]
public string MessageReferenceNumber { get; set; }
}
// Fin d'interchange
[EdiSegment, EdiPath("UNZ")]
public class UNZ
{
// 0036 : COMPTEUR DE CONTROLE DE L’INTERCHANGE
[EdiValue("X(1)", Path = "*/0/0", Mandatory = true)]
public int InterchangeControlCount { get; set; }
// 0020 : REFERENCE DE CONTROLE DE L’INTERCHANGE
[EdiValue("X(14)", Path = "*/1/0", Mandatory = true)]
public string InterchangeControlReference { get; set; }
} |
The schema for SMPRES
|
|
|
I have uploaded to my git the project i'm using for testing serialization and deserilization of message. https://github.com/dvddo/EDI.Net.
Issue is i can serialize it but deserialize does not return the same edi content. I have included SMPRES.xsd in the project to better understand issue.
David
The text was updated successfully, but these errors were encountered: