/// <summary> /// Headers the record found. /// </summary> /// <param name="currentLineNumber">The current line number.</param> /// <param name="textFields">The text fields.</param> /// <param name="lineText">The line text.</param> void HeaderRecordFound(ref int currentLineNumber, TextFieldCollection textFields, string lineText) { // A matching header has been found, we need to create an instance of the opco shipment opcoShipment = new OpCoShipment(); // Fill the opco shipment using the parsed header TextFieldParser.FillObject(opcoShipment, textFields); int Hrs, Mins; string[] HHMMSS; // We need manual conversion here for CheckInTimeHHMMSS as passed on interface in some ridiculous format HHMMSS = textFields["CheckInTimeHHMMSS"].Value.ToString().Split(':'); Hrs = Convert.ToInt32(HHMMSS[0]); Mins = Convert.ToInt32(HHMMSS[1]); opcoShipment.CheckInTime = (Hrs * 60) + Mins; // We need manual conversion here for the current time, we need to add it to the generated date HHMMSS = textFields["GeneratedTimeHHMMSS"].Value.ToString().Split(':'); opcoShipment.GeneratedDateTime = opcoShipment.GeneratedDateTime.AddHours(Convert.ToInt32(HHMMSS[0])); opcoShipment.GeneratedDateTime = opcoShipment.GeneratedDateTime.AddMinutes(Convert.ToInt32(HHMMSS[1])); opcoShipment.GeneratedDateTime = opcoShipment.GeneratedDateTime.AddSeconds(Convert.ToInt32(HHMMSS[2])); // Unwire event handlers for header shipmentParser.RecordFailed -= new TextFieldParser.RecordFailedHandler(HeaderRecordFailed); shipmentParser.RecordFound -= new TextFieldParser.RecordFoundHandler(HeaderRecordFound); // Wire up event handlers for line shipmentParser.RecordFailed += new TextFieldParser.RecordFailedHandler(LineRecordFailed); shipmentParser.RecordFound += new TextFieldParser.RecordFoundHandler(LineRecordFound); // Seed fields for line OpCoShipmentLine.SetParserSchema(shipmentParser.TextFields); }
/// <summary> /// Lines the record found. /// </summary> /// <param name="currentLineNumber">The current line number.</param> /// <param name="textFields">The text fields.</param> /// <param name="lineText">The line text.</param> void LineRecordFound(ref int currentLineNumber, TextFieldCollection textFields, string lineText) { // A matching line has been found, we need to create an instance of the shipment line OpCoShipmentLine opcoShipmentLine = new OpCoShipmentLine(); // Fill the opcoshipment using the parsed header TextFieldParser.FillObject(opcoShipmentLine, textFields); // Add the line to the shipment opcoShipment.ShipmentLines.Add(opcoShipmentLine); }