private void Check(IDirective directive, AbstractPerformanceRecord performance) { if (directive.PerformanceRecords.GetLast() != null) { if (directive.IsClosed && directive.PerformanceRecords.GetLast().RecordDate > performance.RecordDate) { throw new Exception("1629: Can not register performance after directive closing"); } } }
private void AddListViewItem(AbstractRecord record, string[] subs, WorkPackage workPackage) { Color foreColor = Color.Black; if (record is ActualStateRecord) { foreColor = Color.FromArgb(0, 122, 122, 122); } ListViewItem newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups[1], Tag = record, ForeColor = foreColor }; if (record is AbstractPerformanceRecord) { AbstractPerformanceRecord apr = (AbstractPerformanceRecord)record; if (workPackage != null) { //запись о выполнении блокируется найденым пакетом apr.DirectivePackage = workPackage; newItem.BackColor = Color.FromArgb(Highlight.Grey.Color); newItem.ToolTipText = "Perform of the task:" + apr.Parent + "\nadded by Work Package:" + "\n" + apr.DirectivePackage.Title + "\nTo remove a performance of task, you need to exclude task from this work package," + "\nor delete the work package "; } else if (apr is DirectiveRecord) { DirectiveRecord dr = apr as DirectiveRecord; if (dr.MaintenanceDirectiveRecordId > 0) { DirectiveRecord mdr = GlobalObjects.CasEnvironment.NewLoader.GetObjectById <DirectiveRecordDTO, DirectiveRecord>(dr.MaintenanceDirectiveRecordId); if (mdr != null && mdr.ParentType == SmartCoreType.MaintenanceDirective) { MaintenanceDirective md = GlobalObjects.MaintenanceCore.GetMaintenanceDirective(mdr.ParentId); if (md != null) { newItem.ToolTipText = "Perform of the task:" + dr.WorkType + "\nadded by MPD Item:" + "\n" + md.TaskNumberCheck; } } } } } //listViewCompliance.Items.Insert(index, newItem); listViewCompliance.Items.Add(newItem); }
private void AddListViewItem(AbstractPerformanceRecord apr, WorkPackage workPackage) { DirectiveRecord directiveRecord = (DirectiveRecord)apr; string workTypeString = ""; StaticDictionary workType; if (directiveRecord.Parent is MaintenanceDirective) { MaintenanceDirective parentDirective = (MaintenanceDirective)directiveRecord.Parent; workType = parentDirective.WorkType; workTypeString = parentDirective.WorkType.ToString(); } else if (directiveRecord.Parent is ComponentDirective) { ComponentDirective parentDirective = (ComponentDirective)directiveRecord.Parent; workType = parentDirective.DirectiveType; workTypeString = parentDirective.DirectiveType + " of " + parentDirective.ParentComponent.Description; } else { workType = MaintenanceDirectiveTaskType.Unknown; } string[] subs = new[] { workTypeString, UsefulMethods.NormalizeDate(directiveRecord.RecordDate), directiveRecord.OnLifelength != null ? directiveRecord.OnLifelength.ToString() : "", directiveRecord.Remarks, }; ListViewItem newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups[1], Tag = directiveRecord }; if (workPackage != null) { //запись о выполнении блокируется найденым пакетом apr.DirectivePackage = workPackage; newItem.BackColor = Color.FromArgb(Highlight.Grey.Color); newItem.ToolTipText = "Perform of the task:" + workType + "\nadded by Work Package:" + "\n" + directiveRecord.DirectivePackage.Title + "\nTo remove a performance of task, you need to exclude task from this work package," + "\nor delete the work package "; } listViewCompliance.Items.Add(newItem); }
private void AddListViewItem(AbstractPerformanceRecord apr, WorkPackage workPackage, MaintenanceCheckRecord mcr) { DirectiveRecord directiveRecord = (DirectiveRecord)apr; MaintenanceDirective parentDirective = (MaintenanceDirective)directiveRecord.Parent; string[] subs = new[] { parentDirective.WorkType.ToString(), UsefulMethods.NormalizeDate(directiveRecord.RecordDate), directiveRecord.OnLifelength != null ? directiveRecord.OnLifelength.ToString() : "", "", "", directiveRecord.Remarks, }; ListViewItem newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups[1], Tag = directiveRecord }; if (workPackage != null) { //запись о выполнении блокируется найденым пакетом apr.DirectivePackage = workPackage; newItem.BackColor = Color.FromArgb(Highlight.Grey.Color); newItem.ToolTipText = "Perform of the task:" + parentDirective.WorkType + "\nadded by Work Package:" + "\n" + directiveRecord.DirectivePackage.Title + "\nTo remove a performance of task, you need to exclude task from this work package," + "\nor delete the work package "; } else if (directiveRecord.MaintenanceCheckRecordId > 0 && mcr != null && mcr.ParentCheck != null) { MaintenanceCheck mc = mcr.ParentCheck; directiveRecord.MaintenanceCheck = mc; newItem.BackColor = Color.FromArgb(Highlight.Grey.Color); newItem.ToolTipText = "Perform of the task:" + parentDirective.WorkType + "\nadded by Maintenance Check:" + "\n" + mc.Name + "\nTo remove a performance of task, you need to delete performance of maintenance check"; } listViewCompliance.Items.Add(newItem); }
/// <summary> /// Выполняет группировку элементов /// </summary> //protected override void SetGroupsToItems(int columnIndex) // { // itemsListView.Groups.Clear(); // foreach (var item in ListViewItemList) // { // var temp = ListViewGroupHelper.GetGroupString(item.Tag); // itemsListView.Groups.Add(temp, temp); // item.Group = itemsListView.Groups[temp]; // } // } #endregion #region protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(BaseSmartCoreObject item) protected override List <CustomCell> GetListViewSubItems(BaseEntityObject item) { var subItems = new List <CustomCell>(); //if(item.ItemId == 41043) //{ //} if (item is NextPerformance) { NextPerformance np = (NextPerformance)item; double manHours = np.Parent is IEngineeringDirective ? ((IEngineeringDirective)np.Parent).ManHours : 0; double cost = np.Parent is IEngineeringDirective ? ((IEngineeringDirective)np.Parent).Cost : 0; var author = GlobalObjects.CasEnvironment.GetCorrector(item); subItems.Add(CreateRow(np.ATAChapter.ToString(), np.ATAChapter)); subItems.Add(CreateRow(np.Title, np.Title)); subItems.Add(CreateRow(np.Description, np.Description)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = np.KitsToString, Tag = np.Kits.Count }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = np.PerformanceSource.ToString(), Tag = np.PerformanceSource }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = np.Parent.Threshold.RepeatInterval.ToString(), Tag = np.Parent.Threshold.RepeatInterval }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = np.Remains.ToString(), Tag = np.Remains }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = np.WorkType, Tag = np.WorkType }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = np.PerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)np.PerformanceDate), Tag = np.PerformanceDate }); subItems.Add(CreateRow(manHours.ToString(), manHours)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = np.Parent.Cost.ToString(), Tag = np.Parent.Cost }); subItems.Add(CreateRow(author, author)); } else if (item is AbstractPerformanceRecord) { //DirectiveRecord directiveRecord = (DirectiveRecord)item; AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; Lifelength remains = Lifelength.Null; double manHours = apr.Parent is IEngineeringDirective ? ((IEngineeringDirective)apr.Parent).ManHours : 0; double cost = apr.Parent is IEngineeringDirective ? ((IEngineeringDirective)apr.Parent).Cost : 0; subItems.Add(CreateRow(apr.ATAChapter.ToString(), apr.ATAChapter)); subItems.Add(CreateRow(apr.Title, apr.Title)); subItems.Add(CreateRow(apr.Description, apr.Description)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.KitsToString, Tag = apr.Kits.Count }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.OnLifelength.ToString(), Tag = apr.OnLifelength }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.Parent.Threshold.RepeatInterval.ToString(), Tag = apr.Parent.Threshold.RepeatInterval }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = remains.ToString(), Tag = remains }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.WorkType, Tag = apr.WorkType }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = SmartCore.Auxiliary.Convert.GetDateFormat(apr.RecordDate), Tag = apr.RecordDate }); subItems.Add(CreateRow(manHours.ToString(), manHours)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.Parent.Cost.ToString(), Tag = apr.Parent.Cost }); } else if (item is Directive) { Directive directive = (Directive)item; AtaChapter ata = directive.ATAChapter; subItems.Add(CreateRow(ata.ToString(), Tag = ata)); subItems.Add(CreateRow(directive.Title, directive.Title)); subItems.Add(CreateRow(directive.Description, directive.Description)); #region Определение текста для колонки "КИТы" //subItems.Add(new ListViewItem.ListViewSubItem //{ // Text = directive.Kits.Count > 0 ? directive.Kits.Count + " kits" : "", // Tag = directive.Kits.Count //}); #endregion #region Определение текста для колонки "Первое выполнение" //ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(); //if (directive.Threshold.FirstPerformanceSinceNew != null && !directive.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) //{ // subItem.Text = "s/n: " + directive.Threshold.FirstPerformanceSinceNew; // subItem.Tag = directive.Threshold.FirstPerformanceSinceNew; //} //if (directive.Threshold.FirstPerformanceSinceEffectiveDate != null && // !directive.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) //{ // if (subItem.Text != "") subItem.Text += " or "; // else // { // subItem.Text = ""; // subItem.Tag = directive.Threshold.FirstPerformanceSinceEffectiveDate; // } // subItem.Text += "s/e.d: " + directive.Threshold.FirstPerformanceSinceEffectiveDate; //} //subItems.Add(subItem); #endregion #region Определение текста для колонки "повторяющийся интервал" //subItem = new ListViewItem.ListViewSubItem(); //if (!directive.Threshold.RepeatInterval.IsNullOrZero()) //{ // subItem.Text = directive.Threshold.RepeatInterval.ToString(); // subItem.Tag = directive.Threshold.RepeatInterval; //} //else //{ // subItem.Text = ""; // subItem.Tag = Lifelength.Null; //} //subItems.Add(subItem); #endregion #region Определение текста для колонки "Остаток/Просрочено на сегодня" //subItems.Add(new ListViewItem.ListViewSubItem //{ // Text = directive.Remains.ToString(), // Tag = directive.Remains //}); #endregion #region Определение текста для колонки "Тип работ" //subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.WorkType.ToString(), Tag = directive.WorkType }); #endregion #region Определение текста для колонки "Следующее выполнение" //subItems.Add(new ListViewItem.ListViewSubItem //{ // Text = directive.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)directive.NextPerformanceDate), // Tag = directive.NextPerformanceDate //}); #endregion #region Определение текста для колонки "Человек/Часы" subItems.Add(CreateRow(directive.ManHours.ToString(), directive.ManHours)); #endregion #region Определение текста для колонки "Стоимость" //subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.Cost.ToString(), Tag = directive.Cost }); #endregion } else if (item is BaseComponent) { BaseComponent bd = (BaseComponent)item; AtaChapter ata = bd.ATAChapter; subItems.Add(CreateRow(ata.ToString(), ata)); subItems.Add(CreateRow(bd.PartNumber, bd.PartNumber)); subItems.Add(CreateRow(bd.Description, bd.Description)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.Kits.Count > 0 ? bd.Kits.Count + " kits" : "", Tag = bd.Kits.Count }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.LifeLimit.ToString(), Tag = bd.LifeLimit }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.Remains.ToString(), Tag = bd.Remains }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = DetailRecordType.Removal.ToString(), Tag = DetailRecordType.Removal }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)bd.NextPerformanceDate), Tag = bd.NextPerformanceDate }); subItems.Add(CreateRow(bd.ManHours.ToString(), bd.ManHours)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.Cost.ToString(), Tag = bd.Cost }); } else if (item is Component) { Component d = (Component)item; AtaChapter ata = d.ATAChapter; subItems.Add(CreateRow(ata.ToString(), ata)); subItems.Add(CreateRow(d.PartNumber, d.PartNumber)); subItems.Add(CreateRow(d.Description, d.Description)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = d.Kits.Count > 0 ? d.Kits.Count + " kits" : "", Tag = d.Kits.Count }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = d.LifeLimit != null ? d.LifeLimit.ToString() : "", Tag = d.LifeLimit }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = d.Remains != null ? d.Remains.ToString() : "", Tag = d.Remains }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = DetailRecordType.Removal.ToString(), Tag = DetailRecordType.Removal }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = d.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)d.NextPerformanceDate), Tag = d.NextPerformanceDate }); subItems.Add(CreateRow(d.ManHours.ToString(), d.ManHours)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = d.Cost.ToString(), Tag = d.Cost }); } else if (item is ComponentDirective) { ComponentDirective dd = (ComponentDirective)item; AtaChapter ata = dd.ParentComponent.ATAChapter; subItems.Add(CreateRow(ata != null ? ata.ToString() : "", ata)); subItems.Add(CreateRow("", "")); subItems.Add(CreateRow(dd.Remarks, dd.Remarks)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.Kits.Count > 0 ? dd.Kits.Count + " kits" : "", Tag = dd.Kits.Count }); #region Определение текста для колонки "Первое выполнение" //ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(); //if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) //{ // subItem.Text = "s/n: " + dd.Threshold.FirstPerformanceSinceNew; // subItem.Tag = dd.Threshold.FirstPerformanceSinceNew; //} //subItems.Add(subItem); #endregion #region Определение текста для колонки "повторяющийся интервал" //subItem = new ListViewItem.ListViewSubItem(); //if (!dd.Threshold.RepeatInterval.IsNullOrZero()) //{ // subItem.Text = dd.Threshold.RepeatInterval.ToString(); // subItem.Tag = dd.Threshold.RepeatInterval; //} //else //{ // subItem.Text = ""; // subItem.Tag = Lifelength.Null; //} //subItems.Add(subItem); #endregion //subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.Remains.ToString(), Tag = dd.Remains }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.DirectiveType.ToString(), Tag = dd.DirectiveType }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)dd.NextPerformanceDate), Tag = dd.NextPerformanceDate }); subItems.Add(CreateRow(dd.ManHours.ToString(), dd.ManHours)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.Cost.ToString(), Tag = dd.Cost }); } else if (item is MaintenanceCheck) { MaintenanceCheck mc = (MaintenanceCheck)item; subItems.Add(CreateRow("", null)); subItems.Add(CreateRow("", Tag = "")); subItems.Add(CreateRow(mc.Name + (mc.Schedule ? " Shedule" : " Unshedule"), mc.Name)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Kits.Count > 0 ? mc.Kits.Count + " kits" : "", Tag = mc.Kits.Count }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Interval.ToString(), Tag = mc.Interval }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Remains.ToString(), Tag = mc.Remains }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)mc.NextPerformanceDate), Tag = mc.NextPerformanceDate }); subItems.Add(CreateRow(mc.ManHours.ToString(), mc.ManHours)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Cost.ToString(), Tag = mc.Cost }); } else if (item is MaintenanceDirective) { MaintenanceDirective md = (MaintenanceDirective)item; AtaChapter ata = md.ATAChapter; subItems.Add(CreateRow(ata != null ? ata.ToString() : "", ata)); subItems.Add(CreateRow(md.ToString(), md.ToString())); subItems.Add(CreateRow(md.Description, md.Description)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = md.Kits.Count > 0 ? md.Kits.Count + " kits" : "", Tag = md.Kits.Count }); #region Определение текста для колонки "Первое выполнение" //ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(); //if (md.Threshold.FirstPerformanceSinceNew != null && !md.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) //{ // subItem.Text = "s/n: " + md.Threshold.FirstPerformanceSinceNew; // subItem.Tag = md.Threshold.FirstPerformanceSinceNew; //} //if (md.Threshold.FirstPerformanceSinceEffectiveDate != null && // !md.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) //{ // if (subItem.Text != "") subItem.Text += " or "; // else // { // subItem.Text = ""; // subItem.Tag = md.Threshold.FirstPerformanceSinceEffectiveDate; // } // subItem.Text += "s/e.d: " + md.Threshold.FirstPerformanceSinceEffectiveDate; //} //subItems.Add(subItem); #endregion #region Определение текста для колонки "повторяющийся интервал" //subItem = new ListViewItem.ListViewSubItem(); //if (!md.Threshold.RepeatInterval.IsNullOrZero()) //{ // subItem.Text = md.Threshold.RepeatInterval.ToString(); // subItem.Tag = md.Threshold.RepeatInterval; //} //else //{ // subItem.Text = ""; // subItem.Tag = Lifelength.Null; //} //subItems.Add(subItem); #endregion //subItems.Add(new ListViewItem.ListViewSubItem { Text = md.Remains.ToString(), Tag = md.Remains }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = md.WorkType.ToString(), Tag = md.WorkType }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = md.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)md.NextPerformanceDate), Tag = md.NextPerformanceDate }); subItems.Add(CreateRow(md.ManHours.ToString(), md.ManHours)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = md.Cost.ToString(), Tag = md.Cost }); } else if (item is NonRoutineJob) { NonRoutineJob job = (NonRoutineJob)item; AtaChapter ata = job.ATAChapter; subItems.Add(CreateRow(ata != null ? ata.ToString() : "", ata)); subItems.Add(CreateRow(job.Title, job.Title)); subItems.Add(CreateRow(job.Description, job.Description)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = job.Kits.Count > 0 ? job.Kits.Count + " kits" : "", Tag = job.Kits.Count }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); //subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = new DateTime(1950,1,1) }); subItems.Add(CreateRow(job.ManHours.ToString(), job.ManHours)); //subItems.Add(new ListViewItem.ListViewSubItem { Text = job.Cost.ToString(), Tag = job.Cost }); } else { throw new ArgumentOutOfRangeException($"1135: Takes an argument has no known type {item.GetType()}"); } return(subItems); }
/// <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); } } } } }
protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(BaseEntityObject item) { List <ListViewItem.ListViewSubItem> subItems = new List <ListViewItem.ListViewSubItem>(); //if(item.ItemId == 41043) //{ //} if (item is NextPerformance) { NextPerformance np = (NextPerformance)item; double manHours = np.Parent is IEngineeringDirective ? ((IEngineeringDirective)np.Parent).ManHours : 0; double cost = np.Parent is IEngineeringDirective ? ((IEngineeringDirective)np.Parent).Cost : 0; subItems.Add(new ListViewItem.ListViewSubItem { Text = np.ATAChapter.ToString(), Tag = np.ATAChapter }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.Title, Tag = np.Title }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.Description, Tag = np.Description }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.Type, Tag = np.Type }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.KitsToString, Tag = np.Kits.Count }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.PerformanceSource.ToString(), Tag = np.PerformanceSource }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.Parent.Threshold.RepeatInterval.ToString(), Tag = np.Parent.Threshold.RepeatInterval }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.Remains.ToString(), Tag = np.Remains }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.WorkType, Tag = np.WorkType }); subItems.Add(new ListViewItem.ListViewSubItem { Text = np.PerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)np.PerformanceDate), Tag = np.PerformanceDate }); subItems.Add(new ListViewItem.ListViewSubItem { Text = manHours.ToString(), Tag = manHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = cost.ToString(), Tag = cost }); } else if (item is AbstractPerformanceRecord) { AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; Lifelength remains = Lifelength.Null; double manHours = apr.Parent is IEngineeringDirective ? ((IEngineeringDirective)apr.Parent).ManHours : 0; double cost = apr.Parent is IEngineeringDirective ? ((IEngineeringDirective)apr.Parent).Cost : 0; subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.ATAChapter.ToString(), Tag = apr.ATAChapter }); subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.Title, Tag = apr.Title }); subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.Description, Tag = apr.Description }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.KitsToString, Tag = apr.Kits.Count }); subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.OnLifelength.ToString(), Tag = apr.OnLifelength }); subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.Parent.Threshold.RepeatInterval.ToString(), Tag = apr.Parent.Threshold.RepeatInterval }); subItems.Add(new ListViewItem.ListViewSubItem { Text = remains.ToString(), Tag = remains }); subItems.Add(new ListViewItem.ListViewSubItem { Text = apr.WorkType, Tag = apr.WorkType }); subItems.Add(new ListViewItem.ListViewSubItem { Text = SmartCore.Auxiliary.Convert.GetDateFormat(apr.RecordDate), Tag = apr.RecordDate }); subItems.Add(new ListViewItem.ListViewSubItem { Text = manHours.ToString(), Tag = manHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = cost.ToString(), Tag = cost }); } else if (item is Directive) { Directive directive = (Directive)item; AtaChapter ata = directive.ATAChapter; DirectiveType pdType = directive.DirectiveType; subItems.Add(new ListViewItem.ListViewSubItem { Text = ata.ToString(), Tag = ata }); subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.Title, Tag = directive.Title }); subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.Description, Tag = directive.Description }); subItems.Add(new ListViewItem.ListViewSubItem { Text = pdType.ShortName, Tag = pdType.ShortName }); #region Определение текста для колонки "КИТы" subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.Kits.Count > 0 ? directive.Kits.Count + " kits" : "", Tag = directive.Kits.Count }); #endregion #region Определение текста для колонки "Первое выполнение" ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(); if (directive.Threshold.FirstPerformanceSinceNew != null && !directive.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { subItem.Text = "s/n: " + directive.Threshold.FirstPerformanceSinceNew; subItem.Tag = directive.Threshold.FirstPerformanceSinceNew; } if (directive.Threshold.FirstPerformanceSinceEffectiveDate != null && !directive.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (subItem.Text != "") { subItem.Text += " or "; } else { subItem.Text = ""; subItem.Tag = directive.Threshold.FirstPerformanceSinceEffectiveDate; } subItem.Text += "s/e.d: " + directive.Threshold.FirstPerformanceSinceEffectiveDate; } subItems.Add(subItem); #endregion #region Определение текста для колонки "повторяющийся интервал" subItem = new ListViewItem.ListViewSubItem(); if (!directive.Threshold.RepeatInterval.IsNullOrZero()) { subItem.Text = directive.Threshold.RepeatInterval.ToString(); subItem.Tag = directive.Threshold.RepeatInterval; } else { subItem.Text = ""; subItem.Tag = Lifelength.Null; } subItems.Add(subItem); #endregion #region Определение текста для колонки "Остаток/Просрочено на сегодня" subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.Remains.ToString(), Tag = directive.Remains }); #endregion #region Определение текста для колонки "Тип работ" subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.WorkType.ToString(), Tag = directive.WorkType }); #endregion #region Определение текста для колонки "Следующее выполнение" subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)directive.NextPerformanceDate), Tag = directive.NextPerformanceDate }); #endregion #region Определение текста для колонки "Человек/Часы" subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.ManHours.ToString(), Tag = directive.ManHours }); #endregion #region Определение текста для колонки "Стоимость" subItems.Add(new ListViewItem.ListViewSubItem { Text = directive.Cost.ToString(), Tag = directive.Cost }); #endregion } else if (item is BaseComponent) { BaseComponent bd = (BaseComponent)item; AtaChapter ata = bd.ATAChapter; subItems.Add(new ListViewItem.ListViewSubItem { Text = ata.ToString(), Tag = ata }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.PartNumber, Tag = bd.PartNumber }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.Description, Tag = bd.Description }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.MaintenanceControlProcess.ShortName, Tag = bd.MaintenanceControlProcess.ShortName }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.Kits.Count > 0 ? bd.Kits.Count + " kits" : "", Tag = bd.Kits.Count }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.LifeLimit.ToString(), Tag = bd.LifeLimit }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.Remains.ToString(), Tag = bd.Remains }); subItems.Add(new ListViewItem.ListViewSubItem { Text = ComponentRecordType.Remove.ToString(), Tag = ComponentRecordType.Remove }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)bd.NextPerformanceDate), Tag = bd.NextPerformanceDate }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.ManHours.ToString(), Tag = bd.ManHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = bd.Cost.ToString(), Tag = bd.Cost }); } else if (item is Component) { Component d = (Component)item; AtaChapter ata = d.ATAChapter; subItems.Add(new ListViewItem.ListViewSubItem { Text = ata.ToString(), Tag = ata }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.PartNumber, Tag = d.PartNumber }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.Description, Tag = d.Description }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.MaintenanceControlProcess.ShortName, Tag = d.MaintenanceControlProcess.ShortName }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.Kits.Count > 0 ? d.Kits.Count + " kits" : "", Tag = d.Kits.Count }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.LifeLimit != null ? d.LifeLimit.ToString() : "", Tag = d.LifeLimit }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.Remains != null ? d.Remains.ToString() : "", Tag = d.Remains }); subItems.Add(new ListViewItem.ListViewSubItem { Text = ComponentRecordType.Remove.ToString(), Tag = ComponentRecordType.Remove }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)d.NextPerformanceDate), Tag = d.NextPerformanceDate }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.ManHours.ToString(), Tag = d.ManHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = d.Cost.ToString(), Tag = d.Cost }); } else if (item is ComponentDirective) { ComponentDirective dd = (ComponentDirective)item; AtaChapter ata = dd.ParentComponent.ATAChapter; subItems.Add(new ListViewItem.ListViewSubItem { Text = ata != null ? ata.ToString() : "", Tag = ata }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.Remarks, Tag = dd.Remarks }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.Kits.Count > 0 ? dd.Kits.Count + " kits" : "", Tag = dd.Kits.Count }); #region Определение текста для колонки "Первое выполнение" ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(); if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { subItem.Text = "s/n: " + dd.Threshold.FirstPerformanceSinceNew; subItem.Tag = dd.Threshold.FirstPerformanceSinceNew; } subItems.Add(subItem); #endregion #region Определение текста для колонки "повторяющийся интервал" subItem = new ListViewItem.ListViewSubItem(); if (!dd.Threshold.RepeatInterval.IsNullOrZero()) { subItem.Text = dd.Threshold.RepeatInterval.ToString(); subItem.Tag = dd.Threshold.RepeatInterval; } else { subItem.Text = ""; subItem.Tag = Lifelength.Null; } subItems.Add(subItem); #endregion subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.Remains.ToString(), Tag = dd.Remains }); subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.DirectiveType.ToString(), Tag = dd.DirectiveType }); subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)dd.NextPerformanceDate), Tag = dd.NextPerformanceDate }); subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.ManHours.ToString(), Tag = dd.ManHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = dd.Cost.ToString(), Tag = dd.Cost }); } else if (item is MaintenanceCheck) { MaintenanceCheck mc = (MaintenanceCheck)item; subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = null }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Name + (mc.Schedule ? " Shedule" : " Unshedule"), Tag = mc.Name }); subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Name, Tag = mc.Name }); subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Kits.Count > 0 ? mc.Kits.Count + " kits" : "", Tag = mc.Kits.Count }); subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Interval.ToString(), Tag = mc.Interval }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Remains.ToString(), Tag = mc.Remains }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)mc.NextPerformanceDate), Tag = mc.NextPerformanceDate }); subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.ManHours.ToString(), Tag = mc.ManHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = mc.Cost.ToString(), Tag = mc.Cost }); } else if (item is MaintenanceDirective) { MaintenanceDirective md = (MaintenanceDirective)item; AtaChapter ata = md.ATAChapter; string type = md.MaintenanceCheck != null ? md.MaintenanceCheck.Name : "MPD"; subItems.Add(new ListViewItem.ListViewSubItem { Text = ata != null ? ata.ToString() : "", Tag = ata }); subItems.Add(new ListViewItem.ListViewSubItem { Text = md.TaskNumberCheck, Tag = md.TaskNumberCheck }); subItems.Add(new ListViewItem.ListViewSubItem { Text = md.Description, Tag = md.Description, }); subItems.Add(new ListViewItem.ListViewSubItem { Text = type, Tag = type, }); subItems.Add(new ListViewItem.ListViewSubItem { Text = md.Kits.Count > 0 ? md.Kits.Count + " kits" : "", Tag = md.Kits.Count }); #region Определение текста для колонки "Первое выполнение" ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem(); if (md.Threshold.FirstPerformanceSinceNew != null && !md.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { subItem.Text = "s/n: " + md.Threshold.FirstPerformanceSinceNew; subItem.Tag = md.Threshold.FirstPerformanceSinceNew; } if (md.Threshold.FirstPerformanceSinceEffectiveDate != null && !md.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (subItem.Text != "") { subItem.Text += " or "; } else { subItem.Text = ""; subItem.Tag = md.Threshold.FirstPerformanceSinceEffectiveDate; } subItem.Text += "s/e.d: " + md.Threshold.FirstPerformanceSinceEffectiveDate; } subItems.Add(subItem); #endregion #region Определение текста для колонки "повторяющийся интервал" subItem = new ListViewItem.ListViewSubItem(); if (!md.Threshold.RepeatInterval.IsNullOrZero()) { subItem.Text = md.Threshold.RepeatInterval.ToString(); subItem.Tag = md.Threshold.RepeatInterval; } else { subItem.Text = ""; subItem.Tag = Lifelength.Null; } subItems.Add(subItem); #endregion subItems.Add(new ListViewItem.ListViewSubItem { Text = md.Remains.ToString(), Tag = md.Remains }); subItems.Add(new ListViewItem.ListViewSubItem { Text = md.MaintenanceCheck?.ToString(), Tag = md.MaintenanceCheck }); subItems.Add(new ListViewItem.ListViewSubItem { Text = md.WorkType.ToString(), Tag = md.WorkType }); subItems.Add(new ListViewItem.ListViewSubItem { Text = md.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)md.NextPerformanceDate), Tag = md.NextPerformanceDate }); subItems.Add(new ListViewItem.ListViewSubItem { Text = md.ManHours.ToString(), Tag = md.ManHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = md.Cost.ToString(), Tag = md.Cost }); } else if (item is NonRoutineJob) { NonRoutineJob job = (NonRoutineJob)item; AtaChapter ata = job.ATAChapter; subItems.Add(new ListViewItem.ListViewSubItem { Text = ata != null ? ata.ToString() : "", Tag = ata }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); subItems.Add(new ListViewItem.ListViewSubItem { Text = job.Description, Tag = job.Description }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "NRC", Tag = "NRC" }); subItems.Add(new ListViewItem.ListViewSubItem { Text = job.Kits.Count > 0 ? job.Kits.Count + " kits" : "", Tag = job.Kits.Count }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = Lifelength.Null }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = "" }); subItems.Add(new ListViewItem.ListViewSubItem { Text = "", Tag = DateTimeExtend.GetCASMinDateTime() }); subItems.Add(new ListViewItem.ListViewSubItem { Text = job.ManHours.ToString(), Tag = job.ManHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = job.Cost.ToString(), Tag = job.Cost }); } else { throw new ArgumentOutOfRangeException($"1135: Takes an argument has no known type {item.GetType()}"); } return(subItems.ToArray()); }
protected override void SetItemColor(ListViewItem listViewItem, BaseEntityObject item) { if (item is NextPerformance) { NextPerformance nextPerformance = item as NextPerformance; if (nextPerformance.BlockedByPackage != null) { listViewItem.ToolTipText = "This performance blocked by work package:" + nextPerformance.BlockedByPackage.Title; listViewItem.BackColor = Color.FromArgb(Highlight.Grey.Color); } else if (nextPerformance.Condition == ConditionState.Notify) { listViewItem.BackColor = Color.FromArgb(Highlight.Yellow.Color); } else if (nextPerformance.Condition == ConditionState.Overdue) { listViewItem.BackColor = Color.FromArgb(Highlight.Red.Color); } if (nextPerformance.Parent.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом listViewItem.ForeColor = Color.Gray; if (listViewItem.ToolTipText.Trim() != "") { listViewItem.ToolTipText += "\n"; } listViewItem.ToolTipText += $"This {nextPerformance.Parent.SmartCoreObjectType} is deleted"; } } else if (item is AbstractPerformanceRecord) { AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; if (apr.Parent.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом listViewItem.ForeColor = Color.Gray; if (listViewItem.ToolTipText.Trim() != "") { listViewItem.ToolTipText += "\n"; } listViewItem.ToolTipText += $"This {apr.Parent.SmartCoreObjectType} is deleted"; } } else { if (!(item is NonRoutineJob) && !(item is IDirective)) { //Если это не следующее выполнение, не запись о выполнении, и не рутинная работа //значит, выполнение для данной задачи расчитать нельзя //пометка этого выполнения синим цветом listViewItem.BackColor = Color.FromArgb(Highlight.Blue.Color); //подсказка о том, что выполнение не возможео расчитать listViewItem.ToolTipText = "Performance for this directive can not be calculated"; } else { base.SetItemColor(listViewItem, item); } if (item.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом listViewItem.ForeColor = Color.Gray; if (listViewItem.ToolTipText.Trim() != "") { listViewItem.ToolTipText += "\n"; } listViewItem.ToolTipText += $"This {item.SmartCoreObjectType} is deleted"; } } }
protected override void SetRowBackColor(DataGridViewRow dataGridViewRow, BaseEntityObject item) { if (item is NextPerformance) { NextPerformance nextPerformance = item as NextPerformance; if (_currentWorkPackage.Status != WorkPackageStatus.Closed) { if (nextPerformance.BlockedByPackage != null) { dataGridViewRow.Cells[0].ToolTipText = "This performance blocked by work package:" + nextPerformance.BlockedByPackage.Title; dataGridViewRow.DefaultCellStyle.BackColor = Color.FromArgb(Highlight.Grey.Color); } else if (nextPerformance.Condition == ConditionState.Notify) { dataGridViewRow.DefaultCellStyle.BackColor = Color.FromArgb(Highlight.Yellow.Color); } else if (nextPerformance.Condition == ConditionState.Overdue) { dataGridViewRow.DefaultCellStyle.BackColor = Color.FromArgb(Highlight.Red.Color); } } else { //Если это следующее выполнение, но рабочий пакет при этом закрыт //значит, выполнение для данной задачи в рамках данного рабочего пакета //не было введено //пометка этого выполнения краным цветом dataGridViewRow.DefaultCellStyle.BackColor = Color.FromArgb(Highlight.Red.Color); //подсказка о том, что выполнение не было введено dataGridViewRow.Cells[0].ToolTipText = "Performance for this directive within this work package is not entered."; if (nextPerformance.BlockedByPackage != null) { //дополнитльная подсказака, если предшествующее выполнение //имеется в другом открытом рабочем пакете dataGridViewRow.Cells[0].ToolTipText += "\nThis performance blocked by work package:" + nextPerformance.BlockedByPackage.Title + "\nFirst, enter the performance of this directive as part of this work package "; } } if (nextPerformance.Parent.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом dataGridViewRow.DefaultCellStyle.ForeColor = Color.Gray; if (dataGridViewRow.Cells[0].ToolTipText.Trim() != "") { dataGridViewRow.Cells[0].ToolTipText += "\n"; } dataGridViewRow.Cells[0].ToolTipText += $"This {nextPerformance.Parent.SmartCoreObjectType} is deleted"; } } else if (item is AbstractPerformanceRecord) { AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; if (apr.Parent.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом dataGridViewRow.DefaultCellStyle.ForeColor = Color.Gray; if (dataGridViewRow.Cells[0].ToolTipText.Trim() != "") { dataGridViewRow.Cells[0].ToolTipText += "\n"; } dataGridViewRow.Cells[0].ToolTipText += $"This {apr.Parent.SmartCoreObjectType} is deleted"; } } else { if (!(item is NonRoutineJob)) { //Если это не следующее выполнение, не запись о выполнении, и не рутинная работа //значит, выполнение для данной задачи расчитать нельзя //пометка этого выполнения синим цветом dataGridViewRow.DefaultCellStyle.BackColor = Color.FromArgb(Highlight.Blue.Color); //подсказка о том, что выполнение не возможео расчитать dataGridViewRow.Cells[0].ToolTipText = "Performance for this directive can not be calculated"; } if (item.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом dataGridViewRow.DefaultCellStyle.ForeColor = Color.Gray; if (dataGridViewRow.Cells[0].ToolTipText.Trim() != "") { dataGridViewRow.Cells[0].ToolTipText += "\n"; } dataGridViewRow.Cells[0].ToolTipText += $"This {item.SmartCoreObjectType} is deleted"; } } }
protected override void SetItemColor(GridViewRowInfo listViewItem, BaseEntityObject item) { if (item is NextPerformance) { NextPerformance nextPerformance = item as NextPerformance; if (_currentDirective.Status != WorkPackageStatus.Closed) { var color = radGridView1.BackColor; if (nextPerformance.BlockedByPackage != null) { color = Color.FromArgb(Highlight.Grey.Color); } else if (nextPerformance.Condition == ConditionState.Notify) { color = Color.FromArgb(Highlight.Yellow.Color); } else if (nextPerformance.Condition == ConditionState.Overdue) { color = Color.FromArgb(Highlight.Red.Color); } foreach (GridViewCellInfo cell in listViewItem.Cells) { cell.Style.CustomizeFill = true; cell.Style.BackColor = color; } } else { //Если это следующее выполнение, но рабочий пакет при этом закрыт //значит, выполнение для данной задачи в рамках данного рабочего пакета //не было введено //пометка этого выполнения краным цветом foreach (GridViewCellInfo cell in listViewItem.Cells) { cell.Style.CustomizeFill = true; cell.Style.BackColor = Color.FromArgb(Highlight.Red.Color); } } if (nextPerformance.Parent.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом foreach (GridViewCellInfo cell in listViewItem.Cells) { cell.Style.CustomizeFill = true; cell.Style.ForeColor = Color.Gray; } } } else if (item is AbstractPerformanceRecord) { AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; if (apr.Parent.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом foreach (GridViewCellInfo cell in listViewItem.Cells) { cell.Style.CustomizeFill = true; cell.Style.ForeColor = Color.Gray; } } } else { if (!(item is NonRoutineJob)) { //Если это не следующее выполнение, не запись о выполнении, и не рутинная работа //значит, выполнение для данной задачи расчитать нельзя //пометка этого выполнения синим цветом foreach (GridViewCellInfo cell in listViewItem.Cells) { cell.Style.CustomizeFill = true; cell.Style.BackColor = Color.FromArgb(Highlight.Blue.Color); } } if (item.IsDeleted) { foreach (GridViewCellInfo cell in listViewItem.Cells) { cell.Style.CustomizeFill = true; cell.Style.ForeColor = Color.Gray; } } } }
protected override void SetRowBackColor(TreeDataGridViewRow treeDataGridViewRow, BaseEntityObject item) { if (item == null) { return; } if (item is NextPerformance) { NextPerformance nextPerformance = item as NextPerformance; if (nextPerformance.Parent.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом treeDataGridViewRow.DefaultCellStyle.ForeColor = Color.Gray; if (treeDataGridViewRow.Cells[0].ToolTipText.Trim() != "") { treeDataGridViewRow.Cells[0].ToolTipText += "\n"; } treeDataGridViewRow.Cells[0].ToolTipText += $"This {nextPerformance.Parent.SmartCoreObjectType} is deleted"; } } else if (item is AbstractPerformanceRecord) { AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; if (apr.Parent.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом treeDataGridViewRow.DefaultCellStyle.ForeColor = Color.Gray; if (treeDataGridViewRow.Cells[0].ToolTipText.Trim() != "") { treeDataGridViewRow.Cells[0].ToolTipText += "\n"; } treeDataGridViewRow.Cells[0].ToolTipText += $"This {apr.Parent.SmartCoreObjectType} is deleted"; } } else { if (!(item is NonRoutineJob)) { //Если это не следующее выполнение, не запись о выполнении, и не рутинная работа //значит, выполнение для данной задачи расчитать нельзя //пометка этого выполнения синим цветом treeDataGridViewRow.DefaultCellStyle.BackColor = Color.FromArgb(Highlight.Blue.Color); //подсказка о том, что выполнение не возможео расчитать treeDataGridViewRow.Cells[0].ToolTipText = "Performance for this directive can not be calculated"; } if (item.IsDeleted) { //запись так же может быть удаленной //шрифт серым цветом treeDataGridViewRow.DefaultCellStyle.ForeColor = Color.Gray; if (treeDataGridViewRow.Cells[0].ToolTipText.Trim() != "") { treeDataGridViewRow.Cells[0].ToolTipText += "\n"; } treeDataGridViewRow.Cells[0].ToolTipText += $"This {item.SmartCoreObjectType} is deleted"; } } }
protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(BaseEntityObject item) { List <ListViewItem.ListViewSubItem> subItems = new List <ListViewItem.ListViewSubItem> (); AtaChapter ataChapter = null; string title = ""; string description = ""; //string zone = ""; //string access = ""; //string taskType = ""; //MaintenanceDirectiveProgramType program = MaintenanceDirectiveProgramType.Unknown; //StaticDictionary workType = null; //string phase = ""; double manHours = 0; //int mans = 0; //string categories = ""; double cost = 0, costServiceable = 0, costOverhaul = 0; string kits = ""; //Lifelength performance = Lifelength.Null; //Lifelength repeat = Lifelength.Null; //Lifelength remain = Lifelength.Null; //DateTime? performanceDate = null; if (item is NextPerformance) { NextPerformance np = (NextPerformance)item; IEngineeringDirective engineeringDirective = np.Parent as IEngineeringDirective; if (engineeringDirective != null) { ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; //program = engineeringDirective.Program; //workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; //mans = engineeringDirective.Mans; //categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; } title = np.Title; description = np.Description; //taskType = np.Parent.SmartCoreObjectType.ToString(); kits = np.KitsToString; //performance = np.PerformanceSource; //repeat = np.Parent.Threshold != null ? np.Parent.Threshold.RepeatInterval : Lifelength.Null; //remain = np.Remains; //performanceDate = np.PerformanceDate; } else if (item is AbstractPerformanceRecord) { //DirectiveRecord directiveRecord = (DirectiveRecord)item; AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; IEngineeringDirective engineeringDirective = apr.Parent as IEngineeringDirective; if (engineeringDirective != null) { ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; //program = engineeringDirective.Program; //workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; //mans = engineeringDirective.Mans; //categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; } title = apr.Title; description = apr.Description; //taskType = apr.Parent.SmartCoreObjectType.ToString(); kits = apr.KitsToString; //performance = apr.OnLifelength; //repeat = apr.Parent.Threshold != null ? apr.Parent.Threshold.RepeatInterval : Lifelength.Null; //performanceDate = apr.RecordDate; } else if (item is IEngineeringDirective) { IEngineeringDirective engineeringDirective = item as IEngineeringDirective; ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; //program = engineeringDirective.Program; //workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; //mans = engineeringDirective.Mans; //categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; title = engineeringDirective.Title; description = engineeringDirective.Description; //taskType = engineeringDirective.SmartCoreObjectType.ToString(); kits = engineeringDirective is IKitRequired ? ((IKitRequired)engineeringDirective).Kits.ToString() : ""; //performance = engineeringDirective.NextPerformanceSource; //repeat = engineeringDirective.Threshold != null ? engineeringDirective.Threshold.RepeatInterval : Lifelength.Null; //performanceDate = engineeringDirective.NextPerformanceDate; if (engineeringDirective is Component) { Component d = engineeringDirective as Component; costServiceable = d.CostServiceable; costOverhaul = d.CostOverhaul; } } subItems.Add(new ListViewItem.ListViewSubItem { Text = ataChapter != null ? ataChapter.ToString() : "", Tag = ataChapter }); subItems.Add(new ListViewItem.ListViewSubItem { Text = title, Tag = title }); subItems.Add(new ListViewItem.ListViewSubItem { Text = description, Tag = description }); subItems.Add(new ListViewItem.ListViewSubItem { Text = kits, Tag = kits }); subItems.Add(new ListViewItem.ListViewSubItem { Text = manHours.ToString(), Tag = manHours }); subItems.Add(new ListViewItem.ListViewSubItem { Text = cost.ToString(), Tag = cost }); subItems.Add(new ListViewItem.ListViewSubItem { Text = costServiceable.ToString(), Tag = costServiceable }); subItems.Add(new ListViewItem.ListViewSubItem { Text = costOverhaul.ToString(), Tag = costOverhaul }); return(subItems.ToArray()); }
public void RegisterPerformance(IDirective directive, AbstractPerformanceRecord performance, IDirectivePackage directivePackage = null, bool registerPerformanceForBindedItems = true) { if ((directive is Entities.General.Accessory.Component)) { Check((Entities.General.Accessory.Component)directive, (TransferRecord)performance); } else { Check(directive, performance); } // Не можем добавить выполнение для не существующей директивы if (directive.ItemId <= 0) { throw new Exception("1033: Can not register performance for not existing directive"); } // Дополняем необходимые данные performance.ParentId = directive.ItemId; // Выставляем родителя записи о выполнении performance.Parent = directive; if (directivePackage != null) { performance.DirectivePackageId = directivePackage.ItemId; performance.AttachedFile = directivePackage.AttachedFile; } _newKeeper.Save(performance); if (directive.PerformanceRecords.GetItemById(performance.ItemId) == null) { directive.PerformanceRecords.Add(performance); } if (directive is Entities.General.Accessory.Component) { var component = directive as Entities.General.Accessory.Component; var transferRecord = performance as TransferRecord; //выставление нового родителя if (transferRecord.DestinationObjectType == SmartCoreType.Aircraft) { component.ParentAircraftId = transferRecord.DestinationObjectId; } if (component.IsBaseComponent) { //обнуление мат аппарата для этой базовой детали _calculator.ResetMath((BaseComponent)component); } } if (!registerPerformanceForBindedItems) { return; } if (directive is MaintenanceDirective) { var mpd = directive as MaintenanceDirective; CreateAndSavePerformanceForBindedItems(mpd, performance); } else if (directive is ComponentDirective) { var dd = directive as ComponentDirective; var dr = performance as DirectiveRecord; CreateAndSavePerformanceForBindedItems(dd, dr); } }
///<summary> ///</summary> private void UpdateInformation() { if (_currentAudit == null) { return; } Text = _currentAudit.Title; dataGridViewItems.Rows.Clear(); DateTime minComplianceDate = DateTimeExtend.GetCASMinDateTime(); IEnumerable <AuditRecord> proceduresRecords = _currentAudit.AuditRecords.Where(wpr => wpr.Task != null && wpr.Task is Procedure); List <IGrouping <string, AuditRecord> > groupedDirectiveWprs = proceduresRecords.GroupBy(wpr => (((Procedure)wpr.Task).ProcedureType).FullName).ToList(); checkBoxSelectAll.CheckedChanged -= CheckBoxSelectAllCheckedChanged; foreach (IGrouping <string, AuditRecord> grouping in groupedDirectiveWprs) { //добавить расчеты ComlianceDate foreach (AuditRecord item in grouping) { if (item.Task is Procedure || item.Task is Directive || item.Task is ComponentDirective || item.Task is MaintenanceCheck || item.Task is MaintenanceDirective) { //WorkPackageClosingDataGridViewRow r = new WorkPackageClosingDataGridViewRow(); //r.CreateCells(dataGridViewItems); //int index = dataGridViewItems.Rows.Add(r); //index.ToString(); WorkPackageClosingDataGridViewRow r = (WorkPackageClosingDataGridViewRow) dataGridViewItems.Rows[dataGridViewItems.Rows.Add(new WorkPackageClosingDataGridViewRow())]; if (item.Task.NextPerformances.Count > 0) { SetValues(r, _currentAudit, item.Task.NextPerformances[0]); } else if (item.Task.PerformanceRecords.Cast <AbstractPerformanceRecord>().Any(pr => pr.DirectivePackageId == _currentAudit.ItemId)) { AbstractPerformanceRecord apr = item.Task.PerformanceRecords .Cast <AbstractPerformanceRecord>() .First(pr => pr.DirectivePackageId == _currentAudit.ItemId); SetValues(r, _currentAudit, apr); } else { SetValues(r, _currentAudit, item); } } if (item.Task is Component) { //WorkPackageClosingDataGridViewRow r = new WorkPackageClosingDataGridViewRow(); //r.CreateCells(dataGridViewItems); //dataGridViewItems.Rows.Add(r); WorkPackageClosingDataGridViewRow r = (WorkPackageClosingDataGridViewRow) dataGridViewItems.Rows[dataGridViewItems.Rows.Add(new WorkPackageClosingDataGridViewRow())]; Component component = (Component)item.Task; if (component.NextPerformances.Count > 0) { SetValues(r, _currentAudit, component.NextPerformances[0]); } else if (component.TransferRecords.Any(pr => pr.DirectivePackageId == _currentAudit.ItemId)) { AbstractPerformanceRecord apr = component.TransferRecords .Cast <AbstractPerformanceRecord>() .First(pr => pr.DirectivePackageId == _currentAudit.ItemId); SetValues(r, _currentAudit, apr); } else { SetValues(r, _currentAudit, item); } } } } dateTimePickerClosingDate.ValueChanged -= DateTimePickerClosingDateValueChanged; dateTimePickerClosingDate.Value = _currentAudit.Status != WorkPackageStatus.Closed ? minComplianceDate : _currentAudit.ClosingDate; dateTimePickerClosingDate.MinDate = _currentAudit.MinClosingDate != null ? _currentAudit.MinClosingDate.Value : DateTimeExtend.GetCASMinDateTime(); dateTimePickerClosingDate.MaxDate = _currentAudit.MaxClosingDate != null ? _currentAudit.MaxClosingDate.Value : DateTimeExtend.GetCASMinDateTime(); dateTimePickerClosingDate.ValueChanged += DateTimePickerClosingDateValueChanged; checkBoxSelectAll.CheckedChanged += CheckBoxSelectAllCheckedChanged; fileControl.AttachedFile = _currentAudit.AttachedFile; }
/// <summary> /// Добавить выполнение работы к задаче /// </summary> /// <param name="performance"></param> /// <param name="saveAttachedFile"></param> public void Save(AbstractPerformanceRecord performance, bool saveAttachedFile = true) { if (performance == null) { return; } var type = AuditOperation.Created; if (performance.ItemId > 0) { type = AuditOperation.Changed; } performance.CorrectorId = _casEnvironment.IdentityUser.ItemId; _casEnvironment.Keeper.Save(performance, saveAttachedFile); _auditRepository.WriteAsync(performance, type, _casEnvironment.IdentityUser); if (performance.Parent.PerformanceRecords.GetItemById(performance.ItemId) == null) { performance.Parent.PerformanceRecords.Add(performance); } if (performance.Parent is MaintenanceDirective) { DirectiveRecord ddr = _casEnvironment.NewLoader.GetObjectListAll <DirectiveRecordDTO, DirectiveRecord>(new Filter("MaintenanceDirectiveRecordId", performance.ItemId)).FirstOrDefault(); if (ddr != null) { ComponentDirective dd = _casEnvironment.NewLoader.GetObject <ComponentDirectiveDTO, ComponentDirective>(new Filter("ItemId", ddr.ParentId)); if (dd != null) { BaseComponent bd = _componentCore.GetBaseComponentById(dd.ComponentId); if (bd != null) { ddr.OnLifelength = _casEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(bd, performance.RecordDate); } else { General.Accessory.Component d = _componentCore.GetComponentById(dd.ComponentId); if (d != null) { ddr.OnLifelength = _casEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(d, performance.RecordDate); } } } ddr.RecordDate = performance.RecordDate; _casEnvironment.NewKeeper.Save(ddr, saveAttachedFile); } } else if (performance.Parent is ComponentDirective) { DirectiveRecord ddr = performance as DirectiveRecord; if (ddr != null) { DirectiveRecord mpdRecord = _casEnvironment.NewLoader.GetObject <DirectiveRecordDTO, DirectiveRecord>(new Filter("ItemId", ddr.MaintenanceDirectiveRecordId)); if (mpdRecord != null) { MaintenanceDirective md = _maintenanceCore.GetMaintenanceDirective(mpdRecord.ParentId); if (md != null) { mpdRecord.OnLifelength = _casEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(md.ParentBaseComponent, ddr.RecordDate); } mpdRecord.RecordDate = ddr.RecordDate; _casEnvironment.NewKeeper.Save(mpdRecord, saveAttachedFile); } } } }
private void SetValues(WorkPackageClosingDataGridViewRow row, Audit wp, AbstractPerformanceRecord apr) { row.WorkPackage = wp; row.Record = apr; if (apr != null) { row.ClosingItem = apr.Parent; } if (row.ClosingItem == null || apr == null) { return; } SetLabelsAndText(row); if (apr is DirectiveRecord || apr is MaintenanceCheckRecord) { row.Cells[ColumnClosed.Index].Value = true; //Lifelength performanceSource = apr.OnLifelength; //row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null ? performanceSource.Hours.ToString() : "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"; row.Cells[ColumnDate.Index].Value = apr.RecordDate; row.PrevPerfDate = apr.PrevPerformanceDate; row.NextPerfDate = apr.NextPerformanceDate; } else if (apr is TransferRecord) { TransferRecord tr = (TransferRecord)apr; if (tr.ItemId > 0) { //если запись о перемещении имеет itemID > 0 //и она не подтвержддена стороной получателя, то ее можно редактировать и удалять //если подтверждена, то редактировать и удалять ее нельзя if (tr.DODR) { row.Cells[ColumnHours.Index].ReadOnly = false; row.PrevPerfDate = tr.PrevPerformanceDate; row.NextPerfDate = tr.TransferDate; } else { row.Cells[ColumnHours.Index].ReadOnly = true; row.PrevPerfDate = tr.PrevPerformanceDate; row.NextPerfDate = tr.NextPerformanceDate; } row.Cells[ColumnCycles.Index].Value = "Transfer to: " + GetDestination(tr); row.Cells[ColumnDate.Index].Value = tr.StartTransferDate; } else { row.Cells[ColumnCycles.Index].Value = "Transfer to: "; row.PrevPerfDate = apr.PrevPerformanceDate; row.NextPerfDate = apr.NextPerformanceDate; } row.Cells[ColumnClosed.Index].Value = true; } DataGridViewCalendarCell cc = row.Cells[ColumnDate.Index] as DataGridViewCalendarCell; if (cc != null) { if (row.PrevPerfDate != null) { cc.MinDate = (DateTime)row.PrevPerfDate; } else { cc.MinDate = DateTimeExtend.GetCASMinDateTime(); } if (row.NextPerfDate != null) { cc.MaxDate = (DateTime)row.NextPerfDate; } else { cc.MaxDate = DateTime.Now; } } row.MinPerfSource = apr.PrevPerformanceSource.IsNullOrZero() ? Lifelength.Zero : apr.PrevPerformanceSource; row.MaxPerfSource = apr.NextPerformanceSource.IsNullOrZero() //TODO:(Evgenii Babak) пересмотреть подход, наработка считается на конец дня, а в метод передаем DateTime.Now(может быть и концом дня) ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(row.ClosingItem.LifeLengthParent, DateTime.Now) : apr.NextPerformanceSource; }
private void SetWorkTimeGA(BaseComponent powerUnit, FlightRegime flightRegime) { if (powerUnit == null) { return; } List <PowerUnitTimeInRegimeControlItem> fcs = flowLayoutPanelMain.Controls .OfType <PowerUnitTimeInRegimeControlItem>() .Where(c => c.PowerUnit != null && c.PowerUnit.ItemId == powerUnit.ItemId && c.FlightRegime == flightRegime) .ToList(); int t = fcs.Sum(cr => cr.WorkTime); Lifelength baseDetailLifeLenghtInRegimeSinceLastOverhaul = null; Lifelength baseDetailLifeLenghtSinceLastOverhaul = null; Lifelength baseDetailOhInterval = null; Lifelength baseDetailLifeLenghtInRegimeSinceNew = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate, flightRegime); Lifelength baseDetailLifeLenghtSinceNew = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate); Lifelength baseDetailLifeLimit = powerUnit.LifeLimit; ComponentWorkInRegimeParams inRegimeParams = powerUnit.ComponentWorkParams.Where(p => p.FlightRegime == flightRegime).FirstOrDefault(); if (inRegimeParams != null && inRegimeParams.ResorceProvider == SmartCoreType.ComponentDirective && powerUnit.ComponentDirectives.GetItemById(inRegimeParams.ResorceProviderId) != null) { //в парамтрах работы требуется расчитать время работы в режиме с //последнего выполнения директивы ComponentDirective dd = powerUnit.ComponentDirectives.GetItemById(inRegimeParams.ResorceProviderId); if (dd.LastPerformance == null) { baseDetailOhInterval = dd.Threshold.FirstPerformanceSinceNew; //если последнего выполнения директивы нет, //то расчитывается полная работа агрегата в указанном режиме baseDetailLifeLenghtInRegimeSinceLastOverhaul = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate, flightRegime); baseDetailLifeLenghtSinceLastOverhaul = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate); } else { baseDetailOhInterval = dd.Threshold.RepeatInterval; //т.к. может просматриваться старый полет (н: месячной давности) //производится поиск последней записи о выполнении перед текущим полетов AbstractPerformanceRecord r = dd.PerformanceRecords.GetLastKnownRecord(_flightDate); if (r != null) { baseDetailLifeLenghtInRegimeSinceLastOverhaul = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthForPeriod(powerUnit, r.RecordDate, _flightDate.AddHours(-1), flightRegime); baseDetailLifeLenghtSinceLastOverhaul = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthForPeriod(powerUnit, r.RecordDate, _flightDate.AddHours(-1));//TODO:(Evgenii Babak) выяснить почему AddHours(-1) } } } if (Flight.AircraftId <= 0) { //извлечение всех полетов ВС var flights = GlobalObjects.AircraftFlightsCore.GetAircraftFlightsOnDate(Flight.AircraftId, _flightDate); //И поиск всех полетов, что были раньше текущего foreach (AircraftFlight aircraftFlight in flights) { //Если полет был раньше текущего, то его наработка добавляется //к рассчитываемым ресурсам базового агрегата if (aircraftFlight.FlightDate < _flightDate.Date.Add(_outTime.TimeOfDay)) { baseDetailLifeLenghtInRegimeSinceNew.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit, flightRegime)); baseDetailLifeLenghtSinceNew.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit)); if (baseDetailLifeLenghtInRegimeSinceLastOverhaul == null) { continue; } baseDetailLifeLenghtInRegimeSinceLastOverhaul.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit, flightRegime)); if (baseDetailLifeLenghtSinceLastOverhaul == null) { continue; } baseDetailLifeLenghtSinceLastOverhaul.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit)); } } } baseDetailLifeLenghtInRegimeSinceNew.Add(LifelengthSubResource.Minutes, t); if (baseDetailLifeLenghtInRegimeSinceLastOverhaul != null) { baseDetailLifeLenghtInRegimeSinceLastOverhaul.Add(LifelengthSubResource.Minutes, t); } double persentSN = 0, persentLifeLimit = 0, persentSLO = 0, persentOhInt = 0; int? resInRegimeSN = baseDetailLifeLenghtInRegimeSinceNew.GetSubresource(LifelengthSubResource.Minutes); int? resSN = baseDetailLifeLenghtSinceNew.GetSubresource(LifelengthSubResource.Minutes); int? resLl = baseDetailLifeLimit.GetSubresource(LifelengthSubResource.Minutes); if (resSN != null && resInRegimeSN != null && resSN > 0) { persentSN = Convert.ToDouble((double)resInRegimeSN * 100 / resSN); } if (resLl != null && resInRegimeSN != null && resLl > 0) { persentLifeLimit = Convert.ToDouble((double)resInRegimeSN * 100 / resLl); } if (baseDetailLifeLenghtInRegimeSinceLastOverhaul != null) { int?resInRegimeSLO = baseDetailLifeLenghtInRegimeSinceLastOverhaul.GetSubresource(LifelengthSubResource.Minutes); if (baseDetailLifeLenghtSinceLastOverhaul != null) { int?resSLO = baseDetailLifeLenghtSinceLastOverhaul.GetSubresource(LifelengthSubResource.Minutes); if (resSLO != null && resInRegimeSLO != null && resSLO > 0) { persentSLO = Convert.ToDouble((double)resInRegimeSLO * 100 / resSLO); } } if (baseDetailOhInterval != null) { int?resOhInt = baseDetailOhInterval.GetSubresource(LifelengthSubResource.Minutes); if (resOhInt != null && resInRegimeSLO != null && resOhInt > 0) { persentOhInt = Convert.ToDouble((double)resInRegimeSLO * 100 / resOhInt); } } } foreach (PowerUnitTimeInRegimeControlItem fc in fcs) { fc.WorkTimeGA = t; fc.WorkTimeSinceNew = baseDetailLifeLenghtInRegimeSinceNew; fc.WorkTimeSLO = baseDetailLifeLenghtInRegimeSinceLastOverhaul; fc.PersentSN = persentSN; fc.PersentLifeLimit = persentLifeLimit; fc.PersentSLO = persentSLO; fc.PersentOhInt = persentOhInt; } }
protected override void SetRowCellsValues(DataGridViewRow row, BaseEntityObject item) { AtaChapter ataChapter = null; string title = ""; string description = ""; //string zone = ""; //string access = ""; string taskType = ""; MaintenanceDirectiveProgramType program = MaintenanceDirectiveProgramType.Unknown; StaticDictionary workType = null; //string phase = ""; double manHours = 0; int mans = 0; string categories = ""; double cost = 0; string kits = ""; //Lifelength performance = Lifelength.Null; //Lifelength repeat = Lifelength.Null; //Lifelength remain = Lifelength.Null; //DateTime? performanceDate = null; if (item is NextPerformance) { NextPerformance np = (NextPerformance)item; IEngineeringDirective engineeringDirective = np.Parent as IEngineeringDirective; if (engineeringDirective != null) { ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; program = engineeringDirective.Program; workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; mans = engineeringDirective.Mans; categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; } title = np.Title; description = np.Description; taskType = np.Parent.SmartCoreObjectType.ToString(); kits = np.KitsToString; //performance = np.PerformanceSource; //repeat = np.Parent.Threshold != null ? np.Parent.Threshold.RepeatInterval : Lifelength.Null; //remain = np.Remains; //performanceDate = np.PerformanceDate; } else if (item is AbstractPerformanceRecord) { //DirectiveRecord directiveRecord = (DirectiveRecord)item; AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; IEngineeringDirective engineeringDirective = apr.Parent as IEngineeringDirective; if (engineeringDirective != null) { ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; program = engineeringDirective.Program; workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; mans = engineeringDirective.Mans; categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; } title = apr.Title; description = apr.Description; taskType = apr.Parent.SmartCoreObjectType.ToString(); kits = apr.KitsToString; //performance = apr.OnLifelength; //repeat = apr.Parent.Threshold != null ? apr.Parent.Threshold.RepeatInterval : Lifelength.Null; //performanceDate = apr.RecordDate; } else if (item is IEngineeringDirective) { IEngineeringDirective engineeringDirective = item as IEngineeringDirective; ataChapter = engineeringDirective.ATAChapter; //zone = engineeringDirective.Zone; //access = engineeringDirective.Access; program = engineeringDirective.Program; workType = engineeringDirective.WorkType; //phase = engineeringDirective.Phase; manHours = engineeringDirective.ManHours; mans = engineeringDirective.Mans; categories = engineeringDirective.CategoriesRecords.Aggregate("", (current, i) => current + (i.AircraftWorkerCategory + "; ")); cost = engineeringDirective.Cost; title = engineeringDirective.Title; description = engineeringDirective.Description; taskType = engineeringDirective.SmartCoreObjectType.ToString(); kits = engineeringDirective is IKitRequired ? ((IKitRequired)engineeringDirective).Kits.ToString() : ""; //performance = engineeringDirective.NextPerformanceSource; //repeat = engineeringDirective.Threshold != null ? engineeringDirective.Threshold.RepeatInterval : Lifelength.Null; //performanceDate = engineeringDirective.NextPerformanceDate; } //if (performance == null) // performance = Lifelength.Null; //if (repeat == null) // repeat = Lifelength.Null; //if (remain == null) // remain = Lifelength.Null; row.Cells[0].Value = ataChapter != null?ataChapter.ToString() : ""; row.Cells[0].Tag = ataChapter; row.Cells[1].Value = title; row.Cells[1].Tag = title; row.Cells[2].Value = description; row.Cells[2].Tag = description; //row.Cells[3].Value = zone; //row.Cells[3].Tag = zone; //row.Cells[4].Value = access; //row.Cells[4].Tag = access; row.Cells[3].Value = taskType; row.Cells[3].Tag = taskType; row.Cells[4].Value = program.ToString(); row.Cells[4].Tag = program; row.Cells[5].Value = workType != null?workType.ToString() : DirectiveType.Unknown.ToString(); row.Cells[5].Tag = workType != null?workType.ToString() : DirectiveType.Unknown.ToString(); //row.Cells[8].Value = phase; //row.Cells[8].Tag = phase; row.Cells[6].Value = manHours.ToString(); row.Cells[6].Tag = manHours; row.Cells[7].Value = mans.ToString(); row.Cells[7].Tag = mans; row.Cells[8].Value = categories; row.Cells[8].Tag = categories; row.Cells[9].Value = cost.ToString(); row.Cells[9].Tag = cost; row.Cells[10].Value = kits; row.Cells[10].Tag = kits; //row.Cells[14].Value = performance.ToString(); //row.Cells[14].Tag = performance; //row.Cells[15].Value = repeat.ToString(); //row.Cells[15].Tag = repeat; //row.Cells[16].Value = remain.ToString(); //row.Cells[16].Tag = remain.ToString(); //row.Cells[17].Value = performanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)performanceDate); //row.Cells[17].Tag = performanceDate; }
private void CreateAndSavePerformanceForBindedItems(MaintenanceDirective mpd, AbstractPerformanceRecord performance) { var bindedItems = _bindedItemsCore.GetBindedItemsFor(mpd.ParentBaseComponent.ParentAircraftId, mpd); foreach (var bindedItem in bindedItems) { if (bindedItem is ComponentDirective) { var componentDirective = (ComponentDirective)bindedItem; var newPerformance = new DirectiveRecord(performance) { MaintenanceDirectiveRecordId = performance.ItemId, Parent = componentDirective, //TODO:(Evgenii Babak) Выяснить почему при создании записи берем наработку на начало дня, но в отчетах, для записей о выполнении пересчитываем наработку, и выводим наработку на конец дня OnLifelength = _calculator.GetFlightLifelengthOnStartOfDay(componentDirective.ParentComponent, performance.RecordDate), ParentId = componentDirective.ItemId }; _newKeeper.Save(newPerformance, false); } } }