コード例 #1
0
        /// <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;
            }
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        private void NumericUpDownsValueChanged(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;
            }

            //наработка агрегата на сегодня
            Lifelength baseDetailLifeLenght =
                GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_currentForecastData.BaseComponent);

            if (_forecastDate <= DateTime.Today)
            {
                //если дата прогноза меньше сегодняшней, то выводиться зписанная наработка на эту дату
                Lifelength different = new Lifelength(lifelengthViewer_ForecastResource.Lifelength);
                different.Substract(baseDetailLifeLenght);
                lifelengthViewerDifferentSource.Lifelength = different;
            }
            else
            {
                //если дата прогноза выше сегодняшней, то сначала вычисляется
                //наработка на сегодняшний день, а к ней добавляется среднепрогнозируемая наработка
                //между сегодняшним днем и днем прогноза

                Lifelength average = AnalystHelper.GetUtilization(au, Calculator.GetDays(DateTime.Today, _forecastDate));
                lifelengthViewerDifferentSource.Lifelength = average;
                baseDetailLifeLenght.Add(average);
                lifelengthViewer_ForecastResource.Lifelength = baseDetailLifeLenght;
            }
        }
コード例 #5
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        private void AddBaseDetailToDataset(DirectivesListDataSet destinationDataSet)
        {
            if (_reportedAircraft != null)
            {
                return;
            }
            var parentAircaft            = GlobalObjects.AircraftsCore.GetAircraftById(_reportedBaseComponent.ParentAircraftId);
            var parentStore              = GlobalObjects.StoreCore.GetStoreById(_reportedBaseComponent.ParentStoreId);
            var reportAircraftLifeLenght =
                GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent);
            var regNumber = _reportedBaseComponent.GetParentAircraftRegNumber();
            var location  = !string.IsNullOrEmpty(regNumber)
                                                          ? regNumber
                                                          : parentStore != null ? parentStore.Name : "";
            var manufactureDate = _reportedBaseComponent.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var deliveryDate    = _reportedBaseComponent.DeliveryDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var status          = _reportedBaseComponent.Serviceable ? "Serviceable" : "Unserviceable";
            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      = _reportedBaseComponent.LifeLimit;
            var lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : "";

            var lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : "";

            var lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : "";

            var remain = new Lifelength(lifeLimit);

            remain.Substract(reportAircraftLifeLenght);
            var remainHours = remain.Hours != null?remain.Hours.ToString() : "";

            var remainCycles = remain.Cycles != null?remain.Cycles.ToString() : "";

            var remainDays = remain.Days != null?remain.Days.ToString() : "";

            var lastTransferRecord = _reportedBaseComponent.TransferRecords.GetLast();
            var installationDate   = lastTransferRecord.TransferDate;
            var onInstall          = lastTransferRecord.OnLifelength;
            var onInstallDate      = installationDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var onInstallHours     = onInstall.Hours != null?onInstall.Hours.ToString() : "";

            var onInstallCycles = onInstall.Cycles != null?onInstall.Cycles.ToString() : "";

            var onInstallDays = onInstall.Days != null?onInstall.Days.ToString() : "";

            var sinceInstall = new Lifelength(reportAircraftLifeLenght);

            sinceInstall.Substract(onInstall);
            var sinceInstallHours = sinceInstall.Hours != null?sinceInstall.Hours.ToString() : "";

            var sinceInstallCycles = sinceInstall.Cycles != null?sinceInstall.Cycles.ToString() : "";

            var sinceInstallDays = sinceInstall.Days != null?sinceInstall.Days.ToString() : "";

            var warranty       = _reportedBaseComponent.Warranty;
            var warrantyRemain = new Lifelength(warranty);

            warrantyRemain.Substract(reportAircraftLifeLenght);
            warrantyRemain.Resemble(warranty);
            var warrantyHours = warranty.Hours != null?warranty.Hours.ToString() : "";

            var warrantyCycles = warranty.Cycles != null?warranty.Cycles.ToString() : "";

            var warrantyDays = warranty.Days != null?warranty.Days.ToString() : "";

            var warrantyRemainHours = warrantyRemain.Hours != null?warrantyRemain.Hours.ToString() : "";

            var warrantyRemainCycles = warrantyRemain.Cycles != null?warrantyRemain.Cycles.ToString() : "";

            var warrantyRemainDays = warrantyRemain.Days != null?warrantyRemain.Days.ToString() : "";

            var aircraftOnInstall = Lifelength.Null;
            var aircraftCurrent   = Lifelength.Null;

            if (parentAircaft != null)
            {
                var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId);
                aircraftOnInstall = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, installationDate);
                aircraftCurrent   = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircaft);
            }
            var aircraftOnInstallHours = aircraftOnInstall.Hours != null?aircraftOnInstall.Hours.ToString() : "";

            var aircraftOnInstallCycles = aircraftOnInstall.Cycles != null?aircraftOnInstall.Cycles.ToString() : "";

            var aircraftOnInstallDays = aircraftOnInstall.Days != null?aircraftOnInstall.Days.ToString() : "";

            var aircraftCurrentHours  = aircraftCurrent.Hours ?? 0;
            var aircraftCurrentCycles = aircraftCurrent.Cycles ?? 0;


            var sinceOverhaul          = Lifelength.Null;
            var lastOverhaulDate       = DateTime.MinValue;
            var lastOverhaulDateString = "";

            #region поиск последнего ремонта и расчет времени, прошедшего с него
            //поиск директив деталей
            var directives = GlobalObjects.ComponentCore.GetComponentDirectives(_reportedBaseComponent, true);
            //поиск директивы ремонта
            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(_reportedBaseComponent.ATAChapter.ToString(),
                                                                     _reportedBaseComponent.AvionicsInventory.ToString(),
                                                                     _reportedBaseComponent.PartNumber,
                                                                     _reportedBaseComponent.SerialNumber,
                                                                     _reportedBaseComponent.Model != null ? _reportedBaseComponent.Model.ToString() : "",
                                                                     _reportedBaseComponent.BaseComponentType.ToString(),
                                                                     location,
                                                                     lastTransferRecord.Position,
                                                                     _reportedBaseComponent.Manufacturer,
                                                                     manufactureDate,
                                                                     deliveryDate,
                                                                     _reportedBaseComponent.MPDItem,
                                                                     _reportedBaseComponent.Suppliers != null
                                                                        ? _reportedBaseComponent.Suppliers.ToString()
                                                                        : "",
                                                                     status,
                                                                     _reportedBaseComponent.Cost,
                                                                     _reportedBaseComponent.CostOverhaul,
                                                                     _reportedBaseComponent.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 (_forecast == null)
            {
                var aircraftFrame      = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId);
                var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame);
                var au = parentAircaft != null
                                            ? averageUtilization
                                                                                        : _reportedBaseComponent.AverageUtilization;
                averageUtilizationHours  = (int)au.Hours;
                averageUtilizationCycles = (int)au.Cycles;
                averageUtilizationType   = au.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month";
            }
            else
            {
                averageUtilizationHours  = (int)_forecast.ForecastDatas[0].AverageUtilization.Hours;
                averageUtilizationCycles = (int)_forecast.ForecastDatas[0].AverageUtilization.Cycles;
                averageUtilizationType   =
                    _forecast.ForecastDatas[0].AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month";
            }
            destinationDataSet.AircraftDataTable.AddAircraftDataTableRow("",
                                                                         manufactureDate,
                                                                         reportAircraftLifeLenght.ToHoursMinutesFormat(""),
                                                                         reportAircraftLifeLenght.Cycles != null && reportAircraftLifeLenght.Cycles != 0
                                                                            ? reportAircraftLifeLenght.Cycles.ToString()
                                                                            : "",
                                                                         "", "", "", "",
                                                                         averageUtilizationHours, averageUtilizationCycles, averageUtilizationType);
        }
