Beispiel #1
0
        private static NextCompliance _calculate(DateTime lastDate, Lifelength repeat)
        {
            var res = new NextCompliance();

            res.NextDate = lastDate.AddDays(repeat.Days.Value);
            //Считаем Remain
            var days = (res.NextDate.Value - DateTime.Today).Days;

            res.Remains = new Lifelength(days, null, null);

            if (res.Remains.Days < 0)
            {
                res.Condition = ConditionState.Overdue;
            }
            else if (res.Remains.Days >= 0 && res.Remains.Days <= _notify)
            {
                res.Condition = ConditionState.Notify;
            }
            else
            {
                res.Condition = ConditionState.Satisfactory;
            }

            return(res);
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        /// <summary>
        /// Создает несохраненного клона (Itemid которого =-1) переданного элемента
        /// </summary>
        /// <param name="toCopy">Элемент для клонирования (иожет быть равен null)</param>
        /// <returns>Склонированный элемент или элемент по умолчанию</returns>
        public DirectiveRecord(DirectiveRecord toCopy) : this()
        {
            if (toCopy == null)
            {
                return;
            }

            Completed  = toCopy.Completed;
            Dispatched = toCopy.Dispatched;
            MaintenanceOrganization = toCopy.MaintenanceOrganization;
            ODR                 = toCopy.ODR;
            _onLifelength       = toCopy.OnLifelength;
            _parent             = toCopy.Parent;
            _parentId           = toCopy.ParentId;
            _parentType         = toCopy.ParentType;
            _performanceNum     = toCopy.PerformanceNum;
            _recordDate         = toCopy.RecordDate;
            RecordTypeId        = toCopy.RecordTypeId;
            Reference           = toCopy.Reference;
            _remarks            = toCopy.Remarks;
            _directivePackage   = toCopy.DirectivePackage;
            _directivePackageId = toCopy.DirectivePackageId;

            _attachedFile = toCopy.AttachedFile;
        }
Beispiel #4
0
        /// <summary>
        /// Возвращает значение, показывающее были ли изменения в данном элементе управления
        /// </summary>
        /// <param name="directiveExist">Показывает, существует ли уже директива или нет</param>
        /// <returns></returns>
        public bool GetChangeStatus(bool directiveExist)
        {
            Lifelength emptyLifelength = new Lifelength();

            if (directiveExist)
            {
                return(
                    (Title != currentDirective.Title) ||
                    (References != currentDirective.References) ||
                    (TLPNo != currentDirective.Applicability) ||
                    (Requirement != currentDirective.Description) ||
                    (Remarks != currentDirective.Remarks) ||
                    (HiddenRemarks != currentDirective.HiddenRemarks) ||
                    (EngOrderNo != currentDirective.EngeneeringOrders) ||
                    (JobCardNo != currentDirective.JobCardNo) ||
                    lifelengthViewerFrequency.Modified ||
                    lifelengthViewerNotifyBefore.Modified);
            }
            else
            {
                return(
                    (Title != "") ||
                    (References != "") ||
                    (TLPNo != "") ||
                    (Requirement != "") ||
                    (Remarks != "") ||
                    (HiddenRemarks != "") ||
                    (EngOrderNo != "") ||
                    (JobCardNo != "") ||
                    !(lifelengthViewerNotifyBefore.Lifelength.Equals(emptyLifelength)) ||
                    !(lifelengthViewerFrequency.Lifelength.Equals(emptyLifelength))
                    );
            }
        }
        private void DateTimePickerInstallationDateValueChanged(object sender, EventArgs e)
        {
            if (!lifelengthViewerAircraftTCSNOnInstall.Modified)
            {
                if (!_isStore)
                {
                    if (InstallationDate <= DateTime.Today)
                    {
                        AircraftTCSNOnInstall = GlobalObjects.CasEnvironment.Calculator.
                                                GetFlightLifelengthOnEndOfDay((Aircraft)_currentAircraft, InstallationDate);
                    }
                    else
                    {
                        AircraftTCSNOnInstall = GlobalObjects.CasEnvironment.Calculator.
                                                GetFlightLifelengthOnEndOfDay((Aircraft)_currentAircraft, DateTime.Today);
                    }
                    lifelengthViewerAircraftTCSNOnInstall.Modified         = false;
                    lifelengthViewerAircraftTCSNOnInstall.SystemCalculated = true;
                }
            }

            Lifelength onInstall = new Lifelength(ComponentTCSNOnInstall);

            onInstall.Days = (int)(InstallationDate - ManufactureDate).TotalDays;

            ComponentTCSNOnInstall = onInstall;
            lifelengthViewerComponentTCSNOnInstall.SystemCalculated = true;
        }
Beispiel #6
0
        private void comboBoxCalendarType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxCalendarType.SelectedIndex == 0)
            {
                calendarTypes = Lifelength.CalendarTypes.Days;
            }
            else if (comboBoxCalendarType.SelectedIndex == 1)
            {
                calendarTypes = Lifelength.CalendarTypes.Months;
            }
            else
            {
                calendarTypes = Lifelength.CalendarTypes.Years;
            }


            if (readOnly)
            {
                //blockValidatindCalendar = true;
                SetTextBoxCalendarValue(Calendar.TotalDays);
                //blockValidatindCalendar = false;
            }
            else
            {
                double calendar;
                if (double.TryParse(textBoxCalendar.Text, out calendar))
                {
                    SetCalendarData(Lifelength.ParseCalendar(calendar, CalendarTypes), false);
                }
            }
        }
