/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddChecksToDataset(AircraftGeneralDataDataSet destinationDataSet) { if (_reportedAircraft == null) { return; } var mc = GlobalObjects.MaintenanceCore.GetMaintenanceCheck(_reportedAircraft, _reportedAircraft.Schedule); var aircraftChecks = new MaintenanceCheckCollection(mc); GlobalObjects.MaintenanceCheckCalculator.GetNextPerformanceGroup(aircraftChecks, _reportedAircraft.Schedule); foreach (object o in GlobalObjects.CasEnvironment.GetDictionary <MaintenanceCheckType>()) { var checkType = o as MaintenanceCheckType; if (checkType != null) { var lastComplianceGroups = aircraftChecks.GetLastComplianceCheckGroup(_reportedAircraft.Schedule, _reportedAircraft.ItemId, true, LifelengthSubResource.Hours, checkType); if (lastComplianceGroups == null || lastComplianceGroups.Checks.Count == 0) { continue; } var maxCheck = lastComplianceGroups.GetMaxIntervalCheck(); var minCheck = lastComplianceGroups.GetMinIntervalCheck(); var repeatInterval = minCheck.Interval; //расчет остатка от выполнения с даты производтсва var lastComplianceDate = maxCheck.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var lastCompliance = maxCheck.LastPerformance.OnLifelength; var remains = minCheck.Remains; var condition = minCheck.Condition ?? ConditionState.NotEstimated; destinationDataSet.MaintenanceTable.AddMaintenanceTableRow(maxCheck.Name, repeatInterval.Days != null ? repeatInterval.Days.ToString() : "", repeatInterval.Hours != null ? repeatInterval.Hours.ToString() : "", repeatInterval.Cycles != null ? repeatInterval.Cycles.ToString() : "", lastComplianceDate, lastCompliance.Hours != null ? lastCompliance.Hours.ToString() : "", lastCompliance.Cycles != null ? lastCompliance.Cycles.ToString() : "", remains.Days != null ? remains.Days.ToString() : "", remains.Hours != null ? remains.Hours.ToString() : "", remains.Cycles != null ? remains.Cycles.ToString() : "", condition.ToString()); } } }
private void GenerateRows() { listViewProgramChecks.Items.Clear(); if (_grouping) { MaintenanceCheckCollection mcc = new MaintenanceCheckCollection(_maintenanceCheckItems); MaintenanceCheck mc = mcc.GetMinStepCheck(_maintenanceCheckItems[0].Schedule); if (mc == null) { return; } MSG msg = mc.ParentAircraft != null && mc.ParentAircraft.MaintenanceProgramChangeRecords.Count > 0 ? mc.ParentAircraft.MaintenanceProgramChangeRecords.GetLast().MSG : MSG.MSG2; if (msg < MSG.MSG3) { MaintenanceCheckComplianceGroup mccg = mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId, mc.Grouping, mc.Resource); int lastPerformanceGroupNum = mccg != null ? mccg.LastComplianceGroupNum : 0; int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource; foreach (MaintenanceCheck t in _maintenanceCheckItems) { ListViewItem listViewItem = new ListViewItem { Text = t.Name }; listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat()); listViewItem.SubItems.Add(t.Cost.ToString()); listViewItem.SubItems.Add(t.ManHours.ToString()); for (int j = 1; j <= _countColumns; j++) { MaintenanceNextPerformance mnp = t.GetPergormanceGroupByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck); listViewItem.SubItems.Add(mnp != null ? "X" : ""); } listViewProgramChecks.Items.Add(listViewItem); } } else { MaintenanceCheckComplianceGroup mccg = mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId, mc.Grouping, mc.Resource); int lastPerformanceGroupNum = mccg != null ? mccg.LastComplianceGroupNum : 0; int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource; foreach (MaintenanceCheck t in _maintenanceCheckItems) { ListViewItem listViewItem = new ListViewItem { Text = t.Name }; listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat()); listViewItem.SubItems.Add(t.Cost.ToString()); listViewItem.SubItems.Add(t.ManHours.ToString()); for (int j = 1; j <= _countColumns; j++) { MaintenanceNextPerformance mnp = t.GetPergormanceGroupWhereCheckIsSeniorByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck); listViewItem.SubItems.Add(mnp != null ? "X" : ""); } listViewProgramChecks.Items.Add(listViewItem); } } mcc.Clear(); } else { foreach (MaintenanceCheck t in _maintenanceCheckItems) { ListViewItem listViewItem = new ListViewItem { Text = t.Name }; listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat()); listViewItem.SubItems.Add(t.Cost.ToString()); listViewItem.SubItems.Add(t.ManHours.ToString()); Lifelength lastPerformance = t.LastPerformance != null ? new Lifelength(t.LastPerformance.OnLifelength) : Lifelength.Null; int?last = lastPerformance.GetSubresource(_subResource); listViewItem.SubItems.Add(last != null ? lastPerformance.ToString(_subResource, true) : ""); if (t.Schedule == _schedule) { Lifelength nextPerformance = lastPerformance + t.Interval; int? next = nextPerformance.GetSubresource(_subResource); listViewItem.SubItems.Add(next != null ? nextPerformance.ToString(_subResource, true) : ""); } else { listViewItem.SubItems.Add("N/A"); } listViewProgramChecks.Items.Add(listViewItem); } } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddStatusToDataset(MaintenanceStatusDataSet destinationDataSet) { if (_reportedAircraft == null) { return; } MaintenanceCheckComplianceGroup lastComplianceGroup = _reportedDirectives.GetLastComplianceCheckGroup(_filterSelection, _reportedAircraft.ItemId); MaintenanceCheckGroupByType nextComplianceGroup = GlobalObjects.MaintenanceCheckCalculator.GetNextCheckComplianceGroup(_reportedDirectives, _filterSelection, _reportedAircraft); MaintenanceCheck minStepCheck = _reportedDirectives != null ? _reportedDirectives.GetMinStepCheck(_filterSelection) : null; Lifelength reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent); Lifelength minStep = minStepCheck != null ? minStepCheck.Interval : Lifelength.Null; Lifelength used = new Lifelength(reportAircraftLifeLenght); Lifelength remain = Lifelength.Null; string lastComplianceDate = "", lastComplianceHours = "", lastComplianceCycles = ""; string nextComplianceDate = "", nextComplianceHours = "", nextComplianceCycles = ""; string remarks = ""; if (lastComplianceGroup != null) { lastComplianceDate = lastComplianceGroup.LastGroupComplianceDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastComplianceCycles = lastComplianceGroup.LastGroupComplianceLifelength.Cycles != null ? lastComplianceGroup.LastGroupComplianceLifelength.Cycles.ToString() : ""; lastComplianceHours = lastComplianceGroup.LastGroupComplianceLifelength.Hours != null ? lastComplianceGroup.LastGroupComplianceLifelength.Hours.ToString() : ""; used.Substract(lastComplianceGroup.LastGroupComplianceLifelength); remarks = lastComplianceGroup.Remarks; } if (nextComplianceGroup != null) { nextComplianceDate = nextComplianceGroup.GroupComplianceDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); nextComplianceCycles = nextComplianceGroup.GroupComplianceLifelength.Cycles != null ? nextComplianceGroup.GroupComplianceLifelength.Cycles.ToString() : ""; nextComplianceHours = nextComplianceGroup.GroupComplianceLifelength.Hours != null ? nextComplianceGroup.GroupComplianceLifelength.Hours.ToString() : ""; remain.Add(nextComplianceGroup.GroupComplianceLifelength); remain.Substract(reportAircraftLifeLenght); } string usedHours = used.Hours != null?used.Hours.ToString() : ""; string usedCycles = used.Cycles != null?used.Cycles.ToString() : ""; string usedDays = used.Days != null?used.Days.ToString() : ""; string remainHours = remain.Hours != null?remain.Hours.ToString() : ""; string remainCycles = remain.Cycles != null?remain.Cycles.ToString() : ""; string remainDays = remain.Days != null?remain.Days.ToString() : ""; destinationDataSet.StatusTable.AddStatusTableRow(_filterSelection ? "Schedule" : "Unschedule", lastComplianceGroup != null ? lastComplianceGroup.ToStringCheckNames() : "", nextComplianceGroup != null ? nextComplianceGroup.ToStringCheckNames() : "", minStep.Hours != null ? minStep.Hours.ToString() : "", minStep.Cycles != null ? minStep.Cycles.ToString() : "", minStep.Days != null ? minStep.Days.ToString() : "", lastComplianceDate, lastComplianceHours, lastComplianceCycles, usedDays, usedHours, usedCycles, nextComplianceDate, nextComplianceHours, nextComplianceCycles, remainDays, remainHours, remainCycles, remarks); }
/// <summary> /// Выставляет колонки в списке чеков текущей программы обслуживания /// </summary> private void SetHeaders() { _min = Convert.ToInt32(_maintenanceCheckItems[0].Interval.GetSubresource(_subResource)); foreach (MaintenanceCheck liminationItem in _maintenanceCheckItems) { _min = Math.Min(Convert.ToInt32(liminationItem.Interval.GetSubresource(_subResource)), _min); _max = Math.Max(Convert.ToInt32(liminationItem.Interval.GetSubresource(_subResource)), _max); } ColumnHeader column = new ColumnHeader { Text = "Name", TextAlign = HorizontalAlignment.Right, Width = 50 }; listViewProgramChecks.Columns.Add(column); column = new ColumnHeader { Text = "Interval", TextAlign = HorizontalAlignment.Left, Width = 130 }; listViewProgramChecks.Columns.Add(column); column = new ColumnHeader { Text = "Cost", TextAlign = HorizontalAlignment.Left, Width = 50 }; listViewProgramChecks.Columns.Add(column); column = new ColumnHeader { Text = "ManHours", TextAlign = HorizontalAlignment.Left, Width = 64 }; listViewProgramChecks.Columns.Add(column); if (_grouping) { //Определение кол-ва колонок списка if (_upperCheckTypeMinResource == -1) { //Если это самая вышестоящий тип чеков //то делится максимальный на минимальный интервал _countColumns = _max / _min; } else { //Если это самая НЕ вышестоящий тип чеков //то делится минимальный ресурс вышестоящего типа на минимальный интервал _countColumns = _upperCheckTypeMinResource / _min; } MaintenanceCheckCollection mcc = new MaintenanceCheckCollection(_maintenanceCheckItems); MaintenanceCheck mc = mcc.GetMinStepCheck(_maintenanceCheckItems[0].Schedule); if (mc == null) { return; } MSG msg = mc.ParentAircraft != null && mc.ParentAircraft.MaintenanceProgramChangeRecords.Count > 0 ? mc.ParentAircraft.MaintenanceProgramChangeRecords.GetLast().MSG : MSG.MSG2; if (msg < MSG.MSG3) { for (int i = 1; i <= _countColumns; i++) { //ColumnHeader viewColumn = new ColumnHeader // { // Text = i + " [" + (i*_min) + "]", // TextAlign = HorizontalAlignment.Center, // Width = 65 // // }; //listViewProgramChecks.Columns.Add(viewColumn); ColumnHeader viewColumn; //выполняется проверка, достаточно ли расчитано "след.выполнений" //что бы заполнить их данными названия колонок if (mc.NextPerformances.Count >= i) { //Если кол-во расчитанных выполнений достаточно для заполнения //названия тек. колонки, то название колонки берется из ресурса "след. выполнения" int performanceSource = Convert.ToInt32(mc.NextPerformances[i - 1].PerformanceSource.GetSubresource(mc.Resource)); MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance; if (mnp != null) { string checkName = mnp.PerformanceGroup != null?mnp.PerformanceGroup.GetGroupName() : i.ToString(); viewColumn = new ColumnHeader { Text = checkName + " [" + performanceSource + "]", TextAlign = HorizontalAlignment.Center, Width = 85 }; } else { viewColumn = new ColumnHeader { Text = i + " [" + performanceSource + "]", TextAlign = HorizontalAlignment.Center, Width = 85 }; } } else { //Если кол-во расчитанных выполнений недостаточно //то название колонки расчитывается на освоне ресурса последнего выполнения //данного чека и номера тек. колонки viewColumn = new ColumnHeader { Text = i + " [" + (i * _min) + "]", TextAlign = HorizontalAlignment.Center, Width = 85 }; } listViewProgramChecks.Columns.Add(viewColumn); } } else { MaintenanceCheckComplianceGroup mccg = mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId, mc.Grouping, mc.Resource); if (mccg == null) { for (int i = 1; i <= _countColumns; i++) { MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance; string checkName = mnp != null && mnp.PerformanceGroup != null ? mnp.PerformanceGroup.GetGroupName() : ""; ColumnHeader viewColumn = new ColumnHeader { Text = checkName + " [" + (i * _min) + "]", TextAlign = HorizontalAlignment.Center, Width = 65 }; listViewProgramChecks.Columns.Add(viewColumn); } } else { MaintenanceCheck mic = mccg.GetMinIntervalCheck(); for (int i = 1; i <= _countColumns; i++) { ColumnHeader viewColumn; //выполняется проверка, достаточно ли расчитано "след.выполнений" //что бы заполнить их данными названия колонок if (mic.NextPerformances.Count >= i) { //Если кол-во расчитанных выполнений достаточно для заполнения //названия тек. колонки, то название колонки берется из ресурса "след. выполнения" MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance; string checkName = mnp != null && mnp.PerformanceGroup != null ? mnp.PerformanceGroup.GetGroupName() : ""; int performanceSource = Convert.ToInt32(mic.NextPerformances[i - 1].PerformanceSource.GetSubresource(mic.Resource)); viewColumn = new ColumnHeader { Text = checkName + " [" + performanceSource + "]", TextAlign = HorizontalAlignment.Center, Width = 85 }; } else { //Если кол-во расчитанных выполнений недостаточно //то название колонки расчитывается на освоне ресурса последнего выполнения //данного чека и номера тек. колонки int lastPerformaceSource = Convert.ToInt32(mic.LastPerformance.CalculatedPerformanceSource.GetSubresource(mic.Resource)); if (lastPerformaceSource == 0) { lastPerformaceSource = Convert.ToInt32(mic.LastPerformance.OnLifelength.GetSubresource(mic.Resource)); } viewColumn = new ColumnHeader { Text = " [" + (lastPerformaceSource + i * _min) + "]", TextAlign = HorizontalAlignment.Center, Width = 85 }; } listViewProgramChecks.Columns.Add(viewColumn); } } } mcc.Clear(); } else { _countColumns = 2; //Если чеки НЕ группируются по части порогового значения //то выводится ресурс пред. и след. выполнения column = new ColumnHeader { Text = "Last", TextAlign = HorizontalAlignment.Left, Width = 100 }; listViewProgramChecks.Columns.Add(column); column = new ColumnHeader { Text = "Next", TextAlign = HorizontalAlignment.Left, Width = 100 }; listViewProgramChecks.Columns.Add(column); } }