private void RadioButtonDaylyClick(object sender, EventArgs e) { if (radioButtonDayly.Checked && numericUpDownHours.Value >= 24) { numericUpDownHours.Value = (decimal)23.9; } if (radioButtonMonthly.Checked && numericUpDownHours.Value >= 744) { numericUpDownHours.Value = (decimal)743.9; } AverageUtilization au = GetAverageUtilization(); if (au == null || _forecastDate <= DateTime.Today) { return; } if (_forecastDate <= DateTime.Today) { return; } //если дата прогноза выше сегодняшней, то сначала вычисляется //наработка на сегодняшний день, а к ней добавляется среднепрогнозируемая наработка //между сегодняшним днем и днем прогноза //наработка агрегата на сегодня Lifelength baseDetailLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentForecastData.BaseComponent); Lifelength average = AnalystHelper.GetUtilization(au, Calculator.GetDays(DateTime.Today, _forecastDate)); lifelengthViewerDifferentSource.Lifelength = average; baseDetailLifeLenght.Add(average); lifelengthViewer_ForecastResource.Lifelength = baseDetailLifeLenght; }
/// <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; } }
/* * Реализация */ #region private void Init(DateTime date, AverageUtilization average, Lifelength current) /// <summary> /// Инициализирует все поля /// </summary> /// <param name="date"></param> /// <param name="average"></param> /// <param name="current"></param> private void Init(DateTime date, AverageUtilization average, Lifelength current) { CurrentLifelength = new Lifelength(current); _forecastDate = date; AverageUtilization = average; ForecastLifelength = new Lifelength(current); ForecastLifelength.Add(AnalystHelper.GetUtilization(average, Calculator.GetDays(DateTime.Today, date))); IncludeNotifyes = false; Percents = 5; }
private void CalculateUtilizationByDate() { Lifelength baseDetailLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_frame); if (dateTimePickerForecastDate.Value <= DateTime.Today) { //если дата прогноза меньше сегодняшней, то выводиться зписанная наработка на эту дату lifelengthViewer_ForecastResource.Lifelength = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(_frame, dateTimePickerForecastDate.Value); Lifelength different = new Lifelength(lifelengthViewer_ForecastResource.Lifelength); different.Substract(baseDetailLifeLenght); lifelengthViewerDifferentSource.Lifelength = different; } else { //если дата прогноза выше сегодняшней, то сначала вычисляется //наработка на сегодняшний день, а к ней добавляется среднепрогнозируемая наработка //между сегодняшним днем и днем прогноза //если не задана сердняя утилизация, то прогноз строить нельзя AverageUtilization au = GetAverageUtilization(); if (au == null) { return; } Lifelength average; if (dateTimePickerForecastDate.Value.Date == DateTime.Today.Date) { average = AnalystHelper.GetUtilization(au, Calculator.GetDays(DateTime.Today, dateTimePickerForecastDate.Value)); } else { average = AnalystHelper.GetUtilizationNew(au, Calculator.GetDays(DateTime.Today, dateTimePickerForecastDate.Value)); } lifelengthViewerDifferentSource.Lifelength = average; baseDetailLifeLenght.Add(average); lifelengthViewer_ForecastResource.Lifelength = baseDetailLifeLenght; } }
/// <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> /// <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 } }
/// <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); }
private void SetWorkTimeGA(BaseComponent powerUnit, FlightRegime flightRegime) { if (powerUnit == null) { return; } List <PowerUnitTimeInRegimeControlItem> fcs = flowLayoutPanelMain.Controls .OfType <PowerUnitTimeInRegimeControlItem>() .Where(c => c.PowerUnit != null && c.PowerUnit.ItemId == powerUnit.ItemId && c.FlightRegime == flightRegime) .ToList(); int t = fcs.Sum(cr => cr.WorkTime); Lifelength baseDetailLifeLenghtInRegimeSinceLastOverhaul = null; Lifelength baseDetailLifeLenghtSinceLastOverhaul = null; Lifelength baseDetailOhInterval = null; Lifelength baseDetailLifeLenghtInRegimeSinceNew = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate, flightRegime); Lifelength baseDetailLifeLenghtSinceNew = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate); Lifelength baseDetailLifeLimit = powerUnit.LifeLimit; ComponentWorkInRegimeParams inRegimeParams = powerUnit.ComponentWorkParams.Where(p => p.FlightRegime == flightRegime).FirstOrDefault(); if (inRegimeParams != null && inRegimeParams.ResorceProvider == SmartCoreType.ComponentDirective && powerUnit.ComponentDirectives.GetItemById(inRegimeParams.ResorceProviderId) != null) { //в парамтрах работы требуется расчитать время работы в режиме с //последнего выполнения директивы ComponentDirective dd = powerUnit.ComponentDirectives.GetItemById(inRegimeParams.ResorceProviderId); if (dd.LastPerformance == null) { baseDetailOhInterval = dd.Threshold.FirstPerformanceSinceNew; //если последнего выполнения директивы нет, //то расчитывается полная работа агрегата в указанном режиме baseDetailLifeLenghtInRegimeSinceLastOverhaul = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate, flightRegime); baseDetailLifeLenghtSinceLastOverhaul = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate); } else { baseDetailOhInterval = dd.Threshold.RepeatInterval; //т.к. может просматриваться старый полет (н: месячной давности) //производится поиск последней записи о выполнении перед текущим полетов AbstractPerformanceRecord r = dd.PerformanceRecords.GetLastKnownRecord(_flightDate); if (r != null) { baseDetailLifeLenghtInRegimeSinceLastOverhaul = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthForPeriod(powerUnit, r.RecordDate, _flightDate.AddHours(-1), flightRegime); baseDetailLifeLenghtSinceLastOverhaul = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthForPeriod(powerUnit, r.RecordDate, _flightDate.AddHours(-1));//TODO:(Evgenii Babak) выяснить почему AddHours(-1) } } } if (Flight.AircraftId <= 0) { //извлечение всех полетов ВС var flights = GlobalObjects.AircraftFlightsCore.GetAircraftFlightsOnDate(Flight.AircraftId, _flightDate); //И поиск всех полетов, что были раньше текущего foreach (AircraftFlight aircraftFlight in flights) { //Если полет был раньше текущего, то его наработка добавляется //к рассчитываемым ресурсам базового агрегата if (aircraftFlight.FlightDate < _flightDate.Date.Add(_outTime.TimeOfDay)) { baseDetailLifeLenghtInRegimeSinceNew.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit, flightRegime)); baseDetailLifeLenghtSinceNew.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit)); if (baseDetailLifeLenghtInRegimeSinceLastOverhaul == null) { continue; } baseDetailLifeLenghtInRegimeSinceLastOverhaul.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit, flightRegime)); if (baseDetailLifeLenghtSinceLastOverhaul == null) { continue; } baseDetailLifeLenghtSinceLastOverhaul.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit)); } } } baseDetailLifeLenghtInRegimeSinceNew.Add(LifelengthSubResource.Minutes, t); if (baseDetailLifeLenghtInRegimeSinceLastOverhaul != null) { baseDetailLifeLenghtInRegimeSinceLastOverhaul.Add(LifelengthSubResource.Minutes, t); } double persentSN = 0, persentLifeLimit = 0, persentSLO = 0, persentOhInt = 0; int? resInRegimeSN = baseDetailLifeLenghtInRegimeSinceNew.GetSubresource(LifelengthSubResource.Minutes); int? resSN = baseDetailLifeLenghtSinceNew.GetSubresource(LifelengthSubResource.Minutes); int? resLl = baseDetailLifeLimit.GetSubresource(LifelengthSubResource.Minutes); if (resSN != null && resInRegimeSN != null && resSN > 0) { persentSN = Convert.ToDouble((double)resInRegimeSN * 100 / resSN); } if (resLl != null && resInRegimeSN != null && resLl > 0) { persentLifeLimit = Convert.ToDouble((double)resInRegimeSN * 100 / resLl); } if (baseDetailLifeLenghtInRegimeSinceLastOverhaul != null) { int?resInRegimeSLO = baseDetailLifeLenghtInRegimeSinceLastOverhaul.GetSubresource(LifelengthSubResource.Minutes); if (baseDetailLifeLenghtSinceLastOverhaul != null) { int?resSLO = baseDetailLifeLenghtSinceLastOverhaul.GetSubresource(LifelengthSubResource.Minutes); if (resSLO != null && resInRegimeSLO != null && resSLO > 0) { persentSLO = Convert.ToDouble((double)resInRegimeSLO * 100 / resSLO); } } if (baseDetailOhInterval != null) { int?resOhInt = baseDetailOhInterval.GetSubresource(LifelengthSubResource.Minutes); if (resOhInt != null && resInRegimeSLO != null && resOhInt > 0) { persentOhInt = Convert.ToDouble((double)resInRegimeSLO * 100 / resOhInt); } } } foreach (PowerUnitTimeInRegimeControlItem fc in fcs) { fc.WorkTimeGA = t; fc.WorkTimeSinceNew = baseDetailLifeLenghtInRegimeSinceNew; fc.WorkTimeSLO = baseDetailLifeLenghtInRegimeSinceLastOverhaul; fc.PersentSN = persentSN; fc.PersentLifeLimit = persentLifeLimit; fc.PersentSLO = persentSLO; fc.PersentOhInt = persentOhInt; } }
/// <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 + ')' : "", "", ""); }
/// <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(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="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); }
protected override void AddFlight(MonthlyUtilizationDataSet dataSet, AircraftFlight item, string groupName, int counter) { string dateString = SmartCore.Auxiliary.Convert.GetDateFormat(item.FlightDate); Lifelength perDays = Lifelength.Zero; List <AircraftFlight> flights = Flights.Where(f => f.FlightDate.Date.AddMinutes(f.TakeOffTime) <= item.FlightDate.Date.AddMinutes(item.TakeOffTime)).ToList(); foreach (AircraftFlight aircraftFlight in flights) { perDays.Add(aircraftFlight.FlightTimeLifelength); } Lifelength aircraftLifelenght = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(item); #region колонки для отображения наработок по двигателям и ВСУ Lifelength engine1 = Lifelength.Null; Lifelength engine2 = Lifelength.Null; Lifelength apu = Lifelength.Null; if (_engine1 != null) { engine1 = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(_engine1, item); } if (_engine2 != null) { engine2 = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(_engine2, item); } if (_apu != null) { apu = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthIncludingThisFlight(_apu, item); } #endregion string color = UsefulMethods.GetColorName(item); if (!item.Correct) { color = "White"; } dataSet.Items.AddItemsRow(dateString, item.FlightNumber.ToString(), item.StationFromId.ShortName, item.StationToId.ShortName, item.Reference, item.PageNo, UsefulMethods.TimeToString(new TimeSpan(0, 0, item.TakeOffTime, 0)), UsefulMethods.TimeToString(new TimeSpan(0, 0, item.LDGTime, 0)), "1", UsefulMethods.TimeToString(new TimeSpan(0, 0, item.FlightTimeTotalMinutes, 0)), perDays.ToHoursMinutesAndCyclesFormat("", ""), aircraftLifelenght.ToHoursMinutesFormat(""), aircraftLifelenght.Cycles != null ? aircraftLifelenght.Cycles.ToString() : "", groupName, counter.ToString(), engine1.ToHoursMinutesFormat(""), engine1.Cycles != null ? engine1.Cycles.ToString() : "", engine2.ToHoursMinutesFormat(""), engine2.Cycles != null ? engine2.Cycles.ToString() : "", apu.ToHoursMinutesFormat(""), apu.Cycles != null ? apu.Cycles.ToString() : "", color); }
/// <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 (_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="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="destinationDataSet">Таблица, в которую добавляется элемент</param> private void AddStatusToDataset(MaintenanceStatusDataSet destinationDataSet) { if (_reportedAircraft == null) { return; } MaintenanceCheckComplianceGroup lastComplianceGroup = _reportedDirectives.GetLastComplianceCheckGroup(_filterSelection, _reportedAircraft.ItemId); MaintenanceCheckGroupByType nextComplianceGroup = GlobalObjects.MaintenanceCheckCalculator.GetNextCheckComplianceGroup(_reportedDirectives, _filterSelection, _reportedAircraft); MaintenanceCheck minStepCheck = _reportedDirectives != null ? _reportedDirectives.GetMinStepCheck(_filterSelection) : null; Lifelength reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent); Lifelength minStep = minStepCheck != null ? minStepCheck.Interval : Lifelength.Null; Lifelength used = new Lifelength(reportAircraftLifeLenght); Lifelength remain = Lifelength.Null; string lastComplianceDate = "", lastComplianceHours = "", lastComplianceCycles = ""; string nextComplianceDate = "", nextComplianceHours = "", nextComplianceCycles = ""; string remarks = ""; if (lastComplianceGroup != null) { lastComplianceDate = lastComplianceGroup.LastGroupComplianceDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); lastComplianceCycles = lastComplianceGroup.LastGroupComplianceLifelength.Cycles != null ? lastComplianceGroup.LastGroupComplianceLifelength.Cycles.ToString() : ""; lastComplianceHours = lastComplianceGroup.LastGroupComplianceLifelength.Hours != null ? lastComplianceGroup.LastGroupComplianceLifelength.Hours.ToString() : ""; used.Substract(lastComplianceGroup.LastGroupComplianceLifelength); remarks = lastComplianceGroup.Remarks; } if (nextComplianceGroup != null) { nextComplianceDate = nextComplianceGroup.GroupComplianceDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); nextComplianceCycles = nextComplianceGroup.GroupComplianceLifelength.Cycles != null ? nextComplianceGroup.GroupComplianceLifelength.Cycles.ToString() : ""; nextComplianceHours = nextComplianceGroup.GroupComplianceLifelength.Hours != null ? nextComplianceGroup.GroupComplianceLifelength.Hours.ToString() : ""; remain.Add(nextComplianceGroup.GroupComplianceLifelength); remain.Substract(reportAircraftLifeLenght); } string usedHours = used.Hours != null?used.Hours.ToString() : ""; string usedCycles = used.Cycles != null?used.Cycles.ToString() : ""; string usedDays = used.Days != null?used.Days.ToString() : ""; string remainHours = remain.Hours != null?remain.Hours.ToString() : ""; string remainCycles = remain.Cycles != null?remain.Cycles.ToString() : ""; string remainDays = remain.Days != null?remain.Days.ToString() : ""; destinationDataSet.StatusTable.AddStatusTableRow(_filterSelection ? "Schedule" : "Unschedule", lastComplianceGroup != null ? lastComplianceGroup.ToStringCheckNames() : "", nextComplianceGroup != null ? nextComplianceGroup.ToStringCheckNames() : "", minStep.Hours != null ? minStep.Hours.ToString() : "", minStep.Cycles != null ? minStep.Cycles.ToString() : "", minStep.Days != null ? minStep.Days.ToString() : "", lastComplianceDate, lastComplianceHours, lastComplianceCycles, usedDays, usedHours, usedCycles, nextComplianceDate, nextComplianceHours, nextComplianceCycles, remainDays, remainHours, remainCycles, remarks); }
/// <summary> /// Заполняет краткую информацию о директиве /// </summary> 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="flightRegime"></param> /// <param name="date"></param> /// <returns></returns> private Lifelength this[DateTime date, FlightRegime flightRegime] { get { if (flightRegime == null) { flightRegime = FlightRegime.UNK; } if (_Array.ContainsKey(flightRegime)) { if (_Array[flightRegime] == null) { _Array[flightRegime] = new SortedDictionary <DateTime, Lifelength>(); } } else { _Array.Add(flightRegime, new SortedDictionary <DateTime, Lifelength>()); } SortedDictionary <DateTime, Lifelength> array = _Array[flightRegime]; if (date.Date > DateTime.Today) { Lifelength res = _Array.Count > 0 ? new Lifelength(array.Last().Value) : Lifelength.Zero; res.Add(LifelengthSubResource.Calendar, (date.Date - DateTime.Today).Days); return(res); } if (date.Date < _startDate.Date) { return(new Lifelength((_startDate.Date - date.Date).Days, 0, 0)); } return(array.ContainsKey(date.Date) ? array[date.Date] : null); } set { if (flightRegime == null) { flightRegime = FlightRegime.UNK; } if (_Array.ContainsKey(flightRegime)) { if (_Array[flightRegime] == null) { _Array[flightRegime] = new SortedDictionary <DateTime, Lifelength>(); } } else { _Array.Add(flightRegime, new SortedDictionary <DateTime, Lifelength>()); } SortedDictionary <DateTime, Lifelength> array = _Array[flightRegime]; if (array.ContainsKey(date.Date)) { array[date.Date] = value; } else { if (date.Date >= _startDate.Date && date.Date <= DateTime.Today) { array.Add(date.Date, value); } } } }