/* * Реализация */ #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; }
/// <summary> /// Создает прогноз на заданный ресурс агрегата (налет воздушного судна) /// </summary> /// <param name="forecastLifelength">Ресурс агрегата или налет воздушного судна, на который требуется построить отчет</param> /// <param name="average">Среднестатистическая наработка агрегата или налет ВС</param> /// <param name="current">Текущая наработка агрегата или налет ВС</param> public ForecastData(Lifelength forecastLifelength, AverageUtilization average, Lifelength current) { SelectedForecastType = ForecastType.ForecastByLifelength; Lifelength delta = new Lifelength(forecastLifelength); delta.Substract(current); DateTime?date = AnalystHelper.GetApproximateDate(delta, average); if (date == null) { throw new Exception("1327: Can not compose forecast report for null date"); } Init(date.Value, average, current); }
/* * Методы */ #region public static AverageUtilization ConvertFromByteArray(byte[] data) /// <summary> /// Конвертирует данные из БД в AverageUtilization /// </summary> /// <param name="data"></param> public static AverageUtilization ConvertFromByteArray(byte[] data) { AverageUtilization item = new AverageUtilization(); byte[] binaryData = data; if (null == binaryData) { return(item); } if (binaryData == null || binaryData.Length != SerializedDataLength) { throw new ArgumentException("Data cannot be converted to Lifelength"); } item.SelectedInterval = (UtilizationInterval)DbTypes.Int32FromByteArray(binaryData, 0); item._hoursPerMonth = DbTypes.DoubleFromByteArray(binaryData, 4); item._cyclesPerMonth = DbTypes.DoubleFromByteArray(binaryData, 12); return(item); }
/* * Конструктор */ #region public ForecastData(DateTime date, AverageUtilization average, Lifelength current) /// <summary> /// Создает прогноз на заданную дату /// </summary> /// <param name="date">Дата, на которую необходимо построить отчет</param> /// <param name="average">Среднестатистическая наработка агрегата или налет ВС</param> /// <param name="current">Текущая наработка агрегата или налет ВС</param> public ForecastData(DateTime date, AverageUtilization average, Lifelength current) { SelectedForecastType = ForecastType.ForecastByDate; Init(date, average, current); }