Esempio n. 1
0
        protected virtual void AddForecastToDataSet(DirectivesListDataSet destinationDataSet)
        {
            var avgUtilizationCycles = _forecastData != null ? _forecastData.AverageUtilization.Cycles : 0;
            var avgUtilizationHours  = _forecastData != null ? _forecastData.AverageUtilization.Hours : 0;
            var avgUtilizationType   = _forecastData != null
                                            ? _forecastData.AverageUtilization.SelectedInterval.ToString()
                                            : "";

            var forecastCycles = _forecastData != null
                ? _forecastData.ForecastLifelength.Cycles != null ? (int)_forecastData.ForecastLifelength.Cycles : 0
                : 0;
            var forecastHours = _forecastData != null
                ? _forecastData.ForecastLifelength.Hours != null ? (int)_forecastData.ForecastLifelength.Hours : 0
                : 0;
            var forecastDays = _forecastData != null
                ? _forecastData.ForecastLifelength.Days != null ? (int)_forecastData.ForecastLifelength.Days : 0
                : 0;
            var forecastDate = _forecastData != null
                ? _forecastData.ForecastDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString())
                : "";

            destinationDataSet.ForecastTable.AddForecastTableRow(avgUtilizationCycles,
                                                                 avgUtilizationHours,
                                                                 avgUtilizationType,
                                                                 forecastCycles,
                                                                 forecastHours,
                                                                 forecastDays,
                                                                 forecastDate);
        }
Esempio n. 2
0
 /// <summary>
 /// Добавление директив в таблицу данных
 /// </summary>
 /// <param name="dataset">Таблица, в которую добавляются данные</param>
 protected virtual void AddDirectivesToDataSet(DirectivesListDataSet dataset)
 {
     foreach (var directive in _reportedDirectives)
     {
         AddDirectiveToDataset(directive, dataset);
     }
 }
 /// <summary>
 /// Добавление директив в таблицу данных
 /// </summary>
 /// <param name="dataset">Таблица, в которую добавляются данные</param>
 private void AddDirectivesToDataSet(DirectivesListDataSet dataset)
 {
     foreach (Directive t in _reportedDirectives)
     {
         AddDirectiveToDataset(t, dataset);
     }
 }
Esempio n. 4
0
        protected virtual void AddForecastToDataSet(DirectivesListDataSet destinationDataSet)
        {
            ForecastData fd = _forecast != null?_forecast.GetForecastDataFrame() : null;

            if (fd == null)
            {
                destinationDataSet.ForecastTable.AddForecastTableRow(0,
                                                                     0,
                                                                     "",
                                                                     0,
                                                                     0,
                                                                     0,
                                                                     "");
                return;
            }
            double avgUtilizationCycles = fd.AverageUtilization.Cycles;
            double avgUtilizationHours  = fd.AverageUtilization.Hours;
            string avgUtilizationType   = fd.AverageUtilization.SelectedInterval.ToString();
            int    forecastCycles       = fd.ForecastLifelength.Cycles != null
                                     ? (int)fd.ForecastLifelength.Cycles
                                     : 0;
            int forecastHours = fd.ForecastLifelength.Hours != null
                                    ? (int)fd.ForecastLifelength.Hours
                                    : 0;
            int forecastDays = fd.ForecastLifelength.Days != null
                                   ? (int)fd.ForecastLifelength.Days
                                   : 0;
            string forecastDate = "";

            if (fd.SelectedForecastType == ForecastType.ForecastByDate)
            {
                forecastDate = SmartCore.Auxiliary.Convert.GetDateFormat(fd.ForecastDate);
            }
            else if (fd.SelectedForecastType == ForecastType.ForecastByPeriod)
            {
                forecastDate = SmartCore.Auxiliary.Convert.GetDateFormat(fd.LowerLimit) + " - " +
                               SmartCore.Auxiliary.Convert.GetDateFormat(fd.ForecastDate);
            }
            else if (fd.SelectedForecastType == ForecastType.ForecastByCheck)
            {
                if (fd.NextPerformanceByDate)
                {
                    forecastDate = fd.NextPerformanceString;
                }
                else
                {
                    forecastDate =
                        $"{fd.CheckName}. {SmartCore.Auxiliary.Convert.GetDateFormat(Convert.ToDateTime(fd.NextPerformance.PerformanceDate))}";
                }
            }

            destinationDataSet.ForecastTable.AddForecastTableRow(avgUtilizationCycles,
                                                                 avgUtilizationHours,
                                                                 avgUtilizationType,
                                                                 forecastCycles,
                                                                 forecastHours,
                                                                 forecastDays,
                                                                 forecastDate);
        }