コード例 #6
0
        /// <summary>
        /// Добавление директив в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляются данные</param>
        protected virtual void AddDirectivesToDataSet(MaintenanceRecordDataSet destinationDataSet)
        {
            GlobalObjects.MaintenanceCheckCalculator.GetNextPerformanceGroup(_reportedDirectives, true);
            GlobalObjects.MaintenanceCheckCalculator.GetNextPerformanceGroup(_reportedDirectives, false);

            int checkId = 0;

            foreach (var reportedDirective in _reportedDirectives)
            {
                if (_reportedAircraft == null)
                {
                    return;
                }
                checkId++;
                var reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent);
                var minStep = reportedDirective.Interval;
                var used    = new Lifelength(reportAircraftLifeLenght);

                string lastComplianceDate = "", lastComplianceHours = "", lastComplianceCycles = "";
                string nextComplianceDate = "", nextComplianceHours = "", nextComplianceCycles = "";
                double costTotal = 0, mhTotal = 0;

                var remarks = reportedDirective.LastPerformance != null ? reportedDirective.LastPerformance.Remarks : "";

                foreach (AccessoryRequired kit in reportedDirective.Kits)
                {
                    costTotal += kit.Quantity * kit.CostNew;
                    destinationDataSet.FinancesTable.AddFinancesTableRow(remarks,
                                                                         kit.Description,
                                                                         reportedDirective.Schedule ? checkId : 1000 + checkId,
                                                                         "KIT",
                                                                         0,
                                                                         kit.Quantity,
                                                                         0,
                                                                         kit.CostNew);

                    destinationDataSet.EquipmentTable.AddEquipmentTableRow(remarks,
                                                                           kit.Description,
                                                                           reportedDirective.Schedule ? checkId : 1000 + checkId,
                                                                           "KIT",
                                                                           0,
                                                                           "",
                                                                           kit.PartNumber);
                }


                remarks = ""; string hiddenRemarks = "";
                if (reportedDirective.LastPerformance != null)
                {
                    lastComplianceDate   = reportedDirective.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
                    lastComplianceCycles = reportedDirective.LastPerformance.OnLifelength.Cycles != null
                                               ? reportedDirective.LastPerformance.OnLifelength.Cycles.ToString()
                                               : "";

                    lastComplianceHours = reportedDirective.LastPerformance.OnLifelength.Hours != null
                                               ? reportedDirective.LastPerformance.OnLifelength.Hours.ToString()
                                               : "";

                    used.Substract(reportedDirective.LastPerformance.OnLifelength);
                    remarks       = reportedDirective.LastPerformance.Remarks;
                    hiddenRemarks = reportedDirective.LastPerformance.Remarks;
                }
                var next = reportedDirective.NextPerformanceSource;
                var remains = reportedDirective.Remains;

                string usedHours = "", usedCycles = "", usedDays = "",
                       remainHours = "", remainCycles = "", remainDays = "";
                if (reportedDirective.NextPerformanceDate != null)
                {
                    nextComplianceDate   = ((DateTime)reportedDirective.NextPerformanceDate).ToString(new GlobalTermsProvider()["DateFormat"].ToString());
                    nextComplianceCycles = next.Cycles != null
                                               ? next.Cycles.ToString()
                                               : "";

                    nextComplianceHours = next.Hours != null
                                               ? next.Hours.ToString()
                                               : "";

                    usedHours = used.Hours != null?used.Hours.ToString() : "";

                    usedCycles = used.Cycles != null?used.Cycles.ToString() : "";

                    usedDays = used.Days != null?used.Days.ToString() : "";

                    remainHours = remains.Hours != null?remains.Hours.ToString() : "";

                    remainCycles = remains.Cycles != null?remains.Cycles.ToString() : "";

                    remainDays = remains.Days != null?remains.Days.ToString() : "";
                }
                destinationDataSet.StatusTable.AddStatusTableRow(reportedDirective.Schedule ? checkId : 1000 + checkId,
                                                                 reportedDirective.Name + (reportedDirective.Schedule ? " Schedule" : " Unschedule"),
                                                                 costTotal,
                                                                 mhTotal,
                                                                 reportedDirective.CheckType.ToString(),
                                                                 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,
                                                                 hiddenRemarks);
            }
        }
コード例 #7
0
        /// <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
                                                           );
        }
コード例 #8
0
        /// <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() : "");
            }
        }
