public IEnumerable <BillettServiceSete> ReadSeats(XDocument xdoc)
        {
            if (xdoc == null)
            {
                yield break;
            }

            var sectionsElement = FindSectionsElement(xdoc);

            if (sectionsElement == null)
            {
                yield break;
            }

            foreach (var xElement in sectionsElement.Elements("E"))
            {
                var sectionId   = xElement.GetValueOrDefault("Section_id", String.Empty);
                var sectionName = xElement.GetValueOrDefault("Section_name", String.Empty);
                var sectionTag  = xElement.GetValueOrDefault("Section_tag", String.Empty);

                var rowName           = GetRowName(xElement);
                var expectedSeatCount = xElement.GetValueOrDefault("Seat_count", 0);

                var seatNames = ExtractSeatNames(xElement);
                if (seatNames.Count != expectedSeatCount)
                {
                    Console.WriteLine("Rotten element? {0}/{1}/{2}", sectionId, sectionName, sectionTag);
                }

                var esdEntries = ExtractEsds(xElement);
                if (esdEntries.Select(e => e.Item2).Sum() != expectedSeatCount)
                {
                    Console.WriteLine("Rotten element? {0}/{1}/{2}", sectionId, sectionName, sectionTag);
                }

                var currentEttEntry = 0;
                var currentEttCode  = esdEntries[currentEttEntry].Item1;
                var countLeft       = esdEntries[currentEttEntry].Item2;

                for (var i = 0; i < expectedSeatCount; i++)
                {
                    var sete = new BillettServiceSete
                    {
                        SectionId   = sectionId,
                        SectionName = sectionName,
                        SectionTag  = sectionTag,
                        RowName     = rowName,
                        SeatName    = seatNames[i],
                        EttCode     = currentEttCode
                    };
                    yield return(sete);

                    if (--countLeft == 0 && i < expectedSeatCount - 1)
                    {
                        currentEttCode = esdEntries[++currentEttEntry].Item1;
                        countLeft      = esdEntries[currentEttEntry].Item2;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public SeatChange(BillettServiceSete seatA, BillettServiceSete seatB)
 {
     SeatA = seatA;
     SeatB = seatB;
 }