Example #1
0
        /// <summary>
        /// Добавление дополнительной информации
        /// </summary>
        /// <param name="destinationDateSet"></param>
        private void AddAdditionalDataToDataSet(MaintenancePlanDataSet destinationDateSet)
        {
            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, reportFooter, reportFooterPrepared, reportFooterLink);
        }
Example #2
0
        protected virtual void AddForecastToDataSet(MaintenancePlanDataSet 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);
        }
Example #3
0
        /// <summary>
        /// Построить источник данных (DataSet) для вывода в отчет
        /// </summary>
        /// <returns></returns>
        protected virtual DataSet GenerateDataSet()
        {
            MaintenancePlanDataSet dataset = new MaintenancePlanDataSet();

            AddAircraftToDataset(dataset);
            AddDirectivesToDataSet(dataset);
            AddAdditionalDataToDataSet(dataset);
            AddForecastToDataSet(dataset);
            return(dataset);
        }
Example #4
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        private void AddAircraftToDataset(MaintenancePlanDataSet destinationDataSet)
        {
            if (_reportedAircraft == null)
            {
                destinationDataSet.AircraftDataTable.AddAircraftDataTableRow("", "", -1, -1,
                                                                             "", "", "", "",
                                                                             -1, -1, "");
                return;
            }

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

            var    manufactureDate    = _reportedAircraft.ManufactureDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
            var    serialNumber       = _reportedAircraft.SerialNumber;
            var    model              = _reportedAircraft.Model.ToString();
            var    sinceNewHours      = reportAircraftLifeLenght.Hours != null ? (int)reportAircraftLifeLenght.Hours : 0;
            var    sinceNewCycles     = reportAircraftLifeLenght.Cycles != null ? (int)reportAircraftLifeLenght.Cycles : 0;
            var    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";
            }

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

            destinationDataSet.AircraftDataTable.AddAircraftDataTableRow(serialNumber,
                                                                         manufactureDate,
                                                                         sinceNewHours,
                                                                         sinceNewCycles,
                                                                         registrationNumber, model, lineNumber, variableNumber,
                                                                         averageUtilizationHours, averageUtilizationCycles, averageUtilizationType);
        }
