/// <summary> /// Изменение значения наработки агрегата на текущий момент /// </summary> public void ChangeCurrentComponentTSN() { //если отсутствует наработка агрегата на момент установки //то дальнейшее расчитать нельзя if (ComponentTCSNOnInstall.IsNullOrZero()) { if (lifelengthViewerComponentCurrentTSNCSN.SystemCalculated) { //если данные в текущую наработку вводила система, //а не пользователь, то их нужно обнулить ComponentCurrentTSNCSN = Lifelength.Null; } return; } if (ComponentCurrentTSNCSN.IsNullOrZero() || lifelengthViewerComponentCurrentTSNCSN.SystemCalculated) { //Если текущая наработка агрегата не введена или //введена системой, то её надо расчитать Lifelength temp = new Lifelength(ComponentTCSNOnInstall); if (!ComponentTCSI.IsNullOrZero()) { //если известна наработка агрегата с момента установки temp.Add(ComponentTCSI); temp.Resemble(ComponentTCSNOnInstall); ComponentCurrentTSNCSN = temp; lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true; return; } if (_isStore) { return; } Lifelength aircraftCurrent = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay((Aircraft)_currentAircraft, dateTimePickerDateAsOf.Value); if (!AircraftTCSNOnInstall.IsNullOrZero() && !aircraftCurrent.IsNullOrZero()) { //если известна текущая наработка самолета и //наработка самолета на момент установки aircraftCurrent.Substract(AircraftTCSNOnInstall); temp.Substract(aircraftCurrent); temp.Resemble(ComponentTCSNOnInstall); ComponentCurrentTSNCSN = temp; lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true; return; } //иначе, наработку высчитать нельзя ComponentCurrentTSNCSN = Lifelength.Null; lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true; } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> protected virtual void AddDirectiveToDataset(MaintenanceDirective reportedDirective, MaintenanceDirectivesDataSetLatAvia destinationDataSet) { if (reportedDirective == null) { return; } string status = ""; Lifelength remain = Lifelength.Null; Lifelength used = Lifelength.Null; //string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; if (reportedDirective.Status == DirectiveStatus.Closed) { status = "C"; } if (reportedDirective.Status == DirectiveStatus.Open) { status = "O"; } if (reportedDirective.Status == DirectiveStatus.Repetative) { status = "R"; } if (reportedDirective.Status == DirectiveStatus.NotApplicable) { status = "N/A"; } string effectivityDate = UsefulMethods.NormalizeDate(reportedDirective.Threshold.EffectiveDate); string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва string firstPerformanceString = reportedDirective.Threshold.FirstPerformanceSinceNew.ToString(); if (reportedDirective.LastPerformance != null) { used.Add(_current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.RepeatInterval); } else if (!reportedDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Threshold.RepeatInterval); } } var remainCalc = Lifelength.Zero; NextPerformance next = null; try { if (_mpLimit) { if (reportedDirective.LastPerformance != null) { if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero() && !reportedDirective.IsClosed) { next = reportedDirective.NextPerformance; next.PerformanceSource = Lifelength.Zero; next.PerformanceSource.Add(reportedDirective.LastPerformance.OnLifelength); next.PerformanceSource.Add(reportedDirective.Threshold.RepeatInterval); next.PerformanceSource.Resemble(reportedDirective.Threshold.RepeatInterval); if (reportedDirective.Threshold.RepeatInterval.Days.HasValue) { next.PerformanceDate = reportedDirective.LastPerformance.RecordDate.AddDays(reportedDirective.Threshold .RepeatInterval.Days.Value); } else { next.PerformanceDate = null; } remainCalc.Add(next.PerformanceSource); remainCalc.Substract(_current); remainCalc.Resemble(reportedDirective.Threshold.RepeatInterval); if (next.PerformanceDate != null) { remainCalc.Days = DateTimeExtend.DifferenceDateTime(DateTime.Today, next.PerformanceDate.Value).Days; } } } else if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { remainCalc.Add(reportedDirective.NextPerformanceSource); remainCalc.Substract(_current); remainCalc.Resemble(reportedDirective.Threshold.RepeatInterval); } } } else { remainCalc = reportedDirective.Remains; next = reportedDirective.NextPerformance; } destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.TaskCardNumber, reportedDirective.TaskNumberCheck, reportedDirective.Description, firstPerformanceString, reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Hours?.ToString() : "*", reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Cycles?.ToString() : "*", reportedDirective.Threshold.RepeatInterval != null ? reportedDirective.Threshold.RepeatInterval.Days?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.OnLifelength.Hours?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.OnLifelength.Cycles?.ToString() : "*", reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.RecordDate.Date.ToString("dd.MM.yyyy") : "*", next != null ? next.PerformanceSource.Hours.ToString() : "*", next != null ? next.PerformanceSource.Cycles.ToString() : "*", next?.PerformanceDate != null ? next.PerformanceDate.Value.ToString("dd.MM.yyyy") : "*", remainCalc != null ? remainCalc.Hours.ToString() : "*", remainCalc != null ? remainCalc.Cycles.ToString() : "*", remainCalc != null ? remainCalc.Days.ToString() : "*", "", "" ); } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// Заполняет краткую информацию о директиве /// </summary> private void UpdateInformation() { if (_currentComponent == null) { return; } if (_componentDirectivesPerformances == null) { _componentDirectivesPerformances = new List <BaseComponentDirectiveSummaryControl>(); } else { _componentDirectivesPerformances.Clear(); } //очищение плавающей панели и списка контролов отображения директив деталей flowLayoutPanel_Compliance.Controls.Clear(); referenceLinkLabelLLPStatus.Visible = _currentComponent.BaseComponentType == BaseComponentType.Engine; var inspectedBaseComponent = _currentComponent; var baseComponentTypeString = inspectedBaseComponent.BaseComponentType.ToString(); var baseComponentModelString = inspectedBaseComponent.Model != null ? " " + inspectedBaseComponent.Model : ""; var engineThrustString = inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine && !string.IsNullOrEmpty(inspectedBaseComponent.Thrust) ? "/" + inspectedBaseComponent.Thrust : ""; extendableRichContainer.Caption = baseComponentTypeString + baseComponentModelString + engineThrustString //+ " P/N:" + _currentComponent.PartNumber + " S/N:" + _currentComponent.SerialNumber + " M/P:" + _currentComponent.MaintenanceControlProcess.ShortName + " Pos:" + _currentComponent.TransferRecords.GetLast().Position; referenceLinkLabelBaseDetail.Text = baseComponentTypeString; labelCompntTCSN.Text = baseComponentTypeString + " Total:"; labelCompntInstallDate.Text = baseComponentTypeString + " install date:"; labelCompntTCSNonInstall.Text = baseComponentTypeString + " on Install:"; labelCompntTCSNsinceInstall.Text = baseComponentTypeString + " since Install:"; labelRemarksValue.Text = inspectedBaseComponent.Remarks; labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.ManufactureDate); labelWarrantyValue.Text = inspectedBaseComponent.Warranty.ToString(); labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.TransferRecords.GetLast().TransferDate); Lifelength temp, temp2; //Наработка компонента на сегодня temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedBaseComponent); labelCompntTCSNValue.Text = temp.ToString(); //Остаток жизненного времени на сегодня temp2 = new Lifelength(inspectedBaseComponent.LifeLimit); temp2.Substract(temp); temp2.Resemble(inspectedBaseComponent.LifeLimit); if (inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine) { Component firstLimitter = _baseComponentComponents != null && _baseComponentComponents.Count > 0 ? _baseComponentComponents.Where(d => d.NextPerformanceDate != null) .OrderBy(d => d.NextPerformanceDate) .FirstOrDefault() : null; labelCompntLifeLimit.Text = baseComponentTypeString + " Life Limit / First Limit"; labelCompntLifeLimitValue.Text = ((inspectedBaseComponent.LifeLimit.IsNullOrZero() ? "N/A" : inspectedBaseComponent.LifeLimit.ToString()) + " / " + (firstLimitter == null || firstLimitter.LifeLimit.IsNullOrZero() ? "N/A" : firstLimitter.LifeLimit.ToString())); labelCompntLifeLimitRemains.Text = baseComponentTypeString + " Life Limit Remain / First Remains"; labelCompntLifeLimitRemainsValue.Text = ((inspectedBaseComponent.Remains.IsNullOrZero() ? "N/A" : inspectedBaseComponent.Remains.ToString()) + " / " + (firstLimitter == null || firstLimitter.Remains.IsNullOrZero() ? "N/A" : firstLimitter.Remains.ToString())); } else { labelCompntLifeLimit.Text = baseComponentTypeString + " Life Limit"; labelCompntLifeLimitValue.Text = inspectedBaseComponent.LifeLimit.ToString(); labelCompntLifeLimitRemains.Text = baseComponentTypeString + " Life Limit Remain"; labelCompntLifeLimitRemainsValue.Text = temp2.ToString(); } var lastTransferRecord = inspectedBaseComponent.TransferRecords.GetLast(); //Наработка компонента на момент установки temp2 = lastTransferRecord.OnLifelength; labelCompntTCSNonInstallValue.Text = temp2.ToString(); //Наработка компонента с момента установки и по сей день temp.Substract(temp2); labelCompntTCSNsinceInstallValue.Text = temp.ToString(); var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedBaseComponent.ParentAircraftId); //Наработка самолета на сегодня temp = parentAircraft != null ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft) : Lifelength.Zero; labelAircraftTCSNValue.Text = temp.ToString(); //Наработка самолета на момент установки детали temp = parentAircraft != null ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId), lastTransferRecord.TransferDate) : Lifelength.Zero; labelAircraftTCSNonInstallValue.Text = temp.ToString(); //Обновление таблиц выполнения директив //На каждую из директив детали создается отдельная таблица выполнения //После каждая таблица помещается в плавающую панель для отображения var componentDirectives = new List <ComponentDirective>(_currentComponent.ComponentDirectives.ToArray()); for (int i = 0; i < componentDirectives.Count; i++) { var summaryCompliancePerformanceControl = new BaseComponentDirectiveSummaryControl(componentDirectives[i]); summaryCompliancePerformanceControl.UpdateInformation(); _componentDirectivesPerformances.Add(summaryCompliancePerformanceControl); flowLayoutPanel_Compliance.Controls.Add(summaryCompliancePerformanceControl); } }
/// <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(); if (_currentDirective.Zone.Length > 10) { labelZoneValue.Text = _currentDirective.Zone.Replace(Environment.NewLine, " ").Substring(0, 10) + "...."; } else { labelZoneValue.Text = _currentDirective.Zone.Replace(Environment.NewLine, " "); }; if (_currentDirective.Access.Length > 10) { labelAccessValue.Text = _currentDirective.Access.Replace(Environment.NewLine, " ").Substring(0, 10) + "...."; } else { labelAccessValue.Text = _currentDirective.Access.Replace(Environment.NewLine, " "); } 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 } }
private void FindNextCheck() { //вычисление самого последнего выполненного чека, вне зависимости от типа //последний выполненый чек по типу может нессответствовать текущему типу программы //в случае переключения MaintenanceCheck lastComplianceCheck = CheckItems.Where(c => c.LastPerformance != null).OrderByDescending(c => c.LastPerformance.RecordDate).FirstOrDefault(); if (lastComplianceCheck != null && lastComplianceCheck.Schedule != Schedule && Schedule) { //тип программмы Maintenance был переключен, переключение с Unschedule на Schedule //вычисление самого последнего выполненного чека, заданного типа MaintenanceCheck lastComplianceScheduleTypeCheck = CheckItems.Where(c => c.LastPerformance != null && c.Schedule == Schedule).OrderByDescending(c => c.LastPerformance.RecordDate).FirstOrDefault(); MaintenanceCheckGroupByType group = new List <MaintenanceCheck>(CheckItems).GetNextCheckBySourceDifference(lastComplianceScheduleTypeCheck, TsnCsn.Days); //название чеков MaintenanceCheck maxIntervalCheckInGroup = group.GetMaxIntervalCheck(); string tNext = maxIntervalCheckInGroup.Name + " ("; tNext += group.Checks.Aggregate(tNext, (current, maintenanceCheck) => current + (maintenanceCheck.Name + " ")); tNext += ") "; string tNextDate = UsefulMethods.NormalizeDate(group.GroupComplianceDate); group.GroupComplianceLifelength.Cycles = group.GroupComplianceLifelength.Hours = null; string tNextLl = group.GroupComplianceLifelength.ToRepeatIntervalsFormat(); group.GroupComplianceLifelength.Substract(TsnCsn); group.GroupComplianceLifelength.Cycles = group.GroupComplianceLifelength.Hours = null; string tRemainLl = Convert.ToInt32(group.GroupComplianceLifelength.Days).ToString(); Action <string, string, string, string> addLast = AddNextCheckItem; if (InvokeRequired) { Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl); } else { addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl); } } else { if (_complianceGroupCollection == null) { _complianceGroupCollection = CheckItems.GetNextComplianceCheckGroups(Schedule).OrderBy(GetNextComplianceDate); } foreach (MaintenanceCheckComplianceGroup complianceGroup in _complianceGroupCollection) { string tNext, tNextDate, tNextLl, tRemainLl; MaintenanceCheck maxIntervalCheckInGroup; if ((maxIntervalCheckInGroup = complianceGroup.GetMaxIntervalCheck()) == null) { continue; } complianceGroup.Sort(); string prefix = complianceGroup.GetGroupName(); if (complianceGroup.Grouping) { MaintenanceCheck lastOrMinCheck = complianceGroup.GetLastComplianceChecks().FirstOrDefault() != null ? complianceGroup.GetLastComplianceChecks().First() : complianceGroup.GetMinIntervalCheck(); //дата следующего выполнения группы чеков if (lastOrMinCheck.Interval.Days != null && lastOrMinCheck.Interval.Days > 0) { DateTime nextDate = lastOrMinCheck.NextPerformances.Count != 0 && lastOrMinCheck.NextPerformances[0].PerformanceDate != null ? lastOrMinCheck.NextPerformances[0].PerformanceDate.Value : lastOrMinCheck.LastPerformance != null ? lastOrMinCheck.LastPerformance.RecordDate.AddDays(Convert.ToInt32(lastOrMinCheck.Interval.Days)) : lastOrMinCheck.ParentAircraft.ManufactureDate.AddDays(Convert.ToInt32(lastOrMinCheck.Interval.Days)); tNextDate = UsefulMethods.NormalizeDate(nextDate); if (lastOrMinCheck.NextPerformances.Count != 0 && lastOrMinCheck.NextPerformances[0].Remains != null) { //Остаток до выполнения Lifelength remains = lastOrMinCheck.NextPerformances[0].Remains; tRemainLl = remains.IsNullOrZero() ? "N/A" : remains.ToString(); } else { tRemainLl = " N/A "; } } else { tNextDate = lastOrMinCheck.NextPerformances.Count != 0 && lastOrMinCheck.NextPerformances[0].PerformanceDate != null ? " approx. " + UsefulMethods.NormalizeDate(lastOrMinCheck.NextPerformances[0].PerformanceDate.Value) : " N/A "; if (lastOrMinCheck.NextPerformances.Count != 0 && lastOrMinCheck.NextPerformances[0].Remains != null) { //Остаток до выполнения Lifelength remains = lastOrMinCheck.NextPerformances[0].Remains; tRemainLl = remains.IsNullOrZero() ? "N/A" : remains.ToString(); } else { tRemainLl = " N/A "; } } //ресурс, на котором надо поризвести выполнение //след выполнение Lifelength next = lastOrMinCheck.NextPerformances.Count != 0 ? lastOrMinCheck.NextPerformances[0].PerformanceSource : Lifelength.Null; next.Resemble(maxIntervalCheckInGroup.Interval); tNextLl = next.IsNullOrZero() ? "N/A" : next.ToString(); //название чеков tNext = prefix; if (lastOrMinCheck.ParentAircraft != null && lastOrMinCheck.ParentAircraft.MSG < MSG.MSG3) { tNext += " ("; tNext = complianceGroup.Checks.Aggregate(tNext, (current, maintenanceCheck) => current + (maintenanceCheck.Name + " ")); tNext += ") "; } Action <string, string, string, string> addLast = AddNextCheckItem; if (InvokeRequired) { Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl); } else { addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl); } } else { foreach (MaintenanceCheck maintenanceCheck in complianceGroup.Checks) { DateTime nextDate; if (maintenanceCheck.Interval.Days != null && maintenanceCheck.Interval.Days > 0) { nextDate = maintenanceCheck.NextPerformances.Count != 0 && maintenanceCheck.NextPerformances[0].PerformanceDate != null ? maintenanceCheck.NextPerformances[0].PerformanceDate.Value : maintenanceCheck.LastPerformance != null ? maintenanceCheck.LastPerformance.RecordDate.AddDays(Convert.ToInt32(maintenanceCheck.Interval.Days)) : maintenanceCheck.ParentAircraft.ManufactureDate.AddDays(Convert.ToInt32(maintenanceCheck.Interval.Days)); tNextDate = "\n" + UsefulMethods.NormalizeDate(nextDate); if (maintenanceCheck.NextPerformances.Count != 0 && maintenanceCheck.NextPerformances[0].Remains != null) { //Остаток до выполнения Lifelength remains = maintenanceCheck.NextPerformances[0].Remains; tRemainLl = "\n" + (remains.IsNullOrZero() ? "N/A" : remains.ToString()); } else { tRemainLl = "\n N/A "; } } else { if (maintenanceCheck.NextPerformanceDate != null) { nextDate = maintenanceCheck.NextPerformanceDate.Value; tNextDate = "\n approx. " + UsefulMethods.NormalizeDate(nextDate); } else { tNextDate = "\n (N/A) "; } if (maintenanceCheck.NextPerformances.Count != 0 && maintenanceCheck.NextPerformances[0].Remains != null) { //Остаток до выполнения Lifelength remains = maintenanceCheck.NextPerformances[0].Remains; tRemainLl = "\n" + (remains.IsNullOrZero() ? "N/A" : remains.ToString()); } else { tRemainLl = "\n (N/A) "; } } //след выполнение Lifelength next = maintenanceCheck.NextPerformances.Count != 0 ? maintenanceCheck.NextPerformances[0].PerformanceSource : Lifelength.Null; tNextLl = "\n" + (next.IsNullOrZero() ? "N/A" : next.ToString()); //название чеков tNext = "\n" + maintenanceCheck.Name + " "; Action <string, string, string, string> addLast = AddNextCheckItem; if (InvokeRequired) { Invoke(addLast, tNext, tNextDate, tNextLl, tRemainLl); } else { addLast.Invoke(tNext, tNextDate, tNextLl, tRemainLl); } } } } } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddAircraftToDataset(AircraftTechicalConditionDataSet destinationDataSet) { if (_reportedAircraft == null) { return; } var reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft); var lifeLimit = GlobalObjects.ComponentCore.GetBaseComponentById(_reportedAircraft.AircraftFrameId).LifeLimit; var lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : "--"; var lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : "--"; var lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : "--"; var remain = Lifelength.Null; if (!lifeLimit.IsNullOrZero()) { remain = lifeLimit - reportAircraftLifeLenght; remain.Resemble(lifeLimit); } var remainHours = remain.Hours != null?remain.Hours.ToString() : "--"; var remainCycles = remain.Cycles != null?remain.Cycles.ToString() : "--"; var remainDays = remain.Days != null?remain.Days.ToString() : "--"; var ohIntervalHours = ""; var ohIntervalCycles = ""; var ohIntervalCalendar = ""; if (_minCCheck != null) { ohIntervalHours = _minCCheck.Interval.TotalMinutes != null?_minCCheck.Interval.Hours.ToString() : "--"; ohIntervalCycles = _minCCheck.Interval.Cycles != null?_minCCheck.Interval.Cycles.ToString() : "--"; ohIntervalCalendar = _minCCheck.Interval.CalendarValue != null?_minCCheck.Interval.CalendarSpan.Years.ToString() : "--"; } var sinceLastCCheckHours = "--"; var sinceLastCCheckCycles = "--"; var sinceLastCCheckCalendar = "--"; var lastOHCheckDate = ""; var lastOHStation = ""; var lastOHType = ""; var ohRemainHours = ""; var ohRemainCycles = ""; var ohRemainCalendar = ""; if (_lastCСheckRecord != null) { if (_lastCСheckRecord.DirectivePackage == null) { _lastCСheckRecord.DirectivePackage = _workPackages != null ? _workPackages.FirstOrDefault(wp => wp.ItemId == _lastCСheckRecord.DirectivePackageId) : null; } lastOHStation = _lastCСheckRecord.DirectivePackage != null ? _lastCСheckRecord.DirectivePackage.Station + "." : ""; lastOHCheckDate = _lastCСheckRecord.RecordDate.ToString("d.M.yyyy"); lastOHType = _lastCСheckRecord.ParentCheck.CheckType.ToString(); Lifelength sinceLast = reportAircraftLifeLenght - _lastCСheckRecord.OnLifelength; if (_minCCheck != null) { sinceLast.Resemble(_minCCheck.Interval); Lifelength ohRemains = _minCCheck.Interval - sinceLast; ohRemainHours = ohRemains.TotalMinutes != null?ohRemains.Hours.ToString() : "--"; ohRemainCycles = ohRemains.Cycles != null?ohRemains.Cycles.ToString() : "--"; ohRemainCalendar = ohRemains.CalendarValue != null?ohRemains.CalendarSpan.Years.ToString() : "--"; } sinceLastCCheckHours = sinceLast.TotalMinutes != null?sinceLast.Hours.ToString() : "--"; sinceLastCCheckCycles = sinceLast.Cycles != null?sinceLast.Cycles.ToString() : "--"; sinceLastCCheckCalendar = sinceLast.CalendarValue != null?sinceLast.CalendarSpan.Years.ToString() : "--"; } var manufactureDate = _reportedAircraft.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var sinceNewHours = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0; var sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; var sinceNewCalendar = reportAircraftLifeLenght.Days != null?reportAircraftLifeLenght.CalendarSpan.Years.ToString() : "--"; var powerPlantsModelsString = ""; var powerPlantsModels = _aircraftBaseDetails.Where(bd => (bd.BaseComponentType == BaseComponentType.Engine || bd.BaseComponentType == BaseComponentType.Apu) && bd.Model != null) .Select(bd => bd.Model) .Distinct(new ComponentModelStringComparer()) .ToList(); for (int i = 0; i < powerPlantsModels.Count(); i++) { var model = powerPlantsModels[i].ToString(); if (string.IsNullOrEmpty(model)) { continue; } if (powerPlantsModelsString != "" && i > 0) { powerPlantsModelsString += "/"; } powerPlantsModelsString += model; } destinationDataSet.AircraftDataTable.AddAircraftDataTableRow(_reportedAircraft.SerialNumber, manufactureDate, sinceNewHours, sinceNewCycles, _reportedAircraft.RegistrationNumber, _reportedAircraft.Model.ToString(), _reportedAircraft.LineNumber, _reportedAircraft.VariableNumber, lifeLimitHours, lifeLimitCycles, lifeLimitDays, remainHours, remainCycles, remainDays, lastOHCheckDate, lastOHStation, lastOHType, ohIntervalHours, ohIntervalCycles, ohIntervalCalendar, ohRemainHours, ohRemainCycles, ohRemainCalendar, sinceNewCalendar, sinceLastCCheckHours, sinceLastCCheckCycles, sinceLastCCheckCalendar, _countDCheckPerformances > 0 ? _countDCheckPerformances.ToString() : "", powerPlantsModelsString); }
/// <summary> /// Заполняет краткую информацию о директиве /// </summary> public void UpdateInformation() { if ((_currentDefferedItem == null) || _currentDefferedItem.ParentBaseComponent == null) { return; } var aircraft = GlobalObjects.AircraftsCore.GetParentAircraft(_currentDefferedItem); //GlobalObjects.PerformanceCalculator.GetNextPerformance(_currentDefferedItem); var ata = _currentDefferedItem.ATAChapter; labelDirectiveValue.Text = _currentDefferedItem.Title + " for"; labelDescriptionValue.Text = _currentDefferedItem.Description; labelEffectiveDateValue.Text = Convert.GetDateFormat(_currentDefferedItem.Threshold.EffectiveDate); labelSBValue.Text = _currentDefferedItem.ServiceBulletinNo; labelEOValue.Text = _currentDefferedItem.EngineeringOrders; labelATAChapterValue.Text = ata != null?ata.ToString() : ""; labelApplicabilityValue.Text = _currentDefferedItem.Applicability; linkDetailInfoFirst.Text = aircraft.RegistrationNumber; labelRemarksLast.Text = ""; if (CurrentAircraft != null) { linkDirectiveStatus.Text = BackLinkText; } if (_currentDefferedItem.Remains != null && _currentDefferedItem.Condition != ConditionState.NotEstimated) { if (_currentDefferedItem.Remains.IsOverdue() && _currentDefferedItem.Condition == ConditionState.Overdue) { labelRemains.Text = "Overdue:"; imageLinkLabelStatus.Status = Statuses.NotSatisfactory; } else if (_currentDefferedItem.Condition == ConditionState.Notify) { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.Notify; } else if (_currentDefferedItem.Condition == ConditionState.Satisfactory) { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.Satisfactory; } else { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.NotActive; } } imageLinkLabelStatus.Text = _currentDefferedItem.WorkType.ToString(); labelRemainsValue.Text = ""; if (_currentDefferedItem.Remains != null) { labelRemainsValue.Text = _currentDefferedItem.Remains.ToString(); } labelCostValue.Text = _currentDefferedItem.Cost.ToString(); labelManHoursValue.Text = _currentDefferedItem.ManHours.ToString(); labelKitValue.Text = _currentDefferedItem.KitRequired == "" ? "N" : _currentDefferedItem.KitRequired; labelNDTvalue.Text = _currentDefferedItem.NDTType.ShortName; labelRemarksValue.Text = _currentDefferedItem.Remarks; labelHiddenRemarksValue.Text = ""; if (labelHiddenRemarksValue.Text == "") { labelHiddenRemarksValue.Text = "No Important information"; // labelHiddenRemarks.Visible = false; } labelDateLast.Text = ""; labelAircraftTsnCsnLast.Text = ""; labelDateNext.Text = "n/a"; labelAircraftTsnCsnNext.Text = "n/a"; labelComponentTsnCsnNext.Text = "n/a"; labelRemarksValue.Text = ""; BaseComponent parentBaseComponent = _currentDefferedItem.ParentBaseComponent; if (_currentDefferedItem.LastPerformance != null) { labelDateLast.Text = Convert.GetDateFormat(_currentDefferedItem.LastPerformance.RecordDate); if (!_currentDefferedItem.LastPerformance.OnLifelength.IsNullOrZero()) { labelComponentTsnCsnLast.Text = _currentDefferedItem.LastPerformance.OnLifelength.ToString(); labelAircraftTsnCsnLast.Text = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnEndOfDay(parentBaseComponent, _currentDefferedItem.LastPerformance.RecordDate).ToString(); } } /////////////////////////////////////////////////////////////////////////////////////////////// labelFirstPerformanceValue.Text = "n/a"; labelRptIntervalValue.Text = "n/a"; if (_currentDefferedItem.Threshold.FirstPerformanceSinceNew != null && !_currentDefferedItem.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { labelFirstPerformanceValue.Text = "s/n: " + _currentDefferedItem.Threshold.FirstPerformanceSinceNew; } if (_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate != null && !_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (labelFirstPerformanceValue.Text != "n/a") { labelFirstPerformanceValue.Text += " or "; } else { labelFirstPerformanceValue.Text = ""; } labelFirstPerformanceValue.Text += "s/e.d: " + _currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate; } if (_currentDefferedItem.Threshold.RepeatInterval != null) { labelRptIntervalValue.Text = _currentDefferedItem.Threshold.RepeatInterval.IsNullOrZero() ? "n/a" : _currentDefferedItem.Threshold.RepeatInterval.ToString(); } //////////////////////////////////////////////////////////////////////////////////////////////// labelRemarksValue.Text = _currentDefferedItem.Remarks; if (_currentDefferedItem.IsClosed) { return; //если директива принудительно закрыта пользователем } //то вычисление следующего выполнения не нужно labelDateNext.Text = labelAircraftTsnCsnNext.Text = "n/a"; if (_currentDefferedItem.LastPerformance == null) { if (_currentDefferedItem.Threshold.PerformSinceNew && _currentDefferedItem.Threshold.FirstPerformanceSinceNew != null && !_currentDefferedItem.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { //если наработка исчисляется с момента выпуска if (_currentDefferedItem.Threshold.FirstPerformanceSinceNew.Days != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения labelDateNext.Text = Convert.GetDateFormat( parentBaseComponent.ManufactureDate.AddDays( (double)_currentDefferedItem.Threshold.FirstPerformanceSinceNew.Days)) + " s/n"; } else { //иначе, если (дополнительно) дата не определена labelDateNext.Text = "n/a"; } labelComponentTsnCsnNext.Text = "s/n: " + _currentDefferedItem.Threshold.FirstPerformanceSinceNew; //labelAircraftTsnCsnNext.Text = "s/n: " + currentDirective.Threshold.SinceNew.ToString(); } if (_currentDefferedItem.Threshold.PerformSinceEffectiveDate && _currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate != null && !_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { //если наработка исчисляется с эффективной даты //Определение даты исполнения if (_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate.Days != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения if (labelDateNext.Text != "n/a") { labelDateNext.Text += " or "; } else { labelDateNext.Text = ""; } labelDateNext.Text += Convert.GetDateFormat( _currentDefferedItem.Threshold.EffectiveDate.AddDays ((double)_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate.Days)) + " s/e.d."; } else { //иначе, дату определить нельзя if (labelDateNext.Text == "") { labelDateNext.Text = "n/a"; } } //Определение наработки if (_currentDefferedItem.Threshold.EffectiveDate < DateTime.Today) { Lifelength sinceEffDate = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnEndOfDay(parentBaseComponent, _currentDefferedItem.Threshold.EffectiveDate); sinceEffDate.Add(_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDate.Resemble(_currentDefferedItem.Threshold.FirstPerformanceSinceEffectiveDate); if (labelComponentTsnCsnNext.Text != "n/a") { labelComponentTsnCsnNext.Text += " or "; } else { labelComponentTsnCsnNext.Text = ""; } labelComponentTsnCsnNext.Text += "s/e.d: " + sinceEffDate; } } } else { if (_currentDefferedItem.Threshold.PerformRepeatedly && _currentDefferedItem.Threshold.RepeatInterval != null) { //повторяющаяся директива //если есть последнне выполнение, то следующая дата расчитывается //по повторяющемуся интервалу if (_currentDefferedItem.Threshold.RepeatInterval.Days != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения labelDateNext.Text = Convert.GetDateFormat( _currentDefferedItem.LastPerformance.RecordDate.AddDays( (double)_currentDefferedItem.Threshold.RepeatInterval.Days)); } else { //иначе, точную дату выполнения расчитать нельзя labelDateNext.Text = "n/a"; labelComponentTsnCsnNext.Text = "n/a"; } //Определение наработки if (!_currentDefferedItem.Threshold.RepeatInterval.IsNullOrZero()) { Lifelength nextTsnCsn; if (!_currentDefferedItem.LastPerformance.OnLifelength.IsNullOrZero()) { nextTsnCsn = new Lifelength(_currentDefferedItem.LastPerformance.OnLifelength); } else { nextTsnCsn = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(parentBaseComponent, _currentDefferedItem. LastPerformance. RecordDate); } Lifelength nextAircraftTsnCsn = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay( parentBaseComponent, _currentDefferedItem. LastPerformance. RecordDate); nextTsnCsn.Add(_currentDefferedItem.Threshold.RepeatInterval); nextTsnCsn.Resemble(_currentDefferedItem.Threshold.RepeatInterval); labelComponentTsnCsnNext.Text = nextTsnCsn.ToString(); nextAircraftTsnCsn.Add(_currentDefferedItem.Threshold.RepeatInterval); nextAircraftTsnCsn.Resemble(_currentDefferedItem.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"; } } } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> protected override void AddDirectiveToDataset(MaintenanceDirective reportedDirective, MaintenanceDirectivesDataSet destinationDataSet) { if (reportedDirective == null) { return; } string status = ""; Lifelength used = Lifelength.Null; //string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; string remarks = reportedDirective.Remarks; string directiveType = reportedDirective.WorkType.ShortName; double cost = reportedDirective.Cost; double mh = reportedDirective.ManHours; if (reportedDirective.Status == DirectiveStatus.Closed) { status = "C"; } if (reportedDirective.Status == DirectiveStatus.Open) { status = "O"; } if (reportedDirective.Status == DirectiveStatus.Repetative) { status = "R"; } if (reportedDirective.Status == DirectiveStatus.NotApplicable) { status = "N/A"; } string effectivityDate = UsefulMethods.NormalizeDate(reportedDirective.Threshold.EffectiveDate); string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва string firstPerformanceString = ""; string repeatPerformanceToString = reportedDirective.Threshold.RepeatPerformanceToStrings(); if (reportedDirective.LastPerformance != null) { used.Add(Current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.RepeatInterval); } else if (!reportedDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } } else { firstPerformanceString = reportedDirective.Threshold.FirstPerformanceToStrings(); } destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.Applicability, remarks, reportedDirective.HiddenRemarks, reportedDirective.Description.Replace("\r\n", " "), reportedDirective.TaskNumberCheck, reportedDirective.Access, directiveType, status, effectivityDate, firstPerformanceString, reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.ToStrings() : "", reportedDirective.NextPerformance != null ? reportedDirective.NextPerformance.ToStrings() : "", reportedDirective.Remains.ToStrings(), reportedDirective.Condition.ToString(), mh, cost, kits, reportedDirective.Zone, reportedDirective.ATAChapter != null ? reportedDirective.ATAChapter.ShortName : "", reportedDirective.ATAChapter != null ? reportedDirective.ATAChapter.FullName : "", reportedDirective.TaskCardNumber, reportedDirective.Program.ToString(), repeatPerformanceToString, used.ToStrings(), reportedDirective.MaintenanceCheck != null ? reportedDirective.MaintenanceCheck.ToString() : "N/A"); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(object reportedDirective, ComponentListDataSet destinationDataSet) { //if (!DefaultFilter.Acceptable(directive)) // return; Component component; ComponentDirective directive; NextPerformance nextDueAtAircraftUtilization = null; DirectiveRecord lastPerformance = null; string positionString = ""; string remarks = "", condition = ""; string workType = "", lastComplianceDate = "", nextComplianceDate = "", ampReference = ""; double mansHours = 0, cost = 0; DateTime installationDate = DateTimeExtend.GetCASMinDateTime(); string kits = "", equipment = "", status = ""; Lifelength lifeLimit, componentCurrent = Lifelength.Null; Lifelength repeat = Lifelength.Null, lastCompliance = Lifelength.Null; Lifelength used = Lifelength.Null, nextPerformanceSource = Lifelength.Null, remain = Lifelength.Null; if (reportedDirective is ComponentDirective) { directive = (ComponentDirective)reportedDirective; component = directive.ParentComponent; positionString = component.TransferRecords.GetLast().Position; installationDate = component.TransferRecords.GetLast().TransferDate; componentCurrent = directive.ParentComponent.IsBaseComponent ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength((BaseComponent)component) : GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(component); remarks = directive.Remarks; workType = directive.DirectiveType.ToString(); repeat = directive.Threshold.RepeatInterval; lifeLimit = component.LifeLimit; //nextCompliance = GlobalObjects.CasEnvironment.Calculator.GetNextPerformance(directive); GlobalObjects.PerformanceCalculator.GetNextPerformance(directive); nextPerformanceSource = directive.NextPerformanceSource; if (directive.MaintenanceDirective != null) { ampReference = directive.MaintenanceDirective.TaskNumberCheck; } if (nextPerformanceSource != null && directive.Status != DirectiveStatus.Closed) { nextComplianceDate = directive.NextPerformanceDate != null ? ((DateTime)directive.NextPerformanceDate).ToString( new GlobalTermsProvider()["DateFormat"].ToString()) : ""; remain.Add(nextPerformanceSource); remain.Substract(componentCurrent); used.Add(componentCurrent); if (_reportedAircraft != null) { nextDueAtAircraftUtilization = new NextPerformance { PerformanceDate = directive.NextPerformanceDate, PerformanceSource = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft) }; nextDueAtAircraftUtilization.PerformanceSource.Add(remain); } } else { nextPerformanceSource = Lifelength.Null; } if (directive.LastPerformance != null && directive.Status != DirectiveStatus.Closed) { lastPerformance = directive.LastPerformance; lastComplianceDate = directive.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastCompliance = directive.LastPerformance.OnLifelength; used.Substract(lastCompliance); used.Resemble(directive.Threshold.RepeatInterval); remain.Resemble(directive.Threshold.RepeatInterval); if (nextDueAtAircraftUtilization != null) { nextDueAtAircraftUtilization.PerformanceSource.Resemble(directive.Threshold.RepeatInterval); } } else { used.Resemble(directive.Threshold.FirstPerformanceSinceNew); remain.Resemble(directive.Threshold.FirstPerformanceSinceNew); if (nextDueAtAircraftUtilization != null) { nextDueAtAircraftUtilization.PerformanceSource.Resemble(directive.Threshold.FirstPerformanceSinceNew); } } int num = 1; foreach (AccessoryRequired kit in directive.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } condition = directive.Condition.ToString(); } //Если объект является деталью или базовой деталью с директивами //то надо возвратится, т.к. данные по детали/базовой детали будут //добавлены при добавлении их директив в набор данных //Если деталь.базовая деталь без директив, тогда в набор данных надо добавить и данные сразу else if (reportedDirective is Component) { component = (Component)reportedDirective; lifeLimit = component.LifeLimit; if (component.ComponentDirectives.Count != 0) { return; } } else { throw new ArgumentException(); } Lifelength lifeLimitUsed = Lifelength.Null; lifeLimitUsed.Add(componentCurrent); lifeLimitUsed.Resemble(lifeLimit); Lifelength lifeLimitRemain = Lifelength.Null; lifeLimitRemain.Add(lifeLimit); lifeLimitRemain.Substract(componentCurrent); lifeLimitRemain.Resemble(lifeLimit); //string status = ""; //if (.Status == DirectiveStatus.Closed) status = "C"; //if (directive.Status == DirectiveStatus.Open) status = "O"; //if (directive.Status == DirectiveStatus.Repetative) status = "R"; //if (directive.Status == DirectiveStatus.NotApplicable) status = "N/A"; destinationDataSet.ItemsTable.AddItemsTableRow(component.ATAChapter.ShortName, ampReference, component.PartNumber, component.SerialNumber, positionString, component.Description, component.MaintenanceControlProcess.ToString(), installationDate, lifeLimit.Days != null ? lifeLimit.Days.ToString() : "", lifeLimit.Hours != null ? lifeLimit.Hours.ToString() : "", lifeLimit.Cycles != null ? lifeLimit.Cycles.ToString() : "", lifeLimitUsed.Days != null ? lifeLimitUsed.Days.ToString() : "", lifeLimitUsed.Hours != null ? lifeLimitUsed.Hours.ToString() : "", lifeLimitUsed.Cycles != null ? lifeLimitUsed.Cycles.ToString() : "", lifeLimitRemain.Days != null ? lifeLimitRemain.Days.ToString() : "", lifeLimitRemain.Hours != null ? lifeLimitRemain.Hours.ToString() : "", lifeLimitRemain.Cycles != null ? lifeLimitRemain.Cycles.ToString() : "", workType, repeat.Days != null ? repeat.Days.ToString() : "", repeat.Hours != null ? repeat.Hours.ToString() : "", repeat.Cycles != null ? repeat.Cycles.ToString() : "", repeat.ToHoursMinutesAndCyclesStrings(" FH", " FC"), lastComplianceDate, lastCompliance.Hours != null ? lastCompliance.Hours.ToString() : "", lastCompliance.Cycles != null ? lastCompliance.Cycles.ToString() : "", lastPerformance != null ? lastPerformance.ToStrings("/") : "", used.Days != null ? used.Days.ToString() : "", used.Hours != null ? used.Hours.ToString() : "", used.Cycles != null ? used.Cycles.ToString() : "", nextComplianceDate, nextPerformanceSource.Hours != null ? nextPerformanceSource.Hours.ToString() : "", nextPerformanceSource.Cycles != null ? nextPerformanceSource.Cycles.ToString() : "", nextDueAtAircraftUtilization != null ? nextDueAtAircraftUtilization.ToStrings("/") : "", remain.Days != null ? remain.Days.ToString() : "", remain.Hours != null ? remain.Hours.ToString() : "", remain.Cycles != null ? remain.Cycles.ToString() : "", remain.ToHoursMinutesAndCyclesStrings(" FH", " FC"), condition, mansHours, cost, kits, equipment, remarks, status); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddBaseDetailToDataset(ComponentListDataSet destinationDataSet) { if (_reportedAircraft != null) { return; } var reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent); var manufactureDate = _reportedBaseComponent.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var deliveryDate = _reportedBaseComponent.DeliveryDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var status = _reportedBaseComponent.Serviceable ? "Serviceable" : "Unserviceable"; var sinceNewHours = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0; var sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; var sinceNewDays = reportAircraftLifeLenght.Days != null?reportAircraftLifeLenght.Days.ToString() : ""; var lifeLimit = _reportedBaseComponent.LifeLimit; var lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : ""; var lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : ""; var lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : ""; var remain = new Lifelength(lifeLimit); remain.Substract(reportAircraftLifeLenght); var remainHours = remain.Hours != null?remain.Hours.ToString() : ""; var remainCycles = remain.Cycles != null?remain.Cycles.ToString() : ""; var remainDays = remain.Days != null?remain.Days.ToString() : ""; var installationDate = _reportedBaseComponent.TransferRecords.GetLast().TransferDate; //TODO:(Evgenii Babak) нужно брать наработку с записи о выполнении, а не пересчитывать заново var onInstall = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(_reportedBaseComponent, installationDate); var onInstallDate = installationDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var onInstallHours = onInstall.Hours != null?onInstall.Hours.ToString() : ""; var onInstallCycles = onInstall.Cycles != null?onInstall.Cycles.ToString() : ""; var onInstallDays = onInstall.Days != null?onInstall.Days.ToString() : ""; var sinceInstall = new Lifelength(reportAircraftLifeLenght); sinceInstall.Substract(onInstall); var sinceInstallHours = sinceInstall.Hours != null?sinceInstall.Hours.ToString() : ""; var sinceInstallCycles = sinceInstall.Cycles != null?sinceInstall.Cycles.ToString() : ""; var sinceInstallDays = sinceInstall.Days != null?sinceInstall.Days.ToString() : ""; var warranty = _reportedBaseComponent.Warranty; var warrantyRemain = new Lifelength(warranty); warrantyRemain.Substract(reportAircraftLifeLenght); warrantyRemain.Resemble(warranty); var warrantyHours = warranty.Hours != null?warranty.Hours.ToString() : ""; var warrantyCycles = warranty.Cycles != null?warranty.Cycles.ToString() : ""; var warrantyDays = warranty.Days != null?warranty.Days.ToString() : ""; var warrantyRemainHours = warrantyRemain.Hours != null?warrantyRemain.Hours.ToString() : ""; var warrantyRemainCycles = warrantyRemain.Cycles != null?warrantyRemain.Cycles.ToString() : ""; var warrantyRemainDays = warrantyRemain.Days != null?warrantyRemain.Days.ToString() : ""; var parentAircaft = GlobalObjects.AircraftsCore.GetAircraftById(_reportedBaseComponent.ParentAircraftId); var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId); var aircraftOnInstall = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, installationDate); var aircraftOnInstallHours = aircraftOnInstall.Hours != null?aircraftOnInstall.Hours.ToString() : ""; var aircraftOnInstallCycles = aircraftOnInstall.Cycles != null?aircraftOnInstall.Cycles.ToString() : ""; var aircraftOnInstallDays = aircraftOnInstall.Days != null?aircraftOnInstall.Days.ToString() : ""; var aircraftCurrent = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircaft); var aircraftCurrentCycles = aircraftCurrent.Cycles ?? 0; var sinceOverhaul = Lifelength.Null; var lastOverhaulDate = DateTime.MinValue; var lastOverhaulDateString = ""; #region поиск последнего ремонта и расчет времени, прошедшего с него //поиск директив деталей var directives = GlobalObjects.ComponentCore.GetComponentDirectives(_reportedBaseComponent, true); //поиск директивы ремонта var overhauls = directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList(); //поиск последнего ремонта ComponentDirective lastOverhaul = null; foreach (ComponentDirective d in overhauls) { if (d.LastPerformance == null || d.LastPerformance.RecordDate <= lastOverhaulDate) { continue; } lastOverhaulDate = d.LastPerformance.RecordDate; lastOverhaul = d; } if (lastOverhaul != null) { sinceOverhaul.Add(reportAircraftLifeLenght); sinceOverhaul.Substract(lastOverhaul.LastPerformance.OnLifelength); lastOverhaulDateString = lastOverhaul.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); } #endregion destinationDataSet.BaseDetailTable.AddBaseDetailTableRow(_reportedBaseComponent.ATAChapter.ToString(), _reportedBaseComponent.AvionicsInventory.ToString(), _reportedBaseComponent.PartNumber, _reportedBaseComponent.SerialNumber, _reportedBaseComponent.Model != null ? _reportedBaseComponent.Model.ToString() : "", _reportedBaseComponent.BaseComponentType.ToString(), _reportedBaseComponent.GetParentAircraftRegNumber(), _reportedBaseComponent.TransferRecords.GetLast().Position, _reportedBaseComponent.Manufacturer, manufactureDate, deliveryDate, _reportedBaseComponent.MPDItem, _reportedBaseComponent.Suppliers != null ? _reportedBaseComponent.Suppliers.ToString() : "", status, _reportedBaseComponent.Cost, _reportedBaseComponent.CostOverhaul, _reportedBaseComponent.CostServiceable, lifeLimitHours, lifeLimitCycles, lifeLimitDays, sinceNewHours, sinceNewCycles, sinceNewDays, remainCycles, remainHours, remainDays, onInstallDate, onInstallHours, onInstallCycles, onInstallDays, sinceInstallHours, sinceInstallCycles, sinceInstallDays, warrantyHours, warrantyCycles, warrantyDays, warrantyRemainHours, warrantyRemainCycles, warrantyRemainDays, aircraftOnInstallHours, aircraftOnInstallCycles, aircraftOnInstallDays, lastOverhaulDateString, sinceOverhaul.Hours ?? 0, sinceOverhaul.Cycles ?? 0); int averageUtilizationHours; int averageUtilizationCycles; string averageUtilizationType; if (_forecast == null) { var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); //TODO:(Evgenii Babak) убрать повторяющийся код при использовании AverageUtilization averageUtilizationHours = (int)averageUtilization.Hours; averageUtilizationCycles = (int)averageUtilization.Cycles; averageUtilizationType = averageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } else { //TODO:(Evgenii Babak) убрать повторяющийся код при использовании AverageUtilization averageUtilizationHours = (int)_forecast.ForecastDatas[0].AverageUtilization.Hours; averageUtilizationCycles = (int)_forecast.ForecastDatas[0].AverageUtilization.Cycles; averageUtilizationType = _forecast.ForecastDatas[0].AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } var serialNumber = parentAircaft.SerialNumber; var model = parentAircaft.Model.ShortName; var registrationNumber = parentAircaft.RegistrationNumber; var lineNumber = parentAircaft.LineNumber; var variableNumber = parentAircaft.VariableNumber; //destinationDataSet.AircraftDataTable.AddAircraftDataTableRow(serialNumber, // manufactureDate, // aircraftCurrent.ToHoursMinutesFormat(""), // aircraftCurrentCycles, // registrationNumber, model, lineNumber, variableNumber, // averageUtilizationHours, averageUtilizationCycles, averageUtilizationType); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(object reportedDirective, DirectivesListDataSet destinationDataSet) { var detailDirective = (ComponentDirective)reportedDirective; var detail = detailDirective.ParentComponent; var references = ""; var title = ""; var eo = ""; var sb = ""; var remarks = detailDirective.LastPerformance != null ? detailDirective.LastPerformance.Remarks : detail.Remarks; string status = ""; if (detailDirective.Status == DirectiveStatus.Closed) { status = "C"; } if (detailDirective.Status == DirectiveStatus.Open) { status = "O"; } if (detailDirective.Status == DirectiveStatus.Repetative) { status = "R"; } if (detailDirective.Status == DirectiveStatus.NotApplicable) { status = "N/A"; } //string effectivityDate = UsefulMethods.NormalizeDate(detailDirective.Threshold.); string equipment = "";//detailDirective.NonDestructiveTest ? "NDT" : ""; string kits = ""; int num = 1; foreach (var kit in detailDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты Lifelength sinceNewThreshold = Lifelength.Null, sinceEffDateThreshold = Lifelength.Null; Lifelength sinceNewRemain = Lifelength.Null, sinceEffDateRemain = Lifelength.Null; Lifelength firstCompliance = Lifelength.Null, lastCompliance = Lifelength.Null, repeatInterval = Lifelength.Null, nextCompliance, remain = Lifelength.Null; string firstComplianceDate = "", lastComplianceDate = "", nextComplianceDate, sinceNewComplianceDate = ""; Lifelength used = Lifelength.Null; if (detailDirective.Threshold.FirstPerformanceSinceNew != null) { sinceNewThreshold = detailDirective.Threshold.FirstPerformanceSinceNew; if (sinceNewThreshold.Days != null) { sinceNewComplianceDate = _manufactureDate.AddDays(sinceNewThreshold.Days.Value).ToString( new GlobalTermsProvider()["DateFormat"].ToString()); } if (detailDirective.LastPerformance == null) { sinceNewRemain.Add(detailDirective.Threshold.FirstPerformanceSinceNew); sinceNewRemain.Substract(_current); sinceNewRemain.Resemble(detailDirective.Threshold.FirstPerformanceSinceNew); } } GlobalObjects.PerformanceCalculator.GetNextPerformance(detailDirective); if (detailDirective.LastPerformance != null) { firstComplianceDate = detailDirective.PerformanceRecords[0].RecordDate.ToString( new GlobalTermsProvider()["DateFormat"].ToString()); firstCompliance = detailDirective.PerformanceRecords[0].OnLifelength; if (detailDirective.Threshold.RepeatInterval != null) { repeatInterval = detailDirective.Threshold.RepeatInterval; } lastComplianceDate = detailDirective.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastCompliance = detailDirective.LastPerformance.OnLifelength; used.Add(_current); used.Substract(detailDirective.LastPerformance.OnLifelength); if (detailDirective.NextPerformanceSource != null) { remain.Add(detailDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(detailDirective.Threshold.RepeatInterval); } } else { repeatInterval = detailDirective.Threshold.RepeatInterval; } nextComplianceDate = detailDirective.NextPerformanceDate != null ? ((DateTime)detailDirective.NextPerformanceDate).ToString( new GlobalTermsProvider()["DateFormat"].ToString()) : ""; nextCompliance = detailDirective.NextPerformanceSource ?? Lifelength.Null; var condition = detailDirective.Condition.ToString(); destinationDataSet.ItemsTable.AddItemsTableRow("Applicability", remarks, detail.HiddenRemarks, detail.Description, title, references, detailDirective.DirectiveType.ToString(), status, "", sinceNewThreshold.Hours ?? 0, sinceNewThreshold.Cycles ?? 0, sinceNewComplianceDate, detailDirective.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "W.O.F" : "W.O.L", sinceNewRemain.Hours ?? 0, sinceNewRemain.Cycles ?? 0, sinceNewRemain.Days ?? 0, sinceEffDateThreshold.Hours ?? 0, sinceEffDateThreshold.Cycles ?? 0, sinceEffDateThreshold.Days != null ? sinceEffDateThreshold.Days.ToString() : "", detailDirective.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "W.O.F" : "W.O.L", sinceEffDateRemain.Hours ?? 0, sinceEffDateRemain.Cycles ?? 0, sinceEffDateRemain.Days ?? 0, firstComplianceDate, firstCompliance.Hours ?? 0, firstCompliance.Cycles ?? 0, firstCompliance.ToStrings(), repeatInterval.Days ?? 0, repeatInterval.Hours ?? 0, repeatInterval.Cycles ?? 0, repeatInterval.ToStrings(), lastComplianceDate, lastCompliance.Hours ?? 0, lastCompliance.Cycles ?? 0, lastCompliance.ToStrings(), sinceNewThreshold.Days ?? 0, firstCompliance.Days ?? 0, lastCompliance.Days ?? 0, nextComplianceDate, nextCompliance.Hours ?? 0, nextCompliance.Cycles ?? 0, nextCompliance.ToStrings(), remain.Days != null ? remain.Days.ToString() : "", remain.Hours ?? 0, remain.Cycles ?? 0, remain.ToStrings(), condition, detailDirective.ManHours, nextCompliance.Days ?? 0, kits, equipment, detail.ATAChapter.ShortName, detail.ATAChapter.FullName, "", sb, eo != "" ?'(' + eo + ')' : "", "", ""); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddBaseDetailToDataset(DirectivesListDataSet destinationDataSet) { if (_reportedComponent == null) { return; } BaseComponent baseComponent = null; Aircraft parentAircaft; DateTime installationDate; string position; Lifelength reportAircraftLifeLenght; parentAircaft = GlobalObjects.AircraftsCore.GetAircraftById(_reportedComponent.ParentAircraftId); var lastTransferRecord = _reportedComponent.TransferRecords.GetLast(); installationDate = lastTransferRecord.TransferDate; position = lastTransferRecord.Position; if (_reportedComponent.IsBaseComponent) { baseComponent = GlobalObjects.ComponentCore.GetBaseComponentById(_reportedComponent.ItemId); reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(baseComponent); } else { reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedComponent); } var manufactureDate = _reportedComponent.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var deliveryDate = _reportedComponent.DeliveryDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var status = _reportedComponent.ComponentStatus; var sinceNewHours = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0; var sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; var sinceNewDays = reportAircraftLifeLenght.Days != null?reportAircraftLifeLenght.Days.ToString() : ""; var lifeLimit = _reportedComponent.LifeLimit; var lifeLimitHours = lifeLimit.Hours != null && lifeLimit.Hours != 0 ? lifeLimit.Hours.ToString() : ""; var lifeLimitCycles = lifeLimit.Cycles != null && lifeLimit.Cycles != 0 ? lifeLimit.Cycles.ToString() : ""; var lifeLimitDays = lifeLimit.Days != null && lifeLimit.Days != 0 ? lifeLimit.Days.ToString() : ""; var remain = Lifelength.Null; if (!lifeLimit.IsNullOrZero()) { remain.Add(lifeLimit); remain.Substract(reportAircraftLifeLenght); remain.Resemble(lifeLimit); } var remainHours = remain.Hours != null && remain.Hours != 0 ? remain.Hours.ToString() : ""; var remainCycles = remain.Cycles != null && remain.Cycles != 0 ? remain.Cycles.ToString() : ""; var remainDays = remain.Days != null && remain.Days != 0 ? remain.Days.ToString() : ""; var onInstall = baseComponent?.ActualStateRecords.GetLastKnownRecord(lastTransferRecord.RecordDate)?.OnLifelength ?? Lifelength.Null;; var onInstallDate = installationDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var onInstallHours = onInstall.Hours != null && onInstall.Hours != 0 ? onInstall.Hours.ToString() : ""; var onInstallCycles = onInstall.Cycles != null && onInstall.Cycles != 0 ? onInstall.Cycles.ToString() : ""; var onInstallDays = onInstall.Days != null && onInstall.Days != 0 ? onInstall.Days.ToString() : ""; var sinceInstall = new Lifelength(reportAircraftLifeLenght); sinceInstall.Substract(onInstall); var sinceInstallHours = sinceInstall.Hours != null && sinceInstall.Hours != 0 ? sinceInstall.Hours.ToString() : ""; var sinceInstallCycles = sinceInstall.Cycles != null && sinceInstall.Cycles != 0 ? sinceInstall.Cycles.ToString() : ""; var sinceInstallDays = sinceInstall.Days != null && sinceInstall.Days != 0 ? sinceInstall.Days.ToString() : ""; var warranty = _reportedComponent.Warranty; var warrantyRemain = new Lifelength(warranty); warrantyRemain.Substract(reportAircraftLifeLenght); warrantyRemain.Resemble(warranty); var warrantyHours = warranty.Hours != null && warranty.Hours != 0 ? warranty.Hours.ToString() : ""; var warrantyCycles = warranty.Cycles != null && warranty.Cycles != 0 ? warranty.Cycles.ToString() : ""; var warrantyDays = warranty.Days != null && warranty.Days != 0 ? warranty.Days.ToString() : ""; var warrantyRemainHours = warrantyRemain.Hours != null && warrantyRemain.Hours != 0 ? warrantyRemain.Hours.ToString() : ""; var warrantyRemainCycles = warrantyRemain.Cycles != null && warrantyRemain.Cycles != 0 ? warrantyRemain.Cycles.ToString() : ""; var warrantyRemainDays = warrantyRemain.Days != null && warrantyRemain.Days != 0 ? warrantyRemain.Days.ToString() : ""; Lifelength aircraftOnInstall, aircraftCurrent = Lifelength.Null; var aircraftOnInstallHours = ""; var aircraftOnInstallCycles = ""; var aircraftOnInstallDays = ""; var aircraftCurrentHours = 0; var aircraftCurrentCycles = 0; var aircraftReNumString = ""; if (parentAircaft != null) { aircraftReNumString = _reportedComponent.GetParentAircraftRegNumber(); var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId); aircraftOnInstall = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, installationDate); aircraftOnInstallHours = aircraftOnInstall.Hours != null?aircraftOnInstall.Hours.ToString() : ""; aircraftOnInstallCycles = aircraftOnInstall.Cycles != null?aircraftOnInstall.Cycles.ToString() : ""; aircraftOnInstallDays = aircraftOnInstall.Days != null?aircraftOnInstall.Days.ToString() : ""; aircraftCurrent = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircaft); } Lifelength sinceOverhaul = Lifelength.Null; var lastOverhaulDate = DateTime.MinValue; var lastOverhaulDateString = ""; var model = ""; if (_reportedComponent.Model != null) { if (_reportedComponent.IsBaseComponent) { var bc = _reportedComponent as BaseComponent; if (bc.BaseComponentType == BaseComponentType.LandingGear || bc.BaseComponentType == BaseComponentType.Engine) { model = _reportedComponent.Model.FullName; } else { model = _reportedComponent.Model.FullName; } } else { model = _reportedComponent.Model.FullName; } } #region поиск последнего ремонта и расчет времени, прошедшего с него //поиск директив деталей var directives = new List <ComponentDirective>(_reportedComponent.ComponentDirectives.ToArray()); //поиск директивы ремонта var overhauls = directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList(); //поиск последнего ремонта ComponentDirective lastOverhaul = null; foreach (var d in overhauls) { if (d.LastPerformance == null || d.LastPerformance.RecordDate <= lastOverhaulDate) { continue; } lastOverhaulDate = d.LastPerformance.RecordDate; lastOverhaul = d; } if (lastOverhaul != null) { sinceOverhaul.Add(reportAircraftLifeLenght); sinceOverhaul.Substract(lastOverhaul.LastPerformance.OnLifelength); lastOverhaulDateString = lastOverhaul.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); } #endregion destinationDataSet.BaseDetailTable.AddBaseDetailTableRow(_reportedComponent.ATAChapter.ToString(), _reportedComponent.AvionicsInventory.ToString(), _reportedComponent.PartNumber, _reportedComponent.SerialNumber, model, _reportedComponent.Model?.Description, aircraftReNumString, position, _reportedComponent.Manufacturer, manufactureDate, deliveryDate, _reportedComponent.MPDItem, _reportedComponent.Suppliers != null ? _reportedComponent.Suppliers.ToString() : "", status.ToString(), _reportedComponent.Cost, _reportedComponent.CostOverhaul, _reportedComponent.CostServiceable, lifeLimitHours, lifeLimitCycles, lifeLimitDays, sinceNewHours, sinceNewCycles, sinceNewDays, remainCycles, remainHours, remainDays, onInstallDate, onInstallHours, onInstallCycles, onInstallDays, sinceInstallHours, sinceInstallCycles, sinceInstallDays, warrantyHours, warrantyCycles, warrantyDays, warrantyRemainHours, warrantyRemainCycles, warrantyRemainDays, aircraftOnInstallHours, aircraftOnInstallCycles, aircraftOnInstallDays, lastOverhaulDateString, sinceOverhaul.Hours ?? 0, sinceOverhaul.Cycles ?? 0); int averageUtilizationHours; int averageUtilizationCycles; string averageUtilizationType; if (_forecastData == null) { var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId); var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); averageUtilizationHours = parentAircaft != null?(int)averageUtilization.Hours:0; averageUtilizationCycles = parentAircaft != null?(int)averageUtilization.Cycles:0; averageUtilizationType = parentAircaft != null? averageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month" : ""; } else { averageUtilizationHours = (int)_forecastData.AverageUtilization.Hours; averageUtilizationCycles = (int)_forecastData.AverageUtilization.Cycles; averageUtilizationType = _forecastData.AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } destinationDataSet.AircraftDataTable.AddAircraftDataTableRow("", manufactureDate, aircraftCurrent.ToHoursMinutesFormat(""), aircraftCurrent.Cycles != null && aircraftCurrent.Cycles != 0 ? aircraftCurrent.Cycles.ToString() : "", "", "", "", "", averageUtilizationHours, averageUtilizationCycles, averageUtilizationType); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedComponentобавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(Component reportedComponent, LandingGearStatusDataSet destinationDataSet) { Lifelength total = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(reportedComponent); string domTtsnTcsn = SmartCore.Auxiliary.Convert.GetDateFormat(reportedComponent.ManufactureDate, "/"); if (domTtsnTcsn != "") { domTtsnTcsn += "\n"; } domTtsnTcsn += total.ToHoursMinutesAndCyclesStrings("FH", "FC"); string position = reportedComponent.Position; string pos = ""; string dwgItem = ""; string pattern = @"\d+"; Regex r = new Regex(pattern); Match m = r.Match(position); if (m.Success) { pos = position.Substring(0, m.Index); dwgItem = position.Substring(m.Index); } ComponentRecordType workType = ComponentRecordType.Unknown; ComponentDirective overhaul = reportedComponent.ComponentDirectives.FirstOrDefault(dd => dd.DirectiveType == ComponentRecordType.Overhaul); Lifelength interval = Lifelength.Null; Lifelength used = Lifelength.Null; Lifelength remain = Lifelength.Null; string lastPerformanceDateString = ""; string lastPerformanceHours = ""; string lastPerformanceCycles = ""; if (overhaul != null) { if (overhaul.LastPerformance != null) { DirectiveRecord lastPerformance = overhaul.LastPerformance; interval = overhaul.Threshold.RepeatInterval; lastPerformanceDateString = SmartCore.Auxiliary.Convert.GetDateFormat(lastPerformance.RecordDate, "/"); lastPerformanceHours = lastPerformance.OnLifelength.ToHoursMinutesFormat("FH"); lastPerformanceCycles = lastPerformance.OnLifelength.Cycles != null && lastPerformance.OnLifelength.Cycles != 0 ? lastPerformance.OnLifelength.Cycles.ToString() : ""; used = total - lastPerformance.OnLifelength; used.Resemble(interval); } else { interval = overhaul.Threshold.FirstPerformanceSinceNew; used = new Lifelength(total); used.Resemble(interval); } workType = overhaul.DirectiveType; remain = new Lifelength(overhaul.Remains); } destinationDataSet.ItemsTable.AddItemsTableRow( dwgItem, reportedComponent.ATAChapter.ToString(), reportedComponent.PartNumber, reportedComponent.SerialNumber, pos, reportedComponent.Description, reportedComponent.MaintenanceControlProcess.ToString(), SmartCore.Auxiliary.Convert.GetDateFormat(reportedComponent.TransferRecords.GetLast().TransferDate, "/"), reportedComponent.LifeLimit.ToHoursMinutesAndCyclesStrings("FH", "FC"), total.ToHoursMinutesAndCyclesStrings("FH", "FC"), reportedComponent.Remains.ToHoursMinutesAndCyclesStrings("FH", "FC"), workType.ToString(), interval.ToHoursMinutesAndCyclesStrings("FH", "FC"), lastPerformanceDateString, lastPerformanceHours, lastPerformanceCycles, used.Days != null ? used.Days.ToString() : "", used.Hours != null ? used.Hours.ToString() : "", used.Cycles != null ? used.Cycles.ToString(): "", used.ToHoursMinutesAndCyclesStrings("FH", "FC"), "", "", "", remain.ToHoursMinutesAndCyclesStrings("FH", "FC"), reportedComponent.Condition.ToString(), reportedComponent.ManHours, reportedComponent.Cost, reportedComponent.Kits.ToString(), "", reportedComponent.Remarks, reportedComponent.Status.ToString(), domTtsnTcsn); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> protected virtual void AddDirectiveToDataset(MaintenanceDirective reportedDirective, MaintenanceDirectivesDataSetLatAvia destinationDataSet) { if (reportedDirective == null) { return; } string status = ""; Lifelength remain = Lifelength.Null; Lifelength used = Lifelength.Null; //string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; string remarks = reportedDirective.Remarks; string directiveType = reportedDirective.WorkType.ToString(); double cost = reportedDirective.Cost; double mh = reportedDirective.ManHours; if (reportedDirective.Status == DirectiveStatus.Closed) { status = "C"; } if (reportedDirective.Status == DirectiveStatus.Open) { status = "O"; } if (reportedDirective.Status == DirectiveStatus.Repetative) { status = "R"; } if (reportedDirective.Status == DirectiveStatus.NotApplicable) { status = "N/A"; } string effectivityDate = UsefulMethods.NormalizeDate(reportedDirective.Threshold.EffectiveDate); string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва string firstPerformanceString = reportedDirective.Threshold.FirstPerformanceSinceNew.ToString(); if (reportedDirective.LastPerformance != null) { used.Add(_current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (!reportedDirective.Threshold.RepeatInterval.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.RepeatInterval); } else if (!reportedDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { used.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Threshold.RepeatInterval); } } destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.TaskCardNumber, reportedDirective.TaskNumberCheck, reportedDirective.Description, firstPerformanceString, reportedDirective.ParentComponentDirective?.RepeatInterval != null ? reportedDirective.ParentComponentDirective?.RepeatInterval.Hours?.ToString() : "*", reportedDirective.ParentComponentDirective?.RepeatInterval != null ? reportedDirective.ParentComponentDirective?.RepeatInterval.Cycles?.ToString() : "*", reportedDirective.ParentComponentDirective?.RepeatInterval != null ? reportedDirective.ParentComponentDirective?.RepeatInterval.Days?.ToString() : "*", reportedDirective.ParentComponentDirective?.LastPerformance != null ? reportedDirective.ParentComponentDirective?.LastPerformance.OnLifelength.Hours?.ToString() : "*", reportedDirective.ParentComponentDirective?.LastPerformance != null ? reportedDirective.ParentComponentDirective?.LastPerformance.OnLifelength.Cycles?.ToString() : "*", reportedDirective.ParentComponentDirective?.LastPerformance != null ? reportedDirective.ParentComponentDirective?.LastPerformance.RecordDate.ToString("dd.MM.yyyy") : "*", reportedDirective.ParentComponentDirective?.NextPerformance != null ? reportedDirective.ParentComponentDirective?.NextPerformance.PerformanceSource.Hours.ToString() : "*", reportedDirective.ParentComponentDirective?.NextPerformance != null ? reportedDirective.ParentComponentDirective?.NextPerformance.PerformanceSource.Cycles.ToString() : "*", reportedDirective.ParentComponentDirective?.NextPerformance != null ? reportedDirective.ParentComponentDirective?.NextPerformance.PerformanceDate.Value.ToString("dd.MM.yyyy") : "*", reportedDirective.ParentComponentDirective?.Remains != null ? reportedDirective.ParentComponentDirective?.Remains.Hours.ToString() : "*", reportedDirective.ParentComponentDirective?.Remains != null ? reportedDirective.ParentComponentDirective?.Remains.Cycles.ToString() : "*", reportedDirective.ParentComponentDirective?.Remains != null ? reportedDirective.ParentComponentDirective?.Remains.Days.ToString() : "*", reportedDirective.CompnentSN, reportedDirective.CompnentPN ); }
/// <summary> /// Заполняет краткую информацию о директиве /// </summary> public void UpdateInformation() { if (_currentComponent == null) { return; } if (_detailDirectivesPerformances == null) { _detailDirectivesPerformances = new List <ComponentSummaryCompliancePerformanceControl>(); } else { _detailDirectivesPerformances.Clear(); } //очищение плавающей панели и списка контролов отображения директив деталей flowLayoutPanel_Compliance.Controls.Clear(); if (_currentComponent is BaseComponent) { BaseComponent inspectedBaseComponent = (BaseComponent)_currentComponent; var lastTransferRecord = inspectedBaseComponent.TransferRecords.GetLast(); string baseDetailTypeString = inspectedBaseComponent.BaseComponentType.ToString(); labelCompntTCSN.Text = baseDetailTypeString + " Total:"; labelCompntInstallDate.Text = baseDetailTypeString + " install date:"; labelCompntTCSNonInstall.Text = baseDetailTypeString + " on Install:"; labelCompntTCSNsinceInstall.Text = baseDetailTypeString + " since Install:"; labelMPDItemValue.Text = inspectedBaseComponent.MPDItem; labelDescriptionValue.Text = inspectedBaseComponent.Model != null ? inspectedBaseComponent.Model.Description : inspectedBaseComponent.Description; labelRemarksValue.Text = inspectedBaseComponent.Remarks; labelHiddenRemarksValue.Text = inspectedBaseComponent.HiddenRemarks; labelPartNumberValue.Text = inspectedBaseComponent.PartNumber; labelSerialNumberValue.Text = inspectedBaseComponent.SerialNumber; labelPositionValue.Text = lastTransferRecord.Position; //позиция задается только для базовых деталей labelManufacturerValue.Text = inspectedBaseComponent.Manufacturer; labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.ManufactureDate); labelDeliveryDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.DeliveryDate); labelModelValue.Text = inspectedBaseComponent.Model != null?inspectedBaseComponent.Model.ToString() : ""; labelSupplierValue.Text = inspectedBaseComponent.Suppliers.ToString(); labelMaintFreqValue.Text = inspectedBaseComponent.MaintenanceControlProcess.ToString(); labelCostNewValue.Text = inspectedBaseComponent.Cost.ToString(); labelCostServiceableValue.Text = inspectedBaseComponent.CostServiceable.ToString(); labelCostOverhaulValue.Text = inspectedBaseComponent.CostOverhaul.ToString(); labelWarrantyValue.Text = inspectedBaseComponent.Warranty.ToString(); labelClassValue.Text = inspectedBaseComponent.Model != null?inspectedBaseComponent.Model.GoodsClass.ToString() : inspectedBaseComponent.GoodsClass != null?inspectedBaseComponent.GoodsClass.ToString() : ""; labelATAChapterValue.Text = inspectedBaseComponent.ATAChapter.ToString(); if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.None) { labelAvionicsInventoryValue.Text = "None"; } if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Optional) { labelAvionicsInventoryValue.Text = "Optional"; } if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Required) { labelAvionicsInventoryValue.Text = "Required"; } if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Unknown) { labelAvionicsInventoryValue.Text = "Unknown"; } labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(lastTransferRecord.TransferDate); Lifelength temp, temp2; //Наработка компонента на сегодня temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedBaseComponent); labelCompntTCSNValue.Text = temp.ToString(); //Остаток жизненного времени на сегодня temp2 = new Lifelength(inspectedBaseComponent.LifeLimit); temp2.Substract(temp); temp2.Resemble(inspectedBaseComponent.LifeLimit); if (inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine) { Component firstLimitter = _baseComponentComponents != null && _baseComponentComponents.Count > 0 ? _baseComponentComponents.Where(d => d.NextPerformanceDate != null) .OrderBy(d => d.NextPerformanceDate) .FirstOrDefault() : null; labelCompntLifeLimit.Text = baseDetailTypeString + " Life Limit / First Limit"; labelCompntLifeLimitValue.Text = ((inspectedBaseComponent.LifeLimit.IsNullOrZero() ? "N/A" : inspectedBaseComponent.LifeLimit.ToString()) + " / " + (firstLimitter == null || firstLimitter.LifeLimit.IsNullOrZero() ? "N/A" : firstLimitter.LifeLimit.ToString())); labelCompntLifeLimitRemains.Text = baseDetailTypeString + " Life Limit Remain / First Remains"; labelCompntLifeLimitRemainsValue.Text = ((inspectedBaseComponent.Remains.IsNullOrZero() ? "N/A" : inspectedBaseComponent.Remains.ToString()) + " / " + (firstLimitter == null || firstLimitter.Remains.IsNullOrZero() ? "N/A" : firstLimitter.Remains.ToString())); } else { labelCompntLifeLimit.Text = baseDetailTypeString + " Life Limit"; labelCompntLifeLimitValue.Text = inspectedBaseComponent.LifeLimit.ToString(); labelCompntLifeLimitRemains.Text = baseDetailTypeString + " Life Limit Remain"; labelCompntLifeLimitRemainsValue.Text = temp2.ToString(); } //Наработка компонента на момент установки temp2 = inspectedBaseComponent.ActualStateRecords.GetLastKnownRecord(lastTransferRecord.RecordDate)?.OnLifelength ?? Lifelength.Null; labelCompntTCSNonInstallValue.Text = temp2.ToString(); //Наработка компонента с момента установки и по сей день temp.Substract(temp2); labelCompntTCSNsinceInstallValue.Text = temp.ToString(); var tcsnLifeLenght = Lifelength.Zero; var tcsnNonInstallLifeLenght = Lifelength.Zero; var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedBaseComponent.ParentAircraftId); //TODO:(Evgenii Babak) пересмотреть использование ParentAircrafId здесь if (parentAircraft != null) { tcsnLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft); var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId); //Наработка самолета на момент установки детали if (aircraftFrame != null) { tcsnNonInstallLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, lastTransferRecord.TransferDate); } } labelAircraftTCSNValue.Text = tcsnLifeLenght.ToString(); labelAircraftTCSNonInstallValue.Text = tcsnNonInstallLifeLenght.ToString(); } else { var inspectedDetail = _currentComponent; var lastTransferRecord = inspectedDetail.TransferRecords.GetLast(); labelMPDItemValue.Text = inspectedDetail.MPDItem; labelDescriptionValue.Text = inspectedDetail.Model != null ? inspectedDetail.Model.Description : inspectedDetail.Description; labelRemarksValue.Text = inspectedDetail.Remarks; labelHiddenRemarksValue.Text = inspectedDetail.HiddenRemarks; labelPartNumberValue.Text = inspectedDetail.PartNumber; labelSerialNumberValue.Text = inspectedDetail.SerialNumber; labelPositionValue.Text = lastTransferRecord.Position; labelManufacturerValue.Text = inspectedDetail.Manufacturer; labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedDetail.ManufactureDate); labelDeliveryDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedDetail.DeliveryDate); labelModelValue.Text = inspectedDetail.Model != null?inspectedDetail.Model.ToString() : ""; labelSupplierValue.Text = inspectedDetail.Suppliers.ToString(); labelMaintFreqValue.Text = inspectedDetail.MaintenanceControlProcess.ToString(); labelCostNewValue.Text = inspectedDetail.Cost.ToString(); labelCostServiceableValue.Text = inspectedDetail.CostServiceable.ToString(); labelCostOverhaulValue.Text = inspectedDetail.CostOverhaul.ToString(); labelWarrantyValue.Text = inspectedDetail.Warranty.ToString(); labelClassValue.Text = inspectedDetail.Model != null?inspectedDetail.Model.GoodsClass.ToString() : inspectedDetail.GoodsClass != null?inspectedDetail.GoodsClass.ToString() : ""; labelATAChapterValue.Text = inspectedDetail.ATAChapter.ToString(); if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.None) { labelAvionicsInventoryValue.Text = "None"; } if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Optional) { labelAvionicsInventoryValue.Text = "Optional"; } if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Required) { labelAvionicsInventoryValue.Text = "Required"; } if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Unknown) { labelAvionicsInventoryValue.Text = "Unknown"; } labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(lastTransferRecord.TransferDate); labelCompntLifeLimitValue.Text = inspectedDetail?.LifeLimit?.ToString(); var temp = Lifelength.Null; var temp2 = Lifelength.Null; //Наработка компонента на сегодня if (inspectedDetail.LLPMark && inspectedDetail.LLPCategories) { var selectedCategory = inspectedDetail.ChangeLLPCategoryRecords.GetLast()?.ToCategory; if (selectedCategory != null) { var data = inspectedDetail.LLPData.FirstOrDefault(i => i.ParentCategory == selectedCategory); temp = new Lifelength(data?.LLPCurrent); if (data?.Remain != null) { temp2 = data.Remain; } } } else { temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedDetail); } labelCompntTCSNValue.Text = temp.ToString(); //Остаток жизненного времени на сегодня //temp2 = new Lifelength(inspectedDetail.LifeLimit); //temp2.Substract(temp); //temp2.Resemble(inspectedDetail.LifeLimit); labelCompntLifeLimitRemainsValue.Text = temp2.ToString(); //Наработка компонента на момент установки var actualState = inspectedDetail.ActualStateRecords.GetLastKnownRecord(lastTransferRecord.RecordDate); if (actualState != null) { temp2 = actualState.OnLifelength; } else { temp2 = Lifelength.Null; } labelCompntTCSNonInstallValue.Text = temp2.ToString(); //Наработка компонента с момента установки и по сей день if (inspectedDetail.LLPMark && inspectedDetail.LLPCategories) { var selectedCategory = inspectedDetail.ChangeLLPCategoryRecords.GetLast()?.ToCategory; if (selectedCategory != null) { var data = inspectedDetail.LLPData.FirstOrDefault(i => i.ParentCategory.ItemId == selectedCategory.ItemId); temp.Substract(data?.LLPLifelengthCurrent); labelCompntTCSNsinceInstallValue.Text = temp.ToString(); } } else { temp.Substract(temp2); labelCompntTCSNsinceInstallValue.Text = temp.ToString(); } //TODO:(Evgenii Babak) пересмотреть использование ParentAircrafId здесь var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedDetail.ParentAircraftId); //Наработка самолета на сегодня temp = parentAircraft != null ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft) : Lifelength.Zero; labelAircraftTCSNValue.Text = temp.ToString(); //Наработка самолета на момент установки детали temp = parentAircraft != null ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId), lastTransferRecord.TransferDate) : Lifelength.Zero; labelAircraftTCSNonInstallValue.Text = temp.ToString(); } //Обновление таблиц выполнения директив //На каждую из директив детали создается отдельная таблица выполнения //После каждая таблица помещается в плавающую панель для отображения List <ComponentDirective> detailDirectives = new List <ComponentDirective>(((Component)_currentComponent).ComponentDirectives.ToArray()); for (int i = 0; i < detailDirectives.Count; i++) { ComponentSummaryCompliancePerformanceControl summaryCompliancePerformanceControl = new ComponentSummaryCompliancePerformanceControl(detailDirectives[i]); summaryCompliancePerformanceControl.UpdateInformation(); _detailDirectivesPerformances.Add(summaryCompliancePerformanceControl); flowLayoutPanel_Compliance.Controls.Add(summaryCompliancePerformanceControl); } }
///<summary> ///</summary> public void UpdateInformation() { if (_currentComponentDirective == null) { return; } if (_currentComponentDirective.ParentComponent != null && _currentComponentDirective.ParentComponent is BaseComponent) { BaseComponent inspectedBaseComponent = (BaseComponent)_currentComponentDirective.ParentComponent; string baseDetailTypeString = inspectedBaseComponent.BaseComponentType.ToString(); labelCompntTCSN.Text = baseDetailTypeString; } imageLinkLabelStatus.Text = _currentComponentDirective.DirectiveType.ToString(); labelFirstPerformanceValue.Text = "n/a"; if (_currentComponentDirective.Threshold.FirstPerformanceSinceNew != null && !_currentComponentDirective.Threshold.FirstPerformanceSinceNew.IsNullOrZero()) { labelFirstPerformanceValue.Text = "s/n: " + _currentComponentDirective.Threshold.FirstPerformanceSinceNew; } if (_currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate != null && !_currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { if (labelFirstPerformanceValue.Text != "n/a") { labelFirstPerformanceValue.Text += " or "; } else { labelFirstPerformanceValue.Text = ""; } labelFirstPerformanceValue.Text += "s/e.d: " + _currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate; } labelRptIntervalValue.Text = _currentComponentDirective.Threshold.RepeatInterval.ToString(); labelKitValue.Text = _currentComponentDirective.KitRequired; labelManHoursValue.Text = _currentComponentDirective.ManHours.ToString(); labelCostValue.Text = _currentComponentDirective.Cost.ToString(); labelRemarksValue.Text = _currentComponentDirective.Remarks; labelHiddenRemarksValue.Text = _currentComponentDirective.HiddenRemarks; labelWarrantyRemains.Text = _currentComponentDirective.Threshold.Warranty.ToString(); //GlobalObjects.PerformanceCalculator.GetNextPerformance(_currentComponentDirective); Lifelength temp; ComponentDirectiveThreshold threshold; Component tempComponent; var tempAircraft = GlobalObjects.AircraftsCore.GetAircraftById(_currentComponentDirective.ParentComponent.ParentAircraftId);//TODO:(Evgenii Babak) пересмотреть использование ParentAircrafId здесь labelCompntRemains.Text = ""; labelCompntSince.Text = ""; if (_currentComponentDirective.Remains != null && _currentComponentDirective.Condition != ConditionState.NotEstimated) { if (_currentComponentDirective.Remains.IsOverdue() && _currentComponentDirective.Condition == ConditionState.Overdue) { labelRemains.Text = "Overdue:"; imageLinkLabelStatus.Status = Statuses.NotSatisfactory; } else if (_currentComponentDirective.Condition == ConditionState.Notify) { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.Notify; } else if (_currentComponentDirective.Condition == ConditionState.Satisfactory) { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.Satisfactory; } else { labelRemains.Text = "Remains:"; imageLinkLabelStatus.Status = Statuses.NotActive; } labelCompntRemains.Text = _currentComponentDirective.Remains.ToString(); } labelDateLast.Text = ""; labelCompntTCSNLast.Text = ""; labelAircraftTCSNLast.Text = ""; labelDateNext.Text = "n/a"; labelCompntTCSNNext.Text = "n/a"; labelAircraftTCSNNext.Text = "n/a"; if (_currentComponentDirective.LastPerformance != null) { //Заполнение Last-ов //дата последнего выполнения labelDateLast.Text = SmartCore.Auxiliary.Convert.GetDateFormat(_currentComponentDirective.LastPerformance.RecordDate); Lifelength current; if (_currentComponentDirective.ParentComponent is BaseComponent) { current = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength((BaseComponent)_currentComponentDirective.ParentComponent); } else { current = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentComponentDirective.ParentComponent); } //наработка компонента на последнем исполнении temp = _currentComponentDirective.LastPerformance.OnLifelength; if (temp != Lifelength.Null) { labelCompntTCSNLast.Text = temp.ToString(); if (!current.IsNullOrZero()) { current.Substract(temp); labelCompntSince.Text = current.ToString(); } } temp = tempAircraft != null && _currentComponentDirective.ParentComponent.TransferRecords.GetLast().TransferDate < _currentComponentDirective.LastPerformance.RecordDate ? _currentComponentDirective.LastPerformance.OnLifelength : Lifelength.Null; // if (temp != Lifelength.Null) // labelAircraftTCSNLast.Text = temp.ToString(); //наработка самолета на последнем исполнении labelAircraftTCSNLast.Text = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(tempAircraft, _currentComponentDirective.LastPerformance.RecordDate).ToString(); //Заполнение Next-ов threshold = _currentComponentDirective.Threshold; if (threshold.RepeatInterval != null && !threshold.RepeatInterval.IsNullOrZero()) { //наработка компонента на следующее исполнение //var nextComponentTsnCsn = new Lifelength(_currentComponentDirective.LastPerformance.OnLifelength); //nextComponentTsnCsn.Add(threshold.RepeatInterval); //nextComponentTsnCsn.Resemble(threshold.RepeatInterval); //labelCompntTCSNNext.Text = nextComponentTsnCsn.ToString(); labelCompntTCSNNext.Text = _currentComponentDirective.NextPerformance.PerformanceSource.ToString(); if (_currentComponentDirective.NextPerformanceDate.HasValue) { labelDateNext.Text = SmartCore.Auxiliary.Convert.GetDateFormat(_currentComponentDirective.NextPerformanceDate.Value); } //наработка самолета на следующее исполнение //Могут вводится записи, которые были сделаны на агрегате еще //до появления этого агрегате в системе. в данном случае надо проверять //не является ли наработка на след.выполнение меньше той наработки //при которой был установлен агрегат var asr = _currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst(); //if (asr != null && tempAircraft != null && // threshold.FirstPerformanceSinceNew.IsGreaterNullable(_currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst().OnLifelength)) //{ //наработка на след выполнение больше той, что была при установке агрегата temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(tempAircraft); //temp.Add(remains); temp.Add(_currentComponentDirective.Remains); temp.Resemble(threshold.RepeatInterval); labelAircraftTCSNNext.Text = temp.ToString(); //} //else //{ // labelAircraftTCSNNext.Text = ""; //} } } else { //последнего исполнения не было //расчет ведется по FirstPerformance //Заполнение Next-ов threshold = _currentComponentDirective.Threshold; tempComponent = _currentComponentDirective.ParentComponent; if (threshold.FirstPerformanceSinceNew != null && !threshold.FirstPerformanceSinceNew.IsNullOrZero()) { if (_currentComponentDirective.NextPerformanceDate.HasValue) { labelDateNext.Text = SmartCore.Auxiliary.Convert.GetDateFormat(_currentComponentDirective.NextPerformanceDate.Value); } //наработка компонента на следующее исполнение //labelCompntTCSNNext.Text = threshold.FirstPerformanceSinceNew.ToString(); labelCompntTCSNNext.Text = _currentComponentDirective.NextPerformance.PerformanceSource.ToString(); //наработка самолета на следующее исполнение //наработка = наработка самолета на сегодня + остаток до первого исполнения //ActualStateRecord asr = _currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst(); //if (asr != null && tempAircraft != null && // threshold.FirstPerformanceSinceNew.IsGreaterNullable(_currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst().OnLifelength)) //{ //наработка на след выполнение больше той, что была при установке агрегата temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(tempAircraft); //temp.Add(remains); temp.Add(_currentComponentDirective.Remains); temp.Resemble(threshold.FirstPerformanceSinceNew); labelAircraftTCSNNext.Text = temp.ToString(); //else // labelAircraftTCSNNext.Text = ""; } else if (threshold.FirstPerformanceSinceEffectiveDate != null && !threshold.FirstPerformanceSinceEffectiveDate.IsNullOrZero()) { //дата Следующего исполнения if (threshold.FirstPerformanceSinceEffectiveDate.Days != null) { //если в первом выполнении заданы дни //то выводится точная дата следующего выполнения //дата = дата_производства + первое_исполнение.дни labelDateNext.Text = SmartCore.Auxiliary.Convert.GetDateFormat( threshold.EffectiveDate.AddDays((double)threshold.FirstPerformanceSinceEffectiveDate.Days)); }//иначе, точную дату выполнения расчитать нельзя //наработка компонента на следующее исполнение //Определение наработки if (threshold.EffectiveDate < DateTime.Today) { Lifelength sinceEffDate = _currentComponentDirective.ParentComponent is BaseComponent ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay((BaseComponent)_currentComponentDirective.ParentComponent, _currentComponentDirective.Threshold.EffectiveDate) : GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(_currentComponentDirective.ParentComponent, _currentComponentDirective.Threshold.EffectiveDate); sinceEffDate.Add(_currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDate.Resemble(_currentComponentDirective.Threshold.FirstPerformanceSinceEffectiveDate); if (labelCompntTCSNNext.Text != "n/a") { labelCompntTCSNNext.Text += " or "; } else { labelCompntTCSNNext.Text = ""; } labelCompntTCSNNext.Text += "s/e.d: " + sinceEffDate; } //наработка самолета на следующее исполнение //наработка = наработка самолета на сегодня + остаток до первого исполнения ActualStateRecord asr = _currentComponentDirective.ParentComponent.ActualStateRecords.GetFirst(); //if (asr != null && tempAircraft != null && // threshold.FirstPerformanceSinceEffectiveDate.IsGreaterNullable(asr.OnLifelength)) //{ //наработка на след выполнение больше той, что была при установке агрегата temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(tempAircraft); //temp.Add(remains); temp.Add(_currentComponentDirective.Remains); temp.Resemble(threshold.FirstPerformanceSinceNew); labelAircraftTCSNNext.Text = temp.ToString(); //} //else // labelAircraftTCSNNext.Text = ""; } } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddBaseDetailToDataset(DirectivesListDataSet destinationDataSet) { if (_reportedAircraft != null) { return; } var parentAircaft = GlobalObjects.AircraftsCore.GetAircraftById(_reportedBaseComponent.ParentAircraftId); var parentStore = GlobalObjects.StoreCore.GetStoreById(_reportedBaseComponent.ParentStoreId); var reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent); var regNumber = _reportedBaseComponent.GetParentAircraftRegNumber(); var location = !string.IsNullOrEmpty(regNumber) ? regNumber : parentStore != null ? parentStore.Name : ""; var manufactureDate = _reportedBaseComponent.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var deliveryDate = _reportedBaseComponent.DeliveryDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var status = _reportedBaseComponent.Serviceable ? "Serviceable" : "Unserviceable"; var sinceNewHours = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0; var sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; var sinceNewDays = reportAircraftLifeLenght.Days != null?reportAircraftLifeLenght.Days.ToString() : ""; var lifeLimit = _reportedBaseComponent.LifeLimit; var lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : ""; var lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : ""; var lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : ""; var remain = new Lifelength(lifeLimit); remain.Substract(reportAircraftLifeLenght); var remainHours = remain.Hours != null?remain.Hours.ToString() : ""; var remainCycles = remain.Cycles != null?remain.Cycles.ToString() : ""; var remainDays = remain.Days != null?remain.Days.ToString() : ""; var lastTransferRecord = _reportedBaseComponent.TransferRecords.GetLast(); var installationDate = lastTransferRecord.TransferDate; var onInstall = lastTransferRecord.OnLifelength; var onInstallDate = installationDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var onInstallHours = onInstall.Hours != null?onInstall.Hours.ToString() : ""; var onInstallCycles = onInstall.Cycles != null?onInstall.Cycles.ToString() : ""; var onInstallDays = onInstall.Days != null?onInstall.Days.ToString() : ""; var sinceInstall = new Lifelength(reportAircraftLifeLenght); sinceInstall.Substract(onInstall); var sinceInstallHours = sinceInstall.Hours != null?sinceInstall.Hours.ToString() : ""; var sinceInstallCycles = sinceInstall.Cycles != null?sinceInstall.Cycles.ToString() : ""; var sinceInstallDays = sinceInstall.Days != null?sinceInstall.Days.ToString() : ""; var warranty = _reportedBaseComponent.Warranty; var warrantyRemain = new Lifelength(warranty); warrantyRemain.Substract(reportAircraftLifeLenght); warrantyRemain.Resemble(warranty); var warrantyHours = warranty.Hours != null?warranty.Hours.ToString() : ""; var warrantyCycles = warranty.Cycles != null?warranty.Cycles.ToString() : ""; var warrantyDays = warranty.Days != null?warranty.Days.ToString() : ""; var warrantyRemainHours = warrantyRemain.Hours != null?warrantyRemain.Hours.ToString() : ""; var warrantyRemainCycles = warrantyRemain.Cycles != null?warrantyRemain.Cycles.ToString() : ""; var warrantyRemainDays = warrantyRemain.Days != null?warrantyRemain.Days.ToString() : ""; var aircraftOnInstall = Lifelength.Null; var aircraftCurrent = Lifelength.Null; if (parentAircaft != null) { var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId); aircraftOnInstall = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, installationDate); aircraftCurrent = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircaft); } var aircraftOnInstallHours = aircraftOnInstall.Hours != null?aircraftOnInstall.Hours.ToString() : ""; var aircraftOnInstallCycles = aircraftOnInstall.Cycles != null?aircraftOnInstall.Cycles.ToString() : ""; var aircraftOnInstallDays = aircraftOnInstall.Days != null?aircraftOnInstall.Days.ToString() : ""; var aircraftCurrentHours = aircraftCurrent.Hours ?? 0; var aircraftCurrentCycles = aircraftCurrent.Cycles ?? 0; var sinceOverhaul = Lifelength.Null; var lastOverhaulDate = DateTime.MinValue; var lastOverhaulDateString = ""; #region поиск последнего ремонта и расчет времени, прошедшего с него //поиск директив деталей var directives = GlobalObjects.ComponentCore.GetComponentDirectives(_reportedBaseComponent, true); //поиск директивы ремонта var overhauls = directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList(); //поиск последнего ремонта ComponentDirective lastOverhaul = null; foreach (var d in overhauls) { if (d.LastPerformance == null || d.LastPerformance.RecordDate <= lastOverhaulDate) { continue; } lastOverhaulDate = d.LastPerformance.RecordDate; lastOverhaul = d; } if (lastOverhaul != null) { sinceOverhaul.Add(reportAircraftLifeLenght); sinceOverhaul.Substract(lastOverhaul.LastPerformance.OnLifelength); lastOverhaulDateString = lastOverhaul.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); } #endregion destinationDataSet.BaseDetailTable.AddBaseDetailTableRow(_reportedBaseComponent.ATAChapter.ToString(), _reportedBaseComponent.AvionicsInventory.ToString(), _reportedBaseComponent.PartNumber, _reportedBaseComponent.SerialNumber, _reportedBaseComponent.Model != null ? _reportedBaseComponent.Model.ToString() : "", _reportedBaseComponent.BaseComponentType.ToString(), location, lastTransferRecord.Position, _reportedBaseComponent.Manufacturer, manufactureDate, deliveryDate, _reportedBaseComponent.MPDItem, _reportedBaseComponent.Suppliers != null ? _reportedBaseComponent.Suppliers.ToString() : "", status, _reportedBaseComponent.Cost, _reportedBaseComponent.CostOverhaul, _reportedBaseComponent.CostServiceable, lifeLimitHours, lifeLimitCycles, lifeLimitDays, sinceNewHours, sinceNewCycles, sinceNewDays, remainCycles, remainHours, remainDays, onInstallDate, onInstallHours, onInstallCycles, onInstallDays, sinceInstallHours, sinceInstallCycles, sinceInstallDays, warrantyHours, warrantyCycles, warrantyDays, warrantyRemainHours, warrantyRemainCycles, warrantyRemainDays, aircraftOnInstallHours, aircraftOnInstallCycles, aircraftOnInstallDays, lastOverhaulDateString, sinceOverhaul.Hours ?? 0, sinceOverhaul.Cycles ?? 0); int averageUtilizationHours; int averageUtilizationCycles; string averageUtilizationType; if (_forecast == null) { var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId); var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); var au = parentAircaft != null ? averageUtilization : _reportedBaseComponent.AverageUtilization; averageUtilizationHours = (int)au.Hours; averageUtilizationCycles = (int)au.Cycles; averageUtilizationType = au.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } else { averageUtilizationHours = (int)_forecast.ForecastDatas[0].AverageUtilization.Hours; averageUtilizationCycles = (int)_forecast.ForecastDatas[0].AverageUtilization.Cycles; averageUtilizationType = _forecast.ForecastDatas[0].AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month"; } destinationDataSet.AircraftDataTable.AddAircraftDataTableRow("", manufactureDate, reportAircraftLifeLenght.ToHoursMinutesFormat(""), reportAircraftLifeLenght.Cycles != null && reportAircraftLifeLenght.Cycles != 0 ? reportAircraftLifeLenght.Cycles.ToString() : "", "", "", "", "", averageUtilizationHours, averageUtilizationCycles, averageUtilizationType); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddBaseDetailToDataset(AircraftGeneralDataDataSet destinationDataSet) { if (_reportedAircraft == null) { return; } var baseDetails = new List <BaseComponent>(GlobalObjects.ComponentCore.GetAicraftBaseComponents(_reportedAircraft.ItemId)); foreach (var baseDetail in baseDetails) { if (baseDetail.BaseComponentType == BaseComponentType.Frame) { continue; } var currentDetailSource = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(baseDetail); var status = baseDetail.Serviceable ? "Serviceable" : "Unserviceable"; var sinceNewHours = currentDetailSource.Hours != null?currentDetailSource.Hours.ToString() : ""; var sinceNewCycles = currentDetailSource.Cycles != null?currentDetailSource.Cycles.ToString() : ""; var sinceNewDays = currentDetailSource.Days != null?currentDetailSource.Days.ToString() : ""; var lifeLimit = baseDetail.LifeLimit; var lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : ""; var lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : ""; string lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : ""; var remain = Lifelength.Null; if (!lifeLimit.IsNullOrZero()) { remain = new Lifelength(lifeLimit); remain.Substract(currentDetailSource); remain.Resemble(lifeLimit); } var remainHours = remain.Hours != null?remain.Hours.ToString() : ""; var remainCycles = remain.Cycles != null?remain.Cycles.ToString() : ""; var remainDays = remain.Days != null?remain.Days.ToString() : ""; Lifelength betweenOverhaul = Lifelength.Null, lastCompliance = Lifelength.Null; DateTime lastOverhaulDate = DateTime.MinValue; string lastOverhaulDateString = "", lastOverhaulHours = "", lastOverhaulCycles = ""; string remainOverhaulDays = "", remainOverhaulHours = "", remainOverhaulCycles = ""; string type = ""; string registrationNumber = baseDetail.GetParentAircraftRegNumber(); if (baseDetail.BaseComponentType == BaseComponentType.LandingGear) { type = "Part C: Landing Gears"; } if (baseDetail.BaseComponentType == BaseComponentType.Propeller) { type = "Part B1: Propeller"; } if (baseDetail.BaseComponentType == BaseComponentType.Engine) { type = "Part B2: Engines"; } if (baseDetail.BaseComponentType == BaseComponentType.Apu) { type = "Part D: Auxiliary Power Unit "; } #region поиск последнего ремонта и расчет времени, прошедшего с него //поиск директив деталей List <ComponentDirective> directives = GlobalObjects.ComponentCore.GetComponentDirectives(baseDetail, true); //поиск директивы ремонта List <ComponentDirective> overhauls = directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList(); //поиск последнего ремонта if (overhauls.Count != 0) { var remains = Lifelength.Null; ComponentDirective lastOverhaul = null; foreach (ComponentDirective d in overhauls) { GlobalObjects.PerformanceCalculator.GetNextPerformance(d); remains = d.Remains; if (d.LastPerformance == null || d.LastPerformance.RecordDate <= lastOverhaulDate) { continue; } lastOverhaulDate = d.LastPerformance.RecordDate; lastOverhaul = d; } if (lastOverhaul != null) { betweenOverhaul = lastOverhaul.Threshold.RepeatInterval; lastOverhaulDateString = lastOverhaulDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastOverhaulHours = lastOverhaul.LastPerformance.OnLifelength.Hours != null ? lastOverhaul.LastPerformance.OnLifelength.Hours.ToString() : ""; lastOverhaulCycles = lastOverhaul.LastPerformance.OnLifelength.Cycles != null ? lastOverhaul.LastPerformance.OnLifelength.Cycles.ToString() : ""; GlobalObjects.PerformanceCalculator.GetNextPerformance(lastOverhaul); if (lastOverhaul.NextPerformanceDate != null) { remainOverhaulHours = lastOverhaul.Remains.Hours != null?lastOverhaul.Remains.Hours.ToString() : ""; remainOverhaulCycles = lastOverhaul.Remains.Cycles != null?lastOverhaul.Remains.Cycles.ToString() : ""; remainOverhaulDays = lastOverhaul.Remains.Days != null?lastOverhaul.Remains.Days.ToString() : ""; } } else { if (!remains.IsNullOrZero()) { remainOverhaulHours = remains.Hours != null?remains.Hours.ToString() : ""; remainOverhaulCycles = remains.Cycles != null?remains.Cycles.ToString() : ""; remainOverhaulDays = remains.Days != null?remains.Days.ToString() : ""; } betweenOverhaul = overhauls[0].Threshold.RepeatInterval; } } ComponentDirective lastPerformance = directives.Where(d => d.LastPerformance != null). OrderBy(d => d.LastPerformance.RecordDate).LastOrDefault(); if (lastPerformance != null) { lastCompliance.Add(currentDetailSource); lastCompliance.Substract(lastPerformance.LastPerformance.OnLifelength); } #endregion destinationDataSet.BaseDetailTable.AddBaseDetailTableRow(baseDetail.PartNumber, baseDetail.SerialNumber, baseDetail.Model != null ? baseDetail.Model.ToString() : "", type, registrationNumber, baseDetail.TransferRecords.GetLast().Position, status, lifeLimitHours, lifeLimitCycles, lifeLimitDays, sinceNewHours, sinceNewCycles, sinceNewDays, remainCycles, remainHours, remainDays, lastOverhaulDateString, lastOverhaulHours, lastOverhaulCycles, betweenOverhaul.Days != null ? betweenOverhaul.Days.ToString() : "", betweenOverhaul.Hours != null ? betweenOverhaul.Hours.ToString() : "", betweenOverhaul.Cycles != null ? betweenOverhaul.Hours.ToString() : "", remainOverhaulDays, remainOverhaulHours, remainOverhaulCycles, lastCompliance.Days != null ? lastCompliance.Days.ToString() : "", lastCompliance.Hours != null ? lastCompliance.Hours.ToString() : "", lastCompliance.Cycles != null ? lastCompliance.Hours.ToString() : ""); } }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(Directive reportedDirective, DirectivesListDataSet destinationDataSet) { string references = reportedDirective.Paragraph; string title; string eo; string sb; string s1 = reportedDirective.Title; if (!string.IsNullOrEmpty(reportedDirective.Paragraph.Trim())) { s1 += "\n§ " + reportedDirective.Paragraph; } if (_directiveType == DirectiveType.EngineeringOrders) { title = reportedDirective.EngineeringOrders; sb = s1; eo = reportedDirective.ServiceBulletinNo; } else if (_directiveType == DirectiveType.SB) { title = reportedDirective.ServiceBulletinNo; sb = s1; eo = reportedDirective.EngineeringOrders; } else { title = s1; eo = reportedDirective.EngineeringOrders; sb = reportedDirective.ServiceBulletinNo; } Lifelength sinceNewThreshold = Lifelength.Null, sinceEffDateThreshold = Lifelength.Null; Lifelength sinceEffDateCompliance = Lifelength.Null; Lifelength sinceNewRemain = Lifelength.Null, sinceEffDateRemain = Lifelength.Null; Lifelength firstCompliance = Lifelength.Null, lastCompliance = Lifelength.Null, repeatInterval = Lifelength.Null, remain = Lifelength.Null; string firstComplianceDate = "", lastComplianceDate = "", sinceNewComplianceDate = ""; Lifelength used = Lifelength.Null; string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; string performanceType = reportedDirective.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "W.O.F" : "W.O.L"; string effectivityDate = SmartCore.Auxiliary.Convert.GetDateFormat(reportedDirective.Threshold.EffectiveDate, "/"); string equipment = reportedDirective.NDTType.ShortName; string kits = ""; int num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //TODO:(Evgenii Babak) расчетом ресурсов должен заниматься калькулятор //расчет остатка с даты производства и с эффективной даты //расчет остатка от выполнения с даты производтсва if (reportedDirective.Threshold.FirstPerformanceSinceNew != null) { sinceNewThreshold = reportedDirective.Threshold.FirstPerformanceSinceNew; if (sinceNewThreshold.Days != null) { sinceNewComplianceDate = _manufactureDate.AddDays(sinceNewThreshold.Days.Value).ToString( new GlobalTermsProvider()["DateFormat"].ToString()); } if (reportedDirective.LastPerformance == null) { sinceNewRemain.Add(reportedDirective.Threshold.FirstPerformanceSinceNew); sinceNewRemain.Substract(_current); sinceNewRemain.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } } if (reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate != null) { sinceEffDateThreshold = reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate; if (reportedDirective.Threshold.EffectiveDate < DateTime.Today) { sinceEffDateCompliance = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnEndOfDay(_reportedBaseComponent, reportedDirective.Threshold.EffectiveDate); } sinceEffDateCompliance.Add(reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDateCompliance.Resemble(reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDateRemain.Add(reportedDirective.Remains); } GlobalObjects.PerformanceCalculator.GetNextPerformance(reportedDirective); if (reportedDirective.LastPerformance != null) { firstComplianceDate = reportedDirective.PerformanceRecords[0].RecordDate.ToString( new GlobalTermsProvider()["DateFormat"].ToString()); firstCompliance = reportedDirective.PerformanceRecords[0].OnLifelength; if (reportedDirective.Threshold.RepeatInterval != null) { repeatInterval = reportedDirective.Threshold.RepeatInterval; } lastComplianceDate = reportedDirective.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastCompliance = reportedDirective.LastPerformance.OnLifelength; used.Add(_current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (reportedDirective.NextPerformanceSource != null && !reportedDirective.NextPerformanceSource.IsNullOrZero()) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Threshold.RepeatInterval); } } var canadianTitle = ""; if (reportedDirective.Title.Contains('/')) { var res = reportedDirective.Title.Split('/'); canadianTitle = res[0]; title = res[1]; } else if (reportedDirective.Title.StartsWith("C")) { canadianTitle = reportedDirective.Title; title = ""; } else { canadianTitle = ""; title = reportedDirective.Title; } string nextComplianceDate = reportedDirective.NextPerformanceDate != null ? ((DateTime)reportedDirective.NextPerformanceDate).ToString(new GlobalTermsProvider()["DateFormat"].ToString()) : ""; Lifelength nextCompliance = reportedDirective.NextPerformanceSource; NextPerformance np = reportedDirective.NextPerformance; destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.Applicability, reportedDirective.Remarks, reportedDirective.HiddenRemarks, reportedDirective.Description, title, references, reportedDirective.WorkType.ToString(), reportedDirective.Status.FullName, effectivityDate, sinceNewThreshold.Hours ?? 0, sinceNewThreshold.Cycles ?? 0, sinceNewComplianceDate, performanceType, sinceNewRemain.Hours ?? 0, sinceNewRemain.Cycles ?? 0, sinceNewRemain.Days ?? 0, sinceEffDateThreshold.Hours ?? 0, sinceEffDateThreshold.Cycles ?? 0, sinceEffDateThreshold.Days != null ? sinceEffDateThreshold.Days.ToString() : "", performanceType, sinceEffDateRemain.Hours ?? 0, sinceEffDateRemain.Cycles ?? 0, sinceEffDateRemain.Days ?? 0, firstComplianceDate, firstCompliance.Hours ?? 0, firstCompliance.Cycles ?? 0, reportedDirective.Threshold.FirstPerformanceToStrings(), repeatInterval.Days ?? 0, repeatInterval.Hours ?? 0, repeatInterval.Cycles ?? 0, repeatInterval.ToStrings(), lastComplianceDate, lastCompliance.Hours ?? 0, lastCompliance.Cycles ?? 0, reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.ToStrings("/") : "", used.Days ?? 0, used.Hours ?? 0, used.Cycles ?? 0, nextComplianceDate, nextCompliance.Hours ?? 0, nextCompliance.Cycles ?? 0, np != null ? np.ToStrings("/") : "", remain.Days != null ? remain.Days.ToString() : "", remain.Hours ?? 0, remain.Cycles ?? 0, reportedDirective.Remains.ToStrings(), reportedDirective.Condition.ToString(), reportedDirective.Cost, reportedDirective.ManHours, kits, equipment, reportedDirective.ATAChapter != null ? reportedDirective.ATAChapter.ShortName : "", reportedDirective.ATAChapter != null ? reportedDirective.ATAChapter.FullName : "", reportedDirective.ADType == ADType.Airframe ? "AF" : "AP", sb, eo != "" ?'(' + eo + ')' : "", canadianTitle, reportedDirective.StcNo); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddBaseDetailToDataset(LLPDiskSheetDataSet destinationDataSet) { if (_reportedBaseComponent == null) { return; } var reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent); var manufactureDate = _reportedBaseComponent.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var deliveryDate = _reportedBaseComponent.DeliveryDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var status = _reportedBaseComponent.Serviceable ? "Serviceable" : "Unserviceable"; var sinceNewHours = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0; var sinceNewCycles = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0; var sinceNewDays = reportAircraftLifeLenght.Days != null?reportAircraftLifeLenght.Days.ToString() : ""; var lifeLimit = _reportedBaseComponent.LifeLimit; var lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : ""; var lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : ""; var lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : ""; var remain = new Lifelength(lifeLimit); remain.Substract(reportAircraftLifeLenght); var remainHours = remain.Hours != null?remain.Hours.ToString() : ""; var remainCycles = remain.Cycles != null?remain.Cycles.ToString() : ""; var remainDays = remain.Days != null?remain.Days.ToString() : ""; var installationDate = _reportedBaseComponent.TransferRecords.GetLast().TransferDate; //TODO:(Evgenii Babak) нужно брать наработку с записи о перемещении, а не пересчитывать заново var onInstall = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(_reportedBaseComponent, installationDate); var onInstallDate = installationDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var onInstallHours = onInstall.Hours != null?onInstall.Hours.ToString() : ""; var onInstallCycles = onInstall.Cycles != null?onInstall.Cycles.ToString() : ""; var onInstallDays = onInstall.Days != null?onInstall.Days.ToString() : ""; var sinceInstall = new Lifelength(reportAircraftLifeLenght); sinceInstall.Substract(onInstall); var sinceInstallHours = sinceInstall.Hours != null?sinceInstall.Hours.ToString() : ""; var sinceInstallCycles = sinceInstall.Cycles != null?sinceInstall.Cycles.ToString() : ""; var sinceInstallDays = sinceInstall.Days != null?sinceInstall.Days.ToString() : ""; var warranty = _reportedBaseComponent.Warranty; var warrantyRemain = new Lifelength(warranty); warrantyRemain.Substract(reportAircraftLifeLenght); warrantyRemain.Resemble(warranty); var warrantyHours = warranty.Hours != null?warranty.Hours.ToString() : ""; var warrantyCycles = warranty.Cycles != null?warranty.Cycles.ToString() : ""; var warrantyDays = warranty.Days != null?warranty.Days.ToString() : ""; var warrantyRemainHours = warrantyRemain.Hours != null?warrantyRemain.Hours.ToString() : ""; var warrantyRemainCycles = warrantyRemain.Cycles != null?warrantyRemain.Cycles.ToString() : ""; var warrantyRemainDays = warrantyRemain.Days != null?warrantyRemain.Days.ToString() : ""; var parentAircaft = GlobalObjects.AircraftsCore.GetAircraftById(_reportedBaseComponent.ParentAircraftId); var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId); var aircraftOnInstall = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, installationDate); var aircraftOnInstallHours = aircraftOnInstall.Hours != null?aircraftOnInstall.Hours.ToString() : ""; var aircraftOnInstallCycles = aircraftOnInstall.Cycles != null?aircraftOnInstall.Cycles.ToString() : ""; var aircraftOnInstallDays = aircraftOnInstall.Days != null?aircraftOnInstall.Days.ToString() : ""; var aircraftCurrent = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircaft); var sinceOverhaul = Lifelength.Null; var lastOverhaulDate = DateTime.MinValue; var lastOverhaulDateString = ""; #region поиск последнего ремонта и расчет времени, прошедшего с него //поиск директив деталей List <ComponentDirective> directives = GlobalObjects.ComponentCore.GetComponentDirectives(_reportedBaseComponent, true); //поиск директивы ремонта List <ComponentDirective> overhauls = directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList(); //поиск последнего ремонта ComponentDirective lastOverhaul = null; foreach (ComponentDirective d in directives) { if (d.LastPerformance == null || d.LastPerformance.RecordDate <= lastOverhaulDate) { continue; } lastOverhaulDate = d.LastPerformance.RecordDate; lastOverhaul = d; } if (lastOverhaul != null) { sinceOverhaul.Add(reportAircraftLifeLenght); sinceOverhaul.Substract(lastOverhaul.LastPerformance.OnLifelength); lastOverhaulDateString = lastOverhaul.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); } #endregion destinationDataSet.BaseDetailTable.AddBaseDetailTableRow(_reportedBaseComponent.ATAChapter.ToString(), _reportedBaseComponent.AvionicsInventory.ToString(), _reportedBaseComponent.PartNumber, _reportedBaseComponent.SerialNumber, _reportedBaseComponent.Model != null ? _reportedBaseComponent.Model.FullName : "", _reportedBaseComponent.BaseComponentType.ToString(), _reportedBaseComponent.GetParentAircraftRegNumber(), _reportedBaseComponent.TransferRecords.GetLast().Position, _reportedBaseComponent.Thrust, manufactureDate, deliveryDate, _reportedBaseComponent.MPDItem, _reportedBaseComponent.Suppliers != null ? _reportedBaseComponent.Suppliers.ToString() : "", status, _reportedBaseComponent.Cost, _reportedBaseComponent.CostOverhaul, _reportedBaseComponent.CostServiceable, lifeLimitHours, lifeLimitCycles, lifeLimitDays, sinceNewHours, sinceNewCycles, sinceNewDays, reportAircraftLifeLenght.ToStrings(), remainCycles, remainHours, remainDays, onInstallDate, onInstallHours, onInstallCycles, onInstallDays, sinceInstallHours, sinceInstallCycles, sinceInstallDays, warrantyHours, warrantyCycles, warrantyDays, warrantyRemainHours, warrantyRemainCycles, warrantyRemainDays, aircraftOnInstallHours, aircraftOnInstallCycles, aircraftOnInstallDays, lastOverhaulDateString, sinceOverhaul.Hours ?? 0, sinceOverhaul.Cycles ?? 0, sinceOverhaul.ToStrings()); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="reportedDirective">Добавлямая директива</param> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddDirectiveToDataset(Directive reportedDirective, DirectivesListDataSet destinationDataSet) { string title; string eo; string sb; if (_directiveType == DirectiveType.EngineeringOrders) { title = reportedDirective.EngineeringOrders; sb = reportedDirective.Title; eo = reportedDirective.ServiceBulletinNo; } else if (_directiveType == DirectiveType.SB) { title = reportedDirective.ServiceBulletinNo; sb = reportedDirective.Title; eo = reportedDirective.EngineeringOrders; } else { title = reportedDirective.Title; eo = reportedDirective.EngineeringOrders; sb = reportedDirective.ServiceBulletinNo; } string remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : reportedDirective.Remarks; var status = ""; if (reportedDirective.Status == DirectiveStatus.Closed || reportedDirective.Status == DirectiveStatus.Open || reportedDirective.Status == DirectiveStatus.Repetative || reportedDirective.Status == DirectiveStatus.NotApplicable) { status = reportedDirective.Status.ShortName; } var effectivityDate = UsefulMethods.NormalizeDate(reportedDirective.Threshold.EffectiveDate); var equipment = reportedDirective.NDTType.ShortName; var kits = ""; var num = 1; foreach (AccessoryRequired kit in reportedDirective.Kits) { kits += num + ": " + kit.PartNumber + "\n"; num++; } //расчет остатка с даты производства и с эффективной даты Lifelength sinceNewThreshold = Lifelength.Null, sinceEffDateThreshold = Lifelength.Null; var sinceEffDateCompliance = Lifelength.Null; Lifelength sinceNewRemain = Lifelength.Null, sinceEffDateRemain = Lifelength.Null; Lifelength firstCompliance = Lifelength.Null, lastCompliance = Lifelength.Null, repeatInterval = Lifelength.Null, remain = Lifelength.Null; string firstComplianceDate = "", lastComplianceDate = "", sinceNewComplianceDate = ""; var used = Lifelength.Null; //TODO:(Evgenii Babak) расчетом ресурсов должен заниматься калькулятор //расчет остатка от выполнения с даты производтсва if (reportedDirective.Threshold.FirstPerformanceSinceNew != null) { sinceNewThreshold = reportedDirective.Threshold.FirstPerformanceSinceNew; if (sinceNewThreshold.Days != null) { sinceNewComplianceDate = _manufactureDate.AddDays(sinceNewThreshold.Days.Value).ToString( new GlobalTermsProvider()["DateFormat"].ToString()); } if (reportedDirective.LastPerformance == null) { sinceNewRemain.Add(reportedDirective.Threshold.FirstPerformanceSinceNew); sinceNewRemain.Substract(_current); sinceNewRemain.Resemble(reportedDirective.Threshold.FirstPerformanceSinceNew); } } if (reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate != null) { sinceEffDateThreshold = reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate; if (reportedDirective.Threshold.EffectiveDate < DateTime.Today) { sinceEffDateCompliance = GlobalObjects.CasEnvironment.Calculator. GetFlightLifelengthOnEndOfDay(_reportedBaseComponent, reportedDirective.Threshold.EffectiveDate); } sinceEffDateCompliance.Add(reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate); sinceEffDateCompliance.Resemble(reportedDirective.Threshold.FirstPerformanceSinceEffectiveDate); if (reportedDirective.LastPerformance == null) { sinceEffDateRemain.Add(sinceEffDateCompliance); sinceEffDateRemain.Substract(_current); sinceEffDateRemain.Resemble(sinceEffDateCompliance); } } GlobalObjects.PerformanceCalculator.GetNextPerformance(reportedDirective); if (reportedDirective.LastPerformance != null) { firstComplianceDate = reportedDirective.PerformanceRecords[0].RecordDate.ToString( new GlobalTermsProvider()["DateFormat"].ToString()); firstCompliance = reportedDirective.PerformanceRecords[0].OnLifelength; if (reportedDirective.Threshold.RepeatInterval != null) { repeatInterval = reportedDirective.Threshold.RepeatInterval; } lastComplianceDate = reportedDirective.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastCompliance = reportedDirective.LastPerformance.OnLifelength; used.Add(_current); used.Substract(reportedDirective.LastPerformance.OnLifelength); if (reportedDirective.NextPerformanceSource != null) { remain.Add(reportedDirective.NextPerformanceSource); remain.Substract(_current); remain.Resemble(reportedDirective.Threshold.RepeatInterval); } } var nextComplianceDate = reportedDirective.NextPerformanceDate != null ? ((DateTime)reportedDirective.NextPerformanceDate).ToString( new GlobalTermsProvider()["DateFormat"].ToString()) : ""; var nextCompliance = reportedDirective.NextPerformanceSource; var condition = reportedDirective.Condition.ToString(); var ata = reportedDirective.ATAChapter; destinationDataSet.ItemsTable.AddItemsTableRow(reportedDirective.Applicability, remarks, reportedDirective.HiddenRemarks, reportedDirective.Description, title, reportedDirective.Paragraph, reportedDirective.WorkType.ToString(), status, effectivityDate, sinceNewThreshold.Hours ?? 0, sinceNewThreshold.Cycles ?? 0, sinceNewComplianceDate, reportedDirective.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "W.O.F" : "W.O.L", sinceNewRemain.Hours ?? 0, sinceNewRemain.Cycles ?? 0, sinceNewRemain.Days ?? 0, sinceEffDateThreshold.Hours ?? 0, sinceEffDateThreshold.Cycles ?? 0, sinceEffDateThreshold.Days != null ? sinceEffDateThreshold.Days.ToString() : "", reportedDirective.Threshold.FirstPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "W.O.F" : "W.O.L", sinceEffDateRemain.Hours ?? 0, sinceEffDateRemain.Cycles ?? 0, sinceEffDateRemain.Days ?? 0, firstComplianceDate, firstCompliance.Hours ?? 0, firstCompliance.Cycles ?? 0, firstCompliance.ToStrings(), repeatInterval.Days ?? 0, repeatInterval.Hours ?? 0, repeatInterval.Cycles ?? 0, repeatInterval.ToStrings(), lastComplianceDate, lastCompliance.Hours ?? 0, lastCompliance.Cycles ?? 0, lastCompliance.ToStrings(), used.Days ?? 0, used.Hours ?? 0, used.Cycles ?? 0, nextComplianceDate, nextCompliance.Hours ?? 0, nextCompliance.Cycles ?? 0, nextCompliance.ToStrings(), remain.Days != null ? remain.Days.ToString() : "", remain.Hours ?? 0, remain.Cycles ?? 0, remain.ToStrings(), condition, reportedDirective.ManHours, reportedDirective.Cost, kits, equipment, ata.ShortName, ata.FullName, reportedDirective.ADType == ADType.Airframe ? "AF" : "AP", sb, eo != "" ?'(' + eo + ')' : "", "", ""); }