/// <summary> /// Создает форму для редактирования записей о выполнении группы чеков /// </summary> /// <param name="currentAircraft">ВС, которому пренадлежит группа чеков</param> /// <param name="complianceGroup">Группа чеков для редактирования</param> public MaintenanceComplainceForm(Aircraft currentAircraft, MaintenanceCheckGroupByType complianceGroup) : this() { if (currentAircraft == null) { throw new ArgumentNullException("currentAircraft", "must be not null"); } if (complianceGroup == null) { throw new ArgumentNullException("complianceGroup", "must be not null"); } _currentAircraft = currentAircraft; _numGroup = complianceGroup.GroupComplianceNum; _performances = complianceGroup.Checks .SelectMany(c => c.NextPerformances.OfType <MaintenanceNextPerformance>() .Where(np => np.PerformanceGroupNum == _numGroup)) .ToList(); textBoxCheckName.Text = _performances.Count > 0 ? _performances[0].PerformanceGroup.GetGroupName() : ""; _currentChecks = complianceGroup.Checks; _animatedThreadWorker.DoWork += AnimatedThreadWorkerDoLoadForChecks; _animatedThreadWorker.RunWorkerCompleted += AnimatedThreadWorkerDoLoadForChecksCompleted; }
/// <summary> /// загружает элементы начального акта, и производит их калькуляцмю. /// </summary> /// <param name="initialOrder"></param> public void GetInitialOrderItemsWithCalculate(InitialOrder initialOrder) { LoadInitionalOrderItems(initialOrder); //записи по чекам обслуживания нужно сгруппировать по типу чеков (Schedule/Store) //и номеру группы выполнения, после, для каждой группы расчитать ресурс и дату выполнения var maintenanceChecksWprs = initialOrder.PackageRecords.Where(w => w.IsSchedule && w.Task.SmartCoreObjectType == SmartCoreType.MaintenanceCheck && w.Task.ItemId > 0); var mcs = new List <MaintenanceCheck>(); var rmcs = new List <MaintenanceCheck>(); foreach (var maintenanceChecksWpr in maintenanceChecksWprs) { var mc = (MaintenanceCheck)maintenanceChecksWpr.Task; var apr = mc.PerformanceRecords .FirstOrDefault(pr => pr.NumGroup == maintenanceChecksWpr.PerformanceNumFromStart); if (apr != null) { mc.ComplianceGroupNum = apr.NumGroup; rmcs.Add(mc); } else { mc.ComplianceGroupNum = maintenanceChecksWpr.PerformanceNumFromStart; mcs.Add(mc); } mc.ResetMathData(); } #region асчет выполнения для чеков не имеющих записи в рамках данного рабочего пакета //группировка по типу (Schedule/Store) var groupByMaintenanceType = mcs.GroupBy(mc => mc.Schedule); foreach (var maintenanceTypeGroup in groupByMaintenanceType) { var groupByMaintenanceNum = maintenanceTypeGroup.GroupBy(mc => mc.ComplianceGroupNum); foreach (var maintenanceComplianceGroup in groupByMaintenanceNum) { var mcg = new MaintenanceCheckGroupByType(maintenanceComplianceGroup.First().Schedule); foreach (var maintenanceCheck in maintenanceComplianceGroup) { mcg.Checks.Add(maintenanceCheck); } //чеки выполнения _performanceCalculator.GetPerformance(mcg, maintenanceComplianceGroup.Key); } } #endregion foreach (var record in initialOrder.PackageRecords) { if (!record.IsSchedule) { _performanceCalculator.GetNextPerformance(record); continue; } if (record.Task == null || record.Task.ItemId < 0) { continue; } AbstractPerformanceRecord apr = null; apr = record.Task.PerformanceRecords .Cast <AbstractPerformanceRecord>() .FirstOrDefault(r => r.PerformanceNum == record.PerformanceNumFromStart); if (apr == null) { IDirective task = record.Task; if (!task.IsClosed) { if (task is Entities.General.Accessory.Component) { _performanceCalculator.GetPerformance((Entities.General.Accessory.Component)task, record.PerformanceNumFromStart); } else { _performanceCalculator.GetPerformance(task, record.PerformanceNumFromStart); } } } } }
///<summary> ///</summary> ///<param name="checkItems"></param> ///<param name="aircraft"></param> ///<param name="schedule"></param> public void UpdateInformation(MaintenanceCheckCollection checkItems, Aircraft aircraft, bool schedule) { CheckItems = checkItems; Schedule = schedule; _complianceGroupCollection = CheckItems.GetNextComplianceCheckGroups(Schedule).OrderBy(GetNextComplianceDate); TsnCsn = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(aircraft); listViewLastCheck.Items.Clear(); listViewNextCheck.Items.Clear(); if (CheckItems.Count == 0) { return; } if (!BackGroundWorker.IsBusy) { BackGroundWorker.RunWorkerAsync(); } List <MaintenanceCheck> orderedBySchedule = checkItems.OrderBy(c => c.Schedule) .OrderByDescending(c => c.Grouping) .OrderBy(c => c.Resource) .ToList(); List <MaintenanceCheckGroupByType> checkGroups = new List <MaintenanceCheckGroupByType>(); foreach (MaintenanceCheck check in orderedBySchedule) { MaintenanceCheckGroupByType group = checkGroups .FirstOrDefault(g => g.Schedule == check.Schedule && g.Grouping == check.Grouping && g.Resource == check.Resource); if (group != null) { group.Checks.Add(check); } else { group = new MaintenanceCheckGroupByType(check.Schedule) { Grouping = check.Grouping, Resource = check.Resource }; group.Checks.Add(check); checkGroups.Add(group); } } List <MaintenanceProgramControl> mpcs = flowLayoutPanel1.Controls.OfType <MaintenanceProgramControl>().ToList(); for (int j = 0; j < mpcs.Count; j++) { if (j >= checkGroups.Count) { //Если кол-во контролов превышает кол-во групп чеков //то необходимо убрать лишние контролы flowLayoutPanel1.Controls.Remove(mpcs[j]); continue; } mpcs[j].SetParameters(checkGroups[j].Checks, checkGroups[j].Schedule, checkGroups[j].Grouping, checkGroups[j].Resource); } for (int j = mpcs.Count; j < checkGroups.Count; j++) { MaintenanceProgramControl mpc = new MaintenanceProgramControl(checkGroups[j].Checks, checkGroups[j].Schedule, checkGroups[j].Grouping, checkGroups[j].Resource) { Extended = false }; flowLayoutPanel1.Controls.Add(mpc); flowLayoutPanel1.Controls.SetChildIndex(mpc, j); } mpcs = flowLayoutPanel1.Controls.OfType <MaintenanceProgramControl>().ToList(); if (mpcs.Count == 1) { mpcs[0].EnableExtendedControl = false; } else if (mpcs.Count >= 1) { mpcs[0].EnableExtendedControl = true; } maintenancePerformanceControl1.Reload(checkItems, aircraft); }
/// <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> ///<param name="checkItems"></param> ///<param name="aircraftDocuments"></param> ///<param name="aircraft"></param> ///<param name="schedule"></param> public void UpdateInformation(MaintenanceCheckCollection checkItems, IEnumerable <Document> aircraftDocuments, Aircraft aircraft, bool schedule) { _aircraftDocuments.Clear(); _aircraftDocuments.AddRange(aircraftDocuments); _checkItems = checkItems; _schedule = schedule; _currentAircraft = aircraft; _complianceGroupCollection = _checkItems.GetNextComplianceCheckGroups(_schedule).OrderBy(c => c.GetNextComplianceDate()); _aircraftLifelength = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(aircraft); labelMSGValue.Text = aircraft.MSG.ToString(); labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(aircraft.ManufactureDate); labelOwnerValue.Text = aircraft.Owner; labelOperatorValue.Text = GlobalObjects.CasEnvironment.Operators.First(o => o.ItemId == _currentAircraft.OperatorId).Name; labelAircraftTypeCertificateNoValue.Text = aircraft.TypeCertificateNumber; labelCurrentValue.Text = _aircraftLifelength.ToHoursMinutesAndCyclesFormat("FH", "FC"); labelBasicEmptyWeightValue.Text = aircraft.BasicEmptyWeight.ToString(); labelBasicEmptyWeightCargoConfigValue.Text = aircraft.BasicEmptyWeightCargoConfig.ToString(); labelCargoCapacityContainerValue.Text = aircraft.CargoCapacityContainer; labelCruiseValue.Text = aircraft.Cruise; labelCruiseFuelFlowValue.Text = aircraft.CruiseFuelFlow; labelFuelCapacityValue.Text = aircraft.FuelCapacity; labelMaxCruiseAltitudeValue.Text = aircraft.MaxCruiseAltitude; labelMaxLandingWeightValue.Text = aircraft.MaxLandingWeight.ToString(); labelMaxPayloadValue.Text = aircraft.MaxPayloadWeight.ToString(); labelMaxTakeOffCrossWeightValue.Text = aircraft.MaxTakeOffCrossWeight.ToString(); labelMaxZeroFuelWeightValue.Text = aircraft.MaxZeroFuelWeight.ToString(); labelMaxTaxiWeightValue.Text = aircraft.MaxTaxiWeight.ToString(); labelOpertionalEmptyWeightValue.Text = aircraft.OperationalEmptyWeight.ToString(); labelCockpitSeatingValue.Text = aircraft.CockpitSeating; labelGalleysValue.Text = aircraft.Galleys; labelLavatoryValue.Text = aircraft.Lavatory; labelSeatingEconomyValue.Text = aircraft.SeatingEconomy.ToString(); labelSeatingBusinessValue.Text = aircraft.SeatingBusiness.ToString(); labelSeatingFirstValue.Text = aircraft.SeatingFirst.ToString(); labelOvenValue.Text = aircraft.Oven; labelBoilerValue.Text = aircraft.Boiler; labelAirStairDoorsValue.Text = aircraft.AirStairsDoors; var aircraftEquipment = _currentAircraft.AircraftEquipments.Where(a => a.AircraftEquipmetType == AircraftEquipmetType.Equipmet); var aircraftApproval = _currentAircraft.AircraftEquipments.Where(a => a.AircraftEquipmetType == AircraftEquipmetType.TapeOfOperationApproval); var row = 4; foreach (var equipmentse in aircraftApproval) { var labelTitle = new Label { Text = equipmentse.AircraftOtherParameter + " :", Font = new Font("Verdana", 14, GraphicsUnit.Pixel), ForeColor = Color.FromArgb(122, 122, 122), Width = 150 }; var labelValue = new Label { Text = equipmentse.Description, Font = new Font("Verdana", 14, GraphicsUnit.Pixel), ForeColor = Color.FromArgb(122, 122, 122), Width = 150 }; row++; tableLayoutPanelMain.Controls.Add(labelTitle, 2, row); tableLayoutPanelMain.Controls.Add(labelValue, 3, row); } row = 4; foreach (var equipmentse in aircraftEquipment) { var labelTitle = new Label { Text = equipmentse.AircraftOtherParameter + " :", Font = new Font("Verdana", 14, GraphicsUnit.Pixel), ForeColor = Color.FromArgb(122, 122, 122), Width = 150 }; var labelValue = new Label { Text = equipmentse.Description, Font = new Font("Verdana", 14, GraphicsUnit.Pixel), ForeColor = Color.FromArgb(122, 122, 122), Width = 150 }; row++; tableLayoutPanelMain.Controls.Add(labelTitle, 6, row); tableLayoutPanelMain.Controls.Add(labelValue, 7, row); } //List<Document> operatorDocs = // GlobalObjects.CasEnvironment.Loader.GetDocuments(aircraft.Operator, DocumentType.Certificate, true); //DocumentSubType aocType = (DocumentSubType) // GlobalObjects.CasEnvironment.Dictionaries[typeof(DocumentSubType)].ToArray().FirstOrDefault(d => d.FullName == "AOC"); //Document awDoc = aocType != null ? operatorDocs.FirstOrDefault(d => d.DocumentSubType == aocType) : null; //string aocUpTo = awDoc != null && awDoc.ValidTo // ? awDoc.DateValidTo.ToString(new GlobalTermsProvider()["DateFormat"].ToString()) // : ""; var aircraftDocs = GlobalObjects.DocumentCore.GetAircraftDocuments(aircraft); var awType = (DocumentSubType) GlobalObjects.CasEnvironment.GetDictionary <DocumentSubType>().ToArray().FirstOrDefault(d => d.FullName == "AW"); var awDoc = awType != null?aircraftDocs.FirstOrDefault(d => d.DocumentSubType.ItemId == awType.ItemId) : null; string awUpTo = awDoc != null && awDoc.IssueValidTo ? awDoc.IssueDateValidTo.ToString(new GlobalTermsProvider()["DateFormat"].ToString()) : ""; labelAWCValue.Text = awUpTo; tableLayoutPanelLastChecks.RowCount = 1; tableLayoutPanelLastChecks.RowStyles.Clear(); tableLayoutPanelLastChecks.RowStyles.Add(new RowStyle()); tableLayoutPanelLastChecks.Controls.Clear(); tableLayoutPanelLastChecks.Controls.Add(labelLastCheck, 0, 0); tableLayoutPanelLastChecks.Controls.Add(labelLastDate, 1, 0); tableLayoutPanelLastChecks.Controls.Add(labelLastTsnCsn, 2, 0); tableLayoutPanelNextChecks.RowCount = 1; tableLayoutPanelNextChecks.RowStyles.Clear(); tableLayoutPanelNextChecks.RowStyles.Add(new RowStyle()); tableLayoutPanelNextChecks.Controls.Clear(); tableLayoutPanelNextChecks.Controls.Add(labelNextCheck, 0, 0); tableLayoutPanelNextChecks.Controls.Add(labelNextDate, 1, 0); tableLayoutPanelNextChecks.Controls.Add(labelNextTsnCan, 2, 0); tableLayoutPanelNextChecks.Controls.Add(labelRemains, 3, 0); tableLayoutPanelDocs.RowCount = 1; tableLayoutPanelDocs.RowStyles.Clear(); tableLayoutPanelDocs.RowStyles.Add(new RowStyle()); tableLayoutPanelDocs.Controls.Clear(); tableLayoutPanelDocs.Controls.Add(labelDocDescription, 0, 0); tableLayoutPanelDocs.Controls.Add(labelDocNumber, 1, 0); tableLayoutPanelDocs.Controls.Add(labelDocIssue, 2, 0); tableLayoutPanelDocs.Controls.Add(labelDocValidTo, 3, 0); tableLayoutPanelDocs.Controls.Add(labelDocRemain, 4, 0); if (_checkItems.Count == 0) { return; } if (!BackGroundWorker.IsBusy) { BackGroundWorker.RunWorkerAsync(); } List <MaintenanceCheck> orderedBySchedule = checkItems.OrderBy(c => c.Schedule) .ThenByDescending(c => c.Grouping) .OrderBy(c => c.Resource) .ToList(); List <MaintenanceCheckGroupByType> checkGroups = new List <MaintenanceCheckGroupByType>(); foreach (MaintenanceCheck check in orderedBySchedule) { MaintenanceCheckGroupByType group = checkGroups .FirstOrDefault(g => g.Schedule == check.Schedule && g.Grouping == check.Grouping && g.Resource == check.Resource); if (group != null) { group.Checks.Add(check); } else { group = new MaintenanceCheckGroupByType(check.Schedule) { Grouping = check.Grouping, Resource = check.Resource }; group.Checks.Add(check); checkGroups.Add(group); } } }
private void Edit() { DialogResult dlgResult = DialogResult.None; if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["overdue"]) { MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm(_currentAircraft, (MaintenanceCheckGroupByType)listViewCompliance.SelectedItems[0].Tag); dlgResult = complainceForm.ShowDialog(this); } else if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["next"]) { if (listViewCompliance.SelectedItems[0].Tag is NextPerformance) { NextPerformance np = (NextPerformance)listViewCompliance.SelectedItems[0].Tag; //if (np.Condition != ConditionState.Overdue || np.PerformanceDate > DateTime.Now) //{ // MessageBox.Show("You can not enter a record for not delayed performance", // (string)new GlobalTermsProvider()["SystemName"], // MessageBoxButtons.OK, // MessageBoxIcon.Warning, // MessageBoxDefaultButton.Button1); // return; //} if (np.BlockedByPackage != null) { MessageBox.Show("Perform of the task:" + listViewCompliance.SelectedItems[0].Text + "\nblocked by Work Package:" + "\n" + np.BlockedByPackage.Title, (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } } if (listViewCompliance.SelectedItems[0].Tag is MaintenanceNextPerformance) { MaintenanceNextPerformance mnp = listViewCompliance.SelectedItems[0].Tag as MaintenanceNextPerformance; if (mnp.PerformanceGroup == null) { return; } MaintenanceCheckGroupByType pg = mnp.PerformanceGroup; MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm(_currentAircraft, pg); dlgResult = complainceForm.ShowDialog(this); } else if (listViewCompliance.SelectedItems[0].Tag is NextPerformance) { NextPerformance np = listViewCompliance.SelectedItems[0].Tag as NextPerformance; if (np.Parent == null) { return; } MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm(_currentAircraft, np); dlgResult = complainceForm.ShowDialog(this); } } else if (listViewCompliance.SelectedItems[0].Group == listViewCompliance.Groups["last"]) { if (listViewCompliance.SelectedItems[0].Tag is List <MaintenanceCheckRecord> ) { MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm(_currentAircraft, (List <MaintenanceCheckRecord>)listViewCompliance.SelectedItems[0].Tag); dlgResult = complainceForm.ShowDialog(this); } else if (listViewCompliance.SelectedItems[0].Tag is MaintenanceProgramChangeRecord) { List <MaintenanceCheckRecord> records = CheckItems.Where(c => c.Grouping) .SelectMany(c => c.PerformanceRecords) .ToList(); List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups = new List <MaintenanceCheckRecordGroup>(); foreach (MaintenanceCheckRecord record in records) { MaintenanceCheckRecordGroup recordGroup = maintenanceCheckRecordGroups .FirstOrDefault(g => g.Schedule == record.ParentCheck.Schedule && g.Grouping == record.ParentCheck.Grouping && g.Resource == record.ParentCheck.Resource && g.GroupComplianceNum == record.NumGroup); if (recordGroup != null) { //Коллекция найдена //Поиск в ней группы чеков с нужным типом recordGroup.Records.Add(record); } else { //Коллекции с нужными критериями нет //Созадние и добавление recordGroup = new MaintenanceCheckRecordGroup(record.ParentCheck.Schedule, record.ParentCheck.Grouping, record.ParentCheck.Resource, record.NumGroup); recordGroup.Records.Add(record); maintenanceCheckRecordGroups.Add(recordGroup); } } MaintenanceProgramChangeDialog complainceForm = new MaintenanceProgramChangeDialog((MaintenanceProgramChangeRecord)listViewCompliance.SelectedItems[0].Tag, maintenanceCheckRecordGroups); dlgResult = complainceForm.ShowDialog(this); } //MaintenanceComplainceForm complainceForm = new MaintenanceComplainceForm //{ // PerformanceRecords = ((List<MaintenanceCheckRecord>) // listViewCompliance.SelectedItems[0].Tag), // CurrentAircraft = this.CurentAircraft, // NumGroup = ((List<MaintenanceCheckRecord>) // listViewCompliance.SelectedItems[0].Tag)[0].NumGroup //}; // dlgResult = complainceForm.ShowDialog(this); } if (dlgResult == DialogResult.OK) { InvokeComplianceAdded(null); } }
/// <summary> /// Добавление директив в таблицу данных /// </summary> /// <param name="dataset">Таблица, в которую добавляются данные</param> protected virtual void AddDirectivesToDataSet(MaintenanceProgramDataSet dataset) { List <MaintenanceCheck> checks = new List <MaintenanceCheck>(_reportedDirectives.ToArray()); List <MaintenanceCheckGroupByType> groups = new List <MaintenanceCheckGroupByType>(); int groupId = 0; var v = from liminationItem in checks where liminationItem.Schedule == _filterSelection group liminationItem by liminationItem.CheckType.FullName into fileGroup orderby fileGroup.Key select fileGroup; foreach (IGrouping <string, MaintenanceCheck> grouping in v) { MaintenanceCheckGroupByType g = new MaintenanceCheckGroupByType(_filterSelection); groups.Add(g); foreach (MaintenanceCheck liminationItem in grouping) { g.Checks.Add(liminationItem); liminationItem.Tag = groupId; groupId++; } } groups.OrderBy(g => g.MinInterval()); int min, max, countGroups; for (int i = 0; i < groups.Count; i++) { if (_filterSelection) { min = groups[i].MinInterval(); max = i != groups.Count - 1 ? groups[i + 1].MinInterval() : groups[i].MaxInterval(); //Вычисление количества групп выполнения для данного типа чеков (A,B or C) countGroups = max / min; //Вычисление интервала выполнения для каждой группы выполнения //если интервал, на котором должен выполнится чек равени интервалу группы //то чек посещается в даннуб группу выполнения for (int j = 0; j < countGroups; j++) { int interval = min * (j + 1); foreach (MaintenanceCheck liminationItem in groups[i].Checks) { if (interval % liminationItem.Interval.Hours == 0) { dataset.ItemsTable.AddItemsTableRow(interval, (int)liminationItem.Tag, liminationItem.Name, "X"); } } if (i <= 0) { continue; } //Если просматривается не базовая группа (groups[0]) //то в набор данных должны быть включены все предыдущие группы чеков for (int k = 0; k < i; k++) { interval = min * (j + 1); int localInterval = k != groups.Count - 1 ? groups[k + 1].MinInterval() : groups[k].MaxInterval(); foreach (MaintenanceCheck liminationItem in groups[k].Checks) { if (localInterval % liminationItem.Interval.Hours == 0) { dataset.ItemsTable.AddItemsTableRow(interval, (int)liminationItem.Tag, liminationItem.Name, "X"); } else { dataset.ItemsTable.AddItemsTableRow(interval, (int)liminationItem.Tag, liminationItem.Name, "[X]"); } } } } } else { min = groups[i].MinInterval(); max = i != groups.Count - 1 ? groups[i + 1].MinInterval() : groups[i].MaxInterval(); //Вычисление количества групп выполнения для данного типа чеков (A,B or C) countGroups = max / min; //Вычисление интервала выполнения для каждой группы выполнения //если интервал, на котором должен выполнится чек равен интервалу группы //то чек посещается в данную группу выполнения for (int j = 0; j < countGroups; j++) { int interval = min * (j + 1); foreach (MaintenanceCheck liminationItem in groups[i].Checks) { if (interval % liminationItem.Interval.Days == 0) { dataset.ItemsTable.AddItemsTableRow(interval, (int)liminationItem.Tag, liminationItem.Name, "X"); } } if (i <= 0) { continue; } //Если просматривается не базовая группа (groups[0]) //то в набор данных должны быть включены все предыдущие группы чеков for (int k = 0; k < i; k++) { interval = min * (j + 1); int localInterval = k != groups.Count - 1 ? groups[k + 1].MinInterval() : groups[k].MaxInterval(); foreach (MaintenanceCheck liminationItem in groups[k].Checks) { if (localInterval % liminationItem.Interval.Days == 0) { dataset.ItemsTable.AddItemsTableRow(interval, (int)liminationItem.Tag, liminationItem.Name, "X"); } else { dataset.ItemsTable.AddItemsTableRow(interval, (int)liminationItem.Tag, liminationItem.Name, "[X]"); } } } } } } }