public List<LDM> FillListBoxLDM(string Occupation) { List<LDM> messageList = new List<LDM>(); string line; Boolean Blok; Blok = false; int FirstLastLine = 0; string aPartLine = ""; string[] split; string FlightIdentifierV = ""; int DayOfMonthV = 0; string AircraftRegistrationV = ""; string VersionOfAircraftV = ""; string NumberOfCrewV = ""; string FlightKind = ""; string Destination = ""; try { //MessageRCV-нің соңына дейін бару while (readerLDM.Peek() >= 0) { if (readerLDM.ReadLine() == Occupation) { while (readerLDM.Peek() >= 0) { if (readerLDM.ReadLine().Length == 0) { break; } } break; } } while ((line = readerLDM.ReadLine()) != null) { if (line == "LDM") { Blok = true; FlightIdentifierV = ""; FirstLastLine = 1; } else if (line.Length == 0) { Blok = false; } else if (Blok) { if (line.IndexOf("/") != -1 && !line.StartsWith("-TSE") && FirstLastLine == 1 && getSpecifiedIndexOf(line, '.', getSpecifiedIndexOf(line, '.', line.IndexOf(".") + 1)) != 0) { int dot2 = getSpecifiedIndexOf(line, '.', line.IndexOf(".") + 1); int dot3 = getSpecifiedIndexOf(line, '.', dot2); int dot4 = getSpecifiedIndexOf(line, '.', dot3); FlightIdentifierV = line.Substring(0, line.IndexOf("/")); DayOfMonthV = Convert.ToInt32(line.Substring(line.IndexOf("/") + 1, 2)); // B2775/08.EW399PO.MSQ AircraftRegistrationV = line.Substring(line.IndexOf(".") + 1, dot2 - line.IndexOf(".") - 1); VersionOfAircraftV = line.Substring(dot2 + 1, dot3 - dot2 - 1); NumberOfCrewV = line.Substring(dot3 + 1, line.Length - dot3 - 1); FirstLastLine = 2; } else if (line.StartsWith("-TSE") && line.IndexOf("/") != -1 && FirstLastLine == 2) { aPartLine = line; FirstLastLine = 3; FlightKind = "Arrival"; Destination = "TSE"; } else if (!line.StartsWith("-TSE") && line.IndexOf("/") != -1 && FirstLastLine == 2) //Ұшуға дайындалу бірақ қазір сөндірулі { //Әзірге LDM барлық авакомпания жібермейінше 2 - 20 деп қойылд aPartLine = line; FirstLastLine = 3; FlightKind = "Departure"; Destination = line.Substring(1,3); } else if (line.StartsWith(".") && line.IndexOf("/") != -1 && FirstLastLine == 3) { aPartLine = aPartLine + line; FirstLastLine = 4; } else if (FirstLastLine <= 4 && line.Contains(Destination) && line.Contains(" FRE ") && line.Contains(" BAG ")) //fOR KC TK EY { // replace "TSE" to Destination LDM messageLDM = new LDM(); messageLDM.MessageIdentifier = FlightKind; messageLDM.Registration = AircraftRegistrationV; messageLDM.NumberOfCrew = NumberOfCrewV; messageLDM.FlightIdentifier = FlightIdentifierV; messageLDM.DayOfOperation = DayOfMonthV; //messageLDM.MessageIdentifier = aPartLine; Blok = false; FirstLastLine = 0; split = aPartLine.Split('.'); mYfUNV(split, messageLDM); split = line.Split(' '); mYfUNVBag(split, messageLDM); messageList.Add(messageLDM); } else if (FirstLastLine <= 4 && line.Contains(Destination) && line.Contains(" C ") && line.Contains(" M ") && line.Contains(" B ")) //fOR b2 fz fv su { LDM messageLDM = new LDM(); messageLDM.MessageIdentifier = FlightKind; messageLDM.Registration = AircraftRegistrationV; messageLDM.NumberOfCrew = NumberOfCrewV; messageLDM.FlightIdentifier = FlightIdentifierV; messageLDM.DayOfOperation = DayOfMonthV; //messageLDM.MessageIdentifier = aPartLine; Blok = false; FirstLastLine = 0; split = aPartLine.Split('.'); mYfUNV(split, messageLDM); split = line.Split(' '); mYfUNVBag2(split, messageLDM); messageList.Add(messageLDM); } else if (FirstLastLine <= 4 && line.StartsWith(Destination +".B") && line.Contains(".C") && line.Contains(".M")) //fOR OS { LDM messageLDM = new LDM(); messageLDM.MessageIdentifier = FlightKind; messageLDM.Registration = AircraftRegistrationV; messageLDM.NumberOfCrew = NumberOfCrewV; messageLDM.FlightIdentifier = FlightIdentifierV; messageLDM.DayOfOperation = DayOfMonthV; //messageLDM.MessageIdentifier = aPartLine; Blok = false; FirstLastLine = 0; split = aPartLine.Split('.'); mYfUNV(split, messageLDM); split = line.Split('.'); mYfUNVBag3(split, messageLDM); messageList.Add(messageLDM); } else if (FirstLastLine <= 4 && line.Contains(Destination) && line.Contains(" B/") && line.Contains("C/") && line.Contains("M/")) //fOR G9 { LDM messageLDM = new LDM(); messageLDM.MessageIdentifier = FlightKind; messageLDM.Registration = AircraftRegistrationV; messageLDM.NumberOfCrew = NumberOfCrewV; messageLDM.FlightIdentifier = FlightIdentifierV; messageLDM.DayOfOperation = DayOfMonthV; //messageLDM.MessageIdentifier = aPartLine; Blok = false; FirstLastLine = 0; split = aPartLine.Split('.'); mYfUNV(split, messageLDM); split = line.Split(' '); mYfUNVBag4(split, messageLDM); messageList.Add(messageLDM); } // if (messageLDM.DestinationAirport != null) //{ // messageList.Add(messageLDM); // } } else if (line.StartsWith("Message RCV")) { SaveOccupation(line,"LDM"); } } return messageList; } catch (Exception) { throw; } finally { if (readerLDM != null) { // readerLDM.Close(); // readerLDM.Dispose(); } } }
private void mYfUNVBag4(string[] split, LDM ldmE) { foreach (string s in split) { if (s.Trim() != "") { if (s.StartsWith("B") && s.IndexOf("/") != -1) { string[] split2 = s.Split('.'); foreach (string s1 in split2) { if (s1.Trim() != "") { if (s1.StartsWith("B/") && !s1.EndsWith("NIL")) { ldmE.Baggage = Convert.ToInt32(s1.Substring(2, s1.Length - 2)); } if (s1.StartsWith("C/") && !s1.EndsWith("NIL")) { ldmE.Freight = Convert.ToInt32(s1.Substring(2, s1.Length - 2)); } if (s1.StartsWith("M/") && !s1.EndsWith("NIL")) { ldmE.Mail = Convert.ToInt32(s1.Substring(2, s1.Length - 2)); } } } } } } }
private void mYfUNVBag2(string[] split, LDM messageLDM) { string msgType = ""; int bir = 0; foreach (string s in split) { if (s.Trim() != "") { if (messageLDM.Baggage == 0 && bir == 5 && s.IndexOf('/') == -1) { messageLDM.Baggage = Convert.ToInt32(s); bir = 6; } if (msgType == "POS" && bir == 4) { msgType = "BAG"; bir = 5; } if (messageLDM.Mail == 0 && bir == 3) { messageLDM.Mail = Convert.ToInt32(s); bir = 4; } if (msgType == "FRE" && bir == 2) { msgType = "POS"; bir = 3; } if (messageLDM.Freight == 0 && bir == 1) { messageLDM.Freight = Convert.ToInt32(s); bir = 2; } if (messageLDM.Freight == 0 && bir == 0 && s.StartsWith("C")) { msgType = "FRE"; bir = 1; } Console.WriteLine(s); } } }
private void mYfUNVBag3(string[] split, LDM ldmE) { int bir = 0; foreach (string s in split) { if (s.Trim() != "") { if (ldmE.Mail == 0 && bir == 3 && s.StartsWith("M")) { ldmE.Mail = Convert.ToInt32(s.Substring(1, s.Length - 1)); bir = 4; } if (ldmE.Freight == 0 && bir == 1 && s.StartsWith("C")) { ldmE.Freight = Convert.ToInt32(s.Substring(1, s.Length - 1)); bir = 3; } if (ldmE.Baggage == 0 && bir == 0 && s.StartsWith("B")) { ldmE.Baggage = Convert.ToInt32(s.Substring(1, s.Length - 1)); bir = 1; } } } }
private void mYfUNV(string[] split, LDM messageLDM) { int bir = 0; foreach (string s in split) { if (s.Trim() != "") { if (bir == 6) { messageLDM.RemarksForDest = messageLDM.RemarksForDest + " " + s; } //if (bir == 5 && s.StartsWith("PAX")) if (messageLDM.LoadInCompartments != null && bir == 5 && s.StartsWith("PA")) { messageLDM.PassengersInEachClass = s; } if (bir == 5 && s.StartsWith("PAD")) { messageLDM.PadPassengersInEachClass = s; bir = 6; } if (messageLDM.LoadInCompartments != null && bir == 5 && !s.StartsWith("PA")) { messageLDM.LoadInCompartments = messageLDM.LoadInCompartments + " " + s; bir = 5; } if (messageLDM.LoadInCompartments == null && bir == 4) { messageLDM.LoadInCompartments = s; bir = 5; } if (messageLDM.TotalDeadload == null && bir <= 3 && s.StartsWith("T")) { messageLDM.TotalDeadload = s; bir = 4; } if (messageLDM.CabinBaggageWeight == 0 && bir == 2 && !s.StartsWith("T")) { messageLDM.CabinBaggageWeight = Convert.ToInt32(s); bir = 3; } if (messageLDM.PassengerNumbers == null && bir == 1) { messageLDM.PassengerNumbers = s; bir = 2; } if (messageLDM.DestinationAirport == null) { messageLDM.DestinationAirport = s.Substring(1,3); bir = 1; } // Console.WriteLine(s); } } }