Beispiel #7
0
 public Lifelength GetFlightLifelengthOnEndOfDay(BaseEntityObject source, DateTime effDate)
 {
     if (source is Operator || source == null)
     {
         if (effDate.Date <= DateTimeExtend.GetCASMinDateTime())
         {
             return(Lifelength.Zero);
         }
         // вычисляем результат
         var res = new Lifelength {
             Days = GetDays(DateTimeExtend.GetCASMinDateTime(), effDate.Date)
         };
         return(res);
     }
     if (source is Aircraft)
     {
         return(GetFlightLifelengthOnEndOfDay((Aircraft)source, effDate));
     }
     if (source is BaseComponent)
     {
         return(GetFlightLifelengthOnEndOfDay((BaseComponent)source, effDate));
     }
     if (source is Entities.General.Accessory.Component)
     {
         return(GetFlightLifelengthOnEndOfDay((Entities.General.Accessory.Component)source, effDate));
     }
     return(Lifelength.Null);
 }
Beispiel #8
0
 public Lifelength GetFlightLifelengthOnStartOfDay(BaseEntityObject source, DateTime effDate)
 {
     if (source == null)
     {
         return(Lifelength.Null);
     }
     if (source is Operator)
     {
         if (effDate.Date <= DateTimeExtend.GetCASMinDateTime())
         {
             return(Lifelength.Zero);
         }
         // вычисляем результат
         var res = new Lifelength {
             Days = GetDays(DateTimeExtend.GetCASMinDateTime(), effDate.Date)
         };
         return(res);
     }
     if (source is Aircraft)
     {
         return(GetFlightLifelengthOnStartOfDay((Aircraft)source, effDate));
     }
     if (source is BaseComponent)
     {
         return(GetFlightLifelengthOnStartOfDay((BaseComponent)source, effDate));
     }
     //TODO:(Evgenii Babak) выяснить почему берется наработка на конец дня и не делается cast к Component
     if (source is Entities.General.Accessory.Component)
     {
         return(GetFlightLifelengthOnEndOfDay(source, effDate));
     }
     return(Lifelength.Null);
 }