Esempio n. 5
0
        /// <summary>
        /// Построить источник данных (DataSet) для вывода в отчет
        /// </summary>
        /// <returns></returns>
        public virtual DirectivesListDataSet GenerateDataSet()
        {
            var dataset = new DirectivesListDataSet();

            AddBaseDetailToDataset(dataset);
            AddDirectivesToDataSet(dataset);
            AddAdditionalDataToDataSet(dataset);
            AddForecastToDataSet(dataset);
            return(dataset);
        }
Esempio n. 6
0
        /// <summary>
        /// Построить источник данных (DataSet) для вывода в отчет
        /// </summary>
        /// <returns></returns>
        protected virtual DataSet GenerateDataSet()
        {
            DirectivesListDataSet dataset = new DirectivesListDataSet();

            AddAircraftToDataset(dataset);
            AddBaseDetailToDataset(dataset);
            AddDirectivesToDataSet(dataset);
            AddAdditionalDataToDataSet(dataset);
            AddForecastToDataSet(dataset);
            return(dataset);
        }
Esempio n. 7
0
        /// <summary>
        /// Добавление дополнительной информации
        /// </summary>
        /// <param name="destinationDateSet"></param>
        private void AddAdditionalDataToDataSet(DirectivesListDataSet destinationDateSet)
        {
            var firsttitle       = "";
            var discriptiontitle = "";
            var secondtitle      = "";

            var reportFooter         = new GlobalTermsProvider()["ReportFooter"].ToString();
            var reportFooterPrepared = new GlobalTermsProvider()["ReportFooterPrepared"].ToString();
            var reportFooterLink     = new GlobalTermsProvider()["ProductWebsite"].ToString();

            destinationDateSet.AdditionalDataTAble.AddAdditionalDataTAbleRow(_reportTitle, OperatorLogotype, _filterSelection, DateAsOf, firsttitle, discriptiontitle, secondtitle, reportFooter, reportFooterPrepared, _thrust);
        }