Example #5
0
        /// <summary>
        /// Добавление директив в таблицу данных
        /// </summary>
        /// <param name="dataset">Таблица, в которую добавляются данные</param>
        protected virtual void AddDirectivesToDataSet(MaintenancePlanDataSet dataset)
        {
            //группировка по родительскому самолету
            IEnumerable <IGrouping <Aircraft, BaseEntityObject> > groupByAircraft =
                _reportedDirectives.GroupBy(GlobalObjects.AircraftsCore.GetParentAircraft)
                .OrderBy(g => g.Key.ToString() + " " + g.Key.Model.ToString());

            foreach (IGrouping <Aircraft, BaseEntityObject> byAircraft in groupByAircraft)
            {
                IEnumerable <IGrouping <DateTime, BaseEntityObject> > groupedItems =
                    byAircraft.GroupBy(GetDate)
                    .OrderBy(g => g.Key);

                //сбор всех китов ВС в одну коллекцию
                List <AbstractAccessory> aircraftKits =
                    byAircraft.Select(ba => ba)
                    .Select(GetParent)
                    .Where(i => i is IKitRequired)
                    .SelectMany(i => ((IKitRequired)i).Kits)
                    .Cast <AbstractAccessory>()
                    .ToList();

                foreach (IGrouping <DateTime, BaseEntityObject> groupedItem in groupedItems)
                {
                    //Группировка элементов по датам выполнения
                    DateTime dateTime = groupedItem.Key.Date;
                    //Формирование первой части названия группы, состоящей из даты выполнения
                    string temp      = "";
                    string kitString = "";
                    double manHours  = 0;
                    //Собрание всех выполнений на данную дату в одну коллекцию
                    IEnumerable <BaseEntityObject> performances = groupedItem.Select(lvi => lvi).ToArray();
                    //Собрание всех КИТов на данную дату в одну коллекцию
                    IEnumerable <AccessoryRequired> kits =
                        performances.Select(GetParent)
                        .Where(i => i is IKitRequired)
                        .SelectMany(i => ((IKitRequired)i).Kits);
                    IEnumerable <IGrouping <string, AccessoryRequired> > groupByType = kits.GroupBy(GetAccessoryTypeString);
                    foreach (IGrouping <string, AccessoryRequired> grouping in groupByType)
                    {
                        if (!string.IsNullOrEmpty(kitString))
                        {
                            kitString += Environment.NewLine;
                        }
                        kitString += grouping.Key + Environment.NewLine;

                        kitString =
                            grouping.Select(g => g)
                            .Distinct(new AccessoryRequired())
                            .Aggregate(kitString, (current, kit) => current + (kit.ToString() + "; "));
                    }
                    //Добавление в название присутствующих на данную дату чеков программы обслуживания
                    IEnumerable <BaseEntityObject> maintenanceCheckPerformances =
                        performances.Where(np => GetParent(np) is MaintenanceCheck);

                    foreach (BaseEntityObject mcp in maintenanceCheckPerformances)
                    {
                        if (mcp is MaintenanceNextPerformance)
                        {
                            MaintenanceNextPerformance mnp = mcp as MaintenanceNextPerformance;

                            temp += mnp.PerformanceGroup.GetGroupName();
                            if (byAircraft.Key != null && byAircraft.Key.MSG < MSG.MSG3)
                            {
                                temp += "( " + mnp.PerformanceGroup.ToStringCheckNames() + ")";
                            }
                        }
                        else if (mcp is NextPerformance)
                        {
                            NextPerformance np = mcp as NextPerformance;
                            temp += ((MaintenanceCheck)np.Parent).Name;
                        }
                        else if (mcp is MaintenanceCheckRecord)
                        {
                            MaintenanceCheckRecord mcr = mcp as MaintenanceCheckRecord;
                            temp += string.IsNullOrEmpty(mcr.ComplianceCheckName)
                                ? mcr.ParentCheck.Name
                                : mcr.ComplianceCheckName;
                        }
                        else if (mcp is MaintenanceCheck)
                        {
                            MaintenanceCheck mc = (MaintenanceCheck)mcp;
                            if (mc.Grouping)
                            {
                                MaintenanceNextPerformance mnp =
                                    mc.GetNextPergormanceGroupWhereCheckIsSenior();
                                if (mnp != null)
                                {
                                    temp += mnp.PerformanceGroup.GetGroupName();
                                }
                                else
                                {
                                    temp += mc.Name;
                                }
                            }
                            else
                            {
                                temp += mc.Name;
                            }
                        }
                        temp += " ";
                    }
                    IEnumerable <IBaseEntityObject> allDirectives = performances.Select(GetParent).ToArray();
                    //Добавление в название присутствующих на данную дату директив летной годности
                    IEnumerable <Directive> directivesPerformances = allDirectives.OfType <Directive>().ToArray();
                    if (directivesPerformances.Any())
                    {
                        IEnumerable <IGrouping <DirectiveType, Directive> > groupByDirectiveType =
                            directivesPerformances.GroupBy(d => d.DirectiveType);

                        foreach (IGrouping <DirectiveType, Directive> grouping in groupByDirectiveType)
                        {
                            if (!string.IsNullOrEmpty(temp))
                            {
                                temp += Environment.NewLine;
                            }
                            temp += grouping.Key.ShortName + " " + Environment.NewLine;

                            foreach (Directive ad in grouping)
                            {
                                temp += ad.Title + " § " + ad.Paragraph + " " + ad.WorkType;
                                temp += "; ";
                            }
                        }

                        manHours += directivesPerformances.Sum(dp => dp.ManHours);
                    }

                    //Добавление в название присутствующих на данную дату компонентов или задач по ним
                    IEnumerable <IBaseEntityObject> componentPerformances =
                        allDirectives.Where(np => np is Component || np is ComponentDirective).ToArray();
                    if (componentPerformances.Any())
                    {
                        if (!string.IsNullOrEmpty(temp))
                        {
                            temp += Environment.NewLine;
                        }
                        temp += "Component" + Environment.NewLine;

                        foreach (IBaseEntityObject componentPerformance in componentPerformances)
                        {
                            Component d;
                            if (componentPerformance is ComponentDirective)
                            {
                                ComponentDirective dd = (ComponentDirective)componentPerformance;
                                d = ((ComponentDirective)componentPerformance).ParentComponent;
                                if (d != null)
                                {
                                    temp += "P/N:" + d.PartNumber + " S/N:" + d.SerialNumber + " " + dd.DirectiveType;
                                }
                                else
                                {
                                    temp += dd.DirectiveType;
                                }
                                manHours += dd.ManHours;

                                if (dd.DirectiveType == ComponentRecordType.Remove ||
                                    dd.DirectiveType == ComponentRecordType.Discard ||
                                    dd.DirectiveType == ComponentRecordType.Overhaul)
                                {
                                    //типом работ является удаление или уничтожение компонента

                                    //Добавление в коллекцию Китов ВС данного компонента,
                                    //т.к. его необходимо будет приобрести
                                    aircraftKits.Add(d);
                                }
                            }
                            else
                            {
                                d = componentPerformance as Component;
                                if (d != null)
                                {
                                    temp     += "P/N:" + d.PartNumber + " S/N:" + d.SerialNumber + " Discard";
                                    manHours += d.ManHours;
                                    //Добавление в коллекцию Китов ВС данного компонента,
                                    //т.к. его необходимо будет приобрести
                                    aircraftKits.Add(d);
                                }
                            }
                            temp += "; ";
                        }
                    }
                    //Добавление в название присутствующих на данную дату MPD
                    //Вывод только тех MPD что не привязаны к чекам
                    IEnumerable <MaintenanceDirective> mpdPerformances =
                        allDirectives.OfType <MaintenanceDirective>().ToArray();
                    if (mpdPerformances.Any())
                    {
                        if (!string.IsNullOrEmpty(temp))
                        {
                            temp += Environment.NewLine;
                        }
                        temp += "MPD " + Environment.NewLine;

                        foreach (MaintenanceDirective mpd in mpdPerformances)
                        {
                            temp     += mpd.TaskNumberCheck + " " + mpd.WorkType.ShortName + "; ";
                            manHours += mpd.ManHours;
                        }
                    }
                    dataset.ItemsTable.AddItemsTableRow("",
                                                        "",
                                                        temp,
                                                        dateTime,
                                                        manHours,
                                                        0,
                                                        kitString,
                                                        byAircraft.Key != null ? byAircraft.Key + " " + byAircraft.Key.Model : "Unk");
                }


                IEnumerable <IGrouping <Product, AbstractAccessory> > products =
                    aircraftKits.GroupBy(ak => ak.Product ??
                                         new Product {
                    GoodsClass  = ak.GoodsClass,
                    Standart    = ak.Standart,
                    PartNumber  = ak.ParentString,
                    Description = ak.Description
                }
                                         );
                foreach (IGrouping <Product, AbstractAccessory> product in products)
                {
                    string type             = GetAccessoryTypeString(product.First());
                    double quantity         = 0;
                    double totalProductCost = 0;

                    if (product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.Tools) ||
                        product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ControlTestEquipment))
                    {
                        quantity         = product.Max(p => p.Quantity);
                        totalProductCost = 0;
                    }
                    else if (product.Key.GoodsClass.IsNodeOrSubNodeOf(GoodsClass.ComponentsAndParts))
                    {
                        foreach (AbstractAccessory accessoryRequired in product)
                        {
                            int qty = accessoryRequired.Quantity < 1 ? 1 : (int)accessoryRequired.Quantity;
                            quantity         += qty;
                            totalProductCost += (qty * accessoryRequired.CostNew);
                        }
                    }
                    else
                    {
                        foreach (AbstractAccessory accessoryRequired in product)
                        {
                            quantity         += accessoryRequired.Quantity;
                            totalProductCost += (accessoryRequired.Quantity * accessoryRequired.CostNew);
                        }
                    }

                    dataset.KitsTable.AddKitsTableRow(product.Key.ToString(),
                                                      quantity,
                                                      totalProductCost,
                                                      byAircraft.Key != null ? byAircraft.Key + " " + byAircraft.Key.Model : "Unk",
                                                      type);
                }
            }
        }