Beispiel #9
0
        private void DateTimePickerManufactureDateValueChanged(object sender, EventArgs e)
        {
            DateTimePicker dtp = sender as DateTimePicker;

            if (dtp == null)
            {
                return;
            }

            if (dtp.Value > DateTime.Now)
            {
                dtp.Value = DateTime.Now;
            }

            Lifelength lifelength = lifelengthViewerInstallation.Lifelength;

            lifelengthViewerInstallation.Lifelength = new Lifelength
            {
                Hours  = lifelength.Hours,
                Cycles = lifelength.Cycles,
                Days   =
                    (dateTimePickerInstallation.Value -
                     dateTimePickerManufactureDate.Value).Days
            };
        }
Beispiel #10
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        protected virtual void AddAircraftToDataset(WorkPackagesDataSet destinationDataSet)
        {
            if (ReportedAircraft == null)
            {
                return;
            }
            string     registrationNumber    = ReportedAircraft.RegistrationNumber;
            string     serialNumber          = ReportedAircraft.SerialNumber;
            string     manufactureDate       = SmartCore.Auxiliary.Convert.GetDateFormat(ReportedAircraft.ManufactureDate);
            Lifelength lifelength            = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft);
            string     sinceNewHours         = lifelength.Hours.ToString().Trim();
            string     sinceNewCycles        = lifelength.Cycles.ToString().Trim();
            string     lineNumberCaption     = "";
            string     variableNumberCaption = "";

            string lineNumber     = (ReportedAircraft).LineNumber;
            string variableNumber = (ReportedAircraft).VariableNumber;

            if (lineNumber != "")
            {
                lineNumberCaption = "L/N:";
            }
            if (variableNumber != "")
            {
                variableNumberCaption = "V/N:";
            }
            destinationDataSet.
            AircraftInformationTable.
            AddAircraftInformationTableRow(registrationNumber, serialNumber, manufactureDate,
                                           lineNumberCaption, variableNumberCaption, lineNumber,
                                           variableNumber, sinceNewHours, sinceNewCycles);
        }
Beispiel #11
0
 /// <summary>
 /// Задается отображаемое значение у элемента
 /// </summary>
 /// <param name="i">Номер элемента</param>
 /// <param name="lifelength">Задаваемое значение</param>
 public void SetValue(int i, Lifelength lifelength)
 {
     if (i >= 0 && i <= lifeLengthViewers.Count)
     {
         lifeLengthViewers[i].Lifelength = lifelength;
     }
 }
Beispiel #12
0
 /// <summary>
 /// Сохраняет наработки
 /// </summary>
 /// <param name="i"></param>
 /// <param name="lifelength"></param>
 public void SaveData(int i, Lifelength lifelength)
 {
     if (i >= 0 && i <= lifeLengthViewers.Count)
     {
         lifeLengthViewers[i].SaveData(lifelength);
     }
 }
Beispiel #13
0
 private void ApplySettings(Lifelength lifelengthIncrement)
 {
     if (currentBaseDetail != null)
     {
         if (dateAsOf > DateTime.Now)
         {
             CurrentBaseDetail =
                 originalBaseDetail.CloneAsDateOf(dateAsOf, lifelengthIncrement) as BaseDetail;
         }
         else
         {
             CurrentBaseDetail = originalBaseDetail.CloneAsDateOf(dateAsOf) as BaseDetail;
         }
     }
     else
     {
         if (dateAsOf > DateTime.Now)
         {
             CurrentAircraft =
                 originalAircraft.CloneAsDateOf(dateAsOf, lifelengthIncrement) as Aircraft;
         }
         else
         {
             CurrentAircraft = originalAircraft.CloneAsDateOf(dateAsOf) as Aircraft;
         }
     }
 }