コード例 #9
0
ファイル: ComponentSummary.cs プロジェクト: mkbiltek2019/Cas
        /// <summary>
        /// Заполняет краткую информацию о директиве
        /// </summary>
        public void UpdateInformation()
        {
            if (_currentComponent == null)
            {
                return;
            }
            if (_detailDirectivesPerformances == null)
            {
                _detailDirectivesPerformances = new List <ComponentSummaryCompliancePerformanceControl>();
            }
            else
            {
                _detailDirectivesPerformances.Clear();
            }
            //очищение плавающей панели и списка контролов отображения директив деталей
            flowLayoutPanel_Compliance.Controls.Clear();

            if (_currentComponent is BaseComponent)
            {
                BaseComponent inspectedBaseComponent = (BaseComponent)_currentComponent;

                var    lastTransferRecord   = inspectedBaseComponent.TransferRecords.GetLast();
                string baseDetailTypeString = inspectedBaseComponent.BaseComponentType.ToString();
                labelCompntTCSN.Text             = baseDetailTypeString + " Total:";
                labelCompntInstallDate.Text      = baseDetailTypeString + " install date:";
                labelCompntTCSNonInstall.Text    = baseDetailTypeString + " on Install:";
                labelCompntTCSNsinceInstall.Text = baseDetailTypeString + " since Install:";


                labelMPDItemValue.Text         = inspectedBaseComponent.MPDItem;
                labelDescriptionValue.Text     = inspectedBaseComponent.Model != null ? inspectedBaseComponent.Model.Description : inspectedBaseComponent.Description;
                labelRemarksValue.Text         = inspectedBaseComponent.Remarks;
                labelHiddenRemarksValue.Text   = inspectedBaseComponent.HiddenRemarks;
                labelPartNumberValue.Text      = inspectedBaseComponent.PartNumber;
                labelSerialNumberValue.Text    = inspectedBaseComponent.SerialNumber;
                labelPositionValue.Text        = lastTransferRecord.Position;          //позиция задается только для базовых деталей
                labelManufacturerValue.Text    = inspectedBaseComponent.Manufacturer;
                labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.ManufactureDate);
                labelDeliveryDateValue.Text    = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.DeliveryDate);
                labelModelValue.Text           = inspectedBaseComponent.Model != null?inspectedBaseComponent.Model.ToString() : "";

                labelSupplierValue.Text        = inspectedBaseComponent.Suppliers.ToString();
                labelMaintFreqValue.Text       = inspectedBaseComponent.MaintenanceControlProcess.ToString();
                labelCostNewValue.Text         = inspectedBaseComponent.Cost.ToString();
                labelCostServiceableValue.Text = inspectedBaseComponent.CostServiceable.ToString();
                labelCostOverhaulValue.Text    = inspectedBaseComponent.CostOverhaul.ToString();
                labelWarrantyValue.Text        = inspectedBaseComponent.Warranty.ToString();
                labelClassValue.Text           = inspectedBaseComponent.Model != null?inspectedBaseComponent.Model.GoodsClass.ToString() :
                                                     inspectedBaseComponent.GoodsClass != null?inspectedBaseComponent.GoodsClass.ToString() : "";

                labelATAChapterValue.Text = inspectedBaseComponent.ATAChapter.ToString();

                if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.None)
                {
                    labelAvionicsInventoryValue.Text = "None";
                }
                if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Optional)
                {
                    labelAvionicsInventoryValue.Text = "Optional";
                }
                if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Required)
                {
                    labelAvionicsInventoryValue.Text = "Required";
                }
                if (inspectedBaseComponent.AvionicsInventory == AvionicsInventoryMarkType.Unknown)
                {
                    labelAvionicsInventoryValue.Text = "Unknown";
                }

                labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(lastTransferRecord.TransferDate);
                Lifelength temp, temp2;
                //Наработка компонента на сегодня
                temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedBaseComponent);
                labelCompntTCSNValue.Text = temp.ToString();

                //Остаток жизненного времени на сегодня
                temp2 = new Lifelength(inspectedBaseComponent.LifeLimit);
                temp2.Substract(temp);
                temp2.Resemble(inspectedBaseComponent.LifeLimit);


                if (inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine)
                {
                    Component firstLimitter = _baseComponentComponents != null && _baseComponentComponents.Count > 0
                                                                                           ? _baseComponentComponents.Where(d => d.NextPerformanceDate != null)
                                              .OrderBy(d => d.NextPerformanceDate)
                                              .FirstOrDefault()
                                                                                           : null;

                    labelCompntLifeLimit.Text = baseDetailTypeString + " Life Limit / First Limit";

                    labelCompntLifeLimitValue.Text =
                        ((inspectedBaseComponent.LifeLimit.IsNullOrZero() ? "N/A" : inspectedBaseComponent.LifeLimit.ToString()) +
                         " / " +
                         (firstLimitter == null || firstLimitter.LifeLimit.IsNullOrZero() ? "N/A" : firstLimitter.LifeLimit.ToString()));

                    labelCompntLifeLimitRemains.Text = baseDetailTypeString + " Life Limit Remain / First Remains";

                    labelCompntLifeLimitRemainsValue.Text =
                        ((inspectedBaseComponent.Remains.IsNullOrZero() ? "N/A" : inspectedBaseComponent.Remains.ToString()) +
                         " / " +
                         (firstLimitter == null || firstLimitter.Remains.IsNullOrZero() ? "N/A" : firstLimitter.Remains.ToString()));
                }
                else
                {
                    labelCompntLifeLimit.Text             = baseDetailTypeString + " Life Limit";
                    labelCompntLifeLimitValue.Text        = inspectedBaseComponent.LifeLimit.ToString();
                    labelCompntLifeLimitRemains.Text      = baseDetailTypeString + " Life Limit Remain";
                    labelCompntLifeLimitRemainsValue.Text = temp2.ToString();
                }


                //Наработка компонента на момент установки
                temp2 = inspectedBaseComponent.ActualStateRecords.GetLastKnownRecord(lastTransferRecord.RecordDate)?.OnLifelength ?? Lifelength.Null;
                labelCompntTCSNonInstallValue.Text = temp2.ToString();

                //Наработка компонента с момента установки и по сей день
                temp.Substract(temp2);
                labelCompntTCSNsinceInstallValue.Text = temp.ToString();


                var tcsnLifeLenght           = Lifelength.Zero;
                var tcsnNonInstallLifeLenght = Lifelength.Zero;

                var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedBaseComponent.ParentAircraftId);                //TODO:(Evgenii Babak) пересмотреть использование ParentAircrafId здесь

                if (parentAircraft != null)
                {
                    tcsnLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft);

                    var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId);
                    //Наработка самолета на момент установки детали
                    if (aircraftFrame != null)
                    {
                        tcsnNonInstallLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, lastTransferRecord.TransferDate);
                    }
                }

                labelAircraftTCSNValue.Text          = tcsnLifeLenght.ToString();
                labelAircraftTCSNonInstallValue.Text = tcsnNonInstallLifeLenght.ToString();
            }
            else
            {
                var inspectedDetail = _currentComponent;

                var lastTransferRecord = inspectedDetail.TransferRecords.GetLast();
                labelMPDItemValue.Text         = inspectedDetail.MPDItem;
                labelDescriptionValue.Text     = inspectedDetail.Model != null ? inspectedDetail.Model.Description : inspectedDetail.Description;
                labelRemarksValue.Text         = inspectedDetail.Remarks;
                labelHiddenRemarksValue.Text   = inspectedDetail.HiddenRemarks;
                labelPartNumberValue.Text      = inspectedDetail.PartNumber;
                labelSerialNumberValue.Text    = inspectedDetail.SerialNumber;
                labelPositionValue.Text        = lastTransferRecord.Position;
                labelManufacturerValue.Text    = inspectedDetail.Manufacturer;
                labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedDetail.ManufactureDate);
                labelDeliveryDateValue.Text    = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedDetail.DeliveryDate);
                labelModelValue.Text           = inspectedDetail.Model != null?inspectedDetail.Model.ToString() : "";

                labelSupplierValue.Text        = inspectedDetail.Suppliers.ToString();
                labelMaintFreqValue.Text       = inspectedDetail.MaintenanceControlProcess.ToString();
                labelCostNewValue.Text         = inspectedDetail.Cost.ToString();
                labelCostServiceableValue.Text = inspectedDetail.CostServiceable.ToString();
                labelCostOverhaulValue.Text    = inspectedDetail.CostOverhaul.ToString();
                labelWarrantyValue.Text        = inspectedDetail.Warranty.ToString();
                labelClassValue.Text           = inspectedDetail.Model != null?inspectedDetail.Model.GoodsClass.ToString() :
                                                     inspectedDetail.GoodsClass != null?inspectedDetail.GoodsClass.ToString() : "";

                labelATAChapterValue.Text = inspectedDetail.ATAChapter.ToString();

                if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.None)
                {
                    labelAvionicsInventoryValue.Text = "None";
                }
                if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Optional)
                {
                    labelAvionicsInventoryValue.Text = "Optional";
                }
                if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Required)
                {
                    labelAvionicsInventoryValue.Text = "Required";
                }
                if (inspectedDetail.AvionicsInventory == AvionicsInventoryMarkType.Unknown)
                {
                    labelAvionicsInventoryValue.Text = "Unknown";
                }

                labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(lastTransferRecord.TransferDate);
                labelCompntLifeLimitValue.Text   = inspectedDetail?.LifeLimit?.ToString();

                var temp  = Lifelength.Null;
                var temp2 = Lifelength.Null;
                //Наработка компонента на сегодня
                if (inspectedDetail.LLPMark && inspectedDetail.LLPCategories)
                {
                    var selectedCategory = inspectedDetail.ChangeLLPCategoryRecords.GetLast()?.ToCategory;
                    if (selectedCategory != null)
                    {
                        var data = inspectedDetail.LLPData.FirstOrDefault(i => i.ParentCategory == selectedCategory);
                        temp = new Lifelength(data?.LLPCurrent);
                        if (data?.Remain != null)
                        {
                            temp2 = data.Remain;
                        }
                    }
                }
                else
                {
                    temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedDetail);
                }

                labelCompntTCSNValue.Text = temp.ToString();

                //Остаток жизненного времени на сегодня
                //temp2 = new Lifelength(inspectedDetail.LifeLimit);
                //temp2.Substract(temp);
                //temp2.Resemble(inspectedDetail.LifeLimit);
                labelCompntLifeLimitRemainsValue.Text = temp2.ToString();


                //Наработка компонента на момент установки
                var actualState = inspectedDetail.ActualStateRecords.GetLastKnownRecord(lastTransferRecord.RecordDate);
                if (actualState != null)
                {
                    temp2 = actualState.OnLifelength;
                }
                else
                {
                    temp2 = Lifelength.Null;
                }

                labelCompntTCSNonInstallValue.Text = temp2.ToString();

                //Наработка компонента с момента установки и по сей день
                if (inspectedDetail.LLPMark && inspectedDetail.LLPCategories)
                {
                    var selectedCategory = inspectedDetail.ChangeLLPCategoryRecords.GetLast()?.ToCategory;
                    if (selectedCategory != null)
                    {
                        var data = inspectedDetail.LLPData.FirstOrDefault(i => i.ParentCategory.ItemId == selectedCategory.ItemId);
                        temp.Substract(data?.LLPLifelengthCurrent);

                        labelCompntTCSNsinceInstallValue.Text = temp.ToString();
                    }
                }
                else
                {
                    temp.Substract(temp2);
                    labelCompntTCSNsinceInstallValue.Text = temp.ToString();
                }


                //TODO:(Evgenii Babak) пересмотреть использование ParentAircrafId здесь
                var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedDetail.ParentAircraftId);

                //Наработка самолета на сегодня
                temp = parentAircraft != null
                                        ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft)
                                        : Lifelength.Zero;

                labelAircraftTCSNValue.Text = temp.ToString();

                //Наработка самолета на момент установки детали
                temp = parentAircraft != null
                                                   ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId), lastTransferRecord.TransferDate)
                                                   : Lifelength.Zero;

                labelAircraftTCSNonInstallValue.Text = temp.ToString();
            }

            //Обновление таблиц выполнения директив
            //На каждую из директив детали создается отдельная таблица выполнения
            //После каждая таблица помещается в плавающую панель для отображения

            List <ComponentDirective> detailDirectives = new List <ComponentDirective>(((Component)_currentComponent).ComponentDirectives.ToArray());

            for (int i = 0; i < detailDirectives.Count; i++)
            {
                ComponentSummaryCompliancePerformanceControl summaryCompliancePerformanceControl = new ComponentSummaryCompliancePerformanceControl(detailDirectives[i]);

                summaryCompliancePerformanceControl.UpdateInformation();

                _detailDirectivesPerformances.Add(summaryCompliancePerformanceControl);
                flowLayoutPanel_Compliance.Controls.Add(summaryCompliancePerformanceControl);
            }
        }
