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; }
/* * Реализация */ #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; }
public Lifelength GetCurrentFlightLifelength(BaseEntityObject source, ForecastData forecastData = null) { if (source == null) { return(Lifelength.Null); } if (forecastData == null) { return(GetFlightLifelengthOnEndOfDay(source, DateTime.Today)); } if (forecastData.ForecastDate <= DateTime.Today) { return(GetFlightLifelengthOnEndOfDay(source, forecastData.ForecastDate)); } var res = GetFlightLifelengthOnEndOfDay(source, DateTime.Today); res += AnalystHelper.GetUtilization(forecastData.AverageUtilization, (forecastData.ForecastDate - DateTime.Today).Days); return(res); }
/// <summary> /// Инициализирует все поля /// </summary> private void Calc() { if (CurrentLifelength == null || AverageUtilization == null) { return; } if (ForecastLifelength == null) { ForecastLifelength = new Lifelength(CurrentLifelength); } else { ForecastLifelength.Reset(); ForecastLifelength += CurrentLifelength; } ForecastLifelength.Add(AnalystHelper.GetUtilization(AverageUtilization, Calculator.GetDays(DateTime.Today, _forecastDate))); 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; } }
public Lifelength GetFlightLifelengthOnStartOfDay(BaseEntityObject source, ForecastData forecastData = null) { if (source == null) { return new Lifelength { Days = GetDays(DateTimeExtend.GetCASMinDateTime(), DateTime.Today) } } ; if (forecastData == null) { return(GetFlightLifelengthOnStartOfDay(source, DateTime.Today)); } if (forecastData.ForecastDate <= DateTime.Today) { return(GetFlightLifelengthOnStartOfDay(source, forecastData.ForecastDate)); } var res = GetFlightLifelengthOnStartOfDay(source, DateTime.Today); res += AnalystHelper.GetUtilization(forecastData.AverageUtilization, (forecastData.ForecastDate - DateTime.Today).Days); return(res); }