/// <summary> /// Построить источник данных (DataSet) для вывода в отчет /// </summary> /// <returns></returns> protected virtual DataSet GenerateDataSet() { var dataset = new MaintenanceDirectivesDataSetLatAvia(); AddAircraftToDataset(dataset); AddDirectivesToDataSet(dataset); AddAdditionalDataToDataSet(dataset); return(dataset); }
/// <summary> /// Добавление дополнительной информации /// </summary> /// <param name="destinationDateSet"></param> private void AddAdditionalDataToDataSet(MaintenanceDirectivesDataSetLatAvia destinationDateSet) { string firsttitle = "MPD Item"; string discriptiontitle = "Description"; string secondtitle = "Task Card №"; string reportFooter = new GlobalTermsProvider()["ReportFooter"].ToString(); string reportFooterPrepared = new GlobalTermsProvider()["ReportFooterPrepared"].ToString(); string reportFooterLink = new GlobalTermsProvider()["ProductWebsite"].ToString(); destinationDateSet.AdditionalDataTAble.AddAdditionalDataTAbleRow(_reportTitle, _operatorLogotype, _filterSelection, DateAsOf, firsttitle, secondtitle, discriptiontitle, reportFooter, reportFooterPrepared, reportFooterLink); }
/// <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="dataset">Таблица, в которую добавляются данные</param> protected virtual void AddDirectivesToDataSet(MaintenanceDirectivesDataSetLatAvia dataset) { /* List<String> colors = new List<string>(); * for (int i = 0; i < HighlightCollection.Instance.Count; i++ ) * { * colors.Add(HighlightCollection.Instance[i].Color.R.ToString()+" "+ * HighlightCollection.Instance[i].Color.G.ToString()+" "+ * HighlightCollection.Instance[i].Color.B.ToString()); * } * MessageBox.Show(string.Join("\r\n",colors.ToArray()));*/ foreach (MaintenanceDirective t in _reportedDirectives) { AddDirectiveToDataset(t, dataset); } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> protected virtual void AddDirectiveToDataset(MaintenanceDirective reportedDirective, MaintenanceDirectivesDataSetLatAvia destinationDataSet) { if (reportedDirective == null) { return; } string status = ""; Lifelength remain = Lifelength.Null; Lifelength used = Lifelength.Null; //string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; if (reportedDirective.Status == DirectiveStatus.Closed) { status = "C"; } if (reportedDirective.Status == DirectiveStatus.Open) { status = "O"; } if (reportedDirective.Status == DirectiveStatus.Repetative) { status = "R"; } if (reportedDirective.Status == DirectiveStatus.NotApplicable) { status = "N/A"; } string effectivityDate = UsefulMethods.NormalizeDate(reportedDirective.Threshold.EffectiveDate); string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва string firstPerformanceString = reportedDirective.Threshold.FirstPerformanceSinceNew.ToString(); if (reportedDirective.LastPerformance != null) { used.Add(_current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.RepeatInterval); } else if (!reportedDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Threshold.RepeatInterval); } } var remainCalc = Lifelength.Zero; NextPerformance next = null; try { if (_mpLimit) { if (reportedDirective.LastPerformance != null) { if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero() && !reportedDirective.IsClosed) { next = reportedDirective.NextPerformance; next.PerformanceSource = Lifelength.Zero; next.PerformanceSource.Add(reportedDirective.LastPerformance.OnLifelength); next.PerformanceSource.Add(reportedDirective.Threshold.RepeatInterval); next.PerformanceSource.Resemble(reportedDirective.Threshold.RepeatInterval); if (reportedDirective.Threshold.RepeatInterval.Days.HasValue) { next.PerformanceDate = reportedDirective.LastPerformance.RecordDate.AddDays(reportedDirective.Threshold .RepeatInterval.Days.Value); } else { next.PerformanceDate = null; } remainCalc.Add(next.PerformanceSource); remainCalc.Substract(_current); remainCalc.Resemble(reportedDirective.Threshold.RepeatInterval); if (next.PerformanceDate != null) { remainCalc.Days = DateTimeExtend.DifferenceDateTime(DateTime.Today, next.PerformanceDate.Value).Days; } } } else if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { remainCalc.Add(reportedDirective.NextPerformanceSource); remainCalc.Substract(_current); remainCalc.Resemble(reportedDirective.Threshold.RepeatInterval); } } } else { remainCalc = reportedDirective.Remains; next = reportedDirective.NextPerformance; } destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.TaskCardNumber, reportedDirective.TaskNumberCheck, reportedDirective.Description, firstPerformanceString, reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Hours?.ToString() : "*", reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Cycles?.ToString() : "*", reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Days?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.OnLifelength.Hours?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.OnLifelength.Cycles?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.RecordDate.Date.ToString("dd.MM.yyyy") : "*", next != null ? next.PerformanceSource.Hours.ToString() : "*", next != null ? next.PerformanceSource.Cycles.ToString() : "*", next?.PerformanceDate != null ? next.PerformanceDate.Value.ToString("dd.MM.yyyy") : "*", remainCalc != null ? remainCalc.Hours.ToString() : "*", remainCalc != null ? remainCalc.Cycles.ToString() : "*", remainCalc != null ? remainCalc.Days.ToString() : "*", "", "" ); } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> protected virtual void AddDirectiveToDataset(MaintenanceDirective reportedDirective, MaintenanceDirectivesDataSetLatAvia destinationDataSet) { if (reportedDirective == null) { return; } string status = ""; Lifelength remain = Lifelength.Null; Lifelength used = Lifelength.Null; //string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; string remarks = reportedDirective.Remarks; string directiveType = reportedDirective.WorkType.ToString(); double cost = reportedDirective.Cost; double mh = reportedDirective.ManHours; if (reportedDirective.Status == DirectiveStatus.Closed) { status = "C"; } if (reportedDirective.Status == DirectiveStatus.Open) { status = "O"; } if (reportedDirective.Status == DirectiveStatus.Repetative) { status = "R"; } if (reportedDirective.Status == DirectiveStatus.NotApplicable) { status = "N/A"; } string effectivityDate = UsefulMethods.NormalizeDate(reportedDirective.Threshold.EffectiveDate); string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва string firstPerformanceString = reportedDirective.Threshold.FirstPerformanceSinceNew.ToString(); if (reportedDirective.LastPerformance != null) { used.Add(_current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.RepeatInterval); } else if (!reportedDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Threshold.RepeatInterval); } } destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.TaskCardNumber, reportedDirective.TaskNumberCheck, reportedDirective.Description, firstPerformanceString, reportedDirective.ParentComponentDirective?.RepeatInterval != null ? reportedDirective.ParentComponentDirective?.RepeatInterval.Hours?.ToString() : "*", reportedDirective.ParentComponentDirective?.RepeatInterval != null ? reportedDirective.ParentComponentDirective?.RepeatInterval.Cycles?.ToString() : "*", reportedDirective.ParentComponentDirective?.RepeatInterval != null ? reportedDirective.ParentComponentDirective?.RepeatInterval.Days?.ToString() : "*", reportedDirective.ParentComponentDirective?.LastPerformance != null ? reportedDirective.ParentComponentDirective?.LastPerformance.OnLifelength.Hours?.ToString() : "*", reportedDirective.ParentComponentDirective?.LastPerformance != null ? reportedDirective.ParentComponentDirective?.LastPerformance.OnLifelength.Cycles?.ToString() : "*", reportedDirective.ParentComponentDirective?.LastPerformance != null ? reportedDirective.ParentComponentDirective?.LastPerformance.RecordDate.ToString("dd.MM.yyyy") : "*", reportedDirective.ParentComponentDirective?.NextPerformance != null ? reportedDirective.ParentComponentDirective?.NextPerformance.PerformanceSource.Hours.ToString() : "*", reportedDirective.ParentComponentDirective?.NextPerformance != null ? reportedDirective.ParentComponentDirective?.NextPerformance.PerformanceSource.Cycles.ToString() : "*", reportedDirective.ParentComponentDirective?.NextPerformance != null ? reportedDirective.ParentComponentDirective?.NextPerformance.PerformanceDate.Value.ToString("dd.MM.yyyy") : "*", reportedDirective.ParentComponentDirective?.Remains != null ? reportedDirective.ParentComponentDirective?.Remains.Hours.ToString() : "*", reportedDirective.ParentComponentDirective?.Remains != null ? reportedDirective.ParentComponentDirective?.Remains.Cycles.ToString() : "*", reportedDirective.ParentComponentDirective?.Remains != null ? reportedDirective.ParentComponentDirective?.Remains.Days.ToString() : "*", reportedDirective.CompnentSN, reportedDirective.CompnentPN ); }