コード例 #10
0
        /// <summary>
        /// Заполняет краткую информацию о директиве
        /// </summary>
        private void UpdateInformation()
        {
            if (_currentComponent == null)
            {
                return;
            }
            if (_componentDirectivesPerformances == null)
            {
                _componentDirectivesPerformances = new List <BaseComponentDirectiveSummaryControl>();
            }
            else
            {
                _componentDirectivesPerformances.Clear();
            }
            //очищение плавающей панели и списка контролов отображения директив деталей
            flowLayoutPanel_Compliance.Controls.Clear();

            referenceLinkLabelLLPStatus.Visible = _currentComponent.BaseComponentType == BaseComponentType.Engine;

            var inspectedBaseComponent = _currentComponent;

            var baseComponentTypeString  = inspectedBaseComponent.BaseComponentType.ToString();
            var baseComponentModelString = inspectedBaseComponent.Model != null
                                                                                           ? " " + inspectedBaseComponent.Model
                                                                                           : "";
            var engineThrustString =
                inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine &&
                !string.IsNullOrEmpty(inspectedBaseComponent.Thrust)
                                                                                        ? "/" + inspectedBaseComponent.Thrust
                                                                                        : "";

            extendableRichContainer.Caption = baseComponentTypeString + baseComponentModelString + engineThrustString
                                              //+ " P/N:" + _currentComponent.PartNumber
                                              + " S/N:" + _currentComponent.SerialNumber
                                              + " M/P:" + _currentComponent.MaintenanceControlProcess.ShortName
                                              + " Pos:" + _currentComponent.TransferRecords.GetLast().Position;

            referenceLinkLabelBaseDetail.Text = baseComponentTypeString;


            labelCompntTCSN.Text             = baseComponentTypeString + " Total:";
            labelCompntInstallDate.Text      = baseComponentTypeString + " install date:";
            labelCompntTCSNonInstall.Text    = baseComponentTypeString + " on Install:";
            labelCompntTCSNsinceInstall.Text = baseComponentTypeString + " since Install:";


            labelRemarksValue.Text         = inspectedBaseComponent.Remarks;
            labelManufactureDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.ManufactureDate);
            labelWarrantyValue.Text        = inspectedBaseComponent.Warranty.ToString();

            labelCompntInstallDateValue.Text = SmartCore.Auxiliary.Convert.GetDateFormat(inspectedBaseComponent.TransferRecords.GetLast().TransferDate);
            Lifelength temp, temp2;

            //Наработка компонента на сегодня
            temp = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(inspectedBaseComponent);
            labelCompntTCSNValue.Text = temp.ToString();

            //Остаток жизненного времени на сегодня
            temp2 = new Lifelength(inspectedBaseComponent.LifeLimit);
            temp2.Substract(temp);
            temp2.Resemble(inspectedBaseComponent.LifeLimit);


            if (inspectedBaseComponent.BaseComponentType == BaseComponentType.Engine)
            {
                Component firstLimitter = _baseComponentComponents != null && _baseComponentComponents.Count > 0
                                                                                   ? _baseComponentComponents.Where(d => d.NextPerformanceDate != null)
                                          .OrderBy(d => d.NextPerformanceDate)
                                          .FirstOrDefault()
                                                                                   : null;

                labelCompntLifeLimit.Text = baseComponentTypeString + " Life Limit / First Limit";

                labelCompntLifeLimitValue.Text =
                    ((inspectedBaseComponent.LifeLimit.IsNullOrZero() ? "N/A" : inspectedBaseComponent.LifeLimit.ToString()) +
                     " / " +
                     (firstLimitter == null || firstLimitter.LifeLimit.IsNullOrZero() ? "N/A" : firstLimitter.LifeLimit.ToString()));

                labelCompntLifeLimitRemains.Text = baseComponentTypeString + " Life Limit Remain / First Remains";

                labelCompntLifeLimitRemainsValue.Text =
                    ((inspectedBaseComponent.Remains.IsNullOrZero() ? "N/A" : inspectedBaseComponent.Remains.ToString()) +
                     " / " +
                     (firstLimitter == null || firstLimitter.Remains.IsNullOrZero() ? "N/A" : firstLimitter.Remains.ToString()));
            }
            else
            {
                labelCompntLifeLimit.Text             = baseComponentTypeString + " Life Limit";
                labelCompntLifeLimitValue.Text        = inspectedBaseComponent.LifeLimit.ToString();
                labelCompntLifeLimitRemains.Text      = baseComponentTypeString + " Life Limit Remain";
                labelCompntLifeLimitRemainsValue.Text = temp2.ToString();
            }

            var lastTransferRecord = inspectedBaseComponent.TransferRecords.GetLast();

            //Наработка компонента на момент установки
            temp2 = lastTransferRecord.OnLifelength;
            labelCompntTCSNonInstallValue.Text = temp2.ToString();

            //Наработка компонента с момента установки и по сей день
            temp.Substract(temp2);
            labelCompntTCSNsinceInstallValue.Text = temp.ToString();

            var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(inspectedBaseComponent.ParentAircraftId);

            //Наработка самолета на сегодня
            temp = parentAircraft != null
                                           ? GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircraft)
                                           : Lifelength.Zero;

            labelAircraftTCSNValue.Text = temp.ToString();

            //Наработка самолета на момент установки детали
            temp = parentAircraft != null
                                           ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(GlobalObjects.ComponentCore.GetBaseComponentById(parentAircraft.AircraftFrameId),
                                                                                                                   lastTransferRecord.TransferDate)
                                           : Lifelength.Zero;

            labelAircraftTCSNonInstallValue.Text = temp.ToString();

            //Обновление таблиц выполнения директив
            //На каждую из директив детали создается отдельная таблица выполнения
            //После каждая таблица помещается в плавающую панель для отображения

            var componentDirectives = new List <ComponentDirective>(_currentComponent.ComponentDirectives.ToArray());

            for (int i = 0; i < componentDirectives.Count; i++)
            {
                var summaryCompliancePerformanceControl = new BaseComponentDirectiveSummaryControl(componentDirectives[i]);

                summaryCompliancePerformanceControl.UpdateInformation();

                _componentDirectivesPerformances.Add(summaryCompliancePerformanceControl);
                flowLayoutPanel_Compliance.Controls.Add(summaryCompliancePerformanceControl);
            }
        }
