/// <summary> /// Fill historical data /// </summary> /// <param name="actualDataReadFromService"></param> /// <returns></returns> internal Data_Schema.DepartureWebDataTable DepartureAppendHistoryToActualReadData(Data_Schema.DepartureWebDataTable actualDataReadFromService) { Data_Schema.DepartureWebDataTable departureHistoryDataFromFile; lock (departureLock) { departureHistoryDataFromFile = DepartureReadHistoryFromFile(false); if (departureHistoryDataFromFile == null) { departureHistoryDataFromFile = new Data_Schema.DepartureWebDataTable(); } DateTime minimalDateForRemember = DateTime.Now.AddHours(-_history); List <long> ListOfFlightID = actualDataReadFromService.AsEnumerable().Select(Selrow => Selrow.Field <long>("FLIGHTID")).ToList(); if (ListOfFlightID == null) { ListOfFlightID = new List <long>(); } Data_Schema.DepartureWebRow rowForShowOnWeb; for (int i = departureHistoryDataFromFile.Rows.Count; i > 0; i--) { rowForShowOnWeb = departureHistoryDataFromFile.Rows[i - 1] as Data_Schema.DepartureWebRow; if (rowForShowOnWeb != null) { if (ListOfFlightID.Contains(rowForShowOnWeb.FLIGHTID)) { departureHistoryDataFromFile.Rows.RemoveAt(i - 1); } else if (rowForShowOnWeb.TIME_LT < minimalDateForRemember) { departureHistoryDataFromFile.Rows.RemoveAt(i - 1); } } } foreach (Data_Schema.DepartureWebRow rowActualReadFromService in actualDataReadFromService.Rows) { rowForShowOnWeb = departureHistoryDataFromFile.NewDepartureWebRow(); rowForShowOnWeb.FLIGHTID = rowActualReadFromService.FLIGHTID; rowForShowOnWeb.TIME_LT = rowActualReadFromService.TIME_LT; rowForShowOnWeb.ICAO_AIR = rowActualReadFromService.ICAO_AIR; rowForShowOnWeb.IATAICAO = rowActualReadFromService.IATAICAO; rowForShowOnWeb.FLGTNUM = rowActualReadFromService.FLGTNUM; rowForShowOnWeb.S1 = rowActualReadFromService.S1; rowForShowOnWeb.S1CIT = rowActualReadFromService.S1CIT; rowForShowOnWeb.PARID = rowActualReadFromService.PARID; if (!rowActualReadFromService.IsAIRCRFTNull()) { rowForShowOnWeb.AIRCRFT = rowActualReadFromService.AIRCRFT; } if (!rowActualReadFromService.IsHALNull()) { rowForShowOnWeb.HAL = rowActualReadFromService.HAL; } if (!rowActualReadFromService.IsHDGNull()) { rowForShowOnWeb.HDG = rowActualReadFromService.HDG; } if (!rowActualReadFromService.IsORDERNull()) { rowForShowOnWeb.ORDER = rowActualReadFromService.ORDER; } if (!rowActualReadFromService.IsREMARKNull()) { rowForShowOnWeb.REMARK = rowActualReadFromService.REMARK; } if (!rowActualReadFromService.IsS2CITNull()) { rowForShowOnWeb.S2CIT = rowActualReadFromService.S2CIT; } if (!rowActualReadFromService.IsS2Null()) { rowForShowOnWeb.S2 = rowActualReadFromService.S2; } if (!rowActualReadFromService.IsATD_LTNull()) { rowForShowOnWeb.ATD_LT = rowActualReadFromService.ATD_LT; } if (!rowActualReadFromService.IsGATE1Null()) { rowForShowOnWeb.GATE1 = rowActualReadFromService.GATE1; } if (!rowActualReadFromService.IsGATE2Null()) { rowForShowOnWeb.GATE2 = rowActualReadFromService.GATE2; } if (!rowActualReadFromService.IsCHIN_FNull()) { rowForShowOnWeb.CHIN_F = rowActualReadFromService.CHIN_F; } if (!rowActualReadFromService.IsCHIN_LNull()) { rowForShowOnWeb.CHIN_L = rowActualReadFromService.CHIN_L; } departureHistoryDataFromFile.AddDepartureWebRow(rowForShowOnWeb); } string fileName = Utils.CreatePhysicalFileName(Constants.FileName.DepartureShow); Utils.DataTableWriteToFile(fileName, departureHistoryDataFromFile); } return(departureHistoryDataFromFile); }
/// <summary> /// Append history data and new data /// </summary> /// <param name="actualDataReadFromService">actual read data from service</param> /// <returns></returns> internal Data_Schema.ArriveWebDataTable ArriveAppendHistoryToActualReadData(Data_Schema.ArriveWebDataTable actualDataReadFromService) { Data_Schema.ArriveWebDataTable ArriveHistoryDataFromFile; lock (arriveLock) { ArriveHistoryDataFromFile = ArriveReadHistoryFromFile(false); if (ArriveHistoryDataFromFile == null) { ArriveHistoryDataFromFile = new Data_Schema.ArriveWebDataTable(); } /// delete olders then Hist time stamp DateTime minimalDateForRemember = DateTime.Now.AddHours(-_history); List <long> ListOfFlightID = actualDataReadFromService.AsEnumerable().Select(Selrow => Selrow.Field <long>("FLIGHTID")).ToList(); if (ListOfFlightID == null) { ListOfFlightID = new List <long>(); } Data_Schema.ArriveWebRow rowForShowOnWeb; for (int i = ArriveHistoryDataFromFile.Rows.Count; i > 0; i--) { rowForShowOnWeb = ArriveHistoryDataFromFile.Rows[i - 1] as Data_Schema.ArriveWebRow; if (rowForShowOnWeb != null) { if (ListOfFlightID.Contains(rowForShowOnWeb.FLIGHTID)) { ArriveHistoryDataFromFile.Rows.RemoveAt(i - 1); } else if (rowForShowOnWeb.TIME_LT < minimalDateForRemember) { ArriveHistoryDataFromFile.Rows.RemoveAt(i - 1); } } } foreach (Data_Schema.ArriveWebRow rowActualReadFromService in actualDataReadFromService.Rows) { rowForShowOnWeb = ArriveHistoryDataFromFile.NewArriveWebRow(); rowForShowOnWeb.FLIGHTID = rowActualReadFromService.FLIGHTID; rowForShowOnWeb.TIME_LT = rowActualReadFromService.TIME_LT; rowForShowOnWeb.ICAO_AIR = rowActualReadFromService.ICAO_AIR; rowForShowOnWeb.IATAICAO = rowActualReadFromService.IATAICAO; rowForShowOnWeb.PARID = rowActualReadFromService.PARID; rowForShowOnWeb.FLGTNUM = rowActualReadFromService.FLGTNUM; rowForShowOnWeb.S1 = rowActualReadFromService.S1; rowForShowOnWeb.S1CIT = rowActualReadFromService.S1CIT; if (!rowActualReadFromService.IsAIRCRFTNull()) { rowForShowOnWeb.AIRCRFT = rowActualReadFromService.AIRCRFT; } if (!rowActualReadFromService.IsATA_LTNull()) { rowForShowOnWeb.ATA_LT = rowActualReadFromService.ATA_LT; } if (!rowActualReadFromService.IsETA_LTNull()) { rowForShowOnWeb.ETA_LT = rowActualReadFromService.ETA_LT; } if (!rowActualReadFromService.IsHALNull()) { rowForShowOnWeb.HAL = rowActualReadFromService.HAL; } if (!rowActualReadFromService.IsHDGNull()) { rowForShowOnWeb.HDG = rowActualReadFromService.HDG; } if (!rowActualReadFromService.IsORDERNull()) { rowForShowOnWeb.ORDER = rowActualReadFromService.ORDER; } if (!rowActualReadFromService.IsREMARKNull()) { rowForShowOnWeb.REMARK = rowActualReadFromService.REMARK; } if (!rowActualReadFromService.IsS2CITNull()) { rowForShowOnWeb.S2CIT = rowActualReadFromService.S2CIT; } if (!rowActualReadFromService.IsS2Null()) { rowForShowOnWeb.S2 = rowActualReadFromService.S2; } if (!rowActualReadFromService.IsSTANDNull()) { rowForShowOnWeb.STAND = rowActualReadFromService.STAND; } ArriveHistoryDataFromFile.AddArriveWebRow(rowForShowOnWeb); } string fileName = Utils.CreatePhysicalFileName(Constants.FileName.ArriveShow); Utils.DataTableWriteToFile(fileName, ArriveHistoryDataFromFile); } return(ArriveHistoryDataFromFile); }