Esempio n. 8
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        private void AddAircraftToDataset(DirectivesListDataSet destinationDataSet)
        {
            if (_reportedAircraft == null)
            {
                return;
            }

            Lifelength reportAircraftLifeLenght =
                GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(_reportedAircraft);

            string manufactureDate    = _reportedAircraft.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            string serialNumber       = _reportedAircraft.SerialNumber;
            string model              = _reportedAircraft.Model.ShortName;
            int    sinceNewHours      = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0;
            int    sinceNewCycles     = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0;
            string registrationNumber = _reportedAircraft.RegistrationNumber;
            int    averageUtilizationHours;
            int    averageUtilizationCycles;
            string averageUtilizationType;

            if (_forecast == null)
            {
                var aircraftFrame      = GlobalObjects.ComponentCore.GetBaseComponentById(_reportedAircraft.AircraftFrameId);
                var averageUtilization = GlobalObjects.AverageUtilizationCore.GetAverageUtillization(aircraftFrame);

                averageUtilizationHours  = (int)averageUtilization.Hours;
                averageUtilizationCycles = (int)averageUtilization.Cycles;
                averageUtilizationType   = averageUtilization.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";
            }

            string lineNumber     = _reportedAircraft.LineNumber;
            string variableNumber = _reportedAircraft.VariableNumber;

            destinationDataSet.AircraftDataTable.AddAircraftDataTableRow(serialNumber,
                                                                         manufactureDate,
                                                                         reportAircraftLifeLenght.ToHoursMinutesFormat(""),
                                                                         reportAircraftLifeLenght.Cycles != null && reportAircraftLifeLenght.Cycles != 0
                                                                            ? reportAircraftLifeLenght.Cycles.ToString()
                                                                            : "",
                                                                         registrationNumber, model, lineNumber, variableNumber,
                                                                         averageUtilizationHours, averageUtilizationCycles, averageUtilizationType);
        }
        /// <summary>
        /// Добавление дополнительной информации
        /// </summary>
        /// <param name="destinationDateSet"></param>
        private void AddAdditionalDataToDataSet(DirectivesListDataSet destinationDateSet)
        {
            string firsttitle       = "";
            string discriptiontitle = "";
            string secondtitle      = "";

            if (_directiveType == DirectiveType.AirworthenessDirectives)
            {
                firsttitle       = "FAA AD";
                discriptiontitle = "DESCRIPTION";
                secondtitle      = "SERVICE BULLETIN\n (EO, MJC)";
            }
            if (_directiveType == DirectiveType.EngineeringOrders)
            {
                firsttitle       = "EO";
                secondtitle      = "FAA AD\n (SB)";
                discriptiontitle = "DESCRIPTION";
            }
            if (_directiveType == DirectiveType.SB)
            {
                firsttitle       = "SERVICE BULLETIN";
                secondtitle      = "FAA AD\n (EO, MJC)";
                discriptiontitle = "DESCRIPTION";
            }
            if (_directiveType == DirectiveType.OutOfPhase)
            {
                firsttitle       = "\n ITEM #";
                secondtitle      = "\n (EO, MJC)";
                discriptiontitle = "REQUIREMENT";
            }
            if (_directiveType == DirectiveType.DamagesRequiring)
            {
                firsttitle       = "\n ITEM #";
                secondtitle      = "\n (EO, MJC)";
                discriptiontitle = "DESCRIPTION";
            }

            string reportFooter         = new GlobalTermsProvider()["ReportFooter"].ToString();
            string reportFooterPrepared = new GlobalTermsProvider()["ReportFooterPrepared"].ToString();
            string reportFooterLink     = new GlobalTermsProvider()["ProductWebsite"].ToString();

            destinationDateSet.AdditionalDataTAble.AddAdditionalDataTAbleRow(_reportTitle, OperatorLogotype, _filterSelection, _dateAsOf, firsttitle, discriptiontitle, secondtitle, reportFooter, reportFooterPrepared, reportFooterLink);
        }
        /// <summary>
        /// Добавление дополнительной информации
        /// </summary>
        /// <param name="destinationDateSet"></param>
        protected override void AddAdditionalDataToDataSet(DirectivesListDataSet destinationDateSet)
        {
            string firsttitle       = "";
            string discriptiontitle = "";
            string secondtitle      = "";

            if (DirectiveType == SmartCore.Entities.Dictionaries.DirectiveType.AirworthenessDirectives)
            {
                firsttitle       = "AD #";
                discriptiontitle = "Title";
                secondtitle      = "Reference";
            }
            if (DirectiveType == SmartCore.Entities.Dictionaries.DirectiveType.EngineeringOrders)
            {
                firsttitle       = "EO";
                secondtitle      = "AD\n (SB)";
                discriptiontitle = "Title";
            }
            if (DirectiveType == SmartCore.Entities.Dictionaries.DirectiveType.SB)
            {
                firsttitle       = "SB #";
                secondtitle      = "Reference";
                discriptiontitle = "Title";
            }
            if (DirectiveType == SmartCore.Entities.Dictionaries.DirectiveType.OutOfPhase)
            {
                firsttitle       = "\n ITEM #";
                secondtitle      = "\n (EO, MJC)";
                discriptiontitle = "REQUIREMENT";
            }
            if (DirectiveType == SmartCore.Entities.Dictionaries.DirectiveType.DamagesRequiring)
            {
                firsttitle       = "\n ITEM #";
                secondtitle      = "\n (EO, MJC)";
                discriptiontitle = "DESCRIPTION";
            }
            string reportFooter         = new GlobalTermsProvider()["ReportFooter"].ToString();
            string reportFooterPrepared = new GlobalTermsProvider()["ReportFooterPrepared"].ToString();
            string reportFooterLink     = new GlobalTermsProvider()["ProductWebsite"].ToString();

            destinationDateSet.AdditionalDataTAble.AddAdditionalDataTAbleRow(_reportTitle, _operatorLogotype, _filterSelection, DateAsOf, firsttitle, secondtitle, discriptiontitle, reportFooter, reportFooterPrepared, reportFooterLink);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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 + ')' : "", "", "");
        }
Esempio n. 14
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);
        }
        /// <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 + ')' : "", "", "");
        }