/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddAircraftToDataset(MaintenanceDirectivesDataSetLatAvia destinationDataSet) { if (_reportedAircraft == null) { return; } reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft); var apu = GlobalObjects.ComponentCore.GetAicraftBaseComponents(_reportedAircraft.ItemId) .FirstOrDefault(i => i.BaseComponentType == BaseComponentType.Apu); var reportApuLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(apu); var manufactureDate = _reportedAircraft.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var serialNumber = _reportedAircraft.SerialNumber; var model = _reportedAircraft.Model.FullName; var sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; var registrationNumber = _reportedAircraft.RegistrationNumber; int averageUtilizationHours; int averageUtilizationCycles; string averageUtilizationType; if (_forecast == null) { var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(_reportedAircraft.AircraftFrameId); var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); averageUtilizationHours = (int)averageUtilization.Hours; averageUtilizationCycles = (int)averageUtilization.Cycles; averageUtilizationType = averageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } else { averageUtilizationHours = (int)_forecast.ForecastDatas[0].AverageUtilization.Hours; averageUtilizationCycles = (int)_forecast.ForecastDatas[0].AverageUtilization.Cycles; averageUtilizationType = _forecast.ForecastDatas[0].AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } string lineNumber = _reportedAircraft.LineNumber; string variableNumber = _reportedAircraft.VariableNumber; destinationDataSet.AircraftDataTable.AddAircraftDataTableRow(serialNumber, manufactureDate, reportAircraftLifeLenght.ToHoursMinutesFormat(""), sinceNewCycles, registrationNumber, model, lineNumber, variableNumber, averageUtilizationHours, averageUtilizationCycles, averageUtilizationType, reportApuLifeLenght.Hours.ToString(), reportApuLifeLenght.Cycles.ToString()); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddAircraftToDataset(DirectivesListDataSet destinationDataSet) { if (_reportedAircraft == null) { return; } Lifelength reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft); string manufactureDate = _reportedAircraft.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); string serialNumber = _reportedAircraft.SerialNumber; string model = _reportedAircraft.Model.ShortName; int sinceNewHours = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0; int sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; string registrationNumber = _reportedAircraft.RegistrationNumber; int averageUtilizationHours; int averageUtilizationCycles; string averageUtilizationType; if (_forecast == null) { var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(_reportedAircraft.AircraftFrameId); var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); averageUtilizationHours = (int)averageUtilization.Hours; averageUtilizationCycles = (int)averageUtilization.Cycles; averageUtilizationType = averageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } else { averageUtilizationHours = (int)_forecast.ForecastDatas[0].AverageUtilization.Hours; averageUtilizationCycles = (int)_forecast.ForecastDatas[0].AverageUtilization.Cycles; averageUtilizationType = _forecast.ForecastDatas[0].AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } string lineNumber = _reportedAircraft.LineNumber; string variableNumber = _reportedAircraft.VariableNumber; destinationDataSet.AircraftDataTable.AddAircraftDataTableRow(serialNumber, manufactureDate, reportAircraftLifeLenght.ToHoursMinutesFormat(""), reportAircraftLifeLenght.Cycles != null && reportAircraftLifeLenght.Cycles != 0 ? reportAircraftLifeLenght.Cycles.ToString() : "", registrationNumber, model, lineNumber, variableNumber, averageUtilizationHours, averageUtilizationCycles, averageUtilizationType); }
private void DataGridViewItemsCellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } #region //Проверка колонки "Выполнено" if (e.ColumnIndex == ColumnClosed.Index) { checkBoxSelectAll.CheckedChanged -= CheckBoxSelectAllCheckedChanged; IEnumerable <WorkPackageClosingDataGridViewRow> rows = dataGridViewItems.Rows.OfType <WorkPackageClosingDataGridViewRow>(); bool checkedValue = rows.FirstOrDefault(r => (bool)r.Cells[ColumnClosed.Index].Value) != null; bool unCheckedValue = rows.FirstOrDefault(r => !(bool)r.Cells[ColumnClosed.Index].Value) != null; if (checkedValue && unCheckedValue) { checkBoxSelectAll.CheckState = CheckState.Indeterminate; } else if (checkedValue) { checkBoxSelectAll.CheckState = CheckState.Checked; } else { checkBoxSelectAll.CheckState = CheckState.Unchecked; } checkBoxSelectAll.CheckedChanged += CheckBoxSelectAllCheckedChanged; } #endregion #region //Проверка колонки "Часы" if (e.ColumnIndex == ColumnHours.Index) { WorkPackageClosingDataGridViewRow row = dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow; if (row == null || row.ClosingItem is Component) { return; } DataGridViewCell cell = dataGridViewItems[e.ColumnIndex, e.RowIndex]; string value = cell.Value as string; if (value == null) { return; } if (Lifelength.ValidateHours(value)) { int?totalMinutes = Lifelength.ParseTotalMinutes(value); if (totalMinutes == null) { return; } if (row.MinPerfSource != null && row.MinPerfSource.TotalMinutes != null && row.MinPerfSource.TotalMinutes > totalMinutes) { cell.Style.BackColor = Color.Red; } else { cell.Style.BackColor = Color.White; } } else { cell.Style.BackColor = Color.Red; } } #endregion #region //Проверка колонки "Циклы" if (e.ColumnIndex == ColumnCycles.Index) { WorkPackageClosingDataGridViewRow row = dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow; if (row == null || row.ClosingItem is Component) { return; } DataGridViewCell cell = dataGridViewItems[e.ColumnIndex, e.RowIndex]; string value = cell.Value as string; if (value == null) { return; } if (Lifelength.ValidateCyclesOrDays(value)) { int?cycles = Lifelength.ParseCyclesOrDays(value); if (cycles == null) { return; } if (row.MinPerfSource != null && row.MinPerfSource.Cycles != null && row.MinPerfSource.Cycles > cycles) { cell.Style.BackColor = Color.Red; } else { cell.Style.BackColor = Color.White; } } else { cell.Style.BackColor = Color.Red; } } #endregion #region //Проверка колонки "Дни" if (e.ColumnIndex == ColumnDays.Index) { WorkPackageClosingDataGridViewRow row = dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow; if (row == null || row.ClosingItem is Component) { return; } DataGridViewCell cell = dataGridViewItems[e.ColumnIndex, e.RowIndex]; string value = cell.Value as string; if (value == null) { return; } if (Lifelength.ValidateCyclesOrDays(value)) { int?cycles = Lifelength.ParseCyclesOrDays(value); if (cycles == null) { return; } if (row.MinPerfSource != null && row.MinPerfSource.Days != null && row.MinPerfSource.Days > cycles) { cell.Style.BackColor = Color.Red; } else { cell.Style.BackColor = Color.White; } } else { cell.Style.BackColor = Color.Red; } } #endregion #region //Проверка колонки "Дата" if (e.ColumnIndex == ColumnDate.Index) { WorkPackageClosingDataGridViewRow row = dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow; if (row != null && !(row.ClosingItem is Component)) { DateTime dateTime = Convert.ToDateTime(row.Cells[ColumnDate.Index].Value); if (row.PrevPerfDate != null && dateTime < row.PrevPerfDate) { row.Cells[ColumnDate.Index].Value = row.PrevPerfDate.Value; } else if (dateTime < new DateTime(1950, 1, 1)) { row.Cells[ColumnDate.Index].Value = DateTimeExtend.GetCASMinDateTime(); } if (row.NextPerfDate != null && dateTime > row.NextPerfDate) { row.Cells[ColumnDate.Index].Value = row.NextPerfDate.Value; } else if (dateTime > DateTime.Now) { row.Cells[ColumnDate.Index].Value = DateTime.Now; } if (row.ClosingItem.LifeLengthParent is Operator) { row.Cells[ColumnHours.Index].Value = "n/a"; row.Cells[ColumnCycles.Index].Value = "n/a"; row.Cells[ColumnDays.Index].Value = "n/a"; } else { Lifelength performanceSource = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(row.ClosingItem.LifeLengthParent, dateTime); row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null?performanceSource.ToHoursMinutesFormat("") : "n/a"; row.Cells[ColumnCycles.Index].Value = performanceSource.Cycles != null?performanceSource.Cycles.ToString() : "n/a"; row.Cells[ColumnDays.Index].Value = performanceSource.Days != null?performanceSource.Days.ToString() : "n/a"; } } } #endregion }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddBaseDetailToDataset(DirectivesListDataSet destinationDataSet) { if (_reportedComponent == null) { return; } BaseComponent baseComponent = null; Aircraft parentAircaft; DateTime installationDate; string position; Lifelength reportAircraftLifeLenght; parentAircaft = GlobalObjects.AircraftsCore.GetAircraftById(_reportedComponent.ParentAircraftId); var lastTransferRecord = _reportedComponent.TransferRecords.GetLast(); installationDate = lastTransferRecord.TransferDate; position = lastTransferRecord.Position; if (_reportedComponent.IsBaseComponent) { baseComponent = GlobalObjects.ComponentCore.GetBaseComponentById(_reportedComponent.ItemId); reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(baseComponent); } else { reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedComponent); } var manufactureDate = _reportedComponent.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var deliveryDate = _reportedComponent.DeliveryDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var status = _reportedComponent.ComponentStatus; var sinceNewHours = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0; var sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; var sinceNewDays = reportAircraftLifeLenght.Days != null?reportAircraftLifeLenght.Days.ToString() : ""; var lifeLimit = _reportedComponent.LifeLimit; var lifeLimitHours = lifeLimit.Hours != null && lifeLimit.Hours != 0 ? lifeLimit.Hours.ToString() : ""; var lifeLimitCycles = lifeLimit.Cycles != null && lifeLimit.Cycles != 0 ? lifeLimit.Cycles.ToString() : ""; var lifeLimitDays = lifeLimit.Days != null && lifeLimit.Days != 0 ? lifeLimit.Days.ToString() : ""; var remain = Lifelength.Null; if (!lifeLimit.IsNullOrZero()) { remain.Add(lifeLimit); remain.Substract(reportAircraftLifeLenght); remain.Resemble(lifeLimit); } var remainHours = remain.Hours != null && remain.Hours != 0 ? remain.Hours.ToString() : ""; var remainCycles = remain.Cycles != null && remain.Cycles != 0 ? remain.Cycles.ToString() : ""; var remainDays = remain.Days != null && remain.Days != 0 ? remain.Days.ToString() : ""; var onInstall = baseComponent?.ActualStateRecords.GetLastKnownRecord(lastTransferRecord.RecordDate)?.OnLifelength ?? Lifelength.Null;; var onInstallDate = installationDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var onInstallHours = onInstall.Hours != null && onInstall.Hours != 0 ? onInstall.Hours.ToString() : ""; var onInstallCycles = onInstall.Cycles != null && onInstall.Cycles != 0 ? onInstall.Cycles.ToString() : ""; var onInstallDays = onInstall.Days != null && onInstall.Days != 0 ? onInstall.Days.ToString() : ""; var sinceInstall = new Lifelength(reportAircraftLifeLenght); sinceInstall.Substract(onInstall); var sinceInstallHours = sinceInstall.Hours != null && sinceInstall.Hours != 0 ? sinceInstall.Hours.ToString() : ""; var sinceInstallCycles = sinceInstall.Cycles != null && sinceInstall.Cycles != 0 ? sinceInstall.Cycles.ToString() : ""; var sinceInstallDays = sinceInstall.Days != null && sinceInstall.Days != 0 ? sinceInstall.Days.ToString() : ""; var warranty = _reportedComponent.Warranty; var warrantyRemain = new Lifelength(warranty); warrantyRemain.Substract(reportAircraftLifeLenght); warrantyRemain.Resemble(warranty); var warrantyHours = warranty.Hours != null && warranty.Hours != 0 ? warranty.Hours.ToString() : ""; var warrantyCycles = warranty.Cycles != null && warranty.Cycles != 0 ? warranty.Cycles.ToString() : ""; var warrantyDays = warranty.Days != null && warranty.Days != 0 ? warranty.Days.ToString() : ""; var warrantyRemainHours = warrantyRemain.Hours != null && warrantyRemain.Hours != 0 ? warrantyRemain.Hours.ToString() : ""; var warrantyRemainCycles = warrantyRemain.Cycles != null && warrantyRemain.Cycles != 0 ? warrantyRemain.Cycles.ToString() : ""; var warrantyRemainDays = warrantyRemain.Days != null && warrantyRemain.Days != 0 ? warrantyRemain.Days.ToString() : ""; Lifelength aircraftOnInstall, aircraftCurrent = Lifelength.Null; var aircraftOnInstallHours = ""; var aircraftOnInstallCycles = ""; var aircraftOnInstallDays = ""; var aircraftCurrentHours = 0; var aircraftCurrentCycles = 0; var aircraftReNumString = ""; if (parentAircaft != null) { aircraftReNumString = _reportedComponent.GetParentAircraftRegNumber(); var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId); aircraftOnInstall = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, installationDate); aircraftOnInstallHours = aircraftOnInstall.Hours != null?aircraftOnInstall.Hours.ToString() : ""; aircraftOnInstallCycles = aircraftOnInstall.Cycles != null?aircraftOnInstall.Cycles.ToString() : ""; aircraftOnInstallDays = aircraftOnInstall.Days != null?aircraftOnInstall.Days.ToString() : ""; aircraftCurrent = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircaft); } Lifelength sinceOverhaul = Lifelength.Null; var lastOverhaulDate = DateTime.MinValue; var lastOverhaulDateString = ""; var model = ""; if (_reportedComponent.Model != null) { if (_reportedComponent.IsBaseComponent) { var bc = _reportedComponent as BaseComponent; if (bc.BaseComponentType == BaseComponentType.LandingGear || bc.BaseComponentType == BaseComponentType.Engine) { model = _reportedComponent.Model.FullName; } else { model = _reportedComponent.Model.FullName; } } else { model = _reportedComponent.Model.FullName; } } #region поиск последнего ремонта и расчет времени, прошедшего с него //поиск директив деталей var directives = new List <ComponentDirective>(_reportedComponent.ComponentDirectives.ToArray()); //поиск директивы ремонта var overhauls = directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList(); //поиск последнего ремонта ComponentDirective lastOverhaul = null; foreach (var d in overhauls) { if (d.LastPerformance == null || d.LastPerformance.RecordDate <= lastOverhaulDate) { continue; } lastOverhaulDate = d.LastPerformance.RecordDate; lastOverhaul = d; } if (lastOverhaul != null) { sinceOverhaul.Add(reportAircraftLifeLenght); sinceOverhaul.Substract(lastOverhaul.LastPerformance.OnLifelength); lastOverhaulDateString = lastOverhaul.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); } #endregion destinationDataSet.BaseDetailTable.AddBaseDetailTableRow(_reportedComponent.ATAChapter.ToString(), _reportedComponent.AvionicsInventory.ToString(), _reportedComponent.PartNumber, _reportedComponent.SerialNumber, model, _reportedComponent.Model?.Description, aircraftReNumString, position, _reportedComponent.Manufacturer, manufactureDate, deliveryDate, _reportedComponent.MPDItem, _reportedComponent.Suppliers != null ? _reportedComponent.Suppliers.ToString() : "", status.ToString(), _reportedComponent.Cost, _reportedComponent.CostOverhaul, _reportedComponent.CostServiceable, lifeLimitHours, lifeLimitCycles, lifeLimitDays, sinceNewHours, sinceNewCycles, sinceNewDays, remainCycles, remainHours, remainDays, onInstallDate, onInstallHours, onInstallCycles, onInstallDays, sinceInstallHours, sinceInstallCycles, sinceInstallDays, warrantyHours, warrantyCycles, warrantyDays, warrantyRemainHours, warrantyRemainCycles, warrantyRemainDays, aircraftOnInstallHours, aircraftOnInstallCycles, aircraftOnInstallDays, lastOverhaulDateString, sinceOverhaul.Hours ?? 0, sinceOverhaul.Cycles ?? 0); int averageUtilizationHours; int averageUtilizationCycles; string averageUtilizationType; if (_forecastData == null) { var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId); var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); averageUtilizationHours = parentAircaft != null?(int)averageUtilization.Hours:0; averageUtilizationCycles = parentAircaft != null?(int)averageUtilization.Cycles:0; averageUtilizationType = parentAircaft != null? averageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month" : ""; } else { averageUtilizationHours = (int)_forecastData.AverageUtilization.Hours; averageUtilizationCycles = (int)_forecastData.AverageUtilization.Cycles; averageUtilizationType = _forecastData.AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } destinationDataSet.AircraftDataTable.AddAircraftDataTableRow("", manufactureDate, aircraftCurrent.ToHoursMinutesFormat(""), aircraftCurrent.Cycles != null && aircraftCurrent.Cycles != 0 ? aircraftCurrent.Cycles.ToString() : "", "", "", "", "", averageUtilizationHours, averageUtilizationCycles, averageUtilizationType); }
protected override void AddFlight(MonthlyUtilizationDataSet dataSet, AircraftFlight item, string groupName, int counter) { string dateString = SmartCore.Auxiliary.Convert.GetDateFormat(item.FlightDate); Lifelength perDays = Lifelength.Zero; List <AircraftFlight> flights = Flights.Where(f => f.FlightDate.Date.AddMinutes(f.TakeOffTime) <= item.FlightDate.Date.AddMinutes(item.TakeOffTime)).ToList(); foreach (AircraftFlight aircraftFlight in flights) { perDays.Add(aircraftFlight.FlightTimeLifelength); } Lifelength aircraftLifelenght = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(item); #region колонки для отображения наработок по двигателям и ВСУ Lifelength engine1 = Lifelength.Null; Lifelength engine2 = Lifelength.Null; Lifelength apu = Lifelength.Null; if (_engine1 != null) { engine1 = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(_engine1, item); } if (_engine2 != null) { engine2 = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(_engine2, item); } if (_apu != null) { apu = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(_apu, item); } #endregion string color = UsefulMethods.GetColorName(item); if (!item.Correct) { color = "White"; } dataSet.Items.AddItemsRow(dateString, item.FlightNumber.ToString(), item.StationFromId.ShortName, item.StationToId.ShortName, item.Reference, item.PageNo, UsefulMethods.TimeToString(new TimeSpan(0, 0, item.TakeOffTime, 0)), UsefulMethods.TimeToString(new TimeSpan(0, 0, item.LDGTime, 0)), "1", UsefulMethods.TimeToString(new TimeSpan(0, 0, item.FlightTimeTotalMinutes, 0)), perDays.ToHoursMinutesAndCyclesFormat("", ""), aircraftLifelenght.ToHoursMinutesFormat(""), aircraftLifelenght.Cycles != null ? aircraftLifelenght.Cycles.ToString() : "", groupName, counter.ToString(), engine1.ToHoursMinutesFormat(""), engine1.Cycles != null ? engine1.Cycles.ToString() : "", engine2.ToHoursMinutesFormat(""), engine2.Cycles != null ? engine2.Cycles.ToString() : "", apu.ToHoursMinutesFormat(""), apu.Cycles != null ? apu.Cycles.ToString() : "", color); }
/// <summary> /// ?????????? ???????? ? ??????? ?????? /// </summary> /// <param name="dataset">???????, ? ??????? ??????????? ??????</param> private void AddBaseDetailsToDataSet(OperationTimeDataSet dataset) { if (_aircraftBaseDetails == null) { return; } var frame = _aircraftBaseDetails.FirstOrDefault(bd => bd.BaseComponentType == BaseComponentType.Frame); if (frame != null) { var subs = frame.Position.Split('-'); var framePosition = new StringBuilder(); for (int i = 0; i < subs.Length; i++) { if (i == subs.Length - 1) { framePosition.AppendLine(subs[i]); } else { framePosition.AppendLine(subs[i] + '-'); } } var from = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(frame, _from); //Lifelength period = GlobalObjects.CasEnvironment.Calculator.GetLifelength(frame, _from, _to); var total = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(frame, _to); var period = new Lifelength(total); period.Substract(from); //res.Substract(GetLifelength(baseDetail, fromDate)); var onCCheck = _lastCheckRecord != null ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(frame, _lastCheckRecord.RecordDate) : Lifelength.Null; var sinceLast = onCCheck != null ? total - onCCheck : Lifelength.Null; dataset.BaseDetailsTable.AddBaseDetailsTableRow (framePosition.ToString(), frame.SerialNumber, total.TotalMinutes != null ? total.ToHoursMinutesFormat("") : "", total.Cycles != null ? total.Cycles.ToString() : "", sinceLast.TotalMinutes != null ? sinceLast.ToHoursMinutesFormat("") : "", sinceLast.Cycles != null ? sinceLast.Cycles.ToString() : "", period.TotalMinutes != null ? period.ToHoursMinutesFormat("") : "", period.Cycles != null ? period.Cycles.ToString() : "", frame.Model.ToString()); } var engines = _aircraftBaseDetails.Where(bd => bd.BaseComponentType == BaseComponentType.Engine); if (engines.Count() > 0) { var engineNum = 1; foreach (BaseComponent engine in engines) { var from = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(engine, _from); //Lifelength period = GlobalObjects.CasEnvironment.Calculator.GetLifelength(frame, _from, _to); var total = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(engine, _to); var period = new Lifelength(total); period.Substract(from); var onCCheck = _lastCheckRecord != null ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(engine, _lastCheckRecord.RecordDate) : Lifelength.Null; var sinceLast = onCCheck != null ? total - onCCheck : Lifelength.Null; dataset.BaseDetailsTable.AddBaseDetailsTableRow ("Engine " + engineNum, engine.SerialNumber, total.TotalMinutes != null ? total.ToHoursMinutesFormat("") : "", total.Cycles != null ? total.Cycles.ToString() : "", sinceLast.TotalMinutes != null ? sinceLast.ToHoursMinutesFormat("") : "", sinceLast.Cycles != null ? sinceLast.Cycles.ToString() : "", period.TotalMinutes != null ? period.ToHoursMinutesFormat("") : "", period.Cycles != null ? period.Cycles.ToString() : "", engine.Model.ToString()); engineNum++; } } var apu = _aircraftBaseDetails.FirstOrDefault(bd => bd.BaseComponentType == BaseComponentType.Apu); if (apu != null) { #if KAC var subs = apu.SerialNumber.Split('-'); var apuNumber = new StringBuilder(); for (int i = 0; i < subs.Length; i++) { if (i == subs.Length - 1) { apuNumber.AppendLine(subs[i]); } else { apuNumber.AppendLine(subs[i] + '-'); } } var from = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(apu, _from); //Lifelength period = GlobalObjects.CasEnvironment.Calculator.GetLifelength(frame, _from, _to); var total = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(apu, _to); //Lifelength period = new Lifelength(total); //period.Substract(from); var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(apu.ParentAircraftId); var period = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthForPeriod(parentAircraft, _from, _to); var calculated = _currentAircraft.RegistrationNumber == "EX-37401" ? period : new Lifelength(period.Days, period.Cycles, Convert.ToInt32(period.Cycles * 60 * 1.3)); //Lifelength total = GlobalObjects.CasEnvironment.Calculator.GetLifelength(apu, _to); var onCCheck = _lastCheckRecord != null ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(apu, _lastCheckRecord.RecordDate) : Lifelength.Null; var sinceLast = onCCheck != null ? total - onCCheck : Lifelength.Null; dataset.BaseDetailsTable.AddBaseDetailsTableRow ("APU", apuNumber.ToString(), total.TotalMinutes != null ? total.Hours.ToString() : "", "--", sinceLast.TotalMinutes != null ? sinceLast.Hours.ToString() : "", "--", calculated.TotalMinutes != null ? calculated.Hours.ToString() : "", "--", apu.Model.ToString()); #else #endif } }