Beispiel #14
0
        /// <summary>
        /// 3аполняет поля для редактирования директивы
        /// </summary>
        /// <param name="sourceDirective"></param>
        public void UpdateInformation(BaseDetailDirective sourceDirective)
        {
            if (sourceDirective == null)
            {
                throw new ArgumentNullException("sourceDirective");
            }
            Title                    = sourceDirective.Title;
            References               = sourceDirective.References;
            TLPNo                    = sourceDirective.Applicability;
            Requirement              = sourceDirective.Description;
            Remarks                  = sourceDirective.Remarks;
            HiddenRemarks            = sourceDirective.HiddenRemarks;
            FirstPerformNotifyBefore = sourceDirective.Notification;
            Frequency                = sourceDirective.RepeatPerform;
            EngOrderNo               = sourceDirective.EngeneeringOrders;
            JobCardNo                = sourceDirective.JobCardNo;

            bool permission = currentDirective.HasPermission(Users.CurrentUser, DataEvent.Update);

            textboxTitle.ReadOnly                 = !permission;
            textBoxReferences.ReadOnly            = !permission;
            textboxTLPNo.ReadOnly                 = !permission;
            textboxReqirement.ReadOnly            = !permission;
            labelNotifyBefore.Enabled             = permission;
            lifelengthViewerNotifyBefore.ReadOnly = !permission;
            lifelengthViewerFrequency.ReadOnly    = !permission;
            textboxRemarks.ReadOnly               = !permission;
            textboxHiddenRemarks.ReadOnly         = !permission;
            textboxEngOrderNo.ReadOnly            = !permission;
            textboxJobCardNo.ReadOnly             = !permission;
        }
Beispiel #15
0
 /// <summary>
 /// Создается построение отчетов отклонений
 /// </summary>
 /// <param name="thresholdLifelength">Пороговая выборка</param>
 /// <param name="dateAsOf">Дата на которую был создан отчет</param>
 /// <param name="detailDiscrepancies">Отклонения по агрегатам</param>
 /// <param name="detailDiscrepanciesTitle">Заголовок отклонений по агрегатам</param>
 /// <param name="directiveDiscrepancies">Отклонения по директивам</param>
 /// <param name="directiveDiscrepanciesTitles">Заголовки отклонений по директивам</param>
 public DiscrepanciesReportBuilder(Lifelength thresholdLifelength, DateTime dateAsOf, Detail[] detailDiscrepancies, string detailDiscrepanciesTitle, Directive[][] directiveDiscrepancies, string[] directiveDiscrepanciesTitles) : this(thresholdLifelength, dateAsOf)
 {
     this.detailDiscrepanciesTitle = detailDiscrepanciesTitle;
     this.detailDiscrepancies.AddRange(detailDiscrepancies);
     this.directiveDiscrepancies.AddRange(directiveDiscrepancies);
     this.containerTitles.AddRange(directiveDiscrepanciesTitles);
 }
Beispiel #16
0
        /// <summary>
        /// Обновляет отображаемую информацию
        /// </summary>
        /// <param name="sourceDetail">Агрегат по которому отображается информация</param>
        public void UpdateInformation(TemplateAbstractDetail sourceDetail)
        {
            if (sourceDetail == null)
            {
                throw new ArgumentNullException("sourceDetail");
            }
            SinceNewLimitation            = sourceDetail.Limitation.MaxResourceSinceNew;
            SinceLastOverhaulLimitation   = sourceDetail.Limitation.MaxResourceSinceOverhaul;
            SinceLastInspectionLimitation = sourceDetail.Limitation.MaxResourceSinceInspection;
            SinceLastShopVisitLimitation  = sourceDetail.Limitation.MaxResourceSinceShopVisit;

            SinceNewNotification            = sourceDetail.Limitation.NotificationSinceNew;
            SinceLastOverhaulNotification   = sourceDetail.Limitation.NotificationSinceOverhaul;
            SinceLastInspectionNotification = sourceDetail.Limitation.NotificationSinceInspection;
            SinceLastShopVisitNotification  = sourceDetail.Limitation.NotificationSinceShopVisit;

            if (sourceDetail is TemplateEngine)
            {
                notifyWhenRemainsInfo.LifeLengthViewers[4].Visible = true;
                maxResourcesInfo.LifeLengthViewers[4].Visible      = true;
                SinceLastHotInspectionLimitation    = sourceDetail.Limitation.MaxResourceSinceHotSectionInspection;
                SinceLastHostInspectionNotification = sourceDetail.Limitation.NotificationSinceHotSectionInspection;
            }

            bool permission = (currentDetail.HasPermission(Users.CurrentUser, DataEvent.Update));

            maxResourcesInfo.ReadOnly      = !permission;
            notifyWhenRemainsInfo.ReadOnly = !permission;
            labelRemark.Visible            = permission;
        }
Beispiel #17
0
        /// <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);
        }
Beispiel #18
0
 /// <summary>
 /// Переводит объкт баззы данных в Lifelength
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 public static Lifelength ToLifelength(object o)
 {
     if (o == null || o == DBNull.Value)
     {
         return(Lifelength.Null);
     }
     return(Lifelength.ConvertFromByteArray((byte[])o));
 }
Beispiel #19
0
 private CustomCell CreateListViewSubItem(Color backColor, Lifelength lifelength)
 {
     return(new CustomCell
     {
         Text = lifelength.ToHoursMinutesAndCyclesFormat("", ""),
         Tag = lifelength,
     });
 }
Beispiel #20
0
        /// <summary>
        /// Создает прогноз на заданную дату
        /// </summary>
        /// <param name="date">Дата, на которую необходимо построить отчет</param>
        /// <param name="baseComponentгрегат</param>
        /// <param name="current">Текущая наработка агрегата или налет ВС</param>
        /// <param name="lowerLimit">Нижняя граница прогноза</param>
        public ForecastData(DateTime date, BaseComponent baseComponent, Lifelength current, DateTime?lowerLimit = null)
        {
            BaseComponent        = baseComponent;
            SelectedForecastType = lowerLimit != null ? ForecastType.ForecastByPeriod : ForecastType.ForecastByDate;
            LowerLimit           = lowerLimit != null?Convert.ToDateTime(lowerLimit) : DateTimeExtend.GetCASMinDateTime();

            Init(date, BaseComponent.AverageUtilization, current);
        }
