/// <summary> /// /// </summary> private void GetRecordInstance(WorkPackageClosingDataGridViewRow row, Audit wp, NextPerformance nextPerformance = null, AuditRecord workPackageRecord = null) { if (row.ClosingItem == null) { return; } IDirective currentClosingItem = row.ClosingItem; if (currentClosingItem is Procedure) { row.Record = new DirectiveRecord(); } if (nextPerformance != null) { row.Record.PerformanceNum = nextPerformance.PerformanceNum; } if (workPackageRecord != null) { row.Record.PerformanceNum = workPackageRecord.PerformanceNumFromStart; } row.Record.Parent = currentClosingItem; row.Record.ParentId = currentClosingItem.ItemId; row.Record.DirectivePackageId = wp.ItemId; }
protected override void AddListViewItem(NextPerformance np) { Directive d = np.Parent as Directive; string[] subs = new[] { np.WorkType + (d == null ? "" : " §:" + d.Paragraph), np.PerformanceDate != null ? SmartCore.Auxiliary.Convert.GetDateFormat(np.PerformanceDate) : "N/A", np.PerformanceSource.ToString(), np?.NextLimit.Days != null?SmartCore.Auxiliary.Convert.GetDateFormat(np?.NextPerformanceDateNew) : "", np.NextLimit.ToString(), "", }; ListViewItem newItem = new ListViewItem(subs) { BackColor = UsefulMethods.GetColor(np), Group = listViewCompliance.Groups[0], Tag = np, }; listViewCompliance.Items.Add(newItem); }
protected virtual void AddListViewItem(NextPerformance np) { string[] subs = new[] { np.WorkType, np.PerformanceDate != null ? SmartCore.Auxiliary.Convert.GetDateFormat(np.PerformanceDate) : "N/A", np.PerformanceSource.ToString(), np.PerformanceSourceC.ToString(), np?.NextLimit.Days != null?SmartCore.Auxiliary.Convert.GetDateFormat(np?.NextPerformanceDateNew) : "", np.NextLimit.ToString(), np.NextLimitC.ToString(), "", }; ListViewItem newItem = new ListViewItem(subs) { BackColor = UsefulMethods.GetColor(np), Group = listViewCompliance.Groups[0], Tag = np, }; listViewCompliance.Items.Add(newItem); }
protected override void AddListViewItem(NextPerformance np) { string[] subs = new[] { np.WorkType, np.PerformanceDate != null ? SmartCore.Auxiliary.Convert.GetDateFormat(np.PerformanceDate) : "N/A", np.PerformanceSource.ToString(), np?.NextLimit.Days != null?SmartCore.Auxiliary.Convert.GetDateFormat(np?.NextPerformanceDateNew) : "", np.NextLimit.ToString(), "", }; ListViewItem newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups[0], Tag = np, }; newItem.BackColor = _currentDirective.MaintenanceCheck != null ? Color.FromArgb(Highlight.Grey.Color) : UsefulMethods.GetColor(np); listViewCompliance.Items.Add(newItem); }
/// <summary> /// Возвращает дату-время "след. выполнения" задачи /// </summary> /// <param name="destination"></param> /// <returns></returns> protected DateTime GetDate(NextPerformance destination) { if (destination.PerformanceDate.HasValue) { return(destination.PerformanceDate.Value); } return(DateTimeExtend.GetCASMinDateTime()); }
///<summary> ///</summary> ///<param name="currentDirective"></param> ///<param name="nextPerformance"></param> public DirectiveComplianceDialog(IDirective currentDirective, NextPerformance nextPerformance) : this() { _currentDirective = currentDirective; _currentDirectiveRecord = DirectiveRecord.CreateInstance(nextPerformance); _nextPerformance = nextPerformance; _animatedThreadWorker.DoWork += AnimatedThreadWorkerDoLoad; _animatedThreadWorker.RunWorkerCompleted += BackgroundWorkerRunWorkerLoadCompleted; }
/// <summary> /// Создает запись без дополнительной информации /// </summary> public InitialOrderRecord(int rfqId, Product accessory, double quantity, BaseEntityObject parent, DateTime effDate, ComponentStatus costCondition, NextPerformance perfornamce = null, DeferredCategory category = null) : this() { ParentPackageId = rfqId; if (accessory != null) { ProductId = accessory.ItemId; ProductType = accessory.SmartCoreObjectType; EffectiveDate = effDate; DeferredCategory = category ?? DeferredCategory.Unknown; CostCondition = costCondition; _quantity = quantity; if (perfornamce != null) { Task = perfornamce.Parent; PackageItemId = perfornamce.Parent.ItemId; PackageItemType = perfornamce.Parent.SmartCoreObjectType; PerformanceNumFromStart = perfornamce.PerformanceNum; IsSchedule = true; } if (DeferredCategory != DeferredCategory.Unknown && DeferredCategory.Threshold != null) { LifeLimit = DeferredCategory.Threshold.FirstPerformanceSinceEffectiveDate; LifeLimitNotify = DeferredCategory.Threshold.FirstNotification; IsSchedule = false; } if (parent != null && !parent.SmartCoreObjectType.Equals(SmartCoreType.Operator)) { DestinationObject = parent; DestinationObjectType = parent.SmartCoreObjectType; DestinationObjectId = parent.ItemId; } } else { PackageItemId = -1; EffectiveDate = DateTime.Today; costCondition = ComponentStatus.Unknown; PackageItemType = SmartCoreType.Unknown; DeferredCategory = DeferredCategory.Unknown; _quantity = 0; Task = null; ProductId = -1; ProductType = SmartCoreType.Unknown; PerformanceNumFromStart = -1; IsSchedule = false; } }
/// <summary> /// </summary> /// <param name="currentDirective"></param> /// <param name="nextPerformances"></param> /// <param name="averageUtilization"></param> /// <param name="nextPerformance"></param> public DirectiveComplianceDialog(IDirective currentDirective, List <NextPerformance> nextPerformances, AverageUtilization averageUtilization) : this() { _currentDirective = currentDirective; _currentDirectiveRecord = DirectiveRecord.CreateInstance(nextPerformances.FirstOrDefault()); _nextPerformance = nextPerformances.FirstOrDefault(); _nextPerformances = nextPerformances; _averageUtilization = averageUtilization; checkBox1.Visible = true; _animatedThreadWorker.DoWork += AnimatedThreadWorkerDoLoad; _animatedThreadWorker.RunWorkerCompleted += BackgroundWorkerRunWorkerLoadCompleted; }
/// <summary> /// Создает новый зкземпляр записи о выполнении на основе след.выполнения /// </summary> /// <param name="nextPerformance"></param> /// <returns></returns> public static DirectiveRecord CreateInstance(NextPerformance nextPerformance) { DirectiveRecord dr = new DirectiveRecord(); if (nextPerformance == null) { return(dr); } //дата выполнения if (nextPerformance.PerformanceDate.HasValue) { dr.RecordDate = nextPerformance.PerformanceDate.Value; } //номер выполнения dr.PerformanceNum = nextPerformance.PerformanceNum; return(dr); }
protected override void AddListViewItem(NextPerformance np) { string[] subs = new[] { np.WorkType, np.PerformanceDate != null ? UsefulMethods.NormalizeDate((DateTime)np.PerformanceDate) : "N/A", np.PerformanceSource.ToString(), "", }; ListViewItem newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups[0], Tag = np, }; listViewCompliance.Items.Add(newItem); }
/// <summary> /// Создает форму для редактирования записей о выполнении чека /// </summary> /// <param name="currentAircraft">ВС, которому пренадлежит чек</param> /// <param name="nextPerformance">Выполнение чека</param> public MaintenanceComplainceForm(Aircraft currentAircraft, NextPerformance nextPerformance) : this() { if (currentAircraft == null) { throw new ArgumentNullException("currentAircraft", "must be not null"); } if (nextPerformance == null) { throw new ArgumentNullException("nextPerformance", "must be not null"); } _currentAircraft = currentAircraft; _numGroup = nextPerformance.PerformanceNum; _currentChecks = new List <MaintenanceCheck> { nextPerformance.Parent as MaintenanceCheck }; _animatedThreadWorker.DoWork += AnimatedThreadWorkerDoLoadForChecks; _animatedThreadWorker.RunWorkerCompleted += AnimatedThreadWorkerDoLoadForChecksCompleted; }
private void CloseWorkPackage() { IEnumerable <AuditRecord> blockedRecords = _currentDirective.AuditRecords .Where(rec => rec.Task != null && rec.Task.NextPerformances != null && rec.Task.NextPerformances.Count > 0 && rec.Task.NextPerformances.Any(np => np.BlockedByPackage != null && np.BlockedByPackage.ItemId != _currentDirective.ItemId)); if (_currentDirective.CanClose == false || blockedRecords.Any()) { string message = "This audit can not be closed"; foreach (AuditRecord blockedRecord in blockedRecords) { NextPerformance np = blockedRecord.Task.NextPerformances.First(n => n.BlockedByPackage != null); message += $"\nTask: {blockedRecord.Task} blocked by audit {np.BlockedByPackage}"; } if (_currentDirective.MaxClosingDate < _currentDirective.MinClosingDate) { message += $"\nMin Closing Date: {_currentDirective.MinClosingDate} better than Max Closing Date: {_currentDirective.MaxClosingDate}"; } MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AuditClosingFormNew form = new AuditClosingFormNew(_currentDirective); form.ShowDialog(); if (form.DialogResult == DialogResult.OK) { AnimatedThreadWorker.RunWorkerAsync(); } }
private string GetParent(NextPerformance np) { IBaseEntityObject parent = np.Parent; var destination = ""; if (parent is Directive) { var dir = (Directive)parent; destination = GetDestination(dir.ParentBaseComponent.ParentAircraftId, dir.ParentBaseComponent.ParentStoreId); } else if (parent is Component) { var d = (Component)parent; destination = GetDestination(d.ParentBaseComponent.ParentAircraftId, d.ParentStoreId); } else if (parent is ComponentDirective) { var dd = (ComponentDirective)parent; if (dd.ParentComponent != null) { destination = GetDestination(dd.ParentBaseComponent.ParentAircraftId, dd.ParentBaseComponent.ParentAircraftId); } } else if (parent is MaintenanceCheck) { var mc = (MaintenanceCheck)parent; destination = $"{mc.ParentAircraft.RegistrationNumber} {mc.ParentAircraft.Model}";//TODO:(Evgenii Babak) заменить на использование AircraftCore } else if (parent is MaintenanceDirective) { var md = (MaintenanceDirective)parent; destination = GetDestination(md.ParentBaseComponent.ParentAircraftId, md.ParentBaseComponent.ParentStoreId); } return(destination); }
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"; } } }
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); } }
private void SetValues(WorkPackageClosingDataGridViewRow row, Audit wp, NextPerformance nextPerformance) { row.WorkPackage = wp; row.NextPerformance = nextPerformance; if (row.NextPerformance != null) { row.ClosingItem = nextPerformance.Parent; } GetRecordInstance(row, wp, nextPerformance); SetLabelsAndText(row); if (row.ClosingItem == null) { return; } if (row.ClosingItem.IsClosed) { DataGridViewCell cell = row.Cells[ColumnClosed.Index]; cell.Value = false; cell.ReadOnly = true; cell.Style.BackColor = Color.DimGray; cell.ToolTipText = "This item is closed and can't be perform"; SetCellReadOnly(row, new[] { ColumnClosed.Index, ColumnHours.Index, ColumnCycles.Index, ColumnDays.Index, ColumnDate.Index }, false); } if (nextPerformance == null) { return; } row.PrevPerfDate = nextPerformance.PrevPerformanceDate; row.NextPerfDate = nextPerformance.NextPerformanceDate; row.MinPerfSource = nextPerformance.PrevPerformanceSource.IsNullOrZero() ? Lifelength.Zero : nextPerformance.PrevPerformanceSource; row.MaxPerfSource = nextPerformance.NextPerformanceSource.IsNullOrZero() ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(row.ClosingItem.LifeLengthParent, DateTime.Now) : nextPerformance.NextPerformanceSource; row.Cells[ColumnClosed.Index].Value = true; //if(!(row.ClosingItem is Detail)) //{ // Lifelength performanceSource = nextPerformance.PerformanceSource; // 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"; //} if (nextPerformance.PerformanceDate != null) { row.Cells[ColumnDate.Index].Value = (DateTime)nextPerformance.PerformanceDate; } 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; } } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(object reportedDirective, ComponentListDataSet destinationDataSet) { //if (!DefaultFilter.Acceptable(directive)) // return; Component component; ComponentDirective directive; NextPerformance nextDueAtAircraftUtilization = null; DirectiveRecord lastPerformance = null; string positionString = ""; string remarks = "", condition = ""; string workType = "", lastComplianceDate = "", nextComplianceDate = "", ampReference = ""; double mansHours = 0, cost = 0; DateTime installationDate = DateTimeExtend.GetCASMinDateTime(); string kits = "", equipment = "", status = ""; Lifelength lifeLimit, componentCurrent = Lifelength.Null; Lifelength repeat = Lifelength.Null, lastCompliance = Lifelength.Null; Lifelength used = Lifelength.Null, nextPerformanceSource = Lifelength.Null, remain = Lifelength.Null; if (reportedDirective is ComponentDirective) { directive = (ComponentDirective)reportedDirective; component = directive.ParentComponent; positionString = component.TransferRecords.GetLast().Position; installationDate = component.TransferRecords.GetLast().TransferDate; componentCurrent = directive.ParentComponent.IsBaseComponent ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength((BaseComponent)component) : GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(component); remarks = directive.Remarks; workType = directive.DirectiveType.ToString(); repeat = directive.Threshold.RepeatInterval; lifeLimit = component.LifeLimit; //nextCompliance = GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(directive); GlobalObjects.PerformanceCalculator.GetNextPerformance(directive); nextPerformanceSource = directive.NextPerformanceSource; if (directive.MaintenanceDirective != null) { ampReference = directive.MaintenanceDirective.TaskNumberCheck; } if (nextPerformanceSource != null && directive.Status != DirectiveStatus.Closed) { nextComplianceDate = directive.NextPerformanceDate != null ? ((DateTime)directive.NextPerformanceDate).ToString( new GlobalTermsProvider()["DateFormat"].ToString()) : ""; remain.Add(nextPerformanceSource); remain.Substract(componentCurrent); used.Add(componentCurrent); if (_reportedAircraft != null) { nextDueAtAircraftUtilization = new NextPerformance { PerformanceDate = directive.NextPerformanceDate, PerformanceSource = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft) }; nextDueAtAircraftUtilization.PerformanceSource.Add(remain); } } else { nextPerformanceSource = Lifelength.Null; } if (directive.LastPerformance != null && directive.Status != DirectiveStatus.Closed) { lastPerformance = directive.LastPerformance; lastComplianceDate = directive.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastCompliance = directive.LastPerformance.OnLifelength; used.Substract(lastCompliance); used.Resemble(directive.Threshold.RepeatInterval); remain.Resemble(directive.Threshold.RepeatInterval); if (nextDueAtAircraftUtilization != null) { nextDueAtAircraftUtilization.PerformanceSource.Resemble(directive.Threshold.RepeatInterval); } } else { used.Resemble(directive.Threshold.FirstPerformanceSinceNew); remain.Resemble(directive.Threshold.FirstPerformanceSinceNew); if (nextDueAtAircraftUtilization != null) { nextDueAtAircraftUtilization.PerformanceSource.Resemble(directive.Threshold.FirstPerformanceSinceNew); } } int num = 1; foreach (AccessoryRequired kit in directive.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } condition = directive.Condition.ToString(); } //Если объект является деталью или базовой деталью с директивами //то надо возвратится, т.к. данные по детали/базовой детали будут //добавлены при добавлении их директив в набор данных //Если деталь.базовая деталь без директив, тогда в набор данных надо добавить и данные сразу else if (reportedDirective is Component) { component = (Component)reportedDirective; lifeLimit = component.LifeLimit; if (component.ComponentDirectives.Count != 0) { return; } } else { throw new ArgumentException(); } Lifelength lifeLimitUsed = Lifelength.Null; lifeLimitUsed.Add(componentCurrent); lifeLimitUsed.Resemble(lifeLimit); Lifelength lifeLimitRemain = Lifelength.Null; lifeLimitRemain.Add(lifeLimit); lifeLimitRemain.Substract(componentCurrent); lifeLimitRemain.Resemble(lifeLimit); //string status = ""; //if (.Status == DirectiveStatus.Closed) status = "C"; //if (directive.Status == DirectiveStatus.Open) status = "O"; //if (directive.Status == DirectiveStatus.Repetative) status = "R"; //if (directive.Status == DirectiveStatus.NotApplicable) status = "N/A"; destinationDataSet.ItemsTable.AddItemsTableRow(component.ATAChapter.ShortName, ampReference, component.PartNumber, component.SerialNumber, positionString, component.Description, component.MaintenanceControlProcess.ToString(), installationDate, lifeLimit.Days != null ? lifeLimit.Days.ToString() : "", lifeLimit.Hours != null ? lifeLimit.Hours.ToString() : "", lifeLimit.Cycles != null ? lifeLimit.Cycles.ToString() : "", lifeLimitUsed.Days != null ? lifeLimitUsed.Days.ToString() : "", lifeLimitUsed.Hours != null ? lifeLimitUsed.Hours.ToString() : "", lifeLimitUsed.Cycles != null ? lifeLimitUsed.Cycles.ToString() : "", lifeLimitRemain.Days != null ? lifeLimitRemain.Days.ToString() : "", lifeLimitRemain.Hours != null ? lifeLimitRemain.Hours.ToString() : "", lifeLimitRemain.Cycles != null ? lifeLimitRemain.Cycles.ToString() : "", workType, repeat.Days != null ? repeat.Days.ToString() : "", repeat.Hours != null ? repeat.Hours.ToString() : "", repeat.Cycles != null ? repeat.Cycles.ToString() : "", repeat.ToHoursMinutesAndCyclesStrings(" FH", " FC"), lastComplianceDate, lastCompliance.Hours != null ? lastCompliance.Hours.ToString() : "", lastCompliance.Cycles != null ? lastCompliance.Cycles.ToString() : "", lastPerformance != null ? lastPerformance.ToStrings("/") : "", used.Days != null ? used.Days.ToString() : "", used.Hours != null ? used.Hours.ToString() : "", used.Cycles != null ? used.Cycles.ToString() : "", nextComplianceDate, nextPerformanceSource.Hours != null ? nextPerformanceSource.Hours.ToString() : "", nextPerformanceSource.Cycles != null ? nextPerformanceSource.Cycles.ToString() : "", nextDueAtAircraftUtilization != null ? nextDueAtAircraftUtilization.ToStrings("/") : "", remain.Days != null ? remain.Days.ToString() : "", remain.Hours != null ? remain.Hours.ToString() : "", remain.Cycles != null ? remain.Cycles.ToString() : "", remain.ToHoursMinutesAndCyclesStrings(" FH", " FC"), condition, mansHours, cost, kits, equipment, remarks, status); }
/// <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="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> protected virtual void AddDirectiveToDataset(MaintenanceDirective reportedDirective, MaintenanceDirectivesDataSetLatAvia destinationDataSet) { if (reportedDirective == null) { return; } string status = ""; Lifelength remain = Lifelength.Null; Lifelength used = Lifelength.Null; //string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; if (reportedDirective.Status == DirectiveStatus.Closed) { status = "C"; } if (reportedDirective.Status == DirectiveStatus.Open) { status = "O"; } if (reportedDirective.Status == DirectiveStatus.Repetative) { status = "R"; } if (reportedDirective.Status == DirectiveStatus.NotApplicable) { status = "N/A"; } string effectivityDate = UsefulMethods.NormalizeDate(reportedDirective.Threshold.EffectiveDate); string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва string firstPerformanceString = reportedDirective.Threshold.FirstPerformanceSinceNew.ToString(); if (reportedDirective.LastPerformance != null) { used.Add(_current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.RepeatInterval); } else if (!reportedDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Threshold.RepeatInterval); } } var remainCalc = Lifelength.Zero; NextPerformance next = null; try { if (_mpLimit) { if (reportedDirective.LastPerformance != null) { if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero() && !reportedDirective.IsClosed) { next = reportedDirective.NextPerformance; next.PerformanceSource = Lifelength.Zero; next.PerformanceSource.Add(reportedDirective.LastPerformance.OnLifelength); next.PerformanceSource.Add(reportedDirective.Threshold.RepeatInterval); next.PerformanceSource.Resemble(reportedDirective.Threshold.RepeatInterval); if (reportedDirective.Threshold.RepeatInterval.Days.HasValue) { next.PerformanceDate = reportedDirective.LastPerformance.RecordDate.AddDays(reportedDirective.Threshold .RepeatInterval.Days.Value); } else { next.PerformanceDate = null; } remainCalc.Add(next.PerformanceSource); remainCalc.Substract(_current); remainCalc.Resemble(reportedDirective.Threshold.RepeatInterval); if (next.PerformanceDate != null) { remainCalc.Days = DateTimeExtend.DifferenceDateTime(DateTime.Today, next.PerformanceDate.Value).Days; } } } else if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { remainCalc.Add(reportedDirective.NextPerformanceSource); remainCalc.Substract(_current); remainCalc.Resemble(reportedDirective.Threshold.RepeatInterval); } } } else { remainCalc = reportedDirective.Remains; next = reportedDirective.NextPerformance; } destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.TaskCardNumber, reportedDirective.TaskNumberCheck, reportedDirective.Description, firstPerformanceString, reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Hours?.ToString() : "*", reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Cycles?.ToString() : "*", reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Days?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.OnLifelength.Hours?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.OnLifelength.Cycles?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.RecordDate.Date.ToString("dd.MM.yyyy") : "*", next != null ? next.PerformanceSource.Hours.ToString() : "*", next != null ? next.PerformanceSource.Cycles.ToString() : "*", next?.PerformanceDate != null ? next.PerformanceDate.Value.ToString("dd.MM.yyyy") : "*", remainCalc != null ? remainCalc.Hours.ToString() : "*", remainCalc != null ? remainCalc.Cycles.ToString() : "*", remainCalc != null ? remainCalc.Days.ToString() : "*", "", "" ); } catch (Exception e) { Console.WriteLine(e); throw; } }
private void ToolStripMenuItemCloseClick(object sender, EventArgs e) { DialogResult dlgResult = DialogResult.No; foreach (Request item in _directivesViewer.SelectedItems) { if (item.Status == WorkPackageStatus.Closed) { MessageBox.Show("Request " + item.Title + " is already closed.", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); continue; } if (item.PackageItemsLoaded == false) { GlobalObjects.PackageCore.LoadDirectivePackageItems <Request, RequestRecord>(item); } IEnumerable <RequestRecord> blockedRecords = item.PackageRecords.Where(rec => rec.Task != null && rec.Task.NextPerformances != null && rec.Task.NextPerformances.Count > 0 && rec.Task.NextPerformances.Any(np => np.BlockedByPackage != null && np.BlockedByPackage.ItemId != item.ItemId)); if (item.CanClose == false || blockedRecords.Any()) { string message = "This Request can not be closed"; foreach (RequestRecord blockedRecord in blockedRecords) { NextPerformance np = blockedRecord.Task.NextPerformances.First(n => n.BlockedByPackage != null); message += $"\nTask: {blockedRecord.Task} blocked by request {np.BlockedByPackage}"; } if (item.MaxClosingDate < item.MinClosingDate) { message += $"\nMin Closing Date: {item.MinClosingDate} better than Max Closing Date: {item.MaxClosingDate}"; } MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Error); continue; } //AuditClosingFormNew form = new AuditClosingFormNew(item); //form.ShowDialog(); //if (form.DialogResult == DialogResult.OK) //{ // dlgResult = DialogResult.OK; //} } //Если хотя бы одно окно возвратило DialogResult.OK //производится перезагрузка элементов if (dlgResult == DialogResult.OK) { AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoWork; AnimatedThreadWorker.DoWork -= AnimatedThreadWorkerDoFilteringWork; AnimatedThreadWorker.DoWork += AnimatedThreadWorkerDoWork; AnimatedThreadWorker.RunWorkerAsync(); } }
/// <summary> /// Добавление директив в таблицу данных /// </summary> /// <param name="dataset">Таблица, в которую добавляются данные</param> protected virtual void AddDirectivesToDataSet(MaintenancePlanDataSet dataset) { //группировка по родительскому самолету IEnumerable <IGrouping <Aircraft, BaseEntityObject> > groupByAircraft = _reportedDirectives.GroupBy(GlobalObjects.AircraftsCore.GetParentAircraft) .OrderBy(g => g.Key.ToString() + " " + g.Key.Model.ToString()); foreach (IGrouping <Aircraft, BaseEntityObject> byAircraft in groupByAircraft) { IEnumerable <IGrouping <DateTime, BaseEntityObject> > groupedItems = byAircraft.GroupBy(GetDate) .OrderBy(g => g.Key); //сбор всех китов ВС в одну коллекцию List <AbstractAccessory> aircraftKits = byAircraft.Select(ba => ba) .Select(GetParent) .Where(i => i is IKitRequired) .SelectMany(i => ((IKitRequired)i).Kits) .Cast <AbstractAccessory>() .ToList(); foreach (IGrouping <DateTime, BaseEntityObject> groupedItem in groupedItems) { //Группировка элементов по датам выполнения DateTime dateTime = groupedItem.Key.Date; //Формирование первой части названия группы, состоящей из даты выполнения string temp = ""; string kitString = ""; double manHours = 0; //Собрание всех выполнений на данную дату в одну коллекцию IEnumerable <BaseEntityObject> performances = groupedItem.Select(lvi => lvi).ToArray(); //Собрание всех КИТов на данную дату в одну коллекцию IEnumerable <AccessoryRequired> kits = performances.Select(GetParent) .Where(i => i is IKitRequired) .SelectMany(i => ((IKitRequired)i).Kits); IEnumerable <IGrouping <string, AccessoryRequired> > groupByType = kits.GroupBy(GetAccessoryTypeString); foreach (IGrouping <string, AccessoryRequired> grouping in groupByType) { if (!string.IsNullOrEmpty(kitString)) { kitString += Environment.NewLine; } kitString += grouping.Key + Environment.NewLine; kitString = grouping.Select(g => g) .Distinct(new AccessoryRequired()) .Aggregate(kitString, (current, kit) => current + (kit.ToString() + "; ")); } //Добавление в название присутствующих на данную дату чеков программы обслуживания IEnumerable <BaseEntityObject> maintenanceCheckPerformances = performances.Where(np => GetParent(np) is MaintenanceCheck); foreach (BaseEntityObject mcp in maintenanceCheckPerformances) { if (mcp is MaintenanceNextPerformance) { MaintenanceNextPerformance mnp = mcp as MaintenanceNextPerformance; temp += mnp.PerformanceGroup.GetGroupName(); if (byAircraft.Key != null && byAircraft.Key.MSG < MSG.MSG3) { temp += "( " + mnp.PerformanceGroup.ToStringCheckNames() + ")"; } } else if (mcp is NextPerformance) { NextPerformance np = mcp as NextPerformance; temp += ((MaintenanceCheck)np.Parent).Name; } else if (mcp is MaintenanceCheckRecord) { MaintenanceCheckRecord mcr = mcp as MaintenanceCheckRecord; temp += string.IsNullOrEmpty(mcr.ComplianceCheckName) ? mcr.ParentCheck.Name : mcr.ComplianceCheckName; } else if (mcp is MaintenanceCheck) { MaintenanceCheck mc = (MaintenanceCheck)mcp; if (mc.Grouping) { MaintenanceNextPerformance mnp = mc.GetNextPergormanceGroupWhereCheckIsSenior(); if (mnp != null) { temp += mnp.PerformanceGroup.GetGroupName(); } else { temp += mc.Name; } } else { temp += mc.Name; } } temp += " "; } IEnumerable <IBaseEntityObject> allDirectives = performances.Select(GetParent).ToArray(); //Добавление в название присутствующих на данную дату директив летной годности IEnumerable <Directive> directivesPerformances = allDirectives.OfType <Directive>().ToArray(); if (directivesPerformances.Any()) { IEnumerable <IGrouping <DirectiveType, Directive> > groupByDirectiveType = directivesPerformances.GroupBy(d => d.DirectiveType); foreach (IGrouping <DirectiveType, Directive> grouping in groupByDirectiveType) { if (!string.IsNullOrEmpty(temp)) { temp += Environment.NewLine; } temp += grouping.Key.ShortName + " " + Environment.NewLine; foreach (Directive ad in grouping) { temp += ad.Title + " § " + ad.Paragraph + " " + ad.WorkType; temp += "; "; } } manHours += directivesPerformances.Sum(dp => dp.ManHours); } //Добавление в название присутствующих на данную дату компонентов или задач по ним IEnumerable <IBaseEntityObject> componentPerformances = allDirectives.Where(np => np is Component || np is ComponentDirective).ToArray(); if (componentPerformances.Any()) { if (!string.IsNullOrEmpty(temp)) { temp += Environment.NewLine; } temp += "Component" + Environment.NewLine; foreach (IBaseEntityObject componentPerformance in componentPerformances) { Component d; if (componentPerformance is ComponentDirective) { ComponentDirective dd = (ComponentDirective)componentPerformance; d = ((ComponentDirective)componentPerformance).ParentComponent; if (d != null) { temp += "P/N:" + d.PartNumber + " S/N:" + d.SerialNumber + " " + dd.DirectiveType; } else { temp += dd.DirectiveType; } manHours += dd.ManHours; if (dd.DirectiveType == ComponentRecordType.Remove || dd.DirectiveType == ComponentRecordType.Discard || dd.DirectiveType == ComponentRecordType.Overhaul) { //типом работ является удаление или уничтожение компонента //Добавление в коллекцию Китов ВС данного компонента, //т.к. его необходимо будет приобрести aircraftKits.Add(d); } } else { d = componentPerformance as Component; if (d != null) { temp += "P/N:" + d.PartNumber + " S/N:" + d.SerialNumber + " Discard"; manHours += d.ManHours; //Добавление в коллекцию Китов ВС данного компонента, //т.к. его необходимо будет приобрести aircraftKits.Add(d); } } temp += "; "; } } //Добавление в название присутствующих на данную дату MPD //Вывод только тех MPD что не привязаны к чекам IEnumerable <MaintenanceDirective> mpdPerformances = allDirectives.OfType <MaintenanceDirective>().ToArray(); if (mpdPerformances.Any()) { if (!string.IsNullOrEmpty(temp)) { temp += Environment.NewLine; } temp += "MPD " + Environment.NewLine; foreach (MaintenanceDirective mpd in mpdPerformances) { temp += mpd.TaskNumberCheck + " " + mpd.WorkType.ShortName + "; "; manHours += mpd.ManHours; } } dataset.ItemsTable.AddItemsTableRow("", "", temp, dateTime, manHours, 0, kitString, byAircraft.Key != null ? byAircraft.Key + " " + byAircraft.Key.Model : "Unk"); } IEnumerable <IGrouping <Product, AbstractAccessory> > products = aircraftKits.GroupBy(ak => ak.Product ?? new Product { GoodsClass = ak.GoodsClass, Standart = ak.Standart, PartNumber = ak.ParentString, Description = ak.Description } ); foreach (IGrouping <Product, AbstractAccessory> product in products) { string type = GetAccessoryTypeString(product.First()); double quantity = 0; double totalProductCost = 0; if (product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.Tools) || product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ControlTestEquipment)) { quantity = product.Max(p => p.Quantity); totalProductCost = 0; } else if (product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ComponentsAndParts)) { foreach (AbstractAccessory accessoryRequired in product) { int qty = accessoryRequired.Quantity < 1 ? 1 : (int)accessoryRequired.Quantity; quantity += qty; totalProductCost += (qty * accessoryRequired.CostNew); } } else { foreach (AbstractAccessory accessoryRequired in product) { quantity += accessoryRequired.Quantity; totalProductCost += (accessoryRequired.Quantity * accessoryRequired.CostNew); } } dataset.KitsTable.AddKitsTableRow(product.Key.ToString(), quantity, totalProductCost, byAircraft.Key != null ? byAircraft.Key + " " + byAircraft.Key.Model : "Unk", type); } } }
/// <summary> /// Добавляет элементы в ListView /// </summary> /// <param name="itemsArray"></param> //protected override void AddItems(IBaseCoreObject[] itemsArray) //{ // ColumnHeader ch = ColumnHeaderList.FirstOrDefault(h => h.Text == "Performances"); // if (ch == null) // { // base.AddItems(itemsArray); // return; // } // if(itemsArray == null || itemsArray.Length == 0) // { // ch.Width = 0; // base.AddItems(itemsArray); // return; // } // ch.Width = itemsArray.OfType<IDirective>() // .Count(d => d.NextPerformances != null && d.NextPerformances.Count > 1) > 0 ? 100 : 0; // base.AddItems(itemsArray); //} #endregion #region protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(IBaseCoreObject item) protected override List <CustomCell> GetListViewSubItems(IBaseEntityObject item) { var subItems = new List <CustomCell>(); DateTime? approx = null; AtaChapter ata; string maintenanceTypeString = ""; DateTime transferDate = DateTimeExtend.GetCASMinDateTime(); bool isPool = false, IsDangerous = false; Lifelength firstPerformance = Lifelength.Null, lastPerformance = Lifelength.Null, remains = null, next = null, warranty = Lifelength.Null, warrantyRemain = Lifelength.Null, repeatInterval = Lifelength.Null; string partNumber = "", description = "", altPartNumber = "", standart = "", name = "", refference = "", effectivity = "", serialNumber = "", code = "", classString = "", batchNumber = "", idNumber = "", supplier = ""; string status = "", location = "", facility = "", lastPerformanceString = "", kitRequieredString = "", remarks = "", hiddenRemarks = "", workType = "", timesString, quantityString = "", currentString = "", shouldBeOnStockString = "", from = "", id = "", quantityInString = "", author = "", currency = ""; double manHours = 0, unitPrice = 0, totalPrice = 0, shipPrice = 0, subTotal = 0, tax1 = 0, tax2 = 0, tax3 = 0, total = 0, quantity = 0, current = 0, quantityIn = 0, shouldBeOnStock = 0, needWpQuantity = 0, reserve = 0; int times, kitCount = 0; string position = ComponentStorePosition.UNK.ToString(); IDirective parent; if (item is NextPerformance) { NextPerformance np = (NextPerformance)item; parent = np.Parent; int index = np.Parent.NextPerformances.IndexOf(np); timesString = index == 0 ? np.Parent.TimesToString : "#" + (index + 1); times = index == 0 ? np.Parent.Times : index + 1; } else { parent = item as IDirective; if (parent == null) { return(subItems); } timesString = parent.TimesToString; times = parent.Times; } if (parent is Component) { Component componentItem = (Component)parent; id = componentItem.ItemId.ToString(); author = GlobalObjects.CasEnvironment.GetCorrector(componentItem); approx = componentItem.NextPerformanceDate; next = componentItem.NextPerformanceSource; remains = componentItem.Remains; ata = componentItem.Product?.ATAChapter ?? componentItem.ATAChapter; partNumber = componentItem.Product?.PartNumber ?? componentItem.PartNumber; altPartNumber = componentItem.Product?.AltPartNumber ?? componentItem.ALTPartNumber; standart = componentItem.Product?.Standart?.ToString() ?? componentItem.Standart?.ToString(); refference = componentItem.Product?.Reference; effectivity = componentItem.Product?.IsEffectivity; name = componentItem.Product?.Name; description = componentItem.Description; serialNumber = componentItem.SerialNumber; code = componentItem.Product != null ? componentItem.Product.Code :componentItem.Code; classString = componentItem.GoodsClass.ToString(); batchNumber = componentItem.BatchNumber; idNumber = componentItem.IdNumber; position = componentItem.TransferRecords.GetLast()?.State?.ToString(); status = componentItem.ComponentStatus.ToString(); location = componentItem.Location.ToString(); facility = componentItem.Location.LocationsType?.ToString() ?? LocationsType.Unknown.ToString(); maintenanceTypeString = componentItem.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ComponentsAndParts) ? componentItem.MaintenanceControlProcess.ShortName : componentItem.LifeLimit.IsNullOrZero() ? "" : MaintenanceControlProcess.HT.ShortName; transferDate = componentItem.TransferRecords.GetLast().TransferDate; firstPerformance = componentItem.LifeLimit; warranty = componentItem.Warranty; warrantyRemain = componentItem.NextPerformance?.WarrantlyRemains ?? Lifelength.Null; kitRequieredString = componentItem.Kits.Count > 0 ? componentItem.Kits.Count + " kits" : ""; kitCount = componentItem.Kits.Count; bool isComponent = componentItem.GoodsClass.IsNodeOrSubNodeOf(new IDictionaryTreeItem[] { GoodsClass.ComponentsAndParts, GoodsClass.ProductionAuxiliaryEquipment, }); quantity = isComponent && componentItem.ItemId > 0 ? 1 : componentItem.Quantity; quantityString = quantity.ToString(); quantityIn = isComponent && componentItem.ItemId > 0 ? 1 : componentItem.QuantityIn; quantityInString = $"{quantityIn:0.##}" + (componentItem.Measure != null ? " " + componentItem.Measure + "(s)" : "") + componentItem.Packing; needWpQuantity = Math.Round(componentItem.NeedWpQuantity, 2); reserve = quantity - needWpQuantity; shouldBeOnStock = componentItem.ShouldBeOnStock; shouldBeOnStockString = componentItem.ShouldBeOnStock > 0 ? "Yes" : "No"; manHours = componentItem.ManHours; remarks = componentItem.Remarks; hiddenRemarks = componentItem.HiddenRemarks; isPool = componentItem.IsPOOL; IsDangerous = componentItem.IsDangerous; supplier = componentItem.FromSupplier.ToString(); if (componentItem.ProductCosts.Count > 0) { var productost = componentItem.ProductCosts.FirstOrDefault(); unitPrice = productost.UnitPrice; totalPrice = productost.TotalPrice; shipPrice = productost.ShipPrice; subTotal = productost.SubTotal; tax1 = productost.Tax; tax2 = productost.Tax1; tax3 = productost.Tax2; total = productost.Total; currency = productost.Currency.ToString(); } TransferRecord tr = componentItem.TransferRecords.GetLast(); if (tr.FromAircraftId == 0 && tr.FromBaseComponentId == 0 && tr.FromStoreId == 0 && tr.FromSupplierId == 0 && tr.FromSpecialistId == 0) { from = componentItem.Suppliers.ToString(); } else { from = DestinationHelper.FromObjectString(tr); } } else if (parent is ComponentDirective) { ComponentDirective dd = (ComponentDirective)parent; author = GlobalObjects.CasEnvironment.GetCorrector(dd); if (dd.Threshold.FirstPerformanceSinceNew != null && !dd.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { firstPerformance = dd.Threshold.FirstPerformanceSinceNew; } if (dd.LastPerformance != null) { lastPerformanceString = SmartCore.Auxiliary.Convert.GetDateFormat(dd.LastPerformance.RecordDate) + " " + dd.LastPerformance.OnLifelength; lastPerformance = dd.LastPerformance.OnLifelength; } if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero()) { repeatInterval = dd.Threshold.RepeatInterval; } approx = dd.NextPerformanceDate; next = dd.NextPerformanceSource; remains = dd.Remains; ata = dd.ParentComponent.Product?.ATAChapter ?? dd.ParentComponent.ATAChapter; maintenanceTypeString = dd.ParentComponent.MaintenanceControlProcess.ShortName; warranty = dd.Threshold.Warranty; kitRequieredString = dd.Kits.Count > 0 ? dd.Kits.Count + " kits" : ""; kitCount = dd.Kits.Count; manHours = dd.ManHours; remarks = dd.Remarks; hiddenRemarks = dd.HiddenRemarks; workType = dd.DirectiveType.ToString(); position = " " + dd.ParentComponent.TransferRecords.GetLast()?.State?.ToString(); isPool = dd.IsPOOL; IsDangerous = dd.IsDangerous; partNumber = " " + (dd.ParentComponent.Product?.PartNumber ?? dd.ParentComponent.PartNumber); altPartNumber = " " + (dd.ParentComponent.Product?.AltPartNumber ?? dd.ParentComponent.ALTPartNumber); standart = dd.ParentComponent.Product?.Standart?.ToString() ?? dd.ParentComponent.Standart?.ToString(); name = " " + dd.ParentComponent.Product?.Name; description = " " + dd.ParentComponent.Description; serialNumber = " " + dd.ParentComponent.SerialNumber; classString = dd.ParentComponent.GoodsClass.ToString(); warrantyRemain = dd.NextPerformance?.WarrantlyRemains ?? Lifelength.Null; } else { ata = (AtaChapter)GlobalObjects.CasEnvironment.GetDictionary <AtaChapter>().GetItemById(21); } subItems.Add(CreateRow(id, id)); subItems.Add(CreateRow(ata.ToString(), ata)); subItems.Add(CreateRow(refference, refference)); subItems.Add(CreateRow(partNumber, partNumber)); subItems.Add(CreateRow(altPartNumber, altPartNumber)); subItems.Add(CreateRow(standart, standart)); subItems.Add(CreateRow(name, name)); subItems.Add(CreateRow(description, description)); subItems.Add(CreateRow(serialNumber, serialNumber)); subItems.Add(CreateRow(classString, classString)); subItems.Add(CreateRow(batchNumber, batchNumber)); subItems.Add(CreateRow(idNumber, idNumber)); subItems.Add(CreateRow(position.ToUpper(), position)); subItems.Add(CreateRow(status, status)); subItems.Add(CreateRow(location, location)); subItems.Add(CreateRow(facility, facility)); subItems.Add(CreateRow(from, from)); subItems.Add(CreateRow(transferDate > DateTimeExtend.GetCASMinDateTime() ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", transferDate)); subItems.Add(CreateRow(workType, workType)); subItems.Add(CreateRow(needWpQuantity.ToString(), needWpQuantity)); subItems.Add(CreateRow(reserve.ToString(), reserve)); subItems.Add(CreateRow(quantityString, quantity)); subItems.Add(CreateRow(shouldBeOnStockString, shouldBeOnStock)); subItems.Add(CreateRow(quantityInString, quantityIn)); subItems.Add(CreateRow(unitPrice.ToString(), unitPrice)); subItems.Add(CreateRow(totalPrice.ToString(), totalPrice)); subItems.Add(CreateRow(shipPrice.ToString(), shipPrice)); subItems.Add(CreateRow(subTotal.ToString(), subTotal)); subItems.Add(CreateRow(tax1.ToString(), tax1)); subItems.Add(CreateRow(tax2.ToString(), tax2)); subItems.Add(CreateRow(tax3.ToString(), tax3)); subItems.Add(CreateRow(total.ToString(), total)); subItems.Add(CreateRow(currency, currency)); subItems.Add(CreateRow(supplier, supplier)); subItems.Add(CreateRow(code, code)); subItems.Add(CreateRow(remarks, remarks)); subItems.Add(CreateRow(effectivity, effectivity)); subItems.Add(CreateRow(isPool ? "Yes" : "No", isPool)); subItems.Add(CreateRow(IsDangerous ? "Yes" : "No", IsDangerous)); subItems.Add(CreateRow(maintenanceTypeString, maintenanceTypeString)); subItems.Add(CreateRow(manHours.ToString(), manHours)); subItems.Add(CreateRow(firstPerformance.ToString(), firstPerformance)); subItems.Add(CreateRow(repeatInterval.ToString(), repeatInterval)); subItems.Add(CreateRow(timesString, times)); subItems.Add(CreateRow(approx != null ? SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)approx) + " " + next : next != null && !next.IsNullOrZero() ? next.ToString() : "", approx == null ? DateTimeExtend.GetCASMinDateTime() : (DateTime)approx)); subItems.Add(CreateRow(remains != null && !remains.IsNullOrZero() ? remains.ToString() : "", remains ?? Lifelength.Null)); subItems.Add(CreateRow(lastPerformanceString, lastPerformance)); subItems.Add(CreateRow(warranty.ToString(), warranty)); subItems.Add(CreateRow(warrantyRemain.ToString(), warrantyRemain)); subItems.Add(CreateRow(kitRequieredString, kitCount)); subItems.Add(CreateRow(hiddenRemarks, hiddenRemarks)); subItems.Add(CreateRow(author, author)); return(subItems); }
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"; } } }
private void AddToWorkPackageItemClick(object sender, EventArgs e) { if (_directivesViewer.SelectedItems.Count <= 0) { return; } WorkPackage wp = (WorkPackage)((RadMenuItem)sender).Tag; if (MessageBox.Show("Add item to Work Package: " + wp.Title + "?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { List <NextPerformance> wpItems = _directivesViewer.SelectedItems.ToList(); List <NextPerformance> bindedDirectivesPerformances = new List <NextPerformance>(); foreach (NextPerformance wpItem in wpItems) { if (wpItem is MaintenanceNextPerformance) { MaintenanceNextPerformance mnp = wpItem as MaintenanceNextPerformance; if (mnp.PerformanceGroup.Checks.Count > 0) { foreach (MaintenanceCheck mc in mnp.PerformanceGroup.Checks) { foreach (MaintenanceDirective mpd in _currentForecast.MaintenanceDirectives .Where(mpd => mpd.MaintenanceCheck != null && mpd.MaintenanceCheck.ItemId == mc.ItemId)) { NextPerformance performance = mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate.Value.Date == wpItem.PerformanceDate.Value.Date) ?? mpd.NextPerformances.LastOrDefault(p => p.PerformanceDate != null && p.PerformanceDate < wpItem.PerformanceDate) ?? mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate > wpItem.PerformanceDate); if (performance == null) { continue; } if (wpItems.Count(wpi => wpi.Parent != null && wpi.Parent == mpd) == 0) { bindedDirectivesPerformances.Add(performance); } } } } else if (wpItem.Parent is MaintenanceCheck) { MaintenanceCheck mc = wpItem.Parent as MaintenanceCheck; foreach (MaintenanceDirective mpd in _currentForecast.MaintenanceDirectives .Where(mpd => mpd.MaintenanceCheck != null && mpd.MaintenanceCheck.ItemId == mc.ItemId)) { NextPerformance performance = mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate.Value.Date == wpItem.PerformanceDate.Value.Date) ?? mpd.NextPerformances.LastOrDefault(p => p.PerformanceDate != null && p.PerformanceDate < wpItem.PerformanceDate) ?? mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate > wpItem.PerformanceDate); if (performance == null) { continue; } if (wpItems.Count(wpi => wpi.Parent != null && wpi.Parent == mpd) == 0) { bindedDirectivesPerformances.Add(performance); } } } } else if (wpItem.Parent is MaintenanceCheck) { MaintenanceCheck mc = wpItem.Parent as MaintenanceCheck; foreach (MaintenanceDirective mpd in _currentForecast.MaintenanceDirectives .Where(mpd => mpd.MaintenanceCheck != null && mpd.MaintenanceCheck.ItemId == mc.ItemId)) { NextPerformance performance = mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate.Value.Date == wpItem.PerformanceDate.Value.Date) ?? mpd.NextPerformances.LastOrDefault(p => p.PerformanceDate != null && p.PerformanceDate < wpItem.PerformanceDate) ?? mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate > wpItem.PerformanceDate); if (performance == null) { continue; } if (wpItems.Count(wpi => wpi.Parent != null && wpi.Parent == mpd) == 0) { bindedDirectivesPerformances.Add(performance); } } } } wpItems.AddRange(bindedDirectivesPerformances); try { string message; if (!GlobalObjects.WorkPackageCore.AddToWorkPakage(wpItems, wp.ItemId, CurrentAircraft, out message)) { MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Error); return; } foreach (NextPerformance nextPerformance in wpItems) { nextPerformance.BlockedByPackage = wp; _directivesViewer.UpdateItemColor(); } if (MessageBox.Show("Items added successfully. Open work package?", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { ReferenceEventArgs refArgs = new ReferenceEventArgs(); refArgs.TypeOfReflection = ReflectionTypes.DisplayInNew; refArgs.DisplayerText = CurrentAircraft != null ? CurrentAircraft.RegistrationNumber + "." + wp.Title : wp.Title; refArgs.RequestedEntity = new WorkPackageScreen(wp); InvokeDisplayerRequested(refArgs); } } catch (Exception ex) { Program.Provider.Logger.Log("error while create Work Package", ex); } } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(Directive reportedDirective, DirectivesListDataSet destinationDataSet) { string references = reportedDirective.Paragraph; string title; string eo; string sb; string s1 = reportedDirective.Title; if (!string.IsNullOrEmpty(reportedDirective.Paragraph.Trim())) { s1 += "\n§ " + reportedDirective.Paragraph; } if (_directiveType == DirectiveType.EngineeringOrders) { title = reportedDirective.EngineeringOrders; sb = s1; eo = reportedDirective.ServiceBulletinNo; } else if (_directiveType == DirectiveType.SB) { title = reportedDirective.ServiceBulletinNo; sb = s1; eo = reportedDirective.EngineeringOrders; } else { title = s1; eo = reportedDirective.EngineeringOrders; sb = reportedDirective.ServiceBulletinNo; } Lifelength sinceNewThreshold = Lifelength.Null, sinceEffDateThreshold = Lifelength.Null; Lifelength sinceEffDateCompliance = Lifelength.Null; Lifelength sinceNewRemain = Lifelength.Null, sinceEffDateRemain = Lifelength.Null; Lifelength firstCompliance = Lifelength.Null, lastCompliance = Lifelength.Null, repeatInterval = Lifelength.Null, remain = Lifelength.Null; string firstComplianceDate = "", lastComplianceDate = "", sinceNewComplianceDate = ""; Lifelength used = Lifelength.Null; string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; string performanceType = reportedDirective.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "W.O.F" : "W.O.L"; string effectivityDate = SmartCore.Auxiliary.Convert.GetDateFormat(reportedDirective.Threshold.EffectiveDate, "/"); string equipment = reportedDirective.NDTType.ShortName; string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //TODO:(Evgenii Babak) расчетом ресурсов должен заниматься калькулятор //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва if (reportedDirective.Threshold.FirstPerformanceSinceNew != null) { sinceNewThreshold = reportedDirective.Threshold.FirstPerformanceSinceNew; if (sinceNewThreshold.Days != null) { sinceNewComplianceDate = _manufactureDate.AddDays(sinceNewThreshold.Days.Value).ToString( new GlobalTermsProvider()["DateFormat"].ToString()); } if (reportedDirective.LastPerformance == null) { sinceNewRemain.Add(reportedDirective.Threshold.FirstPerformanceSinceNew); sinceNewRemain.Substract(_current); sinceNewRemain.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } } if (reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate != null) { sinceEffDateThreshold = reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate; if (reportedDirective.Threshold.EffectiveDate < DateTime.Today) { sinceEffDateCompliance = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnEndOfDay(_reportedBaseComponent, reportedDirective.Threshold.EffectiveDate); } sinceEffDateCompliance.Add(reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDateCompliance.Resemble(reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDateRemain.Add(reportedDirective.Remains); } GlobalObjects.PerformanceCalculator.GetNextPerformance(reportedDirective); if (reportedDirective.LastPerformance != null) { firstComplianceDate = reportedDirective.PerformanceRecords[0].RecordDate.ToString( new GlobalTermsProvider()["DateFormat"].ToString()); firstCompliance = reportedDirective.PerformanceRecords[0].OnLifelength; if (reportedDirective.Threshold.RepeatInterval != null) { repeatInterval = reportedDirective.Threshold.RepeatInterval; } lastComplianceDate = reportedDirective.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastCompliance = reportedDirective.LastPerformance.OnLifelength; used.Add(_current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Threshold.RepeatInterval); } } var canadianTitle = ""; if (reportedDirective.Title.Contains('/')) { var res = reportedDirective.Title.Split('/'); canadianTitle = res[0]; title = res[1]; } else if (reportedDirective.Title.StartsWith("C")) { canadianTitle = reportedDirective.Title; title = ""; } else { canadianTitle = ""; title = reportedDirective.Title; } string nextComplianceDate = reportedDirective.NextPerformanceDate != null ? ((DateTime)reportedDirective.NextPerformanceDate).ToString(new GlobalTermsProvider()["DateFormat"].ToString()) : ""; Lifelength nextCompliance = reportedDirective.NextPerformanceSource; NextPerformance np = reportedDirective.NextPerformance; destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.Applicability, reportedDirective.Remarks, reportedDirective.HiddenRemarks, reportedDirective.Description, title, references, reportedDirective.WorkType.ToString(), reportedDirective.Status.FullName, effectivityDate, sinceNewThreshold.Hours ?? 0, sinceNewThreshold.Cycles ?? 0, sinceNewComplianceDate, performanceType, sinceNewRemain.Hours ?? 0, sinceNewRemain.Cycles ?? 0, sinceNewRemain.Days ?? 0, sinceEffDateThreshold.Hours ?? 0, sinceEffDateThreshold.Cycles ?? 0, sinceEffDateThreshold.Days != null ? sinceEffDateThreshold.Days.ToString() : "", performanceType, sinceEffDateRemain.Hours ?? 0, sinceEffDateRemain.Cycles ?? 0, sinceEffDateRemain.Days ?? 0, firstComplianceDate, firstCompliance.Hours ?? 0, firstCompliance.Cycles ?? 0, reportedDirective.Threshold.FirstPerformanceToStrings(), repeatInterval.Days ?? 0, repeatInterval.Hours ?? 0, repeatInterval.Cycles ?? 0, repeatInterval.ToStrings(), lastComplianceDate, lastCompliance.Hours ?? 0, lastCompliance.Cycles ?? 0, reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.ToStrings("/") : "", used.Days ?? 0, used.Hours ?? 0, used.Cycles ?? 0, nextComplianceDate, nextCompliance.Hours ?? 0, nextCompliance.Cycles ?? 0, np != null ? np.ToStrings("/") : "", remain.Days != null ? remain.Days.ToString() : "", remain.Hours ?? 0, remain.Cycles ?? 0, reportedDirective.Remains.ToStrings(), reportedDirective.Condition.ToString(), reportedDirective.Cost, reportedDirective.ManHours, kits, equipment, reportedDirective.ATAChapter != null ? reportedDirective.ATAChapter.ShortName : "", reportedDirective.ATAChapter != null ? reportedDirective.ATAChapter.FullName : "", reportedDirective.ADType == ADType.Airframe ? "AF" : "AP", sb, eo != "" ?'(' + eo + ')' : "", canadianTitle, reportedDirective.StcNo); }
protected void SetItemColor(ListViewItem listViewItem, BaseEntityObject item) { if (item == null) { return; } if (item is NextPerformance) { NextPerformance np = item as NextPerformance; if (np.BlockedByPackage != null) { listViewItem.BackColor = Color.FromArgb(Highlight.Grey.Color); listViewItem.ToolTipText = "This performance is involved on Work Package:" + np.BlockedByPackage.Title; } else { if (np.Condition == ConditionState.Overdue) { listViewItem.BackColor = Color.FromArgb(Highlight.Red.Color); } if (np.Condition == ConditionState.Notify) { listViewItem.BackColor = Color.FromArgb(Highlight.Yellow.Color); } if (np.Condition == ConditionState.NotEstimated) { listViewItem.BackColor = Color.FromArgb(Highlight.Blue.Color); } } } //else if (item is AbstractPerformanceRecord) //{ // AbstractPerformanceRecord apr = (AbstractPerformanceRecord)item; // if (apr.WorkPackage != null) // { // //запись о выполнении блокируется найденым пакетом // listViewItem.BackColor = Color.FromArgb(Highlight.Grey.Color); // listViewItem.ToolTipText = // "Perform of the task:" + apr.Parent + // "\nadded by Work Package:" + // "\n" + apr.WorkPackage.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.Loader.GetObject<DirectiveRecord>(dr.MaintenanceDirectiveRecordId); // if (mdr != null && mdr.ParentType == SmartCoreType.MaintenanceDirective) // { // MaintenanceDirective md = GlobalObjects.CasEnvironment.Loader.GetMaintenanceDirective(mdr.ParentId); // if (md != null) // { // listViewItem.ToolTipText = // "Perform of the task:" + dr.WorkType + // "\nadded by MPD Item:" + // "\n" + md.TaskNumberCheck; // } // } // } // } //} }
private void ButtonCreateWorkPakageClick(object sender, EventArgs e) { if (_directivesViewer.SelectedItems.Count <= 0) { return; } if (MessageBox.Show("Create and save a Work Package?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { List <NextPerformance> wpItems = _directivesViewer.SelectedItems.ToList(); List <NextPerformance> bindedDirectivesPerformances = new List <NextPerformance>(); foreach (NextPerformance wpItem in wpItems) { if (wpItem is MaintenanceNextPerformance) { MaintenanceNextPerformance mnp = wpItem as MaintenanceNextPerformance; if (mnp.PerformanceGroup.Checks.Count > 0) { foreach (MaintenanceCheck mc in mnp.PerformanceGroup.Checks) { foreach (MaintenanceDirective mpd in _currentForecast.MaintenanceDirectives .Where(mpd => mpd.MaintenanceCheck != null && mpd.MaintenanceCheck.ItemId == mc.ItemId)) { NextPerformance performance = mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate.Value.Date == wpItem.PerformanceDate.Value.Date) ?? mpd.NextPerformances.LastOrDefault(p => p.PerformanceDate != null && p.PerformanceDate < wpItem.PerformanceDate) ?? mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate > wpItem.PerformanceDate); if (performance == null) { continue; } if (wpItems.Count(wpi => wpi.Parent != null && wpi.Parent == mpd) == 0) { bindedDirectivesPerformances.Add(performance); } } } } else if (wpItem.Parent is MaintenanceCheck) { MaintenanceCheck mc = wpItem.Parent as MaintenanceCheck; foreach (MaintenanceDirective mpd in _currentForecast.MaintenanceDirectives .Where(mpd => mpd.MaintenanceCheck != null && mpd.MaintenanceCheck.ItemId == mc.ItemId)) { NextPerformance performance = mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate.Value.Date == wpItem.PerformanceDate.Value.Date) ?? mpd.NextPerformances.LastOrDefault(p => p.PerformanceDate != null && p.PerformanceDate < wpItem.PerformanceDate) ?? mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate > wpItem.PerformanceDate); if (performance == null) { continue; } if (wpItems.Count(wpi => wpi.Parent != null && wpi.Parent == mpd) == 0) { bindedDirectivesPerformances.Add(performance); } } } } else if (wpItem.Parent is MaintenanceCheck) { MaintenanceCheck mc = wpItem.Parent as MaintenanceCheck; foreach (MaintenanceDirective mpd in _currentForecast.MaintenanceDirectives .Where(mpd => mpd.MaintenanceCheck != null && mpd.MaintenanceCheck.ItemId == mc.ItemId)) { NextPerformance performance = mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate.Value.Date == wpItem.PerformanceDate.Value.Date) ?? mpd.NextPerformances.LastOrDefault(p => p.PerformanceDate != null && p.PerformanceDate < wpItem.PerformanceDate) ?? mpd.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate > wpItem.PerformanceDate); if (performance == null) { continue; } if (wpItems.Count(wpi => wpi.Parent != null && wpi.Parent == mpd) == 0) { bindedDirectivesPerformances.Add(performance); } } } } wpItems.AddRange(bindedDirectivesPerformances); try { string message; WorkPackage wp = GlobalObjects.WorkPackageCore.AddWorkPakage(wpItems, _currentAircraft, out message); if (wp == null) { MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Добавление нового рабочего пакета в коллекцию открытых рабочих пакетов _openPubWorkPackages.Add(wp); //Создание пункта в меню открытых рабочих пакетов var item = new RadMenuItem(wp.Title); item.Click += AddToWorkPackageItemClick; item.Tag = wp; _toolStripMenuItemsWorkPackages.Items.Add(item); foreach (NextPerformance nextPerformance in wpItems) { nextPerformance.BlockedByPackage = wp; _directivesViewer.UpdateItemColor(); } ReferenceEventArgs refArgs = new ReferenceEventArgs(); refArgs.TypeOfReflection = ReflectionTypes.DisplayInNew; refArgs.DisplayerText = CurrentAircraft != null ? CurrentAircraft.RegistrationNumber + "." + wp.Title : wp.Title; refArgs.RequestedEntity = new WorkPackageScreen(wp); InvokeDisplayerRequested(refArgs); } catch (Exception ex) { Program.Provider.Logger.Log("error while create Work Package", ex); } } }
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 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; }
/* * Перегружаемые методы */ #region public override void ApplyChanges() /// <summary> /// Применить к объекту сделанные изменения на контроле. /// Если не все данные удовлетворяют формату ввода (например при вводе чисел), свойства объекта не изменяются, возвращается false /// Вызов base.ApplyChanges() обязателен /// </summary> /// <returns></returns> public override void ApplyChanges() { if (MaintenanceDirective != null) { if (_maintenanceDirectiveRecord != null && checkBoxClose.Checked == false) { _maintenanceDirectiveRecord.IsDeleted = true; } if (_maintenanceDirectiveRecord != null && checkBoxClose.Checked) { _maintenanceDirectiveRecord.RecordDate = dateTimePicker1.Value; } if (!MaintenanceDirective.IsClosed && _maintenanceDirectiveRecord == null && checkBoxClose.Checked) { DirectiveRecord apr = null; if (MaintenanceDirective.PerformanceRecords.Count > 0) { //Поиск записи о выполнении задачи программы обслуживания //которая могла бы подойти под создаваемую запись //о выполнении чека программы обслуживания double?days; if (MaintenanceDirective.MaintenanceCheck != null && MaintenanceDirective.MaintenanceCheck.ParentAircraft != null) { var a = MaintenanceDirective.MaintenanceCheck.ParentAircraft; var partInterval = MaintenanceDirective.MaintenanceCheck.Interval * 0.2; var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(a.AircraftFrameId); var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); days = AnalystHelper.GetApproximateDays(partInterval, averageUtilization); } else { var partInterval = MaintenanceDirective.RepeatInterval * 0.2; days = AnalystHelper.GetApproximateDays(partInterval, MaintenanceDirective.ParentBaseComponent.AverageUtilization); } IEnumerable <DirectiveRecord> aprs = null; if (days != null && days > 0) { double daysValue = Convert.ToDouble(days); //Производится поиск записей о выполнении дата выполнения которых лежит //в заданном диапозоне aprs = MaintenanceDirective.PerformanceRecords.Where( pr => pr.RecordDate >= dateTimePicker1.Value.AddDays(-daysValue) && pr.RecordDate <= dateTimePicker1.Value.AddDays(daysValue)); } if (aprs != null && aprs.Count() > 0) { if (aprs.Count() == 1) { apr = aprs.First(); } else { DirectiveRecord min = null; double minDays = int.MaxValue; foreach (DirectiveRecord record in aprs) { if (min == null) { min = record; minDays = Math.Abs((min.RecordDate - dateTimePicker1.Value).TotalDays); continue; } double candidateMin = Math.Abs((record.RecordDate - dateTimePicker1.Value).TotalDays); if (candidateMin < minDays) { min = record; minDays = candidateMin; } } apr = min; } } } if (apr != null) { _maintenanceDirectiveRecord = apr; } else { NextPerformance performance = MaintenanceDirective.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate.Value.Date == dateTimePicker1.Value) ?? MaintenanceDirective.NextPerformances.LastOrDefault(p => p.PerformanceDate != null && p.PerformanceDate < dateTimePicker1.Value) ?? MaintenanceDirective.NextPerformances.FirstOrDefault(p => p.PerformanceDate != null && p.PerformanceDate > dateTimePicker1.Value); _maintenanceDirectiveRecord = new DirectiveRecord { PerformanceNum = performance != null ? performance.PerformanceNum : 0, Parent = MaintenanceDirective, ParentId = MaintenanceDirective.ItemId, RecordDate = dateTimePicker1.Value }; } } } base.ApplyChanges(); }