コード例 #11
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        private void AddBaseDetailToDataset(ComponentListDataSet destinationDataSet)
        {
            if (_reportedAircraft != null)
            {
                return;
            }

            var reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent);

            var manufactureDate = _reportedBaseComponent.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var deliveryDate    = _reportedBaseComponent.DeliveryDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var status          = _reportedBaseComponent.Serviceable ? "Serviceable" : "Unserviceable";
            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      = _reportedBaseComponent.LifeLimit;
            var lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : "";

            var lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : "";

            var lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : "";

            var remain = new Lifelength(lifeLimit);

            remain.Substract(reportAircraftLifeLenght);
            var remainHours = remain.Hours != null?remain.Hours.ToString() : "";

            var remainCycles = remain.Cycles != null?remain.Cycles.ToString() : "";

            var remainDays = remain.Days != null?remain.Days.ToString() : "";

            var installationDate = _reportedBaseComponent.TransferRecords.GetLast().TransferDate;
            //TODO:(Evgenii Babak)  нужно брать наработку с записи о выполнении, а не пересчитывать заново
            var onInstall      = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(_reportedBaseComponent, installationDate);
            var onInstallDate  = installationDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var onInstallHours = onInstall.Hours != null?onInstall.Hours.ToString() : "";

            var onInstallCycles = onInstall.Cycles != null?onInstall.Cycles.ToString() : "";

            var onInstallDays = onInstall.Days != null?onInstall.Days.ToString() : "";

            var sinceInstall = new Lifelength(reportAircraftLifeLenght);

            sinceInstall.Substract(onInstall);
            var sinceInstallHours = sinceInstall.Hours != null?sinceInstall.Hours.ToString() : "";

            var sinceInstallCycles = sinceInstall.Cycles != null?sinceInstall.Cycles.ToString() : "";

            var sinceInstallDays = sinceInstall.Days != null?sinceInstall.Days.ToString() : "";

            var warranty       = _reportedBaseComponent.Warranty;
            var warrantyRemain = new Lifelength(warranty);

            warrantyRemain.Substract(reportAircraftLifeLenght);
            warrantyRemain.Resemble(warranty);
            var warrantyHours = warranty.Hours != null?warranty.Hours.ToString() : "";

            var warrantyCycles = warranty.Cycles != null?warranty.Cycles.ToString() : "";

            var warrantyDays = warranty.Days != null?warranty.Days.ToString() : "";

            var warrantyRemainHours = warrantyRemain.Hours != null?warrantyRemain.Hours.ToString() : "";

            var warrantyRemainCycles = warrantyRemain.Cycles != null?warrantyRemain.Cycles.ToString() : "";

            var warrantyRemainDays = warrantyRemain.Days != null?warrantyRemain.Days.ToString() : "";

            var parentAircaft          = GlobalObjects.AircraftsCore.GetAircraftById(_reportedBaseComponent.ParentAircraftId);
            var aircraftFrame          = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId);
            var aircraftOnInstall      = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, installationDate);
            var aircraftOnInstallHours = aircraftOnInstall.Hours != null?aircraftOnInstall.Hours.ToString() : "";

            var aircraftOnInstallCycles = aircraftOnInstall.Cycles != null?aircraftOnInstall.Cycles.ToString() : "";

            var aircraftOnInstallDays = aircraftOnInstall.Days != null?aircraftOnInstall.Days.ToString() : "";

            var aircraftCurrent       = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircaft);
            var aircraftCurrentCycles = aircraftCurrent.Cycles ?? 0;

            var sinceOverhaul          = Lifelength.Null;
            var lastOverhaulDate       = DateTime.MinValue;
            var lastOverhaulDateString = "";

            #region поиск последнего ремонта и расчет времени, прошедшего с него
            //поиск директив деталей
            var directives = GlobalObjects.ComponentCore.GetComponentDirectives(_reportedBaseComponent, true);
            //поиск директивы ремонта
            var overhauls = directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList();
            //поиск последнего ремонта
            ComponentDirective lastOverhaul = null;
            foreach (ComponentDirective 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(_reportedBaseComponent.ATAChapter.ToString(),
                                                                     _reportedBaseComponent.AvionicsInventory.ToString(),
                                                                     _reportedBaseComponent.PartNumber,
                                                                     _reportedBaseComponent.SerialNumber,
                                                                     _reportedBaseComponent.Model != null ? _reportedBaseComponent.Model.ToString() : "",
                                                                     _reportedBaseComponent.BaseComponentType.ToString(),
                                                                     _reportedBaseComponent.GetParentAircraftRegNumber(),
                                                                     _reportedBaseComponent.TransferRecords.GetLast().Position,
                                                                     _reportedBaseComponent.Manufacturer,
                                                                     manufactureDate,
                                                                     deliveryDate,
                                                                     _reportedBaseComponent.MPDItem,
                                                                     _reportedBaseComponent.Suppliers != null ? _reportedBaseComponent.Suppliers.ToString() : "",
                                                                     status,
                                                                     _reportedBaseComponent.Cost,
                                                                     _reportedBaseComponent.CostOverhaul,
                                                                     _reportedBaseComponent.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 (_forecast == null)
            {
                var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame);
                //TODO:(Evgenii Babak) убрать повторяющийся код при использовании AverageUtilization
                averageUtilizationHours  = (int)averageUtilization.Hours;
                averageUtilizationCycles = (int)averageUtilization.Cycles;
                averageUtilizationType   = averageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month";
            }
            else
            {
                //TODO:(Evgenii Babak) убрать повторяющийся код при использовании AverageUtilization
                averageUtilizationHours  = (int)_forecast.ForecastDatas[0].AverageUtilization.Hours;
                averageUtilizationCycles = (int)_forecast.ForecastDatas[0].AverageUtilization.Cycles;
                averageUtilizationType   =
                    _forecast.ForecastDatas[0].AverageUtilization.SelectedInterval == UtilizationInterval.Dayly ? "Day" : "Month";
            }

            var serialNumber       = parentAircaft.SerialNumber;
            var model              = parentAircaft.Model.ShortName;
            var registrationNumber = parentAircaft.RegistrationNumber;
            var lineNumber         = parentAircaft.LineNumber;
            var variableNumber     = parentAircaft.VariableNumber;

            //destinationDataSet.AircraftDataTable.AddAircraftDataTableRow(serialNumber,
            //                                                             manufactureDate,
            //                                                             aircraftCurrent.ToHoursMinutesFormat(""),
            //                                                             aircraftCurrentCycles,
            //                                                             registrationNumber, model, lineNumber, variableNumber,
            //                                                             averageUtilizationHours, averageUtilizationCycles, averageUtilizationType);
        }
