/// <summary> /// Обновляет информацию о текущем ВС /// </summary> private void UpdateControl() { dictionaryComboBoxAircraftModel.Type = typeof(AircraftModel); dictionaryComboBoxAircraftModel.SelectedItem = CurrentAircraft.Model; comboBoxMSG.Items.Clear(); foreach (object o in Enum.GetValues(typeof(MSG)).Cast <MSG>().Where(msg => msg != MSG.Unknown)) { comboBoxMSG.Items.Add(o); } comboBoxMSG.SelectedItem = CurrentAircraft.MSG; var apuFlightMinutesList = new List <int> { 0, 20, 30, 40 }; comboBoxApuWorktime.Items.Clear(); foreach (var a in apuFlightMinutesList) { comboBoxApuWorktime.Items.Add(a); } comboBoxApuWorktime.SelectedItem = null; if (CurrentAircraft.ApuUtizationPerFlightinMinutes != null) { comboBoxApuWorktime.Text = CurrentAircraft.ApuUtizationPerFlightinMinutes.ToString(); } else { comboBoxApuWorktime.SelectedItem = comboBoxApuWorktime.Items[0]; } dateTimePickerManufactureDate.MaxDate = DateTime.Now; dateTimePickerManufactureDate.Value = CurrentAircraft.ManufactureDate; textBoxSerialNumber.Text = CurrentAircraft.SerialNumber; textBoxRegistrationNumber.Text = CurrentAircraft.RegistrationNumber; textBoxOwner.Text = CurrentAircraft.Owner; var op = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList <AllOperatorsDTO, AllOperators>(); comboBoxOperator.Items.Clear(); comboBoxOperator.Items.AddRange(op.ToArray()); comboBoxOperator.SelectedIndex = 0; textBoxAircraftTypeCertificateNo.Text = CurrentAircraft.TypeCertificateNumber; textBoxVariableNumber.Text = CurrentAircraft.VariableNumber; numericUpDownAPU.Value = (decimal)CurrentAircraft.APUFH; textBoxLineNumber.Text = CurrentAircraft.LineNumber; lifelengthViewerToday.DateFrom = CurrentAircraft.ManufactureDate; if (GlobalObjects.CasEnvironment != null) { lifelengthViewerToday.Lifelength = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(CurrentAircraft); var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(CurrentAircraft.AircraftFrameId); dateTimePickerStart.Value = aircraftFrame.StartDate.Year > 1950 ? aircraftFrame.StartDate : DateTimeExtend.GetCASMinDateTime(); lifelengthViewerStart.DateFrom = CurrentAircraft.ManufactureDate; if (aircraftFrame.StartLifelength != null) { lifelengthViewerStart.Lifelength = aircraftFrame.StartLifelength; } } //CheckAircraftType(); //CheckPermission(); }
/// <summary> /// Заполняет краткую информацию о директиве /// </summary> /// <param name="bindedItems"></param> private void UpdateInformation(IList <IDirective> bindedItems) { if ((_currentDirective == null) || _currentDirective.ParentBaseComponent == null) { return; } var inspectedComponent = _currentDirective.ParentBaseComponent; labelDirectiveValue.Text = _currentDirective.TaskNumberCheck; labelDescriptionValue.Text = _currentDirective.Description; labelRevisionDateValue.Text = _currentDirective.MpdRevisionNum + " " + Convert.GetDateFormat(_currentDirective.MpdRevisionDate); labelAMP.Text = _currentDirective.ScheduleItem; labelAMPRevison.Text = _currentDirective.ScheduleRevisionNum + " " + (_currentDirective.ScheduleRevisionDate > DateTimeExtend.GetCASMinDateTime() ? Convert.GetDateFormat(_currentDirective.ScheduleRevisionDate) : ""); labelSBValue.Text = _currentDirective.ServiceBulletinNo; labelATAChapterValue.Text = _currentDirective.ATAChapter != null ? _currentDirective.ATAChapter.ToString() : ""; labelRemarksLast.Text = ""; labelApplicabilityValue.Text = _currentDirective.Applicability; labelRemarksValue.Text = _currentDirective.Remarks; labelHiddenRemarksValue.Text = _currentDirective.HiddenRemarks; labelMRBValue.Text = _currentDirective.MRB; labelMaintManualValue.Text = _currentDirective.MaintenanceManual; labelTaskCardNumberValue.Text = _currentDirective.TaskCardNumber; labelMPDNumberValue.Text = _currentDirective.MPDTaskNumber; labelWorkArea.Text = _currentDirective.Workarea; labelSkill.Text = _currentDirective.Skill.ToString(); labelCategory.Text = _currentDirective.Category.ToString(); labelProgramValue.Text = _currentDirective.Program.ToString(); labelCriticalSystemValue.Text = _currentDirective.CriticalSystem.ToString(); labelZoneValue.Text = _currentDirective.Zone; labelAccessValue.Text = _currentDirective.Access; labelCheckValue.Text = _currentDirective.MaintenanceCheck != null ? _currentDirective.MaintenanceCheck.Name : "N/A"; SetTextBoxComponentsString(bindedItems); if (CurrentBaseComponent != null) { linkDirectiveStatus.Text = BackLinkText; } /////////////////////////////////////////////////////////////////////// // Расчетные данные ////////////////////////////////////////////////////////////////////// if (_currentDirective.ItemRelations.Count == 0) { #region асчет при отсутствии привязанных задач if (_currentDirective.Remains != null && _currentDirective.Condition != ConditionState.NotEstimated) { if (_currentDirective.Remains.IsOverdue() && _currentDirective.Condition == ConditionState.Overdue) { labelRemains.Text = "Overdue:"; imageLinkLabelStatus.Status = Statuses.NotSatisfactory; } else if (_currentDirective.Condition == ConditionState.Notify) { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.Notify; } else if (_currentDirective.Condition == ConditionState.Satisfactory) { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.Satisfactory; } else { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.NotActive; } } imageLinkLabelStatus.Text = _currentDirective.WorkType.ToString(); labelRemainsValue.Text = ""; if (_currentDirective.Remains != null) { labelRemainsValue.Text = _currentDirective.Remains.ToString(); } labelCostValue.Text = _currentDirective.Cost.ToString(); labelManHoursValue.Text = _currentDirective.ManHours.ToString(); labelKitValue.Text = _currentDirective.Kits.Count == 0 ? "N" : _currentDirective.Kits.Count + "Kits"; labelNDTvalue.Text = _currentDirective.NDTType.ShortName; //labelRemarksValue.Text = _currentDirective.Remarks; //labelHiddenRemarksValue.Text = ""; //if (labelHiddenRemarksValue.Text == "") // labelHiddenRemarksValue.Text = "No Important information"; // labelHiddenRemarks.Visible = false; labelDateLast.Text = ""; labelAircraftTsnCsnLast.Text = ""; labelNextCompliance.Text = "Next Compliance"; labelDateNext.Text = "n/a"; labelAircraftTsnCsnNext.Text = "n/a"; labelComponentTsnCsnNext.Text = "n/a"; //labelRemarksValue.Text = ""; if (_currentDirective.LastPerformance != null) { labelDateLast.Text = Convert.GetDateFormat(_currentDirective.LastPerformance.RecordDate); //labelRemarksLast.Text = currentDirective.LastPerformance.Description; if (!_currentDirective.LastPerformance.OnLifelength.IsNullOrZero()) { labelComponentTsnCsnLast.Text = _currentDirective.LastPerformance.OnLifelength.ToString(); } else { labelComponentTsnCsnLast.Text = _currentDirective.LastPerformance.OnLifelength.ToString(); } //TODO:(Evgenii Babak)Если тип inspectedDetail будет Frame, то при перерасчете будет проверен тип базового агрегата и если он равен Frame, //то берется parentAircraft от базовой детали и считается наработка для ВС. пересмотреть подход калякуляции для ВС //labelAircraftTsnCsnLast.Text = // GlobalObjects.CasEnvironment.Calculator. // GetFlightLifelengthOnStartOfDay(inspectedComponent, _currentDirective.LastPerformance.RecordDate).ToString(); labelAircraftTsnCsnLast.Text = _currentDirective.LastPerformance.OnLifelength.ToString(); } /////////////////////////////////////////////////////////////////////////////////////////////// labelFirstPerformanceValue.Text = "n/a"; labelRptIntervalValue.Text = "n/a"; if (_currentDirective.Threshold.FirstPerformanceSinceNew != null && !_currentDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { labelFirstPerformanceValue.Text = "s/n: " + _currentDirective.Threshold.FirstPerformanceSinceNew; } if (_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate != null && !_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (labelFirstPerformanceValue.Text != "n/a") { labelFirstPerformanceValue.Text += " or "; } else { labelFirstPerformanceValue.Text = ""; } labelFirstPerformanceValue.Text += "s/e.d: " + _currentDirective.Threshold.FirstPerformanceSinceEffectiveDate; } if (_currentDirective.Threshold.RepeatInterval != null) { labelRptIntervalValue.Text = _currentDirective.Threshold.RepeatInterval.IsNullOrZero() ? "n/a" : _currentDirective.Threshold.RepeatInterval.ToString(); } //////////////////////////////////////////////////////////////////////////////////////////////// //labelRemarksValue.Text = _currentDirective.Remarks; if (_currentDirective.IsClosed) { return; //если директива принудительно закрыта пользователем } //то вычисление следующего выполнения не нужно labelDateNext.Text = labelAircraftTsnCsnNext.Text = "n/a"; if (_currentDirective.LastPerformance == null) { if (_currentDirective.Threshold.FirstPerformanceSinceNew != null && !_currentDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { //если наработка исчисляется с момента выпуска if (_currentDirective.Threshold.FirstPerformanceSinceNew.CalendarValue != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения labelDateNext.Text = Convert.GetDateFormat(inspectedComponent.ManufactureDate. AddCalendarSpan(_currentDirective.Threshold.FirstPerformanceSinceNew.CalendarSpan)) + " s/n"; } else { //иначе, если (дополнительно) дата не определена labelDateNext.Text = "n/a"; } labelComponentTsnCsnNext.Text = "s/n: " + _currentDirective.Threshold.FirstPerformanceSinceNew; //labelAircraftTsnCsnNext.Text = "s/n: " + currentDirective.Threshold.SinceNew.ToString(); } if (_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate != null && !_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { //если наработка исчисляется с эффективной даты //Определение даты исполнения if (_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate.Days != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения if (labelDateNext.Text != "n/a") { labelDateNext.Text += " or "; } else { labelDateNext.Text = ""; } labelDateNext.Text += Convert.GetDateFormat( _currentDirective.Threshold.EffectiveDate.AddCalendarSpan( _currentDirective.Threshold.FirstPerformanceSinceEffectiveDate.CalendarSpan)) + " s/e.d."; } else { //иначе, дату определить нельзя if (labelDateNext.Text == "") { labelDateNext.Text = "n/a"; } } //Определение наработки if (_currentDirective.Threshold.EffectiveDate < DateTime.Today) { Lifelength sinceEffDate = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnEndOfDay(inspectedComponent, _currentDirective.Threshold.EffectiveDate); sinceEffDate.Add(_currentDirective.Threshold.EffectiveDate, _currentDirective.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDate.Resemble(_currentDirective.Threshold.FirstPerformanceSinceEffectiveDate); if (labelComponentTsnCsnNext.Text != "n/a") { labelComponentTsnCsnNext.Text += " or "; } else { labelComponentTsnCsnNext.Text = ""; } labelComponentTsnCsnNext.Text += "s/e.d: " + sinceEffDate; } } } else { if (_currentDirective.Threshold.PerformRepeatedly && _currentDirective.Threshold.RepeatInterval != null) { //повторяющаяся директива //если есть последнне выполнение, то следующая дата расчитывается //по повторяющемуся интервалу if (_currentDirective.Threshold.RepeatInterval.CalendarValue != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения labelDateNext.Text = Convert.GetDateFormat( _currentDirective.LastPerformance.RecordDate.AddCalendarSpan( _currentDirective.Threshold.RepeatInterval.CalendarSpan)); labelDateNext.Text = Convert.GetDateFormat(_currentDirective.NextPerformance.PerformanceDate.Value); } else { //иначе, точную дату выполнения расчитать нельзя labelDateNext.Text = "n/a"; labelComponentTsnCsnNext.Text = "n/a"; } //Определение наработки if (!_currentDirective.Threshold.RepeatInterval.IsNullOrZero()) { Lifelength nextTsnCsn; if (!_currentDirective.LastPerformance.OnLifelength.IsNullOrZero()) { nextTsnCsn = new Lifelength(_currentDirective.LastPerformance.OnLifelength); } else { nextTsnCsn = _currentDirective.LastPerformance.OnLifelength; } Lifelength nextAircraftTsnCsn = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnStartOfDay(inspectedComponent, _currentDirective.LastPerformance.RecordDate); nextTsnCsn.Add(_currentDirective.LastPerformance.RecordDate, _currentDirective.Threshold.RepeatInterval); nextTsnCsn.Resemble(_currentDirective.Threshold.RepeatInterval); //labelComponentTsnCsnNext.Text = nextTsnCsn.ToString(); labelComponentTsnCsnNext.Text = _currentDirective.NextPerformance.PerformanceSource.ToString(); nextAircraftTsnCsn.Add(_currentDirective.LastPerformance.RecordDate, _currentDirective.Threshold.RepeatInterval); nextAircraftTsnCsn.Resemble(_currentDirective.Threshold.RepeatInterval); //labelAircraftTsnCsnNext.Text = nextAircraftTsnCsn.ToString(); labelAircraftTsnCsnNext.Text = _currentDirective.NextPerformance.PerformanceSource.ToString(); if (labelComponentTsnCsnNext.Text == "") { labelComponentTsnCsnNext.Text = "n/a"; } if (labelAircraftTsnCsnNext.Text == "") { labelAircraftTsnCsnNext.Text = "n/a"; } } else { labelComponentTsnCsnNext.Text = "n/a"; } } } #endregion } else { #region асчет при наличии привязанных задач labelDateLast.Text = ""; labelAircraftTsnCsnLast.Text = ""; labelNextCompliance.Text = "First Limitter"; labelDateNext.Text = "n/a"; labelAircraftTsnCsnNext.Text = "n/a"; labelComponentTsnCsnNext.Text = "n/a"; labelRemainsValue.Text = ""; //labelRemarksValue.Text = ""; var firstLimitters = new List <NextPerformance>(); var lastPerformances = new List <DirectiveRecord>(); foreach (var bdd in bindedItems) { if (bdd is ComponentDirective) { var componentDirective = (ComponentDirective)bdd; GlobalObjects.PerformanceCalculator.GetNextPerformance(componentDirective); if (componentDirective.NextPerformances.Count > 0) { firstLimitters.Add(componentDirective.NextPerformances[0]); } if (componentDirective.LastPerformance != null) { lastPerformances.Add(componentDirective.LastPerformance); } } } var firstLimitter = firstLimitters.OrderBy(np => np.PerformanceDate).FirstOrDefault(); var lastPerformance = lastPerformances.OrderByDescending(p => p.RecordDate).FirstOrDefault() ?? _currentDirective.LastPerformance; IDirective parentOfFirstLimitter = firstLimitter != null ? firstLimitter.Parent : lastPerformance != null ? lastPerformance.Parent : _currentDirective; if (firstLimitter != null && firstLimitter.Remains != null && firstLimitter.Condition != ConditionState.NotEstimated) { if (firstLimitter.Remains.IsOverdue() && firstLimitter.Condition == ConditionState.Overdue) { labelRemains.Text = "Overdue:"; imageLinkLabelStatus.Status = Statuses.NotSatisfactory; } else if (firstLimitter.Condition == ConditionState.Notify) { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.Notify; } else if (firstLimitter.Condition == ConditionState.Satisfactory) { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.Satisfactory; } else { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.NotActive; } ComponentDirective componentDirective = (ComponentDirective)firstLimitter.Parent; labelRemainsValue.Text = firstLimitter.Remains.ToString(); imageLinkLabelStatus.Text = componentDirective.DirectiveType.ToString(); labelCostValue.Text = componentDirective.Cost.ToString(); labelManHoursValue.Text = componentDirective.ManHours.ToString(); labelKitValue.Text = componentDirective.Kits.Count == 0 ? "N" : componentDirective.Kits.Count + "Kits"; labelNDTvalue.Text = _currentDirective.NDTType.ShortName; //labelRemarksValue.Text = componentDirective.Remarks; } else { imageLinkLabelStatus.Text = _currentDirective.WorkType.ToString(); labelCostValue.Text = _currentDirective.Cost.ToString(); labelManHoursValue.Text = _currentDirective.ManHours.ToString(); labelKitValue.Text = _currentDirective.Kits.Count == 0 ? "N" : _currentDirective.Kits.Count + "Kits"; labelNDTvalue.Text = _currentDirective.NDTType.ShortName; // labelRemarksValue.Text = _currentDirective.Remarks; } //labelHiddenRemarksValue.Text = ""; //if (labelHiddenRemarksValue.Text == "") // labelHiddenRemarksValue.Text = "No Important information"; // labelHiddenRemarks.Visible = false; if (lastPerformance != null) { labelDateLast.Text = Convert.GetDateFormat(lastPerformance.RecordDate); if (!lastPerformance.OnLifelength.IsNullOrZero()) { labelComponentTsnCsnLast.Text = lastPerformance.OnLifelength.ToString(); } else { labelComponentTsnCsnLast.Text = lastPerformance.OnLifelength.ToString(); } //TODO:(Evgenii Babak)Тип inspectedDetail всегда будет Frame. При перерасчете будет проверен тип базового агрегата и если он равен Frame, //то берется parentAircraft от базовой детали и считается наработка для ВС. пересмотреть подход калякуляции для ВС labelAircraftTsnCsnLast.Text = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnStartOfDay(inspectedComponent, lastPerformance.RecordDate).ToString(); } /////////////////////////////////////////////////////////////////////////////////////////////// labelFirstPerformanceValue.Text = "n/a"; labelRptIntervalValue.Text = "n/a"; if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew != null && !parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { labelFirstPerformanceValue.Text = "s/n: " + parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew; } if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate != null && !parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (labelFirstPerformanceValue.Text != "n/a") { labelFirstPerformanceValue.Text += " or "; } else { labelFirstPerformanceValue.Text = ""; } labelFirstPerformanceValue.Text += "s/e.d: " + parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate; } if (parentOfFirstLimitter.Threshold.RepeatInterval != null) { labelRptIntervalValue.Text = parentOfFirstLimitter.Threshold.RepeatInterval.IsNullOrZero() ? "n/a" : parentOfFirstLimitter.Threshold.RepeatInterval.ToString(); } //////////////////////////////////////////////////////////////////////////////////////////////// if (parentOfFirstLimitter.IsClosed) { return; //если директива принудительно закрыта пользователем } //то вычисление следующего выполнения не нужно labelDateNext.Text = labelAircraftTsnCsnNext.Text = "n/a"; if (parentOfFirstLimitter.LastPerformance == null) { if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew != null && !parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { //если наработка исчисляется с момента выпуска if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew.CalendarValue != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения labelDateNext.Text = Convert.GetDateFormat(inspectedComponent.ManufactureDate. AddCalendarSpan(parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew.CalendarSpan)) + " s/n"; } else { //иначе, если (дополнительно) дата не определена labelDateNext.Text = "n/a"; } labelComponentTsnCsnNext.Text = "s/n: " + parentOfFirstLimitter.Threshold.FirstPerformanceSinceNew; } if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate != null && !parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { //если наработка исчисляется с эффективной даты //Определение даты исполнения if (parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate.Days != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения if (labelDateNext.Text != "n/a") { labelDateNext.Text += " or "; } else { labelDateNext.Text = ""; } labelDateNext.Text += Convert.GetDateFormat(parentOfFirstLimitter.Threshold.EffectiveDate.AddCalendarSpan( parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate.CalendarSpan)) + " s/e.d."; } else { //иначе, дату определить нельзя if (labelDateNext.Text == "") { labelDateNext.Text = "n/a"; } } //Определение наработки if (parentOfFirstLimitter.Threshold.EffectiveDate < DateTime.Today) { Lifelength sinceEffDate = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnEndOfDay(inspectedComponent, parentOfFirstLimitter.Threshold.EffectiveDate); sinceEffDate.Add(parentOfFirstLimitter.Threshold.EffectiveDate, parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDate.Resemble(parentOfFirstLimitter.Threshold.FirstPerformanceSinceEffectiveDate); if (labelComponentTsnCsnNext.Text != "n/a") { labelComponentTsnCsnNext.Text += " or "; } else { labelComponentTsnCsnNext.Text = ""; } labelComponentTsnCsnNext.Text += "s/e.d: " + sinceEffDate; } } } else { if (firstLimitter != null) { //повторяющаяся директива //если есть последнне выполнение, то следующая дата расчитывается //по повторяющемуся интервалу if (parentOfFirstLimitter.Threshold.RepeatInterval.CalendarValue != null && firstLimitter.PerformanceDate != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения labelDateNext.Text = Convert.GetDateFormat(firstLimitter.PerformanceDate.Value); } else { //иначе, точную дату выполнения расчитать нельзя labelDateNext.Text = "n/a"; labelComponentTsnCsnNext.Text = "n/a"; } //Определение наработки if (!parentOfFirstLimitter.Threshold.RepeatInterval.IsNullOrZero() && !firstLimitter.PerformanceSource.IsNullOrZero()) { labelComponentTsnCsnNext.Text = firstLimitter.PerformanceSource.ToString(); //TODO:(Evgenii Babak)Тип inspectedDetail всегда будет Frame. При перерасчете будет проверен тип базового агрегата и если он равен Frame, //то берется parentAircraft от базовой детали и считается наработка для ВС. пересмотреть подход калякуляции для ВС Lifelength nextAircraftTsnCsn = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnStartOfDay(inspectedComponent, lastPerformance.RecordDate); nextAircraftTsnCsn.Add(lastPerformance.RecordDate, parentOfFirstLimitter.Threshold.RepeatInterval); nextAircraftTsnCsn.Resemble(parentOfFirstLimitter.Threshold.RepeatInterval); labelAircraftTsnCsnNext.Text = nextAircraftTsnCsn.ToString(); if (labelComponentTsnCsnNext.Text == "") { labelComponentTsnCsnNext.Text = "n/a"; } if (labelAircraftTsnCsnNext.Text == "") { labelAircraftTsnCsnNext.Text = "n/a"; } } else { labelComponentTsnCsnNext.Text = "n/a"; } } } #endregion } }
/// <summary> /// Возвращает значение, показывающее были ли изменения в данном элементе управления /// </summary> public bool GetChangeStatus() { var manHours = ConvertDoubleValue(textBoxManHours.Text); var cost = ConvertDoubleValue(textBoxCost.Text); ComponentDirectiveThreshold threshold = new ComponentDirectiveThreshold(); if (comboBoxWorkType.SelectedItem as ComponentRecordType == ComponentRecordType.Preservation) { threshold.EffectiveDate = dateTimePickerEffDate.Value; threshold.FirstPerformanceSinceEffectiveDate = lifelengthViewer_FirstPerformance.Lifelength; } else { threshold.EffectiveDate = DateTimeExtend.GetCASMinDateTime(); threshold.FirstPerformanceSinceNew = lifelengthViewer_FirstPerformance.Lifelength; } threshold.FirstNotification = lifelengthViewer_FirstNotify.Lifelength; threshold.RepeatInterval = lifelengthViewerRptInterval.Lifelength; threshold.RepeatNotification = lifelengthViewerRptNotify.Lifelength; threshold.Warranty = lifelengthViewerWarranty.Lifelength; threshold.WarrantyNotification = lifelengthViewerWarrantyNotify.Lifelength; _currentComponentDirective.ExpiryRemainNotify = lifelengthViewerExpiryRemain.Lifelength; threshold.FirstPerformanceConditionType = radio_WhicheverFirst.Checked ? ThresholdConditionType.WhicheverFirst : ThresholdConditionType.WhicheverLater; try { var bindedItemId = -1; var currentRelation = _currentComponentDirective.ItemRelations.SingleOrDefault(); var bindedItemRelationType = ItemRelationHelper.ConvertBLItemRelationToUIITem(_currentComponentDirective.WorkItemsRelationType, _currentComponentDirective.IsFirst.HasValue && _currentComponentDirective.IsFirst.Value); if (currentRelation != null) { bindedItemId = _currentComponentDirective.IsFirst == true ? currentRelation.SecondItemId : currentRelation.FirstItemId; } if (_currentComponentDirective.ManHours != manHours || lookupComboboxMaintenanceDirective.SelectedItemId != bindedItemId || _currentComponentDirective.MPDTaskType != comboBoxMpdTaskType.SelectedItem || (WorkItemsRelationTypeUI)comboBoxRelationType.SelectedValue != bindedItemRelationType || _currentComponentDirective.Cost != cost || _currentComponentDirective.IsClosed != IsClosed || _currentComponentDirective.IsExpiry != IsExpiry || _currentComponentDirective.KitRequired != textBoxKitRequired.Text || _currentComponentDirective.Remarks != textBoxRemarks.Text || textBoxZoneArea.Text != _currentComponentDirective.ZoneArea || textBoxAcess.Text != _currentComponentDirective.AccessDirective || textBoxAAM.Text != _currentComponentDirective.AAM || textBoxCMM.Text != _currentComponentDirective.CMM || dateTimePickerExpiryDate.Value != _currentComponentDirective.ExpiryDate || _currentComponentDirective.NDTType.ItemId != ((NDTType)comboBoxNdt.SelectedItem).ItemId || _currentComponentDirective.Threshold.ToString() != threshold.ToString() || _currentComponentDirective.FaaFormFile != fileControl.AttachedFile || _currentComponentDirective.HiddenRemarks != textBoxHiddenRemarks.Text || _currentComponentDirective.DirectiveType.ItemId != ((ComponentRecordType)comboBoxWorkType.SelectedItem).ItemId || fileControl.GetChangeStatus()) { return(true); } } catch (InvalidOperationException) { ItemRelationHelper.ShowDialogIfItemLinksCountMoreThanOne($"Component {_currentComponentDirective.PartNumber}", _currentComponentDirective.ItemRelations.Count); } catch (Exception ex) { Program.Provider.Logger.Log("Error while saving data", ex); return(true); } return(false); }
/// <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); }
/// <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); }
//protected override void SetItemColor(ListViewItem listViewItem, BaseEntityObject item) //{ // if (item is NextPerformance) // { // NextPerformance nextPerformance = item as NextPerformance; // if(_currentDirective.Status != WorkPackageStatus.Closed) // { // 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); // } // else // { // //Если это следующее выполнение, но рабочий пакет при этом закрыт // //значит, выполнение для данной задачи в рамках данного рабочего пакета // //не было введено // //пометка этого выполнения краным цветом // listViewItem.BackColor = Color.FromArgb(Highlight.Red.Color); // //подсказка о том, что выполнение не было введено // listViewItem.ToolTipText = "Performance for this directive within this work package is not entered."; // if (nextPerformance.BlockedByPackage != null) // { // //дополнитльная подсказака, если предшествующее выполнение // //имеется в другом открытом рабочем пакете // listViewItem.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) // { // //запись так же может быть удаленной // //шрифт серым цветом // listViewItem.ForeColor = Color.Gray; // if (listViewItem.ToolTipText.Trim() != "") // listViewItem.ToolTipText += "\n"; // listViewItem.ToolTipText += string.Format("This {0} is deleted",nextPerformance.Parent.SmartCoreObjectType); // } // } // 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 += string.Format("This {0} is deleted", apr.Parent.SmartCoreObjectType); // } // } // else // { // if(!(item is NonRoutineJob)) // { // //Если это не следующее выполнение, не запись о выполнении, и не рутинная работа // //значит, выполнение для данной задачи расчитать нельзя // //пометка этого выполнения синим цветом // listViewItem.BackColor = Color.FromArgb(Highlight.Blue.Color); // //подсказка о том, что выполнение не возможео расчитать // listViewItem.ToolTipText = "Performance for this directive can not be calculated"; // } // if (item.IsDeleted) // { // //запись так же может быть удаленной // //шрифт серым цветом // listViewItem.ForeColor = Color.Gray; // if (listViewItem.ToolTipText.Trim() != "") // listViewItem.ToolTipText += "\n"; // listViewItem.ToolTipText += string.Format("This {0} is deleted", item.SmartCoreObjectType); // } // } //} #endregion #region protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(BaseSmartCoreObject item) protected override List <CustomCell> GetListViewSubItems(BaseEntityObject item) { var temp = ListViewGroupHelper.GetGroupString(item); var subItems = new List <CustomCell>() { CreateRow(temp, temp) }; var author = GlobalObjects.CasEnvironment.GetCorrector(item); //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(CreateRow(np.ATAChapter.ToString(), np.ATAChapter)); subItems.Add(CreateRow(np.Title, np.Title)); subItems.Add(CreateRow(np.Description, np.Description)); subItems.Add(CreateRow(np.KitsToString, np.Kits.Count)); subItems.Add(CreateRow(np.PerformanceSource.ToString(), np.PerformanceSource)); subItems.Add(CreateRow(np.Parent.Threshold.RepeatInterval.ToString(), np.Parent.Threshold.RepeatInterval)); subItems.Add(CreateRow(np.Remains.ToString(), np.Remains)); subItems.Add(CreateRow(np.WorkType, Tag = np.WorkType)); subItems.Add(CreateRow(np.PerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)np.PerformanceDate), np.PerformanceDate)); subItems.Add(CreateRow(manHours.ToString(), manHours)); subItems.Add(CreateRow(cost.ToString(), 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(CreateRow(apr.KitsToString, apr.Kits.Count)); subItems.Add(CreateRow(apr.OnLifelength.ToString(), apr.OnLifelength)); subItems.Add(CreateRow(apr.Parent.Threshold.RepeatInterval.ToString(), apr.Parent.Threshold.RepeatInterval)); subItems.Add(CreateRow(remains.ToString(), remains)); subItems.Add(CreateRow(apr.WorkType, apr.WorkType)); subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(apr.RecordDate), apr.RecordDate)); subItems.Add(CreateRow(manHours.ToString(), manHours)); subItems.Add(CreateRow(cost.ToString(), cost)); subItems.Add(CreateRow(author, author)); } else if (item is Directive) { Directive directive = (Directive)item; AtaChapter ata = directive.ATAChapter; subItems.Add(CreateRow(ata.ToString(), ata)); subItems.Add(CreateRow(directive.Title, directive.Title)); subItems.Add(CreateRow(directive.Description, directive.Description)); #region Определение текста для колонки "КИТы" subItems.Add(CreateRow(directive.Kits.Count > 0 ? directive.Kits.Count + " kits" : "", directive.Kits.Count)); #endregion #region Определение текста для колонки "Первое выполнение" var subItem = new CustomCell(); 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 CustomCell(); 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(CreateRow(directive.Remains.ToString(), directive.Remains)); #endregion #region Определение текста для колонки "Тип работ" subItems.Add(CreateRow(directive.WorkType.ToString(), directive.WorkType)); #endregion #region Определение текста для колонки "Следующее выполнение" subItems.Add(CreateRow(directive.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)directive.NextPerformanceDate), directive.NextPerformanceDate)); #endregion #region Определение текста для колонки "Человек/Часы" subItems.Add(CreateRow(directive.ManHours.ToString(), directive.ManHours)); #endregion #region Определение текста для колонки "Стоимость" subItems.Add(CreateRow(directive.Cost.ToString(), directive.Cost)); #endregion subItems.Add(CreateRow(author, author)); } 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(CreateRow(bd.Kits.Count > 0 ? bd.Kits.Count + " kits" : "", bd.Kits.Count)); subItems.Add(CreateRow(bd.LifeLimit.ToString(), bd.LifeLimit)); subItems.Add(CreateRow("", Lifelength.Null)); subItems.Add(CreateRow(bd.Remains.ToString(), bd.Remains)); subItems.Add(CreateRow(ComponentRecordType.Remove.ToString(), ComponentRecordType.Remove)); subItems.Add(CreateRow(bd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)bd.NextPerformanceDate), bd.NextPerformanceDate)); subItems.Add(CreateRow(bd.ManHours.ToString(), bd.ManHours)); subItems.Add(CreateRow(bd.Cost.ToString(), bd.Cost)); subItems.Add(CreateRow(author, author)); } 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(CreateRow(d.Kits.Count > 0 ? d.Kits.Count + " kits" : "", d.Kits.Count)); subItems.Add(CreateRow(d.LifeLimit != null ? d.LifeLimit.ToString() : "", d.LifeLimit)); subItems.Add(CreateRow("", Lifelength.Null)); subItems.Add(CreateRow(d.Remains != null ? d.Remains.ToString() : "", d.Remains)); subItems.Add(CreateRow(ComponentRecordType.Remove.ToString(), ComponentRecordType.Remove)); subItems.Add(CreateRow(d.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)d.NextPerformanceDate), d.NextPerformanceDate)); subItems.Add(CreateRow(d.ManHours.ToString(), d.ManHours)); subItems.Add(CreateRow(d.Cost.ToString(), d.Cost)); subItems.Add(CreateRow(author, Tag = author)); } 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(CreateRow(dd.Kits.Count > 0 ? dd.Kits.Count + " kits" : "", dd.Kits.Count)); #region Определение текста для колонки "Первое выполнение" var subItem = new CustomCell(); 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 CustomCell(); 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(CreateRow(dd.Remains.ToString(), dd.Remains)); subItems.Add(CreateRow(dd.DirectiveType.ToString(), dd.DirectiveType)); subItems.Add(CreateRow(dd.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)dd.NextPerformanceDate), dd.NextPerformanceDate)); subItems.Add(CreateRow(dd.ManHours.ToString(), dd.ManHours)); subItems.Add(CreateRow(dd.Cost.ToString(), dd.Cost)); subItems.Add(CreateRow(author, author)); } else if (item is MaintenanceCheck) { MaintenanceCheck mc = (MaintenanceCheck)item; subItems.Add(CreateRow("", null)); subItems.Add(CreateRow("", "")); subItems.Add(CreateRow(mc.Name + (mc.Schedule ? " Shedule" : " Unshedule"), mc.Name)); subItems.Add(CreateRow(mc.Kits.Count > 0 ? mc.Kits.Count + " kits" : "", mc.Kits.Count)); subItems.Add(CreateRow(mc.Interval.ToString(), mc.Interval)); subItems.Add(CreateRow("", Lifelength.Null)); subItems.Add(CreateRow(mc.Remains.ToString(), mc.Remains)); subItems.Add(CreateRow("", "")); subItems.Add(CreateRow(mc.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)mc.NextPerformanceDate), mc.NextPerformanceDate)); subItems.Add(CreateRow(mc.ManHours.ToString(), mc.ManHours)); subItems.Add(CreateRow(mc.Cost.ToString(), mc.Cost)); subItems.Add(CreateRow(author, author)); } 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(CreateRow(md.Kits.Count > 0 ? md.Kits.Count + " kits" : "", md.Kits.Count)); #region Определение текста для колонки "Первое выполнение" var subItem = new CustomCell(); 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 CustomCell(); 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(CreateRow(md.Remains.ToString(), md.Remains)); subItems.Add(CreateRow(md.WorkType.ToString(), md.WorkType)); subItems.Add(CreateRow(md.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)md.NextPerformanceDate), md.NextPerformanceDate)); subItems.Add(CreateRow(md.ManHours.ToString(), md.ManHours)); subItems.Add(CreateRow(md.Cost.ToString(), md.Cost)); subItems.Add(CreateRow(author, author)); } else if (item is Procedure) { Procedure md = (Procedure)item; subItems.Add(CreateRow("", "")); subItems.Add(CreateRow(md.ToString(), md.ToString())); subItems.Add(CreateRow(md.Description, md.Description)); subItems.Add(CreateRow(md.Kits.Count > 0 ? md.Kits.Count + " kits" : "", md.Kits.Count)); #region Определение текста для колонки "Первое выполнение" var subItem = new CustomCell(); 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 CustomCell(); 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(CreateRow(md.Remains.ToString(), md.Remains)); subItems.Add(CreateRow(md.ProcedureType.ToString(), md.ProcedureType)); subItems.Add(CreateRow(md.NextPerformanceDate == null ? "N/A" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)md.NextPerformanceDate), md.NextPerformanceDate)); subItems.Add(CreateRow(md.ManHours.ToString(), md.ManHours)); subItems.Add(CreateRow(md.Cost.ToString(), md.Cost)); subItems.Add(CreateRow(author, author)); } 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(CreateRow(job.Kits.Count > 0 ? job.Kits.Count + " kits" : "", job.Kits.Count)); subItems.Add(CreateRow("", Lifelength.Null)); subItems.Add(CreateRow("", Lifelength.Null)); subItems.Add(CreateRow("", Lifelength.Null)); subItems.Add(CreateRow("", "")); subItems.Add(CreateRow("", DateTimeExtend.GetCASMinDateTime())); subItems.Add(CreateRow(job.ManHours.ToString(), job.ManHours)); subItems.Add(CreateRow(job.Cost.ToString(), job.Cost)); subItems.Add(CreateRow(author, author)); } else { throw new ArgumentOutOfRangeException($"1135: Takes an argument has no known type {item.GetType()}"); } return(subItems); }
/// <summary> /// /// </summary> //protected override void SetGroupsToItems(int columnIndex) //{ //} #endregion #region protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(Procedure item) /// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> protected override List <CustomCell> GetListViewSubItems(Procedure item) { var subItems = new List <CustomCell>(); ////////////////////////////////////////////////////////////////////////////////////// // Определение последнего выполнения директивы и KitRequiered // ////////////////////////////////////////////////////////////////////////////////////// DateTime defaultDateTime = DateTimeExtend.GetCASMinDateTime(); DateTime lastComplianceDate = defaultDateTime; DateTime nextComplianceDate = defaultDateTime; Lifelength lastComplianceLifeLength = Lifelength.Zero; string lastPerformanceString, firstPerformanceString = "N/A"; if (item.LastPerformance != null) { lastComplianceDate = item.LastPerformance.RecordDate; lastComplianceLifeLength = item.LastPerformance.OnLifelength; } if (item.Threshold.FirstPerformanceSinceNew != null && !item.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { firstPerformanceString = "s/n: " + item.Threshold.FirstPerformanceSinceNew; } if (item.Threshold.FirstPerformanceSinceEffectiveDate != null && !item.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (firstPerformanceString != "N/A") { firstPerformanceString += " or "; } else { firstPerformanceString = ""; } firstPerformanceString += "s/e.d: " + item.Threshold.FirstPerformanceSinceEffectiveDate; } //if (item.BindDetailDirectives.Count == 0) //{ if (item.NextPerformanceDate != null && item.NextPerformanceDate > defaultDateTime) { nextComplianceDate = Convert.ToDateTime(item.NextPerformanceDate); } // nextComplianceLifelength = item.NextCompliance; //} //else //{ // DetailDirective firstLimitter = // item.BindDetailDirectives.Where(bdd => bdd.NextComplianceDate != null && // bdd.NextComplianceDate > defaultDateTime) // .OrderBy(d => d) // .FirstOrDefault(); // if (firstLimitter != null) // { // nextComplianceDate = Convert.ToDateTime(firstLimitter.NextComplianceDate); // nextComplianceLifelength = firstLimitter.NextCompliance; // } //} string kitRequieredString = item.Kits.Count + " kits"; string remarksString = item.Remarks; string hiddenRemarksString = item.HiddenRemarks; if (lastComplianceDate <= defaultDateTime) { lastPerformanceString = "N/A"; } else { lastPerformanceString = SmartCore.Auxiliary.Convert.GetDateFormat(lastComplianceDate) + " " + lastComplianceLifeLength; } string nextComplianceString = ((nextComplianceDate <= defaultDateTime) ? "" : SmartCore.Auxiliary.Convert.GetDateFormat(nextComplianceDate) + " ") + item.NextPerformanceSource; string nextRemainString = item.Remains != null && !item.Remains.IsNullOrZero() ? item.Remains.ToString() : "N/A"; ////////////////////////////////////////////////////////////////////////////////////// var author = GlobalObjects.CasEnvironment.GetCorrector(item); string description = item.Description != "" ? item.Description : "N/A"; string title = item.Title != "" ? item.Title : "N/A"; string reqiredDocuments = item.DocumentReferences.Count > 0 ? item.DocumentReferences.Aggregate("", (current, i) => current + (i.Document + "; ")): "N/A"; DirectiveStatus status = item.Status; subItems.Add(CreateRow(title, title)); subItems.Add(CreateRow(description, description)); subItems.Add(CreateRow(item.ProcedureRating.ToString(), item.ProcedureRating)); subItems.Add(CreateRow(item.Level.ToString(), item.Level)); subItems.Add(CreateRow(item.AuditedObject, item.AuditedObject)); subItems.Add(CreateRow(item.ProcedureType.ToString(), item.ProcedureType)); subItems.Add(CreateRow(firstPerformanceString, firstPerformanceString)); subItems.Add(CreateRow(item.Threshold.RepeatInterval.ToString(), item.Threshold.RepeatInterval)); subItems.Add(CreateRow(nextComplianceString, nextComplianceDate)); subItems.Add(CreateRow(nextRemainString, nextRemainString)); subItems.Add(CreateRow(lastPerformanceString, lastComplianceDate)); subItems.Add(CreateRow(status.ToString(), status)); subItems.Add(CreateRow(reqiredDocuments, reqiredDocuments)); subItems.Add(CreateRow(kitRequieredString, kitRequieredString)); subItems.Add(CreateRow(item.ManHours <= 0 ? "" : item.ManHours.ToString(), item.ManHours)); subItems.Add(CreateRow(item.Cost <= 0 ? "" : item.Cost.ToString(), item.Cost)); subItems.Add(CreateRow(remarksString, remarksString)); subItems.Add(CreateRow(hiddenRemarksString, hiddenRemarksString)); subItems.Add(CreateRow(author, author)); return(subItems); }
private void SetParams() { #region Определение ограничений по ресурсу и дате выполнения if (_currentActualStateRecord.ItemId > 0) { //редактируется старая запись IWorkRegime workRegime = comboBoxFlightRegime.SelectedItem as IWorkRegime ?? FlightRegime.UNK; List <ActualStateRecord> asrs = _currentComponent.ActualStateRecords.Where(r => r.WorkRegime == workRegime) .OrderBy(r => r.RecordDate.Date) .ToList(); int index = asrs.Count > 0 ? asrs.IndexOf(_currentActualStateRecord) : 0; if (index == 0) { //редактируется первая запись о выполнении _prevPerfDate = null; _prevPerfLifelength = null; if (asrs.Count > 1) { //было сделано много записей о выполнении _nextPerfDate = asrs[index + 1].RecordDate.Date; _nextPerfLifelength = asrs[index + 1].OnLifelength; } else { _nextPerfDate = null; _nextPerfLifelength = null; } } else if (index < asrs.Count - 1) { //редактируется запись из середины списка записей о выполнении _prevPerfDate = asrs[index - 1].RecordDate.Date; _prevPerfLifelength = asrs[index - 1].OnLifelength; _nextPerfDate = asrs[index + 1].RecordDate.Date; _nextPerfLifelength = asrs[index + 1].OnLifelength; } else //(index == _currentDirective.PerformanceRecords.Count - 1) { //редактируется последняя запись _prevPerfDate = asrs[index - 1].RecordDate.Date; _prevPerfLifelength = asrs[index - 1].OnLifelength; _nextPerfDate = null; _nextPerfLifelength = null; } } lifelengthViewer_LastCompliance.MinLifelength = _prevPerfLifelength ?? Lifelength.Zero; lifelengthViewer_LastCompliance.MaxLifelength = _nextPerfLifelength ?? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentComponent); dateTimePicker1.MinDate = _prevPerfDate != null ? (DateTime)_prevPerfDate : DateTimeExtend.GetCASMinDateTime(); dateTimePicker1.MaxDate = _nextPerfDate != null ? (DateTime)_nextPerfDate : DateTime.Today; #endregion }
private Control GetControl(ICommonFilter commonFilter) { #region ЭУ для базовых типов if (commonFilter is CommonFilter <bool> ) { var boolFilter = commonFilter as CommonFilter <bool>; var boolFilterControl = new CommonBoolFilterControl(boolFilter) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(boolFilterControl); } if (commonFilter is CommonFilter <int> ) { var stringFilter = commonFilter as CommonFilter <int>; var intFilterControl = new CommonIntFilterControl(stringFilter) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(intFilterControl); } if (commonFilter is CommonFilter <string> ) { var stringFilter = commonFilter as CommonFilter <string>; var stringFilterControl = new CommonStringFilterControl(stringFilter) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(stringFilterControl); } if (commonFilter is CommonFilter <DateTime> ) { var dateFilter = commonFilter as CommonFilter <DateTime>; DateTime minDate = DateTimeExtend.GetCASMinDateTime(); DateTime maxDate = DateTime.Today; if (_items != null && _items.Count > 0 && commonFilter.FilterProperty.PropertyType.Name == typeof(DateTime).Name) { var p = commonFilter.FilterProperty; var preCollection = _items.OfType <BaseEntityObject>() .Select(o => p.GetValue(o, null)) .OfType <DateTime>() .OrderBy(time => time) .ToList(); var preMaxDate = preCollection[preCollection.Count - 1]; var preMinDate = preCollection[0]; if (preMinDate > minDate) { minDate = preMinDate; } if (preMaxDate > maxDate) { maxDate = preMaxDate; } } var dateFilterControl = new CommonDateTimePeriodFilterControl(dateFilter, minDate, maxDate) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(dateFilterControl); } #endregion #region ЭУ для ENUM, IDictionaryItem, IBaseEntityObject Type filterType = commonFilter.GetType(); if (filterType.IsGenericType) { Type genericArgumentType = filterType.GetGenericArguments().First(); if (genericArgumentType.IsEnum) { try { var enumFilterControl = new CommonEnumFilterControl(commonFilter) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(enumFilterControl); } catch (Exception) { return(null); } } if (genericArgumentType.GetInterface(typeof(IDictionaryItem).Name) != null) { try { var dictionaryFilter = (ICommonFilter <IDictionaryItem>)commonFilter; IDictionaryItem[] values = null; if (commonFilter.FilterProperty.PropertyType.GetInterface(typeof(IEnumerable <>).Name) != null) { Type t = commonFilter.FilterProperty.PropertyType; if (t != null) { Type filterPropertyGenericArgument = t.GetGenericArguments().FirstOrDefault(); if (filterPropertyGenericArgument != null && filterPropertyGenericArgument.GetInterface(typeof(IDictionaryItem).Name) != null) { PropertyInfo p = commonFilter.FilterProperty; values = _items.OfType <BaseEntityObject>() .Select(o => p.GetValue(o, null)) .Where(o => o != null) .Cast <IEnumerable>() .SelectMany(enumerable => enumerable.OfType <IDictionaryItem>()) .Select(o => o) .ToArray(); } } } else { PropertyInfo p = commonFilter.FilterProperty; values = _items.OfType <BaseEntityObject>() .Select(o => p.GetValue(o, null)) .OfType <IDictionaryItem>() .Distinct() .ToArray(); } var dictionaryFilterControl = new CommonDictionaryFilterControl(dictionaryFilter, values) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(dictionaryFilterControl); } catch (Exception) { return(null); } } if (genericArgumentType.GetInterface(typeof(IBaseEntityObject).Name) != null) { try { var entitiesFilter = commonFilter as ICommonFilter <IBaseEntityObject>; BaseEntityObject[] values = null; if (_items != null && _items.Count > 0) { if (commonFilter.FilterProperty.PropertyType.GetInterface(typeof(IEnumerable <>).Name) != null) { //Свойство типа является универсальным типом, типом аргумента которого является //является тип аргумента данного фильтра Type t = commonFilter.FilterProperty.PropertyType; while (t != null) { if (t.IsGenericType) { break; } t = t.BaseType; } if (t != null) { Type filterPropertyGenericArgument = t.GetGenericArguments().FirstOrDefault(); if (filterPropertyGenericArgument != null && filterPropertyGenericArgument.GetInterface(typeof(IBaseEntityObject).Name) != null) { PropertyInfo p = commonFilter.FilterProperty; values = _items.OfType <BaseEntityObject>() .Select(o => p.GetValue(o, null)) .Where(o => o != null) .Cast <IEnumerable>() .SelectMany(enumerable => enumerable.OfType <BaseEntityObject>()) .Select(o => o) .ToArray(); } } } if (commonFilter.FilterProperty.PropertyType.GetInterface(typeof(IBaseEntityObject).Name) != null) { PropertyInfo p = commonFilter.FilterProperty; values = _items.OfType <BaseEntityObject>() .Select(o => p.GetValue(o, null)) .OfType <BaseEntityObject>() .ToArray(); } } var baseEntityObjectFilterControl = new CommonBaseEntityObjectFilterControl(entitiesFilter, values) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(baseEntityObjectFilterControl); } catch (Exception) { return(null); } } } #endregion #region ЭУ для CommonFilter<Lifelength> if (commonFilter is CommonFilter <Lifelength> ) { var lifelengthFilter = commonFilter as CommonFilter <Lifelength>; Lifelength[] values = null; if (_items != null && _items.Count > 0 && commonFilter.FilterProperty.PropertyType.Name == typeof(Lifelength).Name) { PropertyInfo p = commonFilter.FilterProperty; values = _items.OfType <BaseEntityObject>() .Select(o => p.GetValue(o, null)) .OfType <Lifelength>() .ToArray(); } var stringFilterControl = new CommonLifelengthFilterControl(lifelengthFilter, values) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(stringFilterControl); } #endregion #region ЭУ для CommonFilter<BaseEntityObject> if (commonFilter is CommonFilter <IBaseEntityObject> ) { var lifelengthFilter = commonFilter as CommonFilter <IBaseEntityObject>; BaseEntityObject[] values = null; if (_items != null && _items.Count > 0 && commonFilter.FilterProperty.PropertyType.Name == typeof(Lifelength).Name) { PropertyInfo p = commonFilter.FilterProperty; values = _items.OfType <BaseEntityObject>() .Select(o => p.GetValue(o, null)) .OfType <BaseEntityObject>() .ToArray(); } var baseEntityObjectFilterControl = new CommonBaseEntityObjectFilterControl(lifelengthFilter, values) { AutoSize = true, MinimumSize = new Size(20, 17), Tag = commonFilter.FilterProperty, }; return(baseEntityObjectFilterControl); } #endregion return(null); }
private void SetValues(WorkPackageClosingDataGridViewRow row, Audit wp, AbstractPerformanceRecord apr) { row.WorkPackage = wp; row.Record = apr; if (apr != null) { row.ClosingItem = apr.Parent; } if (row.ClosingItem == null || apr == null) { return; } SetLabelsAndText(row); if (apr is DirectiveRecord || apr is MaintenanceCheckRecord) { row.Cells[ColumnClosed.Index].Value = true; //Lifelength performanceSource = apr.OnLifelength; //row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null ? performanceSource.Hours.ToString() : "n/a"; //row.Cells[ColumnCycles.Index].Value = performanceSource.Cycles != null ? performanceSource.Cycles.ToString() : "n/a"; //row.Cells[ColumnDays.Index].Value = performanceSource.Days != null ? performanceSource.Days.ToString() : "n/a"; row.Cells[ColumnDate.Index].Value = apr.RecordDate; row.PrevPerfDate = apr.PrevPerformanceDate; row.NextPerfDate = apr.NextPerformanceDate; } else if (apr is TransferRecord) { TransferRecord tr = (TransferRecord)apr; if (tr.ItemId > 0) { //если запись о перемещении имеет itemID > 0 //и она не подтвержддена стороной получателя, то ее можно редактировать и удалять //если подтверждена, то редактировать и удалять ее нельзя if (tr.DODR) { row.Cells[ColumnHours.Index].ReadOnly = false; row.PrevPerfDate = tr.PrevPerformanceDate; row.NextPerfDate = tr.TransferDate; } else { row.Cells[ColumnHours.Index].ReadOnly = true; row.PrevPerfDate = tr.PrevPerformanceDate; row.NextPerfDate = tr.NextPerformanceDate; } row.Cells[ColumnCycles.Index].Value = "Transfer to: " + GetDestination(tr); row.Cells[ColumnDate.Index].Value = tr.StartTransferDate; } else { row.Cells[ColumnCycles.Index].Value = "Transfer to: "; row.PrevPerfDate = apr.PrevPerformanceDate; row.NextPerfDate = apr.NextPerformanceDate; } row.Cells[ColumnClosed.Index].Value = true; } DataGridViewCalendarCell cc = row.Cells[ColumnDate.Index] as DataGridViewCalendarCell; if (cc != null) { if (row.PrevPerfDate != null) { cc.MinDate = (DateTime)row.PrevPerfDate; } else { cc.MinDate = DateTimeExtend.GetCASMinDateTime(); } if (row.NextPerfDate != null) { cc.MaxDate = (DateTime)row.NextPerfDate; } else { cc.MaxDate = DateTime.Now; } } row.MinPerfSource = apr.PrevPerformanceSource.IsNullOrZero() ? Lifelength.Zero : apr.PrevPerformanceSource; row.MaxPerfSource = apr.NextPerformanceSource.IsNullOrZero() //TODO:(Evgenii Babak) пересмотреть подход, наработка считается на конец дня, а в метод передаем DateTime.Now(может быть и концом дня) ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(row.ClosingItem.LifeLengthParent, DateTime.Now) : apr.NextPerformanceSource; }
protected override List <CustomCell> GetListViewSubItems(NextPerformance item) { var subItems = new List <CustomCell>(); var tcnColor = radGridView1.ForeColor; var lastComplianceDate = DateTimeExtend.GetCASMinDateTime(); var lastComplianceLifeLength = Lifelength.Zero; string lastPerformanceString, firstPerformanceString = "N/A"; double manHours = item.Parent is IEngineeringDirective ? ((IEngineeringDirective)item.Parent).ManHours : 0; var author = GlobalObjects.CasEnvironment.GetCorrector(item); var title = item.Title; var card = ""; var access = ""; var workArea = ""; var zone = ""; double extension = 0; var description = item.Description; if (item.Parent is Directive directive) { title = directive.Title; card = directive.EngineeringOrders; if (!directive.HasEoFile) { tcnColor = Color.MediumVioletRed; } access = directive.DirectiveAccess; workArea = directive.Workarea; zone = directive.DirectiveZone; extension = directive.Extension; } else if (item.Parent is MaintenanceDirective d) { if (!d.HasTaskCardFile) { tcnColor = Color.MediumVioletRed; } card = d.TaskCardNumber; access = d.Access; workArea = d.Workarea; zone = d.Zone; extension = d.Extension; } else if (item.Parent is ComponentDirective c) { if (!(bool)c.MaintenanceDirective?.HasTaskCardFile) { tcnColor = Color.MediumVioletRed; } description = item.Title; title = c.MaintenanceDirective?.TaskNumberCheck ?? ""; card = c.MaintenanceDirective?.TaskCardNumber ?? ""; access = c.Access; workArea = ""; zone = c.Zone; extension = c.Extension; } //Последнее выполнение if (item.Parent.LastPerformance != null && item.Parent.LastPerformance.RecordDate > lastComplianceDate) { lastComplianceDate = item.Parent.LastPerformance.RecordDate; if (item.Parent is ComponentDirective) { lastComplianceLifeLength = item.Parent.NextPerformance.LastDataC; } else { lastComplianceLifeLength = item.Parent.LastPerformance.OnLifelength; } } //Следующее выполнение if (item.Parent.Threshold.FirstPerformanceSinceNew != null && !item.Parent.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { firstPerformanceString = "s/n: " + item.Parent.Threshold.FirstPerformanceSinceNew; } if (item.Parent.Threshold.FirstPerformanceSinceEffectiveDate != null && !item.Parent.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (firstPerformanceString != "N/A") { firstPerformanceString += " or "; } else { firstPerformanceString = ""; } firstPerformanceString += "s/e.d: " + item.Parent.Threshold.FirstPerformanceSinceEffectiveDate; } var repeatInterval = item.Parent.Threshold.RepeatInterval.ToString(); if (lastComplianceDate <= DateTimeExtend.GetCASMinDateTime()) { lastPerformanceString = "N/A"; } else { lastPerformanceString = lastComplianceLifeLength.ToString(); } var lastDate = (lastComplianceDate <= DateTimeExtend.GetCASMinDateTime()) ? "" : SmartCore.Auxiliary.Convert.GetDateFormat(lastComplianceDate); var condition = !string.IsNullOrEmpty(firstPerformanceString) ? (item.Parent.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "/WF" : "/WL") : ""; var conditionRepeat = !item.Parent.Threshold.RepeatInterval.IsNullOrZero() ? (item.Parent.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "/WF" : "/WL") : ""; var type = item.Parent.SmartCoreObjectType; if (item.Parent is ComponentDirective cd) { if (cd.FromBaseComponent) { type = SmartCoreType.BaseComponent; } } else if (item.Parent is MaintenanceDirective md) { if (md.APUCalc) { firstPerformanceString = firstPerformanceString.Replace("FH", "AH"); repeatInterval = repeatInterval.Replace("FH", "AH"); } } subItems.Add(CreateRow(title, title)); subItems.Add(CreateRow(card, card, tcnColor)); subItems.Add(CreateRow(description, description)); subItems.Add(CreateRow(item.WorkType, item.WorkType)); subItems.Add(CreateRow($"{firstPerformanceString} {condition}", firstPerformanceString)); subItems.Add(CreateRow($"{repeatInterval} {conditionRepeat}", repeatInterval)); subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(item.PerformanceDate), item.PerformanceDate)); subItems.Add(CreateRow(item.PerformanceSource.ToString(), item.PerformanceSource)); subItems.Add(CreateRow(item.Remains.ToString(), item.Remains)); subItems.Add(CreateRow(item.NextLimit.Days != null ? SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformanceDateNew) : "", item.NextPerformanceDateNew)); subItems.Add(CreateRow(item.NextLimit.ToString(), item.NextLimit.ToString())); subItems.Add(CreateRow(item.RemainLimit.ToString(), item.RemainLimit.ToString())); subItems.Add(CreateRow(lastDate, lastComplianceDate)); subItems.Add(CreateRow(lastPerformanceString, lastComplianceLifeLength)); subItems.Add(CreateRow(item.KitsToString, item.Kits?.Count)); subItems.Add(CreateRow(manHours.ToString(), manHours)); subItems.Add(CreateRow(zone, zone)); subItems.Add(CreateRow(workArea, workArea)); subItems.Add(CreateRow(access, access)); subItems.Add(CreateRow(type.ToString(), type.SmartCoreObjectType)); subItems.Add(CreateRow(item.ATAChapter?.ToString(), item.ATAChapter)); subItems.Add(CreateRow(item.MaintenanceCheck != null ? item.MaintenanceCheck.ToString() : "", item.MaintenanceCheck)); subItems.Add(CreateRow(extension.ToString("F0"), extension)); subItems.Add(CreateRow(author, author)); return(subItems); }
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> private void UpdateInformation() { if (_currentAudit == null) { return; } Text = _currentAudit.Title; dataGridViewItems.Rows.Clear(); DateTime minComplianceDate = DateTimeExtend.GetCASMinDateTime(); IEnumerable <AuditRecord> proceduresRecords = _currentAudit.AuditRecords.Where(wpr => wpr.Task != null && wpr.Task is Procedure); List <IGrouping <string, AuditRecord> > groupedDirectiveWprs = proceduresRecords.GroupBy(wpr => (((Procedure)wpr.Task).ProcedureType).FullName).ToList(); checkBoxSelectAll.CheckedChanged -= CheckBoxSelectAllCheckedChanged; foreach (IGrouping <string, AuditRecord> grouping in groupedDirectiveWprs) { //добавить расчеты ComlianceDate foreach (AuditRecord item in grouping) { if (item.Task is Procedure || item.Task is Directive || item.Task is ComponentDirective || item.Task is MaintenanceCheck || item.Task is MaintenanceDirective) { //WorkPackageClosingDataGridViewRow r = new WorkPackageClosingDataGridViewRow(); //r.CreateCells(dataGridViewItems); //int index = dataGridViewItems.Rows.Add(r); //index.ToString(); WorkPackageClosingDataGridViewRow r = (WorkPackageClosingDataGridViewRow) dataGridViewItems.Rows[dataGridViewItems.Rows.Add(new WorkPackageClosingDataGridViewRow())]; if (item.Task.NextPerformances.Count > 0) { SetValues(r, _currentAudit, item.Task.NextPerformances[0]); } else if (item.Task.PerformanceRecords.Cast <AbstractPerformanceRecord>().Any(pr => pr.DirectivePackageId == _currentAudit.ItemId)) { AbstractPerformanceRecord apr = item.Task.PerformanceRecords .Cast <AbstractPerformanceRecord>() .First(pr => pr.DirectivePackageId == _currentAudit.ItemId); SetValues(r, _currentAudit, apr); } else { SetValues(r, _currentAudit, item); } } if (item.Task is Component) { //WorkPackageClosingDataGridViewRow r = new WorkPackageClosingDataGridViewRow(); //r.CreateCells(dataGridViewItems); //dataGridViewItems.Rows.Add(r); WorkPackageClosingDataGridViewRow r = (WorkPackageClosingDataGridViewRow) dataGridViewItems.Rows[dataGridViewItems.Rows.Add(new WorkPackageClosingDataGridViewRow())]; Component component = (Component)item.Task; if (component.NextPerformances.Count > 0) { SetValues(r, _currentAudit, component.NextPerformances[0]); } else if (component.TransferRecords.Any(pr => pr.DirectivePackageId == _currentAudit.ItemId)) { AbstractPerformanceRecord apr = component.TransferRecords .Cast <AbstractPerformanceRecord>() .First(pr => pr.DirectivePackageId == _currentAudit.ItemId); SetValues(r, _currentAudit, apr); } else { SetValues(r, _currentAudit, item); } } } } dateTimePickerClosingDate.ValueChanged -= DateTimePickerClosingDateValueChanged; dateTimePickerClosingDate.Value = _currentAudit.Status != WorkPackageStatus.Closed ? minComplianceDate : _currentAudit.ClosingDate; dateTimePickerClosingDate.MinDate = _currentAudit.MinClosingDate != null ? _currentAudit.MinClosingDate.Value : DateTimeExtend.GetCASMinDateTime(); dateTimePickerClosingDate.MaxDate = _currentAudit.MaxClosingDate != null ? _currentAudit.MaxClosingDate.Value : DateTimeExtend.GetCASMinDateTime(); dateTimePickerClosingDate.ValueChanged += DateTimePickerClosingDateValueChanged; checkBoxSelectAll.CheckedChanged += CheckBoxSelectAllCheckedChanged; fileControl.AttachedFile = _currentAudit.AttachedFile; }
private void DataGridViewItemsCellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } #region //Проверка колонки "Выполнено" if (e.ColumnIndex == ColumnClosed.Index) { checkBoxSelectAll.CheckedChanged -= CheckBoxSelectAllCheckedChanged; IEnumerable <WorkPackageClosingDataGridViewRow> rows = dataGridViewItems.Rows.OfType <WorkPackageClosingDataGridViewRow>(); bool checkedValue = rows.FirstOrDefault(r => (bool)r.Cells[ColumnClosed.Index].Value) != null; bool unCheckedValue = rows.FirstOrDefault(r => !(bool)r.Cells[ColumnClosed.Index].Value) != null; if (checkedValue && unCheckedValue) { checkBoxSelectAll.CheckState = CheckState.Indeterminate; } else if (checkedValue) { checkBoxSelectAll.CheckState = CheckState.Checked; } else { checkBoxSelectAll.CheckState = CheckState.Unchecked; } checkBoxSelectAll.CheckedChanged += CheckBoxSelectAllCheckedChanged; } #endregion #region //Проверка колонки "Часы" if (e.ColumnIndex == ColumnHours.Index) { WorkPackageClosingDataGridViewRow row = dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow; if (row == null || row.ClosingItem is Component) { return; } DataGridViewCell cell = dataGridViewItems[e.ColumnIndex, e.RowIndex]; string value = cell.Value as string; if (value == null) { return; } if (Lifelength.ValidateHours(value)) { int?totalMinutes = Lifelength.ParseTotalMinutes(value); if (totalMinutes == null) { return; } if (row.MinPerfSource != null && row.MinPerfSource.TotalMinutes != null && row.MinPerfSource.TotalMinutes > totalMinutes) { cell.Style.BackColor = Color.Red; } else { cell.Style.BackColor = Color.White; } } else { cell.Style.BackColor = Color.Red; } } #endregion #region //Проверка колонки "Циклы" if (e.ColumnIndex == ColumnCycles.Index) { WorkPackageClosingDataGridViewRow row = dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow; if (row == null || row.ClosingItem is Component) { return; } DataGridViewCell cell = dataGridViewItems[e.ColumnIndex, e.RowIndex]; string value = cell.Value as string; if (value == null) { return; } if (Lifelength.ValidateCyclesOrDays(value)) { int?cycles = Lifelength.ParseCyclesOrDays(value); if (cycles == null) { return; } if (row.MinPerfSource != null && row.MinPerfSource.Cycles != null && row.MinPerfSource.Cycles > cycles) { cell.Style.BackColor = Color.Red; } else { cell.Style.BackColor = Color.White; } } else { cell.Style.BackColor = Color.Red; } } #endregion #region //Проверка колонки "Дни" if (e.ColumnIndex == ColumnDays.Index) { WorkPackageClosingDataGridViewRow row = dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow; if (row == null || row.ClosingItem is Component) { return; } DataGridViewCell cell = dataGridViewItems[e.ColumnIndex, e.RowIndex]; string value = cell.Value as string; if (value == null) { return; } if (Lifelength.ValidateCyclesOrDays(value)) { int?cycles = Lifelength.ParseCyclesOrDays(value); if (cycles == null) { return; } if (row.MinPerfSource != null && row.MinPerfSource.Days != null && row.MinPerfSource.Days > cycles) { cell.Style.BackColor = Color.Red; } else { cell.Style.BackColor = Color.White; } } else { cell.Style.BackColor = Color.Red; } } #endregion #region //Проверка колонки "Дата" if (e.ColumnIndex == ColumnDate.Index) { WorkPackageClosingDataGridViewRow row = dataGridViewItems.Rows[e.RowIndex] as WorkPackageClosingDataGridViewRow; if (row != null && !(row.ClosingItem is Component)) { DateTime dateTime = Convert.ToDateTime(row.Cells[ColumnDate.Index].Value); if (row.PrevPerfDate != null && dateTime < row.PrevPerfDate) { row.Cells[ColumnDate.Index].Value = row.PrevPerfDate.Value; } else if (dateTime < new DateTime(1950, 1, 1)) { row.Cells[ColumnDate.Index].Value = DateTimeExtend.GetCASMinDateTime(); } if (row.NextPerfDate != null && dateTime > row.NextPerfDate) { row.Cells[ColumnDate.Index].Value = row.NextPerfDate.Value; } else if (dateTime > DateTime.Now) { row.Cells[ColumnDate.Index].Value = DateTime.Now; } if (row.ClosingItem.LifeLengthParent is Operator) { row.Cells[ColumnHours.Index].Value = "n/a"; row.Cells[ColumnCycles.Index].Value = "n/a"; row.Cells[ColumnDays.Index].Value = "n/a"; } else { Lifelength performanceSource = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(row.ClosingItem.LifeLengthParent, dateTime); row.Cells[ColumnHours.Index].Value = performanceSource.Hours != null?performanceSource.ToHoursMinutesFormat("") : "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"; } } } #endregion }
protected override List <CustomCell> GetListViewSubItems(MaintenanceDirective item) { var subItems = new List <CustomCell>(); ////////////////////////////////////////////////////////////////////////////////////// // Определение последнего выполнения директивы и KitRequiered // ////////////////////////////////////////////////////////////////////////////////////// DateTime defaultDateTime = DateTimeExtend.GetCASMinDateTime(); DateTime lastComplianceDate = defaultDateTime; DateTime nextComplianceDate = defaultDateTime; Lifelength lastComplianceLifeLength = Lifelength.Zero; //Lifelength nextComplianceLifelength = Lifelength.Null; string lastPerformanceString, firstPerformanceString = "N/A"; Color tcnColor = radGridView1.ForeColor; Color kitColor = radGridView1.BackColor; AtaChapter ata = item.ATAChapter; if (item.LastPerformance != null) { lastComplianceDate = item.LastPerformance.RecordDate; lastComplianceLifeLength = item.LastPerformance.OnLifelength; } if (item.Threshold.FirstPerformanceSinceNew != null && !item.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { firstPerformanceString = "s/n: " + item.Threshold.FirstPerformanceSinceNew; } if (item.Threshold.FirstPerformanceSinceEffectiveDate != null && !item.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (firstPerformanceString != "N/A") { firstPerformanceString += " or "; } else { firstPerformanceString = ""; } firstPerformanceString += "s/e.d: " + item.Threshold.FirstPerformanceSinceEffectiveDate; } if (item.NextPerformanceDate != null && item.NextPerformanceDate > defaultDateTime) { nextComplianceDate = Convert.ToDateTime(item.NextPerformanceDate); } var author = GlobalObjects.CasEnvironment.GetCorrector(item); string kitRequieredString = item.KitsApplicable ? item.Kits.Count + " EA" : "N/A"; string ndtString = item.NDTType.ShortName; string skillString = item.Skill.ShortName; string categoryString = item.Category.ShortName; string remarksString = item.Remarks; string hiddenRemarksString = item.HiddenRemarks; if (lastComplianceDate <= defaultDateTime) { lastPerformanceString = "N/A"; } else { lastPerformanceString = SmartCore.Auxiliary.Convert.GetDateFormat(lastComplianceDate) + " " + lastComplianceLifeLength; } string nextComplianceString = ((nextComplianceDate <= defaultDateTime) ? "" : SmartCore.Auxiliary.Convert.GetDateFormat(nextComplianceDate) + " ") + item.NextPerformanceSource; string nextRemainString = item.Remains != null && !item.Remains.IsNullOrZero() ? item.Remains.ToString() : "N/A"; var repeat = item.Threshold.RepeatInterval.ToString(); if (item.APUCalc) { firstPerformanceString = firstPerformanceString.Replace("FH", "AH"); repeat = repeat.Replace("FH", "AH"); } ////////////////////////////////////////////////////////////////////////////////////// string description = item.Description != "" ? item.Description : "N/A"; string app = item.IsApplicability ? $"APL {item.Applicability}" : $"N/A {item.Applicability}"; string taskNumber = item.MPDTaskNumber != "" ? item.MPDTaskNumber : "N/A"; string taskCheck = item.TaskNumberCheck != "" ? item.TaskNumberCheck : "N/A"; string maintManual = item.MaintenanceManual != "" ? item.MaintenanceManual : "N/A"; string mrb = item.MRB != "" ? item.MRB : "N/A"; string check = item.MaintenanceCheck != null ? item.MaintenanceCheck.Name : "N/A"; DirectiveStatus status = item.Status; if (item.TaskCardNumberFile == null) { tcnColor = Color.MediumVioletRed; } if (item.KitsApplicable && item.Kits.Count == 0) { kitColor = Color.FromArgb(Highlight.Red.Color); } subItems.Add(CreateRow(item.ParentAircraft?.ToString() ?? "", item.ParentAircraft)); subItems.Add(CreateRow(item.ScheduleItem, item.ScheduleItem)); subItems.Add(CreateRow(taskCheck, taskCheck)); subItems.Add(CreateRow(item.TaskCardNumber, item.TaskCardNumber, tcnColor)); subItems.Add(CreateRow(description, description)); subItems.Add(CreateRow(item.Program.ToString(), item.Program)); subItems.Add(CreateRow(item.ProgramIndicator.ShortName, item.ProgramIndicator)); subItems.Add(CreateRow(item.WorkType.ToString(), item.WorkType)); subItems.Add(CreateRow(check, check)); subItems.Add(CreateRow(item.APUCalc ? "Yes" : "No", item.APUCalc)); subItems.Add(CreateRow(firstPerformanceString, firstPerformanceString)); subItems.Add(CreateRow(repeat, item.Threshold.RepeatInterval)); subItems.Add(CreateRow(nextComplianceString, nextComplianceDate)); subItems.Add(CreateRow(nextRemainString, nextRemainString)); subItems.Add(CreateRow(lastPerformanceString, lastComplianceDate)); subItems.Add(CreateRow(item.Zone, item.Zone)); subItems.Add(CreateRow(item.Workarea, item.Workarea)); subItems.Add(CreateRow(item.Access, item.Access)); subItems.Add(CreateRow(status.ToString(), status)); subItems.Add(CreateRow(taskNumber, taskNumber)); subItems.Add(CreateRow(maintManual, maintManual)); subItems.Add(CreateRow(mrb, mrb)); subItems.Add(CreateRow(item.TaskCardNumber, item.TaskCardNumber)); subItems.Add(CreateRow(item.CriticalSystem.ToString(), item.CriticalSystem)); subItems.Add(CreateRow(ata.ToString(), ata)); subItems.Add(CreateRow(kitRequieredString, kitRequieredString, kitColor)); subItems.Add(CreateRow(ndtString, ndtString)); subItems.Add(CreateRow(skillString, skillString)); subItems.Add(CreateRow(categoryString, categoryString)); subItems.Add(CreateRow(item.Elapsed <= 0 ? "" : item.Elapsed.ToString(), item.Elapsed)); subItems.Add(CreateRow(item.ManHours <= 0 ? "" : item.ManHours.ToString(), item.ManHours)); subItems.Add(CreateRow(item.Cost <= 0 ? "" : item.Cost.ToString(), item.Cost)); subItems.Add(CreateRow(app, app)); subItems.Add(CreateRow(remarksString, remarksString)); subItems.Add(CreateRow(hiddenRemarksString, hiddenRemarksString)); subItems.Add(CreateRow(author, author)); return(subItems); }
/// <summary> /// Создает прогноз на заданную дату /// </summary> /// <param name="date">Дата, на которую необходимо построить отчет</param> /// <param name="baseComponentгрегат</param> /// <param name="current">Текущая наработка агрегата или налет ВС</param> /// <param name="lowerLimit">Нижняя граница прогноза</param> public ForecastData(DateTime date, BaseComponent baseComponent, Lifelength current, DateTime?lowerLimit = null) { BaseComponent = baseComponent; SelectedForecastType = lowerLimit != null ? ForecastType.ForecastByPeriod : ForecastType.ForecastByDate; LowerLimit = lowerLimit != null?Convert.ToDateTime(lowerLimit) : DateTimeExtend.GetCASMinDateTime(); Init(date, BaseComponent.AverageUtilization, current); }
/// <summary> /// Обновляет информацию о базовом агрегате текущего ВС /// </summary> private void UpdateControl() { if (_currentBaseComponent == null) { return; } comboBoxEngineModel.Type = typeof(ComponentModel); lifelengthViewerInstallation.MinLifelength = Lifelength.Zero; dateTimePickerInstallation.ValueChanged -= DateTimePickerManufactureDateValueChanged; dateTimePickerManufactureDate.ValueChanged -= DateTimePickerManufactureDateValueChanged; dateTimePickerStart.ValueChanged -= DateTimePickerManufactureDateValueChanged; comboBoxEngineModel.SelectedIndexChanged -= comboBoxEngineModel_SelectedIndexChanged; labelEngineModel.Text = _currentBaseComponent.BaseComponentType.ShortName + " Model"; if (_currentBaseComponent.ItemId <= 0) { linkViewInfo.Visible = false; textBoxSerialNumber.Text = "Please, enter serial number"; comboBoxEngineModel.SelectedItem = null; textBoxManufacturer.Text = "Please, enter manufacturer"; textBoxPosition.Text = "Please, enter position"; textBoxTSNCSN.Text = ""; } else { textBoxSerialNumber.Text = _currentBaseComponent.SerialNumber; comboBoxEngineModel.SelectedItem = _currentBaseComponent.Model; textBoxManufacturer.Text = _currentBaseComponent.Manufacturer; textBoxPosition.Text = _currentBaseComponent.PositionNumber; textBoxTSNCSN.Text = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentBaseComponent).ToString(); } textBoxPartialNumber.Text = _currentBaseComponent.PartNumber; dateTimePickerManufactureDate.Value = _currentBaseComponent.ManufactureDate < dateTimePickerManufactureDate.MinDate ? dateTimePickerManufactureDate.MinDate : _currentBaseComponent.ManufactureDate; if (_currentBaseComponent.StartLifelength != null) { lifelengthViewerStart.Lifelength = _currentBaseComponent.StartLifelength; } if (_currentBaseComponent.StartDate.Year > 1950) { dateTimePickerStart.Value = _currentBaseComponent.StartDate; } else { dateTimePickerStart.Value = DateTimeExtend.GetCASMinDateTime(); } if (_currentBaseComponent.LifeLimit != null) { lifelengthViewerLifeLimit.Lifelength = _currentBaseComponent.LifeLimit; } if (_currentBaseComponent.Warranty != null) { lifelengthViewerWarranty.Lifelength = _currentBaseComponent.Warranty; } var lastTransferRecord = _currentBaseComponent.TransferRecords.GetLast(); if (lastTransferRecord != null) { lifelengthViewerInstallation.Lifelength = lastTransferRecord.OnLifelength; dateTimePickerInstallation.Value = lastTransferRecord.TransferDate; } dateTimePickerInstallation.ValueChanged += DateTimePickerManufactureDateValueChanged; dateTimePickerManufactureDate.ValueChanged += DateTimePickerManufactureDateValueChanged; dateTimePickerStart.ValueChanged += DateTimePickerManufactureDateValueChanged; comboBoxEngineModel.SelectedIndexChanged += comboBoxEngineModel_SelectedIndexChanged; }
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()); }
private void UpdateInformation() { if (_contextMenuStrip == null) { InitToolStripMenuItems(); } listViewCompliance.Items.Clear(); if (CheckItems == null) { return; } var lastRecords = new List <MaintenanceCheckRecord>(); var nextPerformances = new List <NextPerformance>(); //Поиск и заполнение просроченных директив и записей о перемещении //Объекты для в которые будет извлекаться информация //из записеи о перемещении string[] subs; ListViewItem newItem; var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(_currentAircraft.AircraftFrameId); //прогнозируемый ресурс var forecastData = new ForecastData(DateTime.Now, aircraftFrame.AverageUtilization, GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentAircraft)); //GlobalObjects.CasEnvironment.Calculator.GetNextPerformanceGroup(CheckItems, _currentAircraft.Schedule, forecastData); foreach (MaintenanceCheck check in CheckItems) { if (check.Grouping) { foreach (MaintenanceNextPerformance mnp in check.GetPergormanceGroupWhereCheckIsSenior()) { //Добавляются все выполнения, дата которых меньше нынешней //плюс еще одно выполнение дата которого выше нынешней nextPerformances.Add(mnp); if (mnp.PerformanceDate != null && mnp.PerformanceDate > DateTime.Now) { break; } } } else { foreach (NextPerformance mnp in check.NextPerformances) { //Добавляются все выполнения, дата которых меньше нынешней //плюс еще одно выполнение дата которого выше нынешней nextPerformances.Add(mnp); if (mnp.PerformanceDate != null && mnp.PerformanceDate > DateTime.Now) { break; } } } lastRecords.AddRange(check.PerformanceRecords.ToArray()); foreach (MaintenanceDirective mpd in check.BindMpds) { GlobalObjects.PerformanceCalculator.GetNextPerformance(mpd, forecastData); } } //////////////////////////////////////////// //загрузка рабочих пакетов для определения //перекрытых ими выполнений задач if (_openPubWorkPackages == null) { _openPubWorkPackages = new CommonCollection <WorkPackage>(); } _openPubWorkPackages.Clear(); _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft, WorkPackageStatus.Opened)); _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft, WorkPackageStatus.Published)); var allWorkPackagesIncludedTask = new CommonCollection <WorkPackage>(); var openPubWorkPackages = new CommonCollection <WorkPackage>(); var closedWorkPackages = new CommonCollection <WorkPackage>(); allWorkPackagesIncludedTask.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(_currentAircraft, WorkPackageStatus.All, CheckItems.Select(m => (IDirective)m).ToList())); #region Добавление в список просроченных выполнений //и сравнение их с открытыми и опубликованными рабочими пакетами openPubWorkPackages.AddRange(allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Opened || wp.Status == WorkPackageStatus.Published)); //сбор всех записей рабочих пакетов для удобства фильтрации List <WorkPackageRecord> openPubWPRecords = new List <WorkPackageRecord>(); foreach (WorkPackage openWorkPackage in openPubWorkPackages) { openPubWPRecords.AddRange(openWorkPackage.WorkPakageRecords); } //LINQ запрос для сортировки записей по дате List <NextPerformance> sortNextRecords = (from record in nextPerformances orderby record.GetPerformanceDateOrDefault() descending select record).ToList(); for (int i = 0; i < sortNextRecords.Count; i++) { //поиск записи в рабочих пакетах по данному чеку //чей номер группы выполнения (по записи) совпадает с расчитанным MaintenanceCheck check = (MaintenanceCheck)sortNextRecords[i].Parent; //if (check.Name == "5C") //{ //} //номер выполнения int parentCountPerf; if (check.LastPerformance != null) { parentCountPerf = check.LastPerformance.NumGroup <= 0 ? 1 : check.LastPerformance.NumGroup; } else { parentCountPerf = 0; } if (check.Grouping) { MaintenanceNextPerformance mnp = sortNextRecords[i] as MaintenanceNextPerformance; if (mnp != null) { parentCountPerf = mnp.PerformanceGroupNum; } else { parentCountPerf += check.NextPerformances.IndexOf(sortNextRecords[i]); parentCountPerf += 1; } } else { parentCountPerf += check.NextPerformances.IndexOf(sortNextRecords[i]); parentCountPerf += 1; } WorkPackageRecord wpr = openPubWPRecords.Where(r => r.PerformanceNumFromStart == parentCountPerf && r.WorkPackageItemType == check.SmartCoreObjectType.ItemId && r.DirectiveId == check.ItemId).FirstOrDefault(); if (wpr != null) { WorkPackage wp = openPubWorkPackages.GetItemById(wpr.WorkPakageId); //запись о выполнении блокируется найденым пакетом sortNextRecords[i].BlockedByPackage = wp; //последующие записи о выполнении так же должны быть заблокированы for (int j = i - 1; j >= 0; j--) { //блокировать нужно все рабочие записи, или до первой записи, //заблокированной другим рабочим пакетом if (sortNextRecords[j].BlockedByPackage != null && sortNextRecords[j].Parent == check || sortNextRecords[j].Condition != ConditionState.Overdue) { break; } if (sortNextRecords[j].Parent == check) { sortNextRecords[j].BlockedByPackage = wp; listViewCompliance.Items[j].BackColor = Color.FromArgb(Highlight.GrayLight.Color); } } } string type = check.Schedule ? " (Schedule) " : " (Store) "; string resource = check.Resource.ToString(); string grouping = check.Grouping ? " (Group)" : ""; string stringNumGr = (sortNextRecords[i] is MaintenanceNextPerformance ? ((MaintenanceNextPerformance)sortNextRecords[i]).PerformanceGroupNum.ToString() : "N/A") + type + resource + grouping; subs = new[] { stringNumGr, sortNextRecords[i].Title, sortNextRecords[i].PerformanceDate != null ? UsefulMethods.NormalizeDate((DateTime)sortNextRecords[i].PerformanceDate) : "N/A", sortNextRecords[i].PerformanceSource.ToString(), "", }; newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups["next"], Tag = sortNextRecords[i], BackColor = UsefulMethods.GetColor(sortNextRecords[i]) }; listViewCompliance.Items.Add(newItem); } #endregion #region Добавление в список записей о произведенных выполнениях //и сравнение их с закрытыми рабочими пакетами closedWorkPackages.AddRange(allWorkPackagesIncludedTask.Where(wp => wp.Status == WorkPackageStatus.Closed)); //сбор всех записей рабочих пакетов для удобства фильтрации List <WorkPackageRecord> closedWPRecords = new List <WorkPackageRecord>(); foreach (WorkPackage closedWorkPackage in closedWorkPackages) { closedWPRecords.AddRange(closedWorkPackage.WorkPakageRecords); } List <MaintenanceCheckRecordGroup> maintenanceCheckRecordGroups = new List <MaintenanceCheckRecordGroup>(); foreach (MaintenanceCheckRecord record in lastRecords) { //Поиск коллекции групп, в которую входят группы с нужными критериями //по плану, группировка и основному ресурсу if (record.ParentCheck.Grouping) { 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); } } else { MaintenanceCheckRecordGroup recordGroup = new MaintenanceCheckRecordGroup(record.ParentCheck.Schedule, record.ParentCheck.Grouping, record.ParentCheck.Resource); recordGroup.Records.Add(record); maintenanceCheckRecordGroups.Add(recordGroup); } } List <object> tempRecords = new List <object>(); tempRecords.AddRange(maintenanceCheckRecordGroups.ToArray()); tempRecords.AddRange(_currentAircraft.MaintenanceProgramChangeRecords.ToArray()); List <object> sortLastRecords = tempRecords.OrderByDescending(tr => (tr is MaintenanceCheckRecordGroup ? ((MaintenanceCheckRecordGroup)tr).LastGroupComplianceDate : tr is AbstractRecord ? ((AbstractRecord)tr).RecordDate : DateTimeExtend.GetCASMinDateTime())) .ToList(); foreach (object t in sortLastRecords) { if (t is MaintenanceCheckRecordGroup) { MaintenanceCheckRecordGroup mcrg = (MaintenanceCheckRecordGroup)t; MaintenanceCheckRecord directiveRecord = mcrg.Records.First(); MaintenanceCheck parentDirective = (MaintenanceCheck)directiveRecord.Parent; newItem = GetListViewItem(mcrg); WorkPackage workPackage = closedWorkPackages.Where(wp => wp.ItemId == directiveRecord.DirectivePackageId).FirstOrDefault(); if (workPackage != null) { //запись о выполнении блокируется найденым пакетом directiveRecord.DirectivePackage = workPackage; newItem.BackColor = Color.FromArgb(Highlight.Grey.Color); newItem.ToolTipText = "Perform of the task:" + parentDirective.Name + "\nadded by Work Package:" + "\n" + directiveRecord.DirectivePackage.Title + "\nTo remove a performance of task, you need to exclude task from this work package," + "\nor delete the work package "; } listViewCompliance.Items.Add(newItem); } else if (t is MaintenanceProgramChangeRecord) { MaintenanceProgramChangeRecord mpcr = (MaintenanceProgramChangeRecord)t; subs = new[] { "N/A", "Changet to " + mpcr.MSG, UsefulMethods.NormalizeDate(mpcr.RecordDate), mpcr.OnLifelength.ToString(), "", }; newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups["last"], Tag = mpcr, BackColor = Color.FromArgb(Highlight.GrayLight.Color) }; listViewCompliance.Items.Add(newItem); } } #endregion if (_toolStripMenuItemsWorkPackages != null) { foreach (ToolStripMenuItem item in _toolStripMenuItemsWorkPackages.DropDownItems) { item.Click -= AddToWorkPackageItemClick; } _toolStripMenuItemsWorkPackages.DropDownItems.Clear(); foreach (WorkPackage workPackage in _openPubWorkPackages) { ToolStripMenuItem item = new ToolStripMenuItem(workPackage.Title); item.Click += AddToWorkPackageItemClick; item.Tag = workPackage; _toolStripMenuItemsWorkPackages.DropDownItems.Add(item); } } ButtonAdd.Enabled = false; }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> protected virtual void AddDirectiveToDataset(NextPerformance 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.Parent.Threshold.EffectiveDate); string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва string firstPerformanceString = reportedDirective.Parent.Threshold.FirstPerformanceSinceNew.ToString(); if (reportedDirective.Parent.LastPerformance != null) { used.Add(_current); used.Substract(reportedDirective.Parent.LastPerformance.OnLifelength); if (!reportedDirective.Parent.Threshold.RepeatInterval.IsNullOrZero()) { used.Resemble(reportedDirective.Parent.Threshold.RepeatInterval); } else if (!reportedDirective.Parent.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { used.Resemble(reportedDirective.Parent.Threshold.FirstPerformanceSinceNew); } if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Parent.Threshold.RepeatInterval); } } var remainCalc = Lifelength.Zero; NextPerformance next = reportedDirective.Parent.NextPerformance; try { if (_mpLimit) { if (reportedDirective.Parent.LastPerformance != null) { if (!reportedDirective.Parent.Threshold.RepeatInterval.IsNullOrZero() && !reportedDirective.Parent.IsClosed) { next = reportedDirective.Parent.NextPerformance; next.PerformanceSource = Lifelength.Zero; next.PerformanceSource.Add(reportedDirective.Parent.LastPerformance.OnLifelength); next.PerformanceSource.Add(reportedDirective.Parent.Threshold.RepeatInterval); next.PerformanceSource.Resemble(reportedDirective.Parent.Threshold.RepeatInterval); if (reportedDirective.Parent.Threshold.RepeatInterval.Days.HasValue) { next.PerformanceDate = reportedDirective.Parent.LastPerformance.RecordDate.AddDays(reportedDirective.Parent.Threshold .RepeatInterval.Days.Value); } else { next.PerformanceDate = null; } remainCalc.Add(next.PerformanceSource); remainCalc.Substract(_current); remainCalc.Resemble(reportedDirective.Parent.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.Parent.Threshold.RepeatInterval.IsNullOrZero()) { remainCalc.Add(reportedDirective.NextPerformanceSource); remainCalc.Substract(_current); remainCalc.Resemble(reportedDirective.Parent.Threshold.RepeatInterval); } } } else { remainCalc = reportedDirective.Remains; next = reportedDirective.Parent.NextPerformance; } var title = ""; var card = ""; var description = ""; if (reportedDirective.Parent is MaintenanceDirective mpd) { title = mpd.Title; card = mpd.TaskCardNumber; description = mpd.Description; } else if (reportedDirective.Parent is Directive d) { if (d.DirectiveType == DirectiveType.AirworthenessDirectives) { title = d.Title; } else if (d.DirectiveType == DirectiveType.SB) { title = d.ServiceBulletinNo; } else if (d.DirectiveType == DirectiveType.EngineeringOrders) { title = d.EngineeringOrders; } card = d.EngineeringOrders; description = d.Description; } else if (reportedDirective.Parent is ComponentDirective c) { description = c.ParentComponent.ToString(); title = c.MaintenanceDirective?.TaskNumberCheck ?? ""; card = c.MaintenanceDirective?.TaskCardNumber ?? ""; } destinationDataSet.ItemsTable.AddItemsTableRow(title, card, description, firstPerformanceString, reportedDirective.Parent.Threshold.RepeatInterval != null ? reportedDirective.Parent.Threshold.RepeatInterval.Hours?.ToString() : "*", reportedDirective.Parent.Threshold.RepeatInterval != null ? reportedDirective.Parent.Threshold.RepeatInterval.Cycles?.ToString() : "*", reportedDirective.Parent.Threshold.RepeatInterval != null ? reportedDirective.Parent.Threshold.RepeatInterval.Days?.ToString() : "*", reportedDirective.Parent.LastPerformance != null ? reportedDirective.Parent.LastPerformance.OnLifelength.Hours?.ToString() : "*", reportedDirective.Parent.LastPerformance != null ? reportedDirective.Parent.LastPerformance.OnLifelength.Cycles?.ToString() : "*", reportedDirective.Parent.LastPerformance != null ? reportedDirective.Parent.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; } }
protected override List <CustomCell> GetListViewSubItems(BaseEntityObject item) { var subItems = new List <CustomCell>(); var author = GlobalObjects.CasEnvironment.GetCorrector(item); DateTime? approx; Lifelength remains = Lifelength.Null, next; AtaChapter ata; MaintenanceControlProcess maintenanceType; DateTime transferDate; DateTime? lastPerformanceDate = null; DateTime? nextEstimated = null; DateTime? nextLimit = null; Lifelength firstPerformance = Lifelength.Null, lastPerformance = Lifelength.Null, lastPerformanceC = Lifelength.Null, expiryRemain = Lifelength.Null, nextEstimatedData = Lifelength.Null, nextEstimatedDataC = Lifelength.Null, remainEstimated = Lifelength.Null, nextLimitData = Lifelength.Null, nextLimitDataC = Lifelength.Null, remainLimit = Lifelength.Null, remainLimitC = Lifelength.Null, IDD = Lifelength.Null, IDDC = Lifelength.Null, warranty, repeatInterval = Lifelength.Null; string partNumber, description, serialNumber, position, mpdString = "", mpdNumString = "", lastPerformanceString = "", type = getGroupName(item), classString = "", kitRequieredString, remarks, hiddenRemarks, workType = "", zone = "", destination = "", access = "", expiryDate = "", condition = "", conditionRepeat = "", ndtString = ""; double manHours, cost, costServiceable = 0, costOverhaul = 0; if (item is Component) { Component componentItem = (Component)item; approx = componentItem.NextPerformanceDate; next = componentItem.NextPerformanceSource; destination = GlobalObjects.AircraftsCore.GetAircraftById(componentItem.ParentBaseComponent?.ParentAircraftId ?? -1)?.ToString(); var selectedCategory = componentItem.ChangeLLPCategoryRecords.GetLast()?.ToCategory; if (selectedCategory != null) { var llp = componentItem.LLPData.GetItemByCatagory(selectedCategory); remains = llp?.Remain; } if (componentItem.LLPCategories) { nextEstimated = componentItem.NextPerformance?.PerformanceDate; nextEstimatedData = componentItem.NextPerformance?.PerformanceSource; nextEstimatedDataC = componentItem.NextPerformance?.PerformanceSourceC; remainEstimated = componentItem.NextPerformance?.Remains; nextLimit = componentItem.NextPerformance?.NextPerformanceDateNew; nextLimitData = componentItem.NextPerformance?.NextLimit; nextLimitDataC = componentItem.NextPerformance?.NextLimitC; remainLimit = componentItem.NextPerformance?.RemainLimit; remainLimitC = componentItem.NextPerformance?.RemainLimitC; IDD = componentItem.NextPerformance?.IDD; IDDC = componentItem.NextPerformance?.IDDC; } ata = componentItem.Model != null ? componentItem.Model.ATAChapter : componentItem.ATAChapter; partNumber = componentItem.PartNumber; description = componentItem.Model != null ? componentItem.Model.Description : componentItem.Description; serialNumber = componentItem.SerialNumber; position = componentItem.TransferRecords.GetLast().Position.ToUpper(); maintenanceType = componentItem.MaintenanceControlProcess; transferDate = componentItem.TransferRecords.GetLast().TransferDate; firstPerformance = componentItem.LifeLimit; warranty = componentItem.Warranty; classString = componentItem.GoodsClass != null?componentItem.GoodsClass.ToString() : ""; kitRequieredString = componentItem.Kits.Count + " kits"; manHours = componentItem.ManHours; cost = componentItem.Cost; costOverhaul = componentItem.CostOverhaul; costServiceable = componentItem.CostServiceable; remarks = componentItem.Remarks; hiddenRemarks = componentItem.HiddenRemarks; expiryDate = " "; expiryRemain = Lifelength.Null; condition = !firstPerformance.IsNullOrZero() ? (componentItem.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "/WF" : "/WL") : ""; conditionRepeat = !componentItem.Threshold.RepeatInterval.IsNullOrZero() ? (componentItem.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "/WF" : "/WL") : ""; } else { ComponentDirective dd = (ComponentDirective)item; destination = GlobalObjects.AircraftsCore.GetAircraftById(dd.ParentComponent.ParentBaseComponent?.ParentAircraftId ?? -1)?.ToString(); 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); lastPerformance = dd.LastPerformance?.OnLifelength; lastPerformanceC = dd.NextPerformance?.LastDataC; lastPerformanceDate = dd.LastPerformance?.RecordDate; } if (dd.Threshold.RepeatInterval != null && !dd.Threshold.RepeatInterval.IsNullOrZero()) { repeatInterval = dd.Threshold.RepeatInterval; } //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd, out next, out remains, out approx, out cond); //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd); approx = dd.NextPerformanceDate; next = dd.NextPerformanceSource; remains = dd.Remains; nextEstimated = dd.NextPerformance?.PerformanceDate; nextEstimatedData = dd.NextPerformance?.PerformanceSource; nextEstimatedDataC = dd.NextPerformance?.PerformanceSourceC; remainEstimated = dd.NextPerformance?.Remains; nextLimit = dd.NextPerformance?.NextPerformanceDateNew; nextLimitData = dd.NextPerformance?.NextLimit; nextLimitDataC = dd.NextPerformance?.NextLimitC; remainLimit = dd.NextPerformance?.RemainLimit; remainLimitC = dd.NextPerformance?.RemainLimitC; IDD = dd.NextPerformance?.IDD; IDDC = dd.NextPerformance?.IDDC; ata = dd.ParentComponent.Model != null ? dd.ParentComponent.Model.ATAChapter : dd.ParentComponent.ATAChapter; partNumber = " " + dd.PartNumber; var desc = dd.ParentComponent.Model != null ? dd.ParentComponent.Model.Description : dd.ParentComponent.Description; description = " " + desc; serialNumber = " " + dd.SerialNumber; position = " " + dd.ParentComponent.TransferRecords.GetLast().Position.ToUpper(); transferDate = dd.ParentComponent.TransferRecords.GetLast().TransferDate; maintenanceType = dd.ParentComponent.MaintenanceControlProcess; warranty = dd.Threshold.Warranty; classString = dd.ParentComponent.GoodsClass != null?dd.ParentComponent.GoodsClass.ToString() : ""; kitRequieredString = dd.Kits.Count + " kits"; manHours = dd.ManHours; cost = dd.Cost; zone = dd.ZoneArea; access = dd.AccessDirective; remarks = dd.Remarks; hiddenRemarks = dd.HiddenRemarks; workType = dd.DirectiveType.ToString(); ndtString = dd.NDTType.ShortName; condition = !firstPerformance.IsNullOrZero() ? (dd.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "/WF" : "/WL") : ""; conditionRepeat = !dd.Threshold.RepeatInterval.IsNullOrZero() ? (dd.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "/WF" : "/WL") : ""; if (dd.IsExpiry) { expiryDate = dd.IsExpiry ? (dd.ExpiryDate.HasValue ? SmartCore.Auxiliary.Convert.GetDateFormat(dd.ExpiryDate.Value) : "") : ""; expiryRemain = dd.IsExpiry ? new Lifelength((int)(dd.ExpiryDate.Value - DateTime.Today).TotalDays, 0, 0) : Lifelength.Null; } if (dd.MaintenanceDirective != null) { mpdString = dd.MaintenanceDirective.TaskNumberCheck; mpdNumString = dd.MaintenanceDirective.TaskCardNumber; } } subItems.Add(CreateRow(destination, destination)); subItems.Add(CreateRow(ata.ToString(), ata)); subItems.Add(CreateRow(partNumber, partNumber)); subItems.Add(CreateRow(description, description)); subItems.Add(CreateRow(type, type)); subItems.Add(CreateRow(workType, workType)); subItems.Add(CreateRow(serialNumber, serialNumber)); subItems.Add(CreateRow(mpdString, mpdString)); subItems.Add(CreateRow(mpdNumString, mpdNumString)); subItems.Add(CreateRow(position, position)); subItems.Add(CreateRow(maintenanceType.ShortName, maintenanceType)); subItems.Add(CreateRow(zone, zone)); subItems.Add(CreateRow(access, access)); subItems.Add(CreateRow(transferDate > DateTimeExtend.GetCASMinDateTime() ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", transferDate)); subItems.Add(CreateRow(IDD?.ToString(), IDD)); subItems.Add(CreateRow(IDDC?.ToString(), IDDC)); subItems.Add(CreateRow($"{firstPerformance} {condition}", firstPerformance)); subItems.Add(CreateRow($"{repeatInterval} {conditionRepeat}", repeatInterval)); subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(nextEstimated), nextEstimated)); subItems.Add(CreateRow(nextEstimatedData?.ToString(), nextEstimatedData)); subItems.Add(CreateRow(nextEstimatedDataC?.ToString(), nextEstimatedDataC)); subItems.Add(CreateRow(remainEstimated?.ToString(), remainEstimated)); subItems.Add(CreateRow(nextLimitData?.Days != null ? SmartCore.Auxiliary.Convert.GetDateFormat(nextLimit) : "", nextLimit)); subItems.Add(CreateRow(nextLimitData?.ToString(), nextLimitData)); subItems.Add(CreateRow(nextLimitDataC?.ToString(), nextLimitDataC)); subItems.Add(CreateRow(remainLimit?.ToString(), remainLimit)); subItems.Add(CreateRow(remainLimitC?.ToString(), remainLimitC)); subItems.Add(CreateRow(lastPerformanceString, lastPerformanceDate)); subItems.Add(CreateRow(lastPerformanceC?.ToString(), lastPerformanceC)); subItems.Add(CreateRow(lastPerformance?.ToString(), lastPerformance)); subItems.Add(CreateRow(expiryDate, expiryDate)); subItems.Add(CreateRow(!expiryRemain.IsNullOrZero() ? $"{expiryRemain?.Days}d" : "", expiryRemain)); subItems.Add(CreateRow(warranty.ToString(), warranty)); subItems.Add(CreateRow(classString, classString)); subItems.Add(CreateRow(kitRequieredString, kitRequieredString)); subItems.Add(CreateRow(ndtString, ndtString)); subItems.Add(CreateRow(manHours.ToString(), manHours)); subItems.Add(CreateRow(cost.ToString(), cost)); subItems.Add(CreateRow(costOverhaul.ToString(), costOverhaul)); subItems.Add(CreateRow(costServiceable.ToString(), costServiceable)); subItems.Add(CreateRow(remarks, remarks)); subItems.Add(CreateRow(hiddenRemarks, hiddenRemarks)); subItems.Add(CreateRow(author, author)); return(subItems); }
protected override ListViewItem.ListViewSubItem[] GetListViewSubItems(BaseEntityObject item) { ListViewItem.ListViewSubItem[] subItems = new ListViewItem.ListViewSubItem[21]; DateTime? approx; Lifelength remains, next; AtaChapter ata; MaintenanceControlProcess maintenanceType; DateTime transferDate = DateTimeExtend.GetCASMinDateTime(); Lifelength firstPerformance = Lifelength.Null, lastPerformance = Lifelength.Null, warranty, repeatInterval = Lifelength.Null; string partNumber = "", description, serialNumber = "", position = "", lastPerformanceString = "", kitRequieredString, remarks, hiddenRemarks, workType = ""; double manHours, cost, costServiceable = 0, costOverhaul = 0; if (item is Component) { Component componentItem = (Component)item; //if(detailItem is BaseDetail) // GlobalObjects.CasEnvironment.Calculator.GetLifelength((BaseDetail)detailItem, out cond, out remains, out next, out approx); //else GlobalObjects.CasEnvironment.Calculator.GetLifelength(detailItem, out cond, out remains, out next, out approx); //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(detailItem); approx = componentItem.NextPerformanceDate; next = componentItem.NextPerformanceSource; remains = componentItem.Remains; ata = componentItem.ATAChapter; partNumber = componentItem.PartNumber; description = componentItem.Description; serialNumber = componentItem.SerialNumber; position = componentItem.TransferRecords.GetLast().Position.ToUpper(); maintenanceType = componentItem.MaintenanceControlProcess; transferDate = componentItem.TransferRecords.GetLast().TransferDate; firstPerformance = componentItem.LifeLimit; warranty = componentItem.Warranty; kitRequieredString = componentItem.Kits.Count + " kits"; manHours = componentItem.ManHours; cost = componentItem.Cost; costOverhaul = componentItem.CostOverhaul; costServiceable = componentItem.CostServiceable; remarks = componentItem.Remarks; hiddenRemarks = componentItem.HiddenRemarks; } else { ComponentDirective dd = (ComponentDirective)item; 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; } //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd, out next, out remains, out approx, out cond); //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(dd); approx = dd.NextPerformanceDate; next = dd.NextPerformanceSource; remains = dd.Remains; ata = dd.ParentComponent.ATAChapter; description = " " + dd.ParentComponent.Description;// +" " + dd.DirectiveType; maintenanceType = dd.ParentComponent.MaintenanceControlProcess; warranty = dd.Threshold.Warranty; kitRequieredString = dd.Kits.Count + " kits"; manHours = dd.ManHours; cost = dd.Cost; remarks = dd.Remarks; hiddenRemarks = dd.HiddenRemarks; workType = dd.DirectiveType.ToString(); } subItems[0] = new ListViewItem.ListViewSubItem { Text = ata.ToString(), Tag = ata }; subItems[1] = new ListViewItem.ListViewSubItem { Text = partNumber, Tag = partNumber }; subItems[2] = new ListViewItem.ListViewSubItem { Text = description, Tag = description }; subItems[3] = new ListViewItem.ListViewSubItem { Text = serialNumber, Tag = serialNumber }; subItems[4] = new ListViewItem.ListViewSubItem { Text = position, Tag = position }; subItems[5] = new ListViewItem.ListViewSubItem { Text = maintenanceType.ShortName, Tag = maintenanceType }; subItems[6] = new ListViewItem.ListViewSubItem { Text = transferDate > DateTimeExtend.GetCASMinDateTime() ? SmartCore.Auxiliary.Convert.GetDateFormat(transferDate) : "", Tag = transferDate }; subItems[7] = new ListViewItem.ListViewSubItem { Text = workType, Tag = workType }; subItems[8] = new ListViewItem.ListViewSubItem { Text = firstPerformance.ToString(), Tag = firstPerformance }; subItems[9] = new ListViewItem.ListViewSubItem { Text = repeatInterval.ToString(), Tag = repeatInterval }; subItems[10] = new ListViewItem.ListViewSubItem { Text = approx == null ? "" : SmartCore.Auxiliary.Convert.GetDateFormat((DateTime)approx) + " " + next, Tag = approx == null?DateTimeExtend.GetCASMinDateTime() : (DateTime)approx }; subItems[11] = new ListViewItem.ListViewSubItem { Text = remains != null && !remains.IsNullOrZero() ? remains.ToString() : "", Tag = remains ?? Lifelength.Null }; subItems[12] = new ListViewItem.ListViewSubItem { Text = lastPerformanceString, Tag = lastPerformance }; subItems[13] = new ListViewItem.ListViewSubItem { Text = warranty.ToString(), Tag = warranty }; subItems[14] = new ListViewItem.ListViewSubItem { Text = kitRequieredString, Tag = kitRequieredString }; subItems[15] = new ListViewItem.ListViewSubItem { Text = manHours.ToString(), Tag = manHours }; subItems[16] = new ListViewItem.ListViewSubItem { Text = cost.ToString(), Tag = cost }; subItems[17] = new ListViewItem.ListViewSubItem { Text = costOverhaul.ToString(), Tag = costOverhaul }; subItems[18] = new ListViewItem.ListViewSubItem { Text = costServiceable.ToString(), Tag = costServiceable }; subItems[19] = new ListViewItem.ListViewSubItem { Text = remarks, Tag = remarks }; subItems[20] = new ListViewItem.ListViewSubItem { Text = hiddenRemarks, Tag = hiddenRemarks }; return(subItems); }
protected override List <CustomCell> GetListViewSubItems(Directive item) { var subItems = new List <CustomCell>(); ////////////////////////////////////////////////////////////////////////////////////// // Определение последнего выполнения директивы и KitRequiered // ////////////////////////////////////////////////////////////////////////////////////// var lastComplianceDate = DateTimeExtend.GetCASMinDateTime(); var lastComplianceLifeLength = Lifelength.Zero; string lastPerformanceString, firstPerformanceString = "N/A"; var adColor = radGridView1.ForeColor; var sbColor = radGridView1.ForeColor; var eoColor = radGridView1.ForeColor; var stcColor = radGridView1.ForeColor; var effDate = DateTimeExtend.GetCASMinDateTime(); var ata = item.ATAChapter; ////////////////////////////////////////////////////////////////////////////////////// // Определение последнего выполнения директивы и KitRequiered // ////////////////////////////////////////////////////////////////////////////////////// //Последнее выполнение if (item.LastPerformance != null && item.LastPerformance.RecordDate > lastComplianceDate) { lastComplianceDate = item.LastPerformance.RecordDate; lastComplianceLifeLength = item.LastPerformance.OnLifelength; } //Следующее выполнение //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(directive); if (item.Threshold.FirstPerformanceSinceNew != null && !item.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { firstPerformanceString = "s/n: " + item.Threshold.FirstPerformanceSinceNew; } if (item.Threshold.FirstPerformanceSinceEffectiveDate != null && !item.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (firstPerformanceString != "N/A") { firstPerformanceString += " or "; } else { firstPerformanceString = ""; } firstPerformanceString += "s/e.d: " + item.Threshold.FirstPerformanceSinceEffectiveDate; } var repeatInterval = item.Threshold.RepeatInterval; if (lastComplianceDate <= DateTimeExtend.GetCASMinDateTime()) { lastPerformanceString = "N/A"; } else { lastPerformanceString = lastComplianceLifeLength.ToString(); } var lastDate = (lastComplianceDate <= DateTimeExtend.GetCASMinDateTime()) ? "" : SmartCore.Auxiliary.Convert.GetDateFormat(lastComplianceDate); effDate = item.Threshold.EffectiveDate; var descriptionString = item.Description; var applicabilityString = item.IsApplicability ? $"APL {item.Applicability}" : $"N/A {item.Applicability}"; var kitRequieredString = item.Kits.Count + " EA"; var ndtString = item.NDTType.ShortName; var manHours = item.ManHours; var cost = item.Cost; var remarksString = item.Remarks; var hiddenRemarksString = item.HiddenRemarks; var adno = item.Title + " §: " + item.Paragraph; var sbno = item.ServiceBulletinNo != "" ? item.ServiceBulletinNo : "N/A"; var eono = item.EngineeringOrders != "" ? item.EngineeringOrders : "N/A"; var stcno = item.StcNo != "" ? item.StcNo : "N/A"; var baseDetail = item.ParentBaseComponent.ToString(); var status = item.Status; var workType = item.WorkType; var access = item.DirectiveAccess; var zone = item.DirectiveZone; var workarea = item.Workarea; var author = GlobalObjects.CasEnvironment.GetCorrector(item); var condition = !string.IsNullOrEmpty(firstPerformanceString) ? (item.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "/WF" : "/WL") : ""; var conditionRepeat = !item.Threshold.RepeatInterval.IsNullOrZero() ? (item.Threshold.RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "/WF" : "/WL") : ""; if (item.ADNoFile == null) { adColor = Color.MediumVioletRed; } if (item.ServiceBulletinFile == null) { sbColor = Color.MediumVioletRed; } if (item.EngineeringOrderFile == null) { eoColor = Color.MediumVioletRed; } if (item.STCFile == null) { stcColor = Color.MediumVioletRed; } string s1 = ""; string s2 = ""; string s3 = ""; Color c1 = Color.White, c2 = Color.White, c3 = Color.White; if (CurrentPrimatyDirectiveType == DirectiveType.AirworthenessDirectives || CurrentPrimatyDirectiveType == DirectiveType.ModificationStatus) { s1 = adno; s2 = sbno; s3 = eono; c1 = adColor; c2 = sbColor; c3 = eoColor; } else if (CurrentPrimatyDirectiveType == DirectiveType.SB) { s1 = sbno; s2 = eono; s3 = adno; c1 = sbColor; c2 = eoColor; c3 = adColor; } else if (CurrentPrimatyDirectiveType == DirectiveType.EngineeringOrders) { s1 = eono; s2 = sbno; s3 = adno; c1 = eoColor; c2 = sbColor; c3 = adColor; } subItems.Add(CreateRow(s1, s1, c1)); subItems.Add(CreateRow(s2, s2, c2)); subItems.Add(CreateRow(s3, s3, c3)); subItems.Add(CreateRow(item.EOFileName, item.EOFileName)); subItems.Add(CreateRow(applicabilityString, applicabilityString)); subItems.Add(CreateRow(descriptionString, descriptionString)); subItems.Add(CreateRow($"{firstPerformanceString} {condition}", firstPerformanceString)); subItems.Add(CreateRow($"{repeatInterval} {conditionRepeat}", repeatInterval)); subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformance?.PerformanceDate), item.NextPerformance?.PerformanceDate)); subItems.Add(CreateRow(item.NextPerformance?.PerformanceSource.ToString(), item.NextPerformance?.PerformanceSource)); subItems.Add(CreateRow(item.NextPerformance?.Remains.ToString(), item.NextPerformance?.Remains)); subItems.Add(CreateRow(item.NextPerformance?.NextLimit.Days != null ? SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformance?.NextPerformanceDateNew) : "", item.NextPerformance?.NextPerformanceDateNew)); subItems.Add(CreateRow(item.NextPerformance?.NextLimit.ToString(), item.NextPerformance?.NextLimit.ToString())); subItems.Add(CreateRow(item.NextPerformance?.RemainLimit.ToString(), item.NextPerformance?.RemainLimit.ToString())); subItems.Add(CreateRow(lastDate, lastComplianceDate)); subItems.Add(CreateRow(lastPerformanceString, lastComplianceDate)); subItems.Add(CreateRow(status.ToString(), status)); subItems.Add(CreateRow(remarksString, remarksString)); subItems.Add(CreateRow(effDate > DateTimeExtend.GetCASMinDateTime() ? SmartCore.Auxiliary.Convert.GetDateFormat(effDate) : "", effDate)); subItems.Add(CreateRow(item.Affects.ToString(), item.Affects)); subItems.Add(CreateRow(zone, zone)); subItems.Add(CreateRow(workarea, workarea)); subItems.Add(CreateRow(access, access)); subItems.Add(CreateRow(workType.ToString(), workType)); subItems.Add(CreateRow(stcno, stcno, stcColor)); subItems.Add(CreateRow(ata.ToString(), ata)); subItems.Add(CreateRow(baseDetail, baseDetail)); subItems.Add(CreateRow(kitRequieredString, kitRequieredString)); subItems.Add(CreateRow(ndtString, ndtString)); subItems.Add(CreateRow(manHours == -1 ? "" : manHours.ToString(), manHours)); subItems.Add(CreateRow(cost == -1 ? "" : cost.ToString(), cost)); subItems.Add(CreateRow(hiddenRemarksString, hiddenRemarksString)); subItems.Add(CreateRow(author, author)); return(subItems); }
public void ImportComponentStore() { var env = GetEnviroment(); var aircraftCore = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader); var itemRelationCore = new ItemsRelationsDataAccess(env); var componentCore = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore, itemRelationCore); var store = env.Loader.GetObject <Store>(new CommonFilter <int>(BaseEntityObject.ItemIdProperty, 11)); var models = env.Loader.GetObjectList <ComponentModel>(); var storeComponent = componentCore.GetStoreComponents(store); var ds = ExcelToDataTableUsingExcelDataReader(@"D:\CRJ200 NEW Compon 1.xlsx"); foreach (DataTable table in ds.Tables) { foreach (DataRow row in table.Rows) { if (string.IsNullOrEmpty(row[0].ToString()) && string.IsNullOrEmpty(row[1].ToString()) && string.IsNullOrEmpty(row[2].ToString())) { continue; } var comp = new Entities.General.Accessory.Component(); var goodClass = row[0].ToString().Replace('−', '-'); comp.GoodsClass = GoodsClass.Items.FirstOrDefault(i => goodClass.ToLower().Equals(i.FullName.ToLower())); if (comp.GoodsClass == null || comp.GoodsClass == GoodsClass.Unknown) { comp.GoodsClass = GoodsClass.Items.FirstOrDefault(i => goodClass.ToLower().Contains(i.FullName.ToLower())); } if (comp.GoodsClass == null || comp.GoodsClass == GoodsClass.Unknown) { comp.GoodsClass = GoodsClass.Items.FirstOrDefault(i => goodClass.ToLower().Contains(i.ShortName.ToLower())); } comp.PartNumber = row[3].ToString(); comp.ALTPartNumber = row[4].ToString(); comp.SerialNumber = row[5].ToString(); comp.BatchNumber = row[6].ToString(); comp.Remarks = $"{DateTime.Today} CIT Comp"; Double.TryParse(row[7].ToString().Replace('.', ','), out double quantityIn); Double.TryParse(row[8].ToString().Replace('.', ','), out double current); comp.QuantityIn = quantityIn; comp.Quantity = current; #region E&M //comp.Product = models.FirstOrDefault(i =>i.PartNumber == comp.PartNumber); //comp.Measure = Measure.Unit; #endregion comp.Model = models.FirstOrDefault(i => i.PartNumber == comp.PartNumber); comp.Measure = Measure.Unknown; //comp.GoodsClass = GoodsClass.MaintenanceMaterials; DateTime.TryParse(row[1].ToString(), out var date); if (date.Year < DateTimeExtend.GetCASMinDateTime().Year) { date = DateTimeExtend.GetCASMinDateTime(); } comp.ManufactureDate = date; var find = storeComponent.FirstOrDefault(i => i.PartNumber == comp.PartNumber && i.SerialNumber == comp.SerialNumber && i.BatchNumber == comp.BatchNumber); if (find != null) { continue; } componentCore.AddComponent(comp, store, date, "", ComponentStorePosition.Serviceable, destinationResponsible: true); Double.TryParse(row[10].ToString().Replace('.', ','), out double unitPrice); Double.TryParse(row[11].ToString().Replace('.', ','), out double totalPrice); comp.ProductCosts = new CommonCollection <ProductCost>() { new ProductCost { Currency = Сurrency.USD, UnitPrice = unitPrice, TotalPrice = totalPrice, ParentId = comp.ItemId, ParentTypeId = comp.SmartCoreType.ItemId } }; foreach (var compProductCost in comp.ProductCosts) { env.Keeper.Save(compProductCost); } } } }
protected override List <CustomCell> GetListViewSubItems(Directive item) { var subItems = new List <CustomCell>(); var author = GlobalObjects.CasEnvironment.GetCorrector(item); ////////////////////////////////////////////////////////////////////////////////////// // Определение последнего выполнения директивы и KitRequiered // ////////////////////////////////////////////////////////////////////////////////////// var lastComplianceDate = DateTimeExtend.GetCASMinDateTime(); var nextComplianceDate = DateTimeExtend.GetCASMinDateTime(); var lastComplianceLifeLength = Lifelength.Zero; var nextComplianceRemain = Lifelength.Null; string lastPerformanceString, firstPerformanceString = "N/A"; DeferredItem pd = (DeferredItem)item; DirectiveStatus status = pd.Status; DeferredCategory cat = pd.DeferredCategory; ////////////////////////////////////////////////////////////////////////////////////// // Определение последнего выполнения директивы и KitRequiered // ////////////////////////////////////////////////////////////////////////////////////// var par = " §: " + item.Paragraph; //Последнее выполнение if (item.LastPerformance != null && item.LastPerformance.RecordDate > lastComplianceDate) { lastComplianceDate = item.LastPerformance.RecordDate; lastComplianceLifeLength = item.LastPerformance.OnLifelength; } //Следующее выполнение //GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(pd.DirectiveCollection[0]); var nextComplianceLifeLength = item.NextPerformanceSource; if (item.NextPerformanceDate != null) { nextComplianceDate = (DateTime)item.NextPerformanceDate; } if (item.Remains != null) { nextComplianceRemain = item.Remains; } if (item.Threshold.FirstPerformanceSinceNew != null && !item.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { firstPerformanceString = "s/n: " + item.Threshold.FirstPerformanceSinceNew; } if (item.Threshold.FirstPerformanceSinceEffectiveDate != null && !item.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (firstPerformanceString != "N/A") { firstPerformanceString += " or "; } else { firstPerformanceString = ""; } firstPerformanceString += "s/e.d: " + item.Threshold.FirstPerformanceSinceEffectiveDate; } var repeatInterval = item.Threshold.RepeatInterval; var kitRequieredString = item.Kits.Count + " kits"; var ndtString = item.NDTType.ShortName; var workType = item.WorkType; var effDate = item.Threshold.EffectiveDate; var manHours = item.ManHours; var cost = item.Cost; var remarksString = pd.Remarks; var hiddenRemarksString = pd.HiddenRemarks; if (lastComplianceDate <= DateTimeExtend.GetCASMinDateTime()) { lastPerformanceString = "N/A"; } else { lastPerformanceString = lastComplianceLifeLength.ToString(); } var lastDate = (lastComplianceDate <= DateTimeExtend.GetCASMinDateTime()) ? "" : SmartCore.Auxiliary.Convert.GetDateFormat(lastComplianceDate); var titleString = pd.Title != "" ? pd.Title + par : "N/A"; var sbString = pd.ServiceBulletinNo != "" ? pd.ServiceBulletinNo : "N/A"; var eoString = pd.EngineeringOrders != "" ? pd.EngineeringOrders : "N/A"; var descriptionString = pd.Description; var applicabilityString = pd.Applicability; var ata = pd.ATAChapter; subItems.Add(CreateRow(titleString, titleString)); subItems.Add(CreateRow(sbString, sbString)); subItems.Add(CreateRow(eoString, eoString)); subItems.Add(CreateRow(descriptionString, descriptionString)); subItems.Add(CreateRow(applicabilityString, applicabilityString)); subItems.Add(CreateRow(workType.ToString(), workType)); subItems.Add(CreateRow(cat.ToString(), cat)); subItems.Add(CreateRow(status.ToString(), status)); subItems.Add(CreateRow(effDate > DateTimeExtend.GetCASMinDateTime() ? SmartCore.Auxiliary.Convert.GetDateFormat(effDate) : "", effDate)); subItems.Add(CreateRow(firstPerformanceString, firstPerformanceString)); subItems.Add(CreateRow(repeatInterval.ToString(), repeatInterval)); subItems.Add(CreateRow(SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformance?.PerformanceDate), item.NextPerformance?.PerformanceDate)); subItems.Add(CreateRow(item.NextPerformance?.PerformanceSource.ToString(), item.NextPerformance?.PerformanceSource)); subItems.Add(CreateRow(item.NextPerformance?.Remains.ToString(), item.NextPerformance?.Remains)); subItems.Add(CreateRow(item.NextPerformance?.NextLimit.Days != null ? SmartCore.Auxiliary.Convert.GetDateFormat(item.NextPerformance?.NextPerformanceDateNew) : "", item.NextPerformance?.NextPerformanceDateNew)); subItems.Add(CreateRow(item.NextPerformance?.NextLimit.ToString(), item.NextPerformance?.NextLimit.ToString())); subItems.Add(CreateRow(item.NextPerformance?.RemainLimit.ToString(), item.NextPerformance?.RemainLimit.ToString())); subItems.Add(CreateRow(lastDate, lastComplianceDate)); subItems.Add(CreateRow(lastPerformanceString, lastComplianceDate)); subItems.Add(CreateRow(ata.ToString(), ata)); subItems.Add(CreateRow(kitRequieredString, kitRequieredString)); subItems.Add(CreateRow(ndtString, ndtString)); subItems.Add(CreateRow(manHours == -1 ? "" : manHours.ToString(), manHours)); subItems.Add(CreateRow(cost == -1 ? "" : cost.ToString(), cost)); subItems.Add(CreateRow(remarksString, remarksString)); subItems.Add(CreateRow(hiddenRemarksString, hiddenRemarksString)); subItems.Add(CreateRow(author, author)); return(subItems); }
public static IEnumerable <ProductionActual> GetDetails(DateTime time, Workshop workshop, StatisticProcessTimeEnum timeType, int range, string step) { var res = new List <ProductionActual>(); try { var shiftTime = DateTimeExtend.GetDayWorkDay(workshop.Shifts, workshop.StatisticTimeList, time); IEnumerable <ProductionActual> data = null; var startTime = default(DateTime); var endTime = default(DateTime); switch (timeType) { case StatisticProcessTimeEnum.小时: break; case StatisticProcessTimeEnum.日: endTime = shiftTime.Item1.Date; startTime = shiftTime.Item1.AddDays(1 - range).Date; break; case StatisticProcessTimeEnum.周: var week = DateTimeExtend.GetWorkWeek(0, time, workshop.StatisticTimeList); endTime = week.Item2.Date; startTime = week.Item1.AddWeeks(-range).Date; break; case StatisticProcessTimeEnum.月: var month = DateTimeExtend.GetWorkMonth(0, time, workshop.StatisticTimeList); endTime = month.Item2.Date; startTime = month.Item1.AddMonths(-range).Date; break; case StatisticProcessTimeEnum.年: var year = DateTimeExtend.GetWorkYear(0, time, workshop.StatisticTimeList); endTime = year.Item2.Date; startTime = year.Item1.AddYears(-range).Date; break; } if (startTime == default(DateTime) || endTime == default(DateTime)) { return(res); } data = GetDetails(startTime, endTime, step); var productionList = data.Select(x => x.Production).Distinct(); switch (timeType) { case StatisticProcessTimeEnum.小时: break; case StatisticProcessTimeEnum.日: #region 日 for (var i = range; i > 0; i--) { var t = endTime.AddDays(-i); var sfTimes = new Tuple <DateTime, DateTime>(t, t.AddDays(1)); foreach (var production in productionList) { var tData = data.Where(x => x.Date.InSameRange(sfTimes) && x.Production == production); AddProduction(sfTimes.Item1, ref res, tData, production); } } #endregion break; case StatisticProcessTimeEnum.周: #region 周 for (var i = range; i > 0; i--) { var t = endTime.AddWeeks(-i); var week = DateTimeExtend.GetWeek(0, t); foreach (var production in productionList) { var tData = data.Where(x => { if (x.Date.InSameRange(week) && x.Production == production) { var sfTimes = new Tuple <DateTime, DateTime>(t, t.AddWeeks(1)); return(x.Date.InSameRange(sfTimes)); } return(false); }); AddProduction(week.Item1, ref res, tData, production); } } #endregion break; case StatisticProcessTimeEnum.月: #region 月 for (var i = range; i > 0; i--) { var t = endTime.AddMonths(-i); var month = DateTimeExtend.GetMonth(0, t); foreach (var production in productionList) { var tData = data.Where(x => { if (x.Date.InSameRange(month) && x.Production == production) { var sfTimes = new Tuple <DateTime, DateTime>(t, t.AddMonths(1)); return(x.Date.InSameRange(sfTimes)); } return(false); }); AddProduction(month.Item1, ref res, tData, production); } } #endregion break; case StatisticProcessTimeEnum.年: #region 年 for (var i = range; i > 0; i--) { var t = endTime.AddYears(-i); var year = DateTimeExtend.GetYear(0, t); foreach (var production in productionList) { var tData = data.Where(x => { if (x.Date.InSameRange(year) && x.Production == production) { var sfTimes = new Tuple <DateTime, DateTime>(t, t.AddYears(1)); return(x.Date.InSameRange(sfTimes)); } return(false); }); AddProduction(year.Item1, ref res, tData, production); } } #endregion break; } } catch (Exception e) { Log.Error(e); } return(res); }