/// <summary> /// </summary> public LDNDForecastForm(Aircraft aircraft, AverageUtilization averageUtilization) : this() { _aircraft = aircraft; _averageUtilization = averageUtilization; UpdateInformation(); }
public ComponentView(Component source) { if (source == null) { return; } Id = source.Id; AircaraftId = source.AircaraftId; PartNumber = source.PartNumber; ManufactureDate = source.ManufactureDate.Value; IsBaseComponent = source.IsBaseComponent; LLPMark = source.LLPMark; LLPCategories = source.LLPCategories; _threshold = new Threshold(); Warranty = Lifelength.ConvertFromByteArray(source.Warranty); WarrantyNotify = Lifelength.ConvertFromByteArray(source.WarrantyNotify); LifeLimit = Lifelength.ConvertFromByteArray(source.LifeLimit); LifeLimitNotify = Lifelength.ConvertFromByteArray(source.LifeLimitNotify); ActualStateRecords = source.ActualStateRecords?.Select(i => new ActualStateRecordView(i)).ToList(); TransferRecords = source.TransferRecords?.Select(i => new TransferRecordView(i)).ToList(); ChangeLLPCategoryRecords = source.ChangeLLPCategoryRecords?.Select(i => new ComponentLLPCategoryChangeRecordView(i)).ToList(); ComponentDirectives = source.ComponentDirectives?.Select(i => new ComponentDirectiveView(i)).ToList(); LLPData = source.LLPData?.Select(i => new ComponentLLPCategoryDataView(i)).ToList(); AverageUtilization = AverageUtilization.ConvertFromByteArray(source.AverageUtilization); }
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> /// Возвращает приблизительное количество дней, за которое наберется ресурс remains с заданной среднестатистической наработкой /// </summary> /// <param name="from"></param> /// <param name="remains"></param> /// <param name="average"></param> /// <param name="conditionType"></param> /// <returns></returns> public static Double?GetApproximateDays(DateTime from, Lifelength remains, AverageUtilization average, ThresholdConditionType conditionType = ThresholdConditionType.WhicheverFirst) { // if (remains == null || average == null) { return(null); } if (remains.CalendarValue != null && remains.CalendarValue != 0) { DateTime to = from.AddCalendarSpan(remains.CalendarSpan); return((to - from).Days); } Double?d1 = average.CyclesPerMonth != 0 && remains.Cycles != null ? new Double?(remains.Cycles.Value / (average.Hours / average.Cycles)) : null; Double?d2 = average.HoursPerMonth != 0 && remains.Hours != null ? remains.Hours * 30 / average.HoursPerMonth : null; Double?d3 = remains.Days; // Whichever First vs. Whichever Later if (conditionType == ThresholdConditionType.WhicheverFirst) { // Выбираем минимум Double?min = null; if (d1 != null) { min = d1; } if (d2 != null && (min == null || d2 < min)) { min = d2; } if (d3 != null && (min == null || d3 < min)) { min = d3; } // Возвращаем результат return(min); } // Выбираем максимум Double?max = null; if (d1 != null) { max = d1; } if (d2 != null && (max == null || d2 > max)) { max = d2; } if (d3 != null && (max == null || d3 > max)) { max = d3; } // Возвращаем результат return(max); }
/// <summary> /// Переводит объкт баззы данных в ToAverageUtilization /// </summary> /// <param name="o"></param> /// <returns></returns> public static AverageUtilization ToAverageUtilization(object o) { if (o == null || o == DBNull.Value) { return(new AverageUtilization(0, 0, UtilizationInterval.Dayly)); } return(AverageUtilization.ConvertFromByteArray((byte[])o)); }
private void ForecastContextMenuClick(object sender, EventArgs e) { var form = new LDNDForecastForm(CurrentAircraft, _averageUtilization); if (form.ShowDialog() == DialogResult.OK) { _averageUtilization = form.AverageUtilization; AnimatedThreadWorker.RunWorkerAsync(); } }
/* * Методы */ #region public BaseComponent() /// <summary> /// Создает воздушное судно без дополнительной информации /// </summary> public BaseComponent() { ItemId = -1; IsBaseComponent = true; AverageUtilization = new AverageUtilization(); manufactureDate = DateTimeExtend.GetCASMinDateTime(); SmartCoreObjectType = SmartCoreType.BaseComponent; // Мат аппарат // OpeningLifelengthCalculated = new LifelengthCollection(); //LifelengthCalculated = new LifelengthCollection(); ComponentWorkParams = new CommonCollection <ComponentWorkInRegimeParams>(); }
protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { return; } //вычисление периода в днях var periodDays = (dateTimePickerDateTo.Value - dateTimePickerDateFrom.Value).Days; //вычисление сред. кол-ва часов в день var totalHoursClear = GlobalObjects.CasEnvironment.Calculator.GetTotalHours(_resultDirectiveArray); var avgHoursPerDay = totalHoursClear / periodDays; //вычисление сред. кол-ва циклов в день var totalCycleClear = GlobalObjects.CasEnvironment.Calculator.GetTotalCycles(_resultDirectiveArray); var avgCyclesPerDay = (double)totalCycleClear / periodDays; //плановая утилизация var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(CurrentAircraft.AircraftFrameId); var plan = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame);; //вычисление фактической утилизации AverageUtilization factPerPeriod; if (plan.SelectedInterval == UtilizationInterval.Dayly) { factPerPeriod = new AverageUtilization(avgCyclesPerDay, avgHoursPerDay, UtilizationInterval.Dayly); } else { factPerPeriod = new AverageUtilization(avgCyclesPerDay * 30, avgHoursPerDay * 30, UtilizationInterval.Monthly); } if (CurrentAircraft != null) { labelTitle.Text = "Date as of: " + SmartCore.Auxiliary.Convert.GetDateFormat(DateTime.Today) + " Aircraft TSN/CSN: " + GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(CurrentAircraft); } else { labelTitle.Text = ""; labelTitle.Status = Statuses.NotActive; } labelAvgUtilization.Text = "Avg. Utilz. Plan:" + plan.CustomToString() + " Avg. Utilz. Fact per period: " + factPerPeriod; _directivesViewer.WorkParams = _workParams; _directivesViewer.OilConditions = _oilConditions; ; _directivesViewer.SetItemsArray(_resultDirectiveArray.OrderBy(i => i.FlightDate).ThenByDescending(i => i.TakeOffTime).ToArray()); headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0; _directivesViewer.Focus(); }
///<summary> /// Возвращает объект средне утилизации в соотвествии со значениями заданными а ЭУ ///</summary> ///<returns></returns> public AverageUtilization GetAverageUtilization() { double eps = 0.00000001; double hours = (double)numericUpDownHours.Value; double cycles = (double)numericUpDownCycles.Value; if (radioButtonDayly.Checked && numericUpDownHours.Value >= 24) { MessageBox.Show(numericUpDownHours.Value + ". Invalid value", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } if (radioButtonMonthly.Checked && numericUpDownHours.Value >= 744) { MessageBox.Show(numericUpDownHours.Value + ". Invalid value", (string)new GlobalTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } AverageUtilization au = new AverageUtilization(); if (radioButtonDayly.Checked) { au.SelectedInterval = UtilizationInterval.Dayly; } else { au.SelectedInterval = UtilizationInterval.Monthly; } if (Math.Abs(au.Hours - hours) > eps) { if (au.SelectedInterval == UtilizationInterval.Dayly) { au.HoursPerDay = hours; } else { au.HoursPerMonth = hours; } } if (Math.Abs(au.Cycles - cycles) > eps) { if (au.SelectedInterval == UtilizationInterval.Dayly) { au.CyclesPerDay = cycles; } else { au.CyclesPerMonth = cycles; } } return(au); }
/// <summary> /// Возвращает наработку агрегата или налет воздушного судна за указанный период времени /// </summary> /// <param name="average"></param> /// <param name="days"></param> /// <returns></returns> public static Lifelength GetUtilization(AverageUtilization average, Int32 days) { Lifelength res = Lifelength.Zero; if (average != null && average.CyclesPerMonth != 0 && average.HoursPerMonth != 0) { res.Cycles = (int)(days * average.CyclesPerMonth / 30); res.TotalMinutes = (int)(days * average.HoursPerMonth * 60 / 30); } res.Days = days; return(res); }
public MTOPComplainceForm(MTOPCheckRecord check, Aircraft aircraft, AverageUtilization averageUtilization) : this() { if (check == null) { return; } _aircraft = aircraft; _checkRecord = check; _averageUtilization = averageUtilization; dateTimePicker1.ValueChanged -= dateTimePicker1_ValueChanged; UpdateInformation(); dateTimePicker1.ValueChanged += dateTimePicker1_ValueChanged; }
/// <summary> /// </summary> /// <param name="currentDirective"></param> /// <param name="nextPerformances"></param> /// <param name="averageUtilization"></param> /// <param name="nextPerformance"></param> public DirectiveComplianceDialog(IDirective currentDirective, List <NextPerformance> nextPerformances, AverageUtilization averageUtilization) : this() { _currentDirective = currentDirective; _currentDirectiveRecord = DirectiveRecord.CreateInstance(nextPerformances.FirstOrDefault()); _nextPerformance = nextPerformances.FirstOrDefault(); _nextPerformances = nextPerformances; _averageUtilization = averageUtilization; checkBox1.Visible = true; _animatedThreadWorker.DoWork += AnimatedThreadWorkerDoLoad; _animatedThreadWorker.RunWorkerCompleted += BackgroundWorkerRunWorkerLoadCompleted; }
/// <summary> /// Возвращает дату, когда наберется ресурс remains с заданной среднестатистической наработкой /// </summary> /// <param name="remains"></param> /// <param name="average"></param> /// <param name="conditionType"></param> /// <returns></returns> public static DateTime?GetApproximateDate(Lifelength remains, AverageUtilization average, ThresholdConditionType conditionType = ThresholdConditionType.WhicheverFirst) { // if (remains == null || average == null) { return(null); } // расчитываем количество дней Double?days = GetApproximateDays(DateTime.Today, remains, average, conditionType); if (days == null) { return(null); } // возвращаем дату return(DateTime.Today.AddDays(days.Value)); }
public MTOPComplainceForm(MTOPCheck check, Aircraft aircraft, AverageUtilization averageUtilization) : this() { if (check == null) { return; } _aircraft = aircraft; _averageUtilization = averageUtilization; _checkRecord = new MTOPCheckRecord { RecordDate = DateTime.Today, CheckName = check.Name, GroupName = check.Group, CalculatedPerformanceSource = check.NextPerformance.PerformanceSource, ParentId = check.ItemId }; UpdateInformation(); }
/// <summary> /// Данные работы обновляются по введенным значениям /// </summary> public bool SaveData() { AverageUtilization au = GetAverageUtilization(); if (au == null) { return(false); } _currentBaseComponent.AverageUtilization = au; try { GlobalObjects.ComponentCore.Save(_currentBaseComponent); } catch (Exception ex) { Program.Provider.Logger.Log("Error while loading data", ex); return(false); } return(true); }
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; } }
public static Lifelength GetUtilizationNew(AverageUtilization average, int days) { var res = Lifelength.Zero; if (average != null && average.CyclesPerMonth != 0 && average.HoursPerMonth != 0) { res.Cycles = (int)(days * average.CyclesPerMonth / 30); res.TotalMinutes = ((int)average.HoursPerDay * 60); var decimalParts = average.HoursPerDay.ToString("F").Split('.'); string decimalPart = decimalParts[1]; if (decimalPart.StartsWith("0")) { decimalPart = decimalPart.Substring(1); } res.TotalMinutes += int.Parse(decimalPart); res.TotalMinutes *= days; } res.Days = days; return(res); }
private void UpdateInformation() { var frame = GlobalObjects.CasEnvironment.BaseComponents.FirstOrDefault(i => i.ParentAircraftId == _aircraft.ItemId && Equals(i.BaseComponentType, BaseComponentType.Frame)); _averageUtilization = frame.AverageUtilization; dateTimePickerFrom.Value = DateTime.Today; dateTimePickerTo.Value = DateTime.Today; tempHours = _averageUtilization.HoursPerDay; tempCycles = _averageUtilization.CyclesPerDay; if (checkBox1.Checked) { var current = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_aircraft); _averageUtilization.HoursPerDay = (double)current.Hours / (double)current.Days; _averageUtilization.CyclesPerDay = (double)current.Hours / (double)current.Cycles; } numericUpDownHours.Value = (decimal)_averageUtilization.Hours; numericUpDownCycles.Value = (decimal)_averageUtilization.Cycles; }
public void UpdateControl(List <MTOPCheck> maintenanceChecks, List <MTOPCheck> maintenanceChecksDeleted, Aircraft currentAircraft, AverageUtilization averageUtilization) { _averageUtilization = averageUtilization; _currentAircraft = currentAircraft; listViewCompliance.Items.Clear(); ListViewItem newItem; string[] subs; var mtopCheckRecords = new List <MTOPCheckRecord>(); mtopCheckRecords.AddRange(maintenanceChecksDeleted.SelectMany(i => i.PerformanceRecords)); mtopCheckRecords.AddRange(maintenanceChecks.SelectMany(i => i.PerformanceRecords)); var nps = maintenanceChecks.SelectMany(i => i.NextPerformances); foreach (var np in nps.OrderByDescending(i => i.PerformanceSource.Days)) { string perfDate = ""; if (np.PerformanceDate.HasValue) { perfDate = UsefulMethods.NormalizeDate(np.PerformanceDate.Value); } var group = np.ParentCheck.IsZeroPhase ? $"0{np.Group}" : np.Group.ToString(); subs = new[] { group, np.ParentCheck.Name, perfDate, np.PerformanceSource.ToRepeatIntervalsFormat(), $"HRS/DAY: {Math.Round(np.ParentCheck.AverageUtilization.Hours, 2)} CYC/DAY: {Math.Round((double) (np.ParentCheck?.AverageUtilization?.Hours / np.ParentCheck.AverageUtilization?.CyclesPerDay), 2)}", "" }; newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups["next"], Tag = np, BackColor = UsefulMethods.GetColor(np) }; listViewCompliance.Items.Add(newItem); } foreach (var record in mtopCheckRecords.OrderByDescending(i => i.CalculatedPerformanceSource.Days)) { var group = record.Parent.IsZeroPhase ? $"0{record.GroupName}" : record.GroupName.ToString(); subs = new[] { group, record.CheckName, UsefulMethods.NormalizeDate(record.RecordDate), record.CalculatedPerformanceSource.ToRepeatIntervalsFormat(), record.AverageUtilization != null ? $"HRS/DAY: {Math.Round(record.AverageUtilization.Hours, 2)} CYC/DAY: {Math.Round((double) (record.AverageUtilization?.Hours / record.AverageUtilization?.CyclesPerDay), 2)}" : "", record.Remarks }; newItem = new ListViewItem(subs) { Group = listViewCompliance.Groups["last"], Tag = record }; listViewCompliance.Items.Add(newItem); } }
private void ButtonOkClick(object sender, EventArgs e) { DialogResult = DialogResult.OK; _averageUtilization = GetAverageUtilization(); this.Close(); }
/// <summary> /// Добавляется элемент в таблицу данных /// </summary> /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param> protected virtual void AddAircraftToDataset(MonthlyUtilizationDataSet destinationDataSet) { var aircraftLifelength = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentAircraft); var serialNumber = _currentAircraft.SerialNumber; var manufactureDate = _currentAircraft.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString()); var sinceNewHours = aircraftLifelength.Hours.ToString(); var sinceNewCycles = aircraftLifelength.Cycles.ToString().Trim(); var registrationNumber = _currentAircraft.RegistrationNumber; string lineNumber; string variableNumber; string lineNumberCaption = ""; string variableNumberCaption = ""; string averageUtilizationHoursPlan; string averageUtilizationCyclesPlan; string averageUtilizationPlanType; string averageUtilizationHoursFact; string averageUtilizationCyclesFact; string averageUtilizationFactType; string selection; string engineCaption1 = ""; string engineCaption2 = ""; string apuCaption = ""; var engine = GlobalObjects.ComponentCore.GetAircraftEngines(_currentAircraft.ItemId); var apu = GlobalObjects.ComponentCore.GetAircraftApu(_currentAircraft.ItemId); if (engine[0] != null) { engineCaption1 = "Engine " + engine[0].PositionNumber + "\r\nS/N: " + engine[0].SerialNumber; } if (engine[1] != null) { engineCaption2 = "Engine " + engine[1].PositionNumber + "\r\nS/N: " + engine[1].SerialNumber; } if (apu != null) { apuCaption = "APU" + "\r\nS/N: " + apu.SerialNumber; } //вычисление периода в днях int periodDays = (_periodTo - _periodFrom).Days; //вычисление сред. кол-ва часов в день double avgHoursPerDay = _totalHoursClear / periodDays; //вычисление сред. кол-ва циклов в день double avgCyclesPerDay = _totalCyclesClear / periodDays; //плановая утилизация var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(_currentAircraft.AircraftFrameId); var plan = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame); //вычисление фактической утилизации AverageUtilization factPerPeriod; if (plan.SelectedInterval == UtilizationInterval.Dayly) { factPerPeriod = new AverageUtilization(avgCyclesPerDay, avgHoursPerDay, UtilizationInterval.Dayly); } else { factPerPeriod = new AverageUtilization(avgCyclesPerDay * 30, avgHoursPerDay * 30, UtilizationInterval.Monthly); } averageUtilizationHoursPlan = plan.Hours.ToString(); averageUtilizationCyclesPlan = plan.Cycles.ToString(); averageUtilizationPlanType = plan.SelectedInterval == UtilizationInterval.Dayly ? "DAY" : "MONTH"; const string specifier = "G3"; CultureInfo culture = CultureInfo.CreateSpecificCulture("eu-ES"); averageUtilizationHoursFact = factPerPeriod.Hours.ToString(specifier, culture); averageUtilizationCyclesFact = factPerPeriod.Cycles.ToString(specifier, culture); averageUtilizationFactType = factPerPeriod.SelectedInterval == UtilizationInterval.Dayly ? "DAY" : "MONTH"; selection = SmartCore.Auxiliary.Convert.DatePeriodToString(_periodFrom, _periodTo); lineNumber = (_currentAircraft).LineNumber; variableNumber = (_currentAircraft).VariableNumber; if (lineNumber != "") { lineNumberCaption = "L/N:"; } if (variableNumber != "") { variableNumberCaption = "V/N:"; } destinationDataSet.BaseDetailTable.AddBaseDetailTableRow(serialNumber, manufactureDate, sinceNewHours, sinceNewCycles, registrationNumber, lineNumber, variableNumber, lineNumberCaption, variableNumberCaption, averageUtilizationHoursPlan, averageUtilizationHoursFact, averageUtilizationCyclesPlan, averageUtilizationCyclesFact, engineCaption1, "", engineCaption2, "", apuCaption, "", averageUtilizationPlanType, averageUtilizationFactType, selection); }
protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e) { _maintenanceChecks.Clear(); _maintenanceZeroChecks.Clear(); _groupLifelengths.Clear(); _groupLifelengthsForZeroCheck.Clear(); _initialMaintenanceDirectives.Clear(); _initialZeroMaintenanceDirectives.Clear(); AnimatedThreadWorker.ReportProgress(0, "load records"); #region Загрузка try { var checks = GlobalObjects.CasEnvironment.NewLoader.GetObjectListAll <MTOPCheckDTO, MTOPCheck>( new Filter("ParentAircraftId", CurrentAircraft.ItemId), true, true); _maintenanceChecks.AddRange(checks.Where(i => !i.IsDeleted)); _maintenanceChecksDeleted.AddRange(checks.Where(i => i.IsDeleted)); var baseComponents = GlobalObjects.ComponentCore.GetAicraftBaseComponents(CurrentAircraft.ItemId); var components = GlobalObjects.ComponentCore.GetComponents(baseComponents.ToList()); var componentDirectives = components.SelectMany(i => i.ComponentDirectives); var mpds = GlobalObjects.MaintenanceCore.GetMaintenanceDirectives(CurrentAircraft); foreach (var componentDirective in componentDirectives) { foreach (var items in componentDirective.ItemRelations.Where(i => i.FirtsItemTypeId == SmartCoreType.MaintenanceDirective.ItemId || i.SecondItemTypeId == SmartCoreType.MaintenanceDirective.ItemId)) { var id = componentDirective.IsFirst == true ? items.SecondItemId : items.FirstItemId; componentDirective.MaintenanceDirective = mpds.FirstOrDefault(i => i.ItemId == id); } } _initialMaintenanceDirectives.AddRange(mpds); _initialMaintenanceDirectives.AddRange(GlobalObjects.DirectiveCore.GetDirectives(CurrentAircraft, DirectiveType.All).ToList()); _initialMaintenanceDirectives.AddRange(componentDirectives); var bindedItemsDict = GlobalObjects.BindedItemsCore.GetBindedItemsFor(CurrentAircraft.ItemId, _initialMaintenanceDirectives.Where(m => m is MaintenanceDirective) .Cast <MaintenanceDirective>().Where(m => m.WorkItemsRelationType == WorkItemsRelationType.CalculationDepend)); CalculateMaintenanceDirectives(_initialMaintenanceDirectives, bindedItemsDict); } catch (Exception exception) { Program.Provider.Logger.Log("Error while load records", exception); } if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } #endregion AnimatedThreadWorker.ReportProgress(50, "Calculate MTOP"); #region асчет foreach (var check in _maintenanceChecks) { foreach (var record in check.PerformanceRecords) { record.Parent = check; } } foreach (var check in _maintenanceChecksDeleted) { foreach (var record in check.PerformanceRecords) { record.Parent = check; } } if (_maintenanceChecks.Count > 0) { //Берем утилизацию с Frame var frame = GlobalObjects.CasEnvironment.BaseComponents.FirstOrDefault(i => i.ParentAircraftId == CurrentAircraft.ItemId && Equals(i.BaseComponentType, BaseComponentType.Frame)); _averageUtilization = frame.AverageUtilization; var lastCompliance = _maintenanceChecks.Where(i => !i.IsZeroPhase).SelectMany(i => i.PerformanceRecords) .OrderByDescending(i => i.RecordDate).FirstOrDefault(); GlobalObjects.MTOPCalculator.CalculateMtopChecks(_maintenanceChecks, _averageUtilization); _groupLifelengths = GlobalObjects.MTOPCalculator.CalculateGroupNew(_maintenanceChecks .Where(i => !i.Thresh.IsNullOrZero() && !i.IsZeroPhase).ToList()); GlobalObjects.MTOPCalculator.CalculateNextPerformance( _maintenanceChecks.Where(i => !i.IsZeroPhase).ToList(), frame.StartDate, _groupLifelengths, CurrentAircraft, _averageUtilization, lastCompliance); GlobalObjects.MTOPCalculator.CalculateNextPerformance( _maintenanceChecks.Where(i => !i.IsZeroPhase).ToList(), frame.StartDate, _groupLifelengths, CurrentAircraft, _averageUtilization, lastCompliance, true); GlobalObjects.MTOPCalculator.CalculatePhase(_initialMaintenanceDirectives, _maintenanceChecks.Where(i => !i.Thresh.IsNullOrZero() && !i.IsZeroPhase).ToList(), _averageUtilization); _maintenanceZeroChecks = _maintenanceChecks.Where(i => i.IsZeroPhase).ToList(); var lowerZeroCheck = _maintenanceZeroChecks.Where(i => !i.Thresh.IsNullOrZero()).OrderBy(i => i.Thresh) .FirstOrDefault(); if (lowerZeroCheck != null) { lastCompliance = _maintenanceChecks.Where(i => i.IsZeroPhase).SelectMany(i => i.PerformanceRecords) .OrderByDescending(i => i.RecordDate).FirstOrDefault(); GlobalObjects.MTOPCalculator.CalculateMtopChecks(_maintenanceZeroChecks, _averageUtilization); _groupLifelengthsForZeroCheck = GlobalObjects.MTOPCalculator.CalculateGroupNew(_maintenanceZeroChecks); GlobalObjects.MTOPCalculator.CalculateNextPerformance(_maintenanceZeroChecks, frame.StartDate, _groupLifelengthsForZeroCheck, CurrentAircraft, _averageUtilization, lastCompliance); GlobalObjects.MTOPCalculator.CalculateNextPerformance(_maintenanceZeroChecks, frame.StartDate, _groupLifelengthsForZeroCheck, CurrentAircraft, _averageUtilization, lastCompliance, true); _initialZeroMaintenanceDirectives.AddRange(_initialMaintenanceDirectives .Where(i => i.MTOPPhase?.FirstPhase == 0).ToArray()); GlobalObjects.MTOPCalculator.CalculatePhase(_initialZeroMaintenanceDirectives, _maintenanceChecks.Where(i => !i.Thresh.IsNullOrZero() && i.IsZeroPhase).ToList(), _averageUtilization, true); } foreach (var d in _initialZeroMaintenanceDirectives) { _initialMaintenanceDirectives.Remove(d); } //var q = _maintenanceChecks.Where(i => !i.IsZeroPhase).SelectMany(i => i.NextPerformances); //var last = _maintenanceChecks.Where(i => !i.IsZeroPhase).SelectMany(i => i.PerformanceRecords).OrderByDescending(i => i.RecordDate).FirstOrDefault(); //var group = last.GroupName; //var value = Lifelength.Null; //foreach (var performance in q.OrderBy(i => i.PerformanceSource.Days)) //{ // if (value.Days == performance.PerformanceSource.Days) // { // performance.Group = group --; // } // else // { // performance.Group = group++; // } // value = performance.PerformanceSource; //} } if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } #endregion #region Фильтрация директив AnimatedThreadWorker.ReportProgress(70, "filter records"); FilterItems(_initialMaintenanceDirectives, _resultMaintenanceDirectives); if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } AnimatedThreadWorker.ReportProgress(90, "filter records"); FilterZeroItems(_initialZeroMaintenanceDirectives, _resultZeroMaintenanceDirectives); if (AnimatedThreadWorker.CancellationPending) { e.Cancel = true; return; } #endregion AnimatedThreadWorker.ReportProgress(100, "Complete"); }