コード例 #12
0
        /// <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 + ')' : "", "", "");
        }
コード例 #13
0
        /// <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);
        }
コード例 #14
0
        /// <summary>
        /// ?????????? ???????? ? ??????? ??????
        /// </summary>
        /// <param name="dataset">???????, ? ??????? ??????????? ??????</param>
        private void AddBaseDetailsToDataSet(OperationTimeDataSet dataset)
        {
            if (_aircraftBaseDetails == null)
            {
                return;
            }

            var frame = _aircraftBaseDetails.FirstOrDefault(bd => bd.BaseComponentType == BaseComponentType.Frame);

            if (frame != null)
            {
                var subs          = frame.Position.Split('-');
                var framePosition = new StringBuilder();
                for (int i = 0; i < subs.Length; i++)
                {
                    if (i == subs.Length - 1)
                    {
                        framePosition.AppendLine(subs[i]);
                    }
                    else
                    {
                        framePosition.AppendLine(subs[i] + '-');
                    }
                }

                var from = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(frame, _from);
                //Lifelength period = GlobalObjects.CasEnvironment.Calculator.GetLifelength(frame, _from, _to);
                var total  = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(frame, _to);
                var period = new Lifelength(total);
                period.Substract(from);
                //res.Substract(GetLifelength(baseDetail, fromDate));
                var onCCheck = _lastCheckRecord != null
                                        ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(frame, _lastCheckRecord.RecordDate)
                                        : Lifelength.Null;

                var sinceLast = onCCheck != null ? total - onCCheck : Lifelength.Null;
                dataset.BaseDetailsTable.AddBaseDetailsTableRow
                    (framePosition.ToString(),
                    frame.SerialNumber,
                    total.TotalMinutes != null ? total.ToHoursMinutesFormat("") : "",
                    total.Cycles != null ? total.Cycles.ToString() : "",
                    sinceLast.TotalMinutes != null ? sinceLast.ToHoursMinutesFormat("") : "",
                    sinceLast.Cycles != null ? sinceLast.Cycles.ToString() : "",
                    period.TotalMinutes != null ? period.ToHoursMinutesFormat("") : "",
                    period.Cycles != null ? period.Cycles.ToString() : "",
                    frame.Model.ToString());
            }

            var engines = _aircraftBaseDetails.Where(bd => bd.BaseComponentType == BaseComponentType.Engine);

            if (engines.Count() > 0)
            {
                var engineNum = 1;
                foreach (BaseComponent engine in engines)
                {
                    var from = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(engine, _from);
                    //Lifelength period = GlobalObjects.CasEnvironment.Calculator.GetLifelength(frame, _from, _to);
                    var total  = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(engine, _to);
                    var period = new Lifelength(total);
                    period.Substract(from);
                    var onCCheck = _lastCheckRecord != null
                                                ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(engine, _lastCheckRecord.RecordDate)
                                                : Lifelength.Null;

                    var sinceLast = onCCheck != null ? total - onCCheck : Lifelength.Null;
                    dataset.BaseDetailsTable.AddBaseDetailsTableRow
                        ("Engine " + engineNum,
                        engine.SerialNumber,
                        total.TotalMinutes != null ? total.ToHoursMinutesFormat("") : "",
                        total.Cycles != null ? total.Cycles.ToString() : "",
                        sinceLast.TotalMinutes != null ? sinceLast.ToHoursMinutesFormat("") : "",
                        sinceLast.Cycles != null ? sinceLast.Cycles.ToString() : "",
                        period.TotalMinutes != null ? period.ToHoursMinutesFormat("") : "",
                        period.Cycles != null ? period.Cycles.ToString() : "",
                        engine.Model.ToString());

                    engineNum++;
                }
            }

            var apu = _aircraftBaseDetails.FirstOrDefault(bd => bd.BaseComponentType == BaseComponentType.Apu);

            if (apu != null)
            {
#if KAC
                var subs      = apu.SerialNumber.Split('-');
                var apuNumber = new StringBuilder();
                for (int i = 0; i < subs.Length; i++)
                {
                    if (i == subs.Length - 1)
                    {
                        apuNumber.AppendLine(subs[i]);
                    }
                    else
                    {
                        apuNumber.AppendLine(subs[i] + '-');
                    }
                }
                var from = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(apu, _from);
                //Lifelength period = GlobalObjects.CasEnvironment.Calculator.GetLifelength(frame, _from, _to);
                var total = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(apu, _to);
                //Lifelength period = new Lifelength(total);
                //period.Substract(from);

                var parentAircraft = GlobalObjects.AircraftsCore.GetAircraftById(apu.ParentAircraftId);
                var period         = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthForPeriod(parentAircraft, _from, _to);
                var calculated     = _currentAircraft.RegistrationNumber == "EX-37401"
                                        ? period
                                        : new Lifelength(period.Days, period.Cycles, Convert.ToInt32(period.Cycles * 60 * 1.3));
                //Lifelength total = GlobalObjects.CasEnvironment.Calculator.GetLifelength(apu, _to);
                var onCCheck = _lastCheckRecord != null
                                        ? GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(apu, _lastCheckRecord.RecordDate)
                                        : Lifelength.Null;

                var sinceLast = onCCheck != null ? total - onCCheck : Lifelength.Null;
                dataset.BaseDetailsTable.AddBaseDetailsTableRow
                    ("APU",
                    apuNumber.ToString(),
                    total.TotalMinutes != null ? total.Hours.ToString() : "",
                    "--",
                    sinceLast.TotalMinutes != null ? sinceLast.Hours.ToString() : "",
                    "--",
                    calculated.TotalMinutes != null ? calculated.Hours.ToString() : "",
                    "--",
                    apu.Model.ToString());
#else
#endif
            }
        }
コード例 #15
0
        /// <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);
        }
コード例 #16
0
        /// <summary>
        /// Добавление директив в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляются данные</param>
        protected virtual void AddDirectivesToDataSet(MaintenanceHistoryDataSet destinationDataSet)
        {
            if (_reportedAircraft == null)
            {
                return;
            }
            var compliance = from item in _reportedDirectives
                             group item by item.NumGroup into compl
                             orderby compl.First().RecordDate descending
                             select compl;

            foreach (IGrouping <int, MaintenanceCheckRecord> grouping in compliance)
            {
                MaintenanceCheckRecord reportedDirective = grouping.First();
                string name = grouping.Aggregate("", (current, g) => current + (g.ParentCheck.Name + " "));

                Lifelength reportAircraftLifeLenght =
                    GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent);
                Lifelength used = new Lifelength(reportAircraftLifeLenght);

                string lastComplianceDate = "", lastComplianceHours = "", lastComplianceCycles = "", lastComplianceDays = "";
                string remarks, references = "";


                remarks              = reportedDirective.Remarks;
                lastComplianceDate   = reportedDirective.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
                lastComplianceCycles = reportedDirective.OnLifelength.Cycles != null
                                               ? reportedDirective.OnLifelength.Cycles.ToString()
                                               : "";

                lastComplianceHours = reportedDirective.OnLifelength.Hours != null
                                               ? reportedDirective.OnLifelength.Hours.ToString()
                                               : "";

                lastComplianceDays = reportedDirective.OnLifelength.Days != null
                                               ? reportedDirective.OnLifelength.Days.ToString()
                                               : "";

                var unusedDays     = reportedDirective.Unused?.Days.ToString() ?? "";
                var unusedHours    = reportedDirective.Unused?.Hours.ToString() ?? "";
                var unusedCycles   = reportedDirective.Unused?.Cycles.ToString() ?? "";
                var overusedDays   = reportedDirective.Overused?.Days.ToString() ?? "";
                var overusedHours  = reportedDirective.Overused?.Hours.ToString() ?? "";
                var overusedCycles = reportedDirective.Overused?.Cycles.ToString() ?? "";

                used.Substract(reportedDirective.OnLifelength);
                destinationDataSet.ItemsTable.AddItemsTableRow(lastComplianceDate,
                                                               reportedDirective.NumGroup,
                                                               reportedDirective.ParentCheck.Schedule ? "SCHEDULE" : "UNSCHEDULE",
                                                               name,
                                                               lastComplianceDays,
                                                               lastComplianceHours,
                                                               lastComplianceCycles,
                                                               unusedDays,
                                                               unusedHours,
                                                               unusedCycles,
                                                               overusedDays,
                                                               overusedHours,
                                                               overusedCycles,
                                                               remarks,
                                                               references);
            }
        }
コード例 #17
0
        /// <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);
        }
コード例 #18
0
        /// <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;
            }
        }
コード例 #19
0
        public void CalculateLifeLength()
        {
            //изменение значения наработки агрегата на момент установки
            if (ComponentTCSNOnInstall.IsNullOrZero())
            {
                return;                                       //разбанить поля
            }
            //if (ComponentCurrentTSNCSN != Lifelength.Null)
            //{
            //    Lifelength tempLifelength = new Lifelength(ComponentCurrentTSNCSN);
            //    tempLifelength.Substract(ComponentTCSNOnInstall);
            //    ComponentTCSI = tempLifelength;
            //}

            Lifelength aircraftCurrentTSN =
                GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength((Aircraft)_currentAircraft);
            Lifelength tempLifelength = null;

            //Расчитывание текущей наработки агрегата
            if (!ComponentTCSI.IsNullOrZero())
            {
                tempLifelength = new Lifelength(ComponentTCSI);
            }
            else if (!AircraftTCSNOnInstall.IsNullOrZero() && _currentAircraft is Aircraft)
            {
                tempLifelength = new Lifelength(aircraftCurrentTSN);
                tempLifelength.Substract(AircraftTCSNOnInstall);
            }

            if (tempLifelength != null && !tempLifelength.IsNullOrZero())
            {
                tempLifelength.Add(ComponentTCSNOnInstall);
                ComponentCurrentTSNCSN = tempLifelength;
            }
            else
            {
                ComponentCurrentTSNCSN = Lifelength.Null;
            }

            //расчет наработки с момента установки
            if (!ComponentTCSNOnInstall.IsNullOrZero() && !ComponentCurrentTSNCSN.IsNullOrZero())
            {
                tempLifelength = new Lifelength(ComponentCurrentTSNCSN);
                tempLifelength.Substract(ComponentTCSNOnInstall);
                ComponentTCSI = tempLifelength;
            }
            else if (!AircraftTCSNOnInstall.IsNullOrZero() && !aircraftCurrentTSN.IsNullOrZero())
            {
                tempLifelength = new Lifelength(aircraftCurrentTSN);
                tempLifelength.Substract(AircraftTCSNOnInstall);
                ComponentTCSI = tempLifelength;
            }
            else
            {
                ComponentTCSI = Lifelength.Null;
            }

            //расчет наработки самолета на момент установки
            if (!ComponentTCSI.IsNullOrZero())
            {
                tempLifelength = new Lifelength(aircraftCurrentTSN);
                tempLifelength.Substract(ComponentTCSI);
                AircraftTCSNOnInstall = tempLifelength;
            }
            else if (!ComponentCurrentTSNCSN.IsNullOrZero() && !ComponentTCSNOnInstall.IsNullOrZero())
            {
                Lifelength temp2 = new Lifelength(ComponentCurrentTSNCSN);
                temp2.Substract(ComponentTCSNOnInstall);
                tempLifelength = new Lifelength(aircraftCurrentTSN);
                tempLifelength.Substract(temp2);
                AircraftTCSNOnInstall = tempLifelength;
            }
            else
            {
                AircraftTCSNOnInstall = Lifelength.Null;
            }
        }