Beispiel #21
0
        private bool ValidateData()
        {
            foreach (WorkPackageClosingDataGridViewRow row in dataGridViewItems.Rows.OfType <WorkPackageClosingDataGridViewRow>())
            {
                if ((bool)row.Cells[ColumnClosed.Index].Value == false)
                {
                    continue;
                }

                string message;
                if (row.ClosingItem is Component)
                {
                    TransferRecord tr = row.Record as TransferRecord;
                    if (tr == null)
                    {
                        message =
                            "Performance for:" + $"\n{row.ClosingItem} " + "\nin not transfer record";
                        message += "\nAbort operation";
                        MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"],
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                    if (tr.DestinationObjectId == 0 || tr.TransferDate < DateTimeExtend.GetCASMinDateTime())
                    {
                        message = @"Displacement parameters are specified components" +
                                  "\nClick the link 'Edit Transfer' for set it";
                        message += "\nAbort operation";
                        MessageBox.Show(message, (string)new GlobalTermsProvider()["SystemName"],
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }
                }
                else
                {
                    if (!Lifelength.ValidateHours((string)row.Cells[ColumnHours.Index].Value))
                    {
                        MessageBox.Show("Invalid value for hours parameter",
                                        new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);

                        row.Cells[ColumnHours.Index].Style.BackColor = Color.Red;

                        return(false);
                    }
                    if (!Lifelength.ValidateCyclesOrDays((string)row.Cells[ColumnCycles.Index].Value))
                    {
                        MessageBox.Show("Invalid value for cycles parameter",
                                        new GlobalTermsProvider()["SystemName"].ToString(), MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation);

                        row.Cells[ColumnCycles.Index].Style.BackColor = Color.Red;

                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #22
0
 /*
  * Реализация
  */
 #region public EventCategory()
 /// <summary>
 /// Конструктор создает объект повреждения
 /// </summary>
 public EventCategory()
 {
     _weight = 1;
     _eventCountInMinPeriod = 1;
     _eventCountInMaxPeriod = 1;
     _minReportPeriod       = Lifelength.Null;
     _maxReportPeriod       = Lifelength.Null;
     SmartCoreObjectType    = SmartCoreType.EventCategory;
 }
Beispiel #23
0
        /*
         * Методы
         */

        #region public ComponentThreshold()
        /// <summary>
        /// Пустой конструктор
        /// </summary>
        public ComponentThreshold()
        {
            //EffectiveDate = DateTime.Today;
            _sinceNew            = Lifelength.Null;
            FirstNotification    = Lifelength.Null;
            _performRepeatedly   = true;
            Warranty             = Lifelength.Null;
            WarrantyNotification = Lifelength.Null;
        }
Beispiel #24
0
        /*
         * Методы
         */

        #region public DirectiveThreshold()
        /// <summary>
        /// Пустой конструктор
        /// </summary>
        public DirectiveThreshold()
        {
            EffectiveDate = DateTime.Today;
            FirstPerformanceSinceEffectiveDate = new Lifelength();
            FirstPerformanceSinceNew           = new Lifelength();
            RepeatInterval     = new Lifelength();
            FirstNotification  = new Lifelength();
            RepeatNotification = new Lifelength();
        }
        /// <summary>
        /// Изменение значения наработки агрегата с момента установки
        /// </summary>
        public void ChangeComponentTSNSinseInstall()
        {
            if (_isStore)
            {
                return;
            }
            //если отсутствует наработка агрегата на момент установки
            //то дальнейшее расчитать нельзя
            Lifelength aircraftCurrent =
                GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay((Aircraft)_currentAircraft, dateTimePickerDateAsOf.Value);

            if ((aircraftCurrent.IsNullOrZero() && AircraftTCSNOnInstall.IsNullOrZero()) ||
                (ComponentCurrentTSNCSN.IsNullOrZero() && ComponentTCSNOnInstall.IsNullOrZero()))
            {
                if (lifelengthViewerComponentTCSI.SystemCalculated)
                {
                    //если данные в наработку с момента установеи вводила система,
                    //а не пользователь, то их нужно обнулить
                    ComponentTCSI = Lifelength.Null;
                }
                return;
            }

            if (ComponentTCSI.IsNullOrZero() ||
                lifelengthViewerComponentTCSI.SystemCalculated)
            {
                //Если наработка агрегата с момента установки не введена или
                //введена системой, то её надо расчитать
                Lifelength temp;
                if (!aircraftCurrent.IsNullOrZero() &&
                    !AircraftTCSNOnInstall.IsNullOrZero())
                {
                    //если известна текущая наработка самолета и
                    //наработка самолета на момент установки
                    temp = new Lifelength(aircraftCurrent);
                    temp.Substract(AircraftTCSNOnInstall);
                    ComponentTCSI = temp;
                    lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true;
                    return;
                }

                if (!ComponentCurrentTSNCSN.IsNullOrZero() &&
                    !ComponentTCSNOnInstall.IsNullOrZero())
                {
                    //если известна текущая наработка агрегата и
                    //наработка агрегата на момент установки
                    temp = new Lifelength(ComponentCurrentTSNCSN);
                    temp.Substract(ComponentTCSNOnInstall);
                    ComponentTCSI = temp;
                    lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true;
                    return;
                }
                //иначе, наработку высчитать нельзя
                ComponentTCSI = Lifelength.Null;
                lifelengthViewerComponentCurrentTSNCSN.SystemCalculated = true;
            }
        }
        /*
         * Методы
         */

        #region public MaintenanceCheckThreshold()
        /// <summary>
        /// Пустой конструктор
        /// </summary>
        public MaintenanceCheckThreshold()
        {
            //EffectiveDate = DateTime.Today;
            _sinceNew          = Lifelength.Null;
            FirstNotification  = Lifelength.Null;
            _performRepeatedly = true;
            RepeatInterval     = Lifelength.Null;
            RepeatNotification = Lifelength.Null;
        }
Beispiel #27
0
 ///<summary>
 ///</summary>
 public ComponentLifeLimitControlItem(Component component) : this()
 {
     _currentComponent = component;
     _limit            = component.LifeLimit;
     _remain           = component.LifeLimitNotify;
     _mainLimit        = true;
     UpdateContol();
     UpdateInformation();
 }
        /// <summary>
        /// Добавление директив в таблицу данных
        /// </summary>
        /// <param name="dataset">Таблица, в которую добавляются данные</param>
        protected virtual void AddDirectivesToDataSet(MaintenanceStatusDataSet dataset)
        {
            GlobalObjects.MaintenanceCheckCalculator.GetNextPerformanceGroup(_reportedDirectives, _filterSelection);

            foreach (MaintenanceCheck t in _reportedDirectives)
            {
                var        hiddenRemark   = "";
                Lifelength lastCompliance = Lifelength.Null,
                           repeatInterval = Lifelength.Null;
                var lastComplianceDate    = "";
                var used = Lifelength.Null;

                var remarks = t.LastPerformance != null ? t.LastPerformance.Remarks : "";
                //расчет остатка от выполнения с даты производтсва
                var next      = t.NextPerformanceSource;
                var remains   = t.Remains;
                var condition = t.Condition;

                if (t.LastPerformance != null)
                {
                    if (t.Interval != null)
                    {
                        repeatInterval = t.Interval;
                    }

                    lastComplianceDate = t.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
                    lastCompliance     = t.LastPerformance.OnLifelength;
                    used.Add(_current);
                    used.Substract(lastCompliance);
                }
                var nextComplianceDate = t.NextPerformanceDate != null
                                                ? ((DateTime)t.NextPerformanceDate).ToString(new GlobalTermsProvider()["DateFormat"].ToString())
                                                : "";

                dataset.ItemsTable.AddItemsTableRow(remarks,
                                                    hiddenRemark,
                                                    "",
                                                    t.Name,
                                                    repeatInterval.Days != null ? repeatInterval.Days.ToString() : "",
                                                    repeatInterval.Hours != null ? repeatInterval.Hours.ToString() : "",
                                                    repeatInterval.Cycles != null ? repeatInterval.Cycles.ToString() : "",
                                                    lastComplianceDate,
                                                    lastCompliance.Hours != null ? lastCompliance.Hours.ToString() : "",
                                                    lastCompliance.Cycles != null ? lastCompliance.Cycles.ToString() : "",
                                                    used.Days != null ? used.Days.ToString() : "",
                                                    used.Hours != null ? used.Hours.ToString() : "",
                                                    used.Cycles != null ? used.Cycles.ToString() : "",
                                                    nextComplianceDate,
                                                    next.Hours != null ? next.Hours.ToString() : "",
                                                    next.Cycles != null ? next.Cycles.ToString() : "",
                                                    remains.Days != null ? remains.Days.ToString() : "",
                                                    remains.Hours != null ? remains.Hours.ToString() : "",
                                                    remains.Cycles != null ? remains.Cycles.ToString() : "",
                                                    condition.ToString());
            }
        }
Beispiel #29
0
        /*
         * Реализация
         */

        #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;
        }
Beispiel #30
0
        /*
         *  Методы
         */

        #region public ComponentLLPCategoryChangeRecord()
        /// <summary>
        /// Создает воздушное судно без дополнительной информации
        /// </summary>
        public ComponentLLPCategoryChangeRecord()
        {
            ItemId = -1;
            SmartCoreObjectType = SmartCoreType.ComponentLLPCategoryChangeRecord;
            _parentId           = -1;
            _recordDate         = DateTimeExtend.GetCASMinDateTime();
            ToCategory          = LLPLifeLimitCategory.Unknown;
            _onLifelength       = Lifelength.Null;
            _remarks            = "";
        }