コード例 #20
0
        /// <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");
        }
コード例 #21
0
        /// <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);
        }
コード例 #22
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        private void AddBaseDetailToDataset(LLPDiskSheetDataSet destinationDataSet)
        {
            if (_reportedBaseComponent == null)
            {
                return;
            }

            var reportAircraftLifeLenght = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedBaseComponent);

            var manufactureDate = _reportedBaseComponent.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var deliveryDate    = _reportedBaseComponent.DeliveryDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var status          = _reportedBaseComponent.Serviceable ? "Serviceable" : "Unserviceable";
            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      = _reportedBaseComponent.LifeLimit;
            var lifeLimitHours = lifeLimit.Hours != null?lifeLimit.Hours.ToString() : "";

            var lifeLimitCycles = lifeLimit.Cycles != null?lifeLimit.Cycles.ToString() : "";

            var lifeLimitDays = lifeLimit.Days != null?lifeLimit.Days.ToString() : "";

            var remain = new Lifelength(lifeLimit);

            remain.Substract(reportAircraftLifeLenght);
            var remainHours = remain.Hours != null?remain.Hours.ToString() : "";

            var remainCycles = remain.Cycles != null?remain.Cycles.ToString() : "";

            var remainDays = remain.Days != null?remain.Days.ToString() : "";

            var installationDate = _reportedBaseComponent.TransferRecords.GetLast().TransferDate;
            //TODO:(Evgenii Babak)  нужно брать наработку с записи о перемещении, а не пересчитывать заново
            var onInstall      = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(_reportedBaseComponent, installationDate);
            var onInstallDate  = installationDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var onInstallHours = onInstall.Hours != null?onInstall.Hours.ToString() : "";

            var onInstallCycles = onInstall.Cycles != null?onInstall.Cycles.ToString() : "";

            var onInstallDays = onInstall.Days != null?onInstall.Days.ToString() : "";

            var sinceInstall = new Lifelength(reportAircraftLifeLenght);

            sinceInstall.Substract(onInstall);
            var sinceInstallHours = sinceInstall.Hours != null?sinceInstall.Hours.ToString() : "";

            var sinceInstallCycles = sinceInstall.Cycles != null?sinceInstall.Cycles.ToString() : "";

            var sinceInstallDays = sinceInstall.Days != null?sinceInstall.Days.ToString() : "";

            var warranty       = _reportedBaseComponent.Warranty;
            var warrantyRemain = new Lifelength(warranty);

            warrantyRemain.Substract(reportAircraftLifeLenght);
            warrantyRemain.Resemble(warranty);
            var warrantyHours = warranty.Hours != null?warranty.Hours.ToString() : "";

            var warrantyCycles = warranty.Cycles != null?warranty.Cycles.ToString() : "";

            var warrantyDays = warranty.Days != null?warranty.Days.ToString() : "";

            var warrantyRemainHours = warrantyRemain.Hours != null?warrantyRemain.Hours.ToString() : "";

            var warrantyRemainCycles = warrantyRemain.Cycles != null?warrantyRemain.Cycles.ToString() : "";

            var warrantyRemainDays = warrantyRemain.Days != null?warrantyRemain.Days.ToString() : "";

            var parentAircaft          = GlobalObjects.AircraftsCore.GetAircraftById(_reportedBaseComponent.ParentAircraftId);
            var aircraftFrame          = GlobalObjects.ComponentCore.GetBaseComponentById(parentAircaft.AircraftFrameId);
            var aircraftOnInstall      = GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnEndOfDay(aircraftFrame, installationDate);
            var aircraftOnInstallHours = aircraftOnInstall.Hours != null?aircraftOnInstall.Hours.ToString() : "";

            var aircraftOnInstallCycles = aircraftOnInstall.Cycles != null?aircraftOnInstall.Cycles.ToString() : "";

            var aircraftOnInstallDays = aircraftOnInstall.Days != null?aircraftOnInstall.Days.ToString() : "";

            var aircraftCurrent = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(parentAircaft);

            var sinceOverhaul          = Lifelength.Null;
            var lastOverhaulDate       = DateTime.MinValue;
            var lastOverhaulDateString = "";

            #region поиск последнего ремонта и расчет времени, прошедшего с него
            //поиск директив деталей
            List <ComponentDirective> directives = GlobalObjects.ComponentCore.GetComponentDirectives(_reportedBaseComponent, true);
            //поиск директивы ремонта
            List <ComponentDirective> overhauls = directives.Where(d => d.DirectiveType == ComponentRecordType.Overhaul).ToList();
            //поиск последнего ремонта
            ComponentDirective lastOverhaul = null;
            foreach (ComponentDirective d in directives)
            {
                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(_reportedBaseComponent.ATAChapter.ToString(),
                                                                     _reportedBaseComponent.AvionicsInventory.ToString(),
                                                                     _reportedBaseComponent.PartNumber,
                                                                     _reportedBaseComponent.SerialNumber,
                                                                     _reportedBaseComponent.Model != null ? _reportedBaseComponent.Model.FullName : "",
                                                                     _reportedBaseComponent.BaseComponentType.ToString(),
                                                                     _reportedBaseComponent.GetParentAircraftRegNumber(),
                                                                     _reportedBaseComponent.TransferRecords.GetLast().Position,
                                                                     _reportedBaseComponent.Thrust,
                                                                     manufactureDate,
                                                                     deliveryDate,
                                                                     _reportedBaseComponent.MPDItem,
                                                                     _reportedBaseComponent.Suppliers != null
                                                                        ? _reportedBaseComponent.Suppliers.ToString()
                                                                        : "",
                                                                     status,
                                                                     _reportedBaseComponent.Cost,
                                                                     _reportedBaseComponent.CostOverhaul,
                                                                     _reportedBaseComponent.CostServiceable,
                                                                     lifeLimitHours,
                                                                     lifeLimitCycles,
                                                                     lifeLimitDays,
                                                                     sinceNewHours,
                                                                     sinceNewCycles,
                                                                     sinceNewDays,
                                                                     reportAircraftLifeLenght.ToStrings(),
                                                                     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,
                                                                     sinceOverhaul.ToStrings());
        }
コード例 #23
0
        /// <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 + ')' : "", "", "");
        }