Beispiel #1
0
        public override void DisposeScreen()
        {
            CancelAsync();

            AnimatedThreadWorker.Dispose();

            if (_itemPrintReportGeneralData != null)
            {
                _itemPrintReportGeneralData.Dispose();
            }
            if (_itemPrintReportTechnicalCondition != null)
            {
                _itemPrintReportTechnicalCondition.Dispose();
            }
            if (_buttonPrintMenuStrip != null)
            {
                _buttonPrintMenuStrip.Dispose();
            }


            if (_preResult != null)
            {
                _preResult.Clear();
                _preResult = null;
            }
            Dispose(true);
        }
Beispiel #2
0
        /// <summary>
        /// Возвращает чеки которые нужно выполнить на назначенный ресурс lifeLenghtSourcе
        /// если вернет null то значит входные данные не верны
        /// </summary>
        /// <param name="checkInput"></param>
        /// <param name="schedule"></param>
        /// <param name="lifeLenghtSource"></param>
        /// <returns></returns>
        public static MaintenanceCheckGroupCollection GetFirstCheckBySource(this IEnumerable <MaintenanceCheck> checkInput, bool schedule, int?lifeLenghtSource)
        {
            //if (lifeLenghtSource == null || lifeLenghtSource.Value == 0) return null;
            if (lifeLenghtSource == null)
            {
                return(null);
            }
            //сортировка коллекции по типу Shedule;
            MaintenanceCheckCollection sourceCollection = new MaintenanceCheckCollection(checkInput.Where(c => c.Schedule == schedule).ToList());
            //поиск минимального шага
            int?minStep = sourceCollection.FindMinStep(schedule);

            if (minStep == null)
            {
                return(null);
            }

            List <MaintenanceCheckGroupByType> checksGroups = new List <MaintenanceCheckGroupByType>(sourceCollection.GroupingCheckByType(minStep, schedule));

            if (checksGroups.Count == 0)
            {
                return(null);
            }

            return(GetCheckBySource(checksGroups, lifeLenghtSource, minStep, schedule));
        }
Beispiel #3
0
        /// <summary>
        /// Перезагружает данные с БД
        /// </summary>
        public void UpdateInformation(MaintenanceCheckCollection liminationItems, Aircraft aircraft, List <MaintenanceDirective> maintenanceDirectives)
        {
            _currentAircraft = aircraft;

            comboBoxCheckNaming.SelectedIndexChanged -= ComboBoxCheckNamingSelectedIndexChanged;
            checkedListBoxItems.SelectedIndexChanged -= CheckedListBoxItemsSelectedIndexChanged;
            comboBoxSchedule.SelectedIndexChanged    -= ComboBoxScheduleSelectedIndexChanged;

            comboBoxCheckNaming.SelectedIndex = _currentAircraft.MaintenanceProgramCheckNaming ? 1 : 0;
            comboBoxSchedule.SelectedIndex    = _currentAircraft.Schedule ? 0 : 1;
            checkedListBoxItems.Items.Clear();
            listViewBindedTasks.ItemListView.Items.Clear();
            listViewTasksForSelect.ItemListView.Items.Clear();

            CheckItems     = liminationItems;
            _allDirectives = maintenanceDirectives;
            _mpdForSelect  = _allDirectives.Where(mpd => mpd.MaintenanceCheck == null).ToList();
            listViewTasksForSelect.SetItemsArray(_mpdForSelect.ToArray());

            FillCheck();
            GetMaintenanceDirectivesIntervals();
            ListViewMaintenanceChecksSelectedIndexChanged(null, null);

            comboBoxCheckNaming.SelectedIndexChanged += ComboBoxCheckNamingSelectedIndexChanged;
            checkedListBoxItems.SelectedIndexChanged += CheckedListBoxItemsSelectedIndexChanged;
            comboBoxSchedule.SelectedIndexChanged    += ComboBoxScheduleSelectedIndexChanged;
        }
Beispiel #4
0
        /// <summary>
        /// Возвращает группу следующих чеков заданного типа, который должны быть выполнены до назначенного ресурса lifeLenghtSourcе
        /// если вернет null то значит входные данные неверны
        /// </summary>
        /// <param name="checkInput"></param>
        /// <param name="lastComplianceCheck"></param>
        /// <param name="lifeLenghtSource"></param>
        /// <returns></returns>
        public static MaintenanceCheckGroupByType GetNextCheckBySourceDifference(this IEnumerable <MaintenanceCheck> checkInput, MaintenanceCheck lastComplianceCheck, int?lifeLenghtSource)
        {
            if (lifeLenghtSource == null || lifeLenghtSource.Value == 0 || lastComplianceCheck == null)
            {
                return(null);
            }
            //сортировка коллекции по типу Shedule;
            MaintenanceCheckCollection sourceCollection =
                new MaintenanceCheckCollection(checkInput.Where(c => c.Schedule == lastComplianceCheck.Schedule).ToList());
            //поиск минимального шага
            int?minStep = lastComplianceCheck.Interval.Days;

            if (minStep == null)
            {
                return(null);
            }

            List <MaintenanceCheckGroupByType> checksGroups =
                new List <MaintenanceCheckGroupByType>(sourceCollection.GroupingCheckByType(minStep, lastComplianceCheck.Schedule));

            if (checksGroups.Count == 0)
            {
                return(null);
            }

            return(GetCheckPacketBySource(checksGroups, lifeLenghtSource, minStep, lastComplianceCheck));
        }
Beispiel #5
0
        protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                return;
            }
            if (_preResult == null)
            {
                return;
            }
            if (_checkItems == null)
            {
                _checkItems = new MaintenanceCheckCollection();
            }
            _checkItems.Clear();
            _checkItems.AddRange(_preResult.ToArray());
            _preResult.Clear();

            statusControl.Aircraft       = CurrentAircraft;
            statusControl.ConditionState = e.Result as ConditionState ?? ConditionState.NotEstimated;

            maintenanceSummaryControl1.UpdateInformation(_checkItems, CurrentAircraft, CurrentAircraft.Schedule);
            //обновление главной информацию по директиве
            maintenanceLimitationControl1.UpdateInformation(_checkItems, CurrentAircraft, _maintenanceDirectives);
            //обновление информации подзадач директивы
            maintenancePerformanceControl1.Reload(_checkItems, CurrentAircraft);
            //обновление информации об выполнении директивы
            complianceControl.Reload(_checkItems, CurrentAircraft, CurrentAircraft.Schedule);
        }
Beispiel #6
0
        /// <summary>
        /// Добавляется элемент в таблицу данных
        /// </summary>
        /// <param name="destinationDataSet">Таблица, в которую добавляется элемент</param>
        private void AddChecksToDataset(AircraftGeneralDataDataSet destinationDataSet)
        {
            if (_reportedAircraft == null)
            {
                return;
            }
            var mc             = GlobalObjects.MaintenanceCore.GetMaintenanceCheck(_reportedAircraft, _reportedAircraft.Schedule);
            var aircraftChecks = new MaintenanceCheckCollection(mc);

            GlobalObjects.MaintenanceCheckCalculator.GetNextPerformanceGroup(aircraftChecks, _reportedAircraft.Schedule);
            foreach (object o in GlobalObjects.CasEnvironment.GetDictionary <MaintenanceCheckType>())
            {
                var checkType = o as MaintenanceCheckType;
                if (checkType != null)
                {
                    var lastComplianceGroups =
                        aircraftChecks.GetLastComplianceCheckGroup(_reportedAircraft.Schedule, _reportedAircraft.ItemId,
                                                                   true, LifelengthSubResource.Hours,
                                                                   checkType);

                    if (lastComplianceGroups == null || lastComplianceGroups.Checks.Count == 0)
                    {
                        continue;
                    }
                    var maxCheck       = lastComplianceGroups.GetMaxIntervalCheck();
                    var minCheck       = lastComplianceGroups.GetMinIntervalCheck();
                    var repeatInterval = minCheck.Interval;
                    //расчет остатка от выполнения с даты производтсва
                    var lastComplianceDate = maxCheck.LastPerformance.RecordDate.ToString(new GlobalTermsProvider()["DateFormat"].ToString());
                    var lastCompliance     = maxCheck.LastPerformance.OnLifelength;
                    var remains            = minCheck.Remains;
                    var condition          = minCheck.Condition ?? ConditionState.NotEstimated;
                    destinationDataSet.MaintenanceTable.AddMaintenanceTableRow(maxCheck.Name,
                                                                               repeatInterval.Days != null ? repeatInterval.Days.ToString() : "",
                                                                               repeatInterval.Hours != null ? repeatInterval.Hours.ToString() : "",
                                                                               repeatInterval.Cycles != null ? repeatInterval.Cycles.ToString() : "",
                                                                               lastComplianceDate,
                                                                               lastCompliance.Hours != null ? lastCompliance.Hours.ToString() : "",
                                                                               lastCompliance.Cycles != null ? lastCompliance.Cycles.ToString() : "",
                                                                               remains.Days != null ? remains.Days.ToString() : "",
                                                                               remains.Hours != null ? remains.Hours.ToString() : "",
                                                                               remains.Cycles != null ? remains.Cycles.ToString() : "",
                                                                               condition.ToString());
                }
            }
        }
        ///<summary>
        ///</summary>
        public void Reload(MaintenanceCheckCollection checkItems, Aircraft curentAircraft, bool schedule)
        {
            _currentAircraft = curentAircraft;
            CheckItems       = checkItems;
            Schedule         = schedule;
            _allCompliance   = new List <MaintenanceCheckRecord>();

            listViewCompliance.Items.Clear();

            foreach (MaintenanceCheck check in checkItems)
            {
                if (check.PerformanceRecords != null)
                {
                    foreach (MaintenanceCheckRecord item in check.PerformanceRecords)
                    {
                        item.ParentCheck = check;
                        _allCompliance.Add(item);
                    }
                }
            }

            UpdateInformation();
        }
Beispiel #8
0
        /// <summary>
        /// Возвращает чеки которые нужно выполнить на следующем шаге(должен быть выполнен хотя бы один шаг)
        /// если вернет null то значит входные данные не верны
        /// </summary>
        /// <param name="checkInput"></param>
        /// <param name="schedule"></param>
        /// <returns></returns>
        public static MaintenanceCheckGroupCollection GetNextCheckByLastCompliane(this IEnumerable <MaintenanceCheck> checkInput, bool schedule)
        {
            //сортировка коллекции по типу Shedule;
            MaintenanceCheckCollection sourceCollection = new MaintenanceCheckCollection(checkInput.Where(c => c.Schedule == schedule).ToList());
            //поиск минимального шага
            int?minStep = sourceCollection.FindMinStep(schedule);

            if (minStep == null)
            {
                return(null);
            }

            List <MaintenanceCheckGroupByType> checksGroups = new List <MaintenanceCheckGroupByType>(sourceCollection.GroupingCheckByType(minStep, schedule));

            if (checksGroups.Count == 0)
            {
                return(null);
            }

            return(schedule
                                ? GetNextCheckSchedule(checkInput, checksGroups, minStep)
                                : GetNextCheckUnschedule(checkInput, checksGroups, minStep));
        }
        ///<summary>
        ///</summary>
        ///<param name="checkItems"></param>
        ///<param name="aircraft"></param>
        ///<param name="schedule"></param>
        public void UpdateInformation(MaintenanceCheckCollection checkItems,
                                      Aircraft aircraft,
                                      bool schedule)
        {
            CheckItems = checkItems;
            Schedule   = schedule;
            _complianceGroupCollection = CheckItems.GetNextComplianceCheckGroups(Schedule).OrderBy(GetNextComplianceDate);
            TsnCsn = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(aircraft);

            listViewLastCheck.Items.Clear();
            listViewNextCheck.Items.Clear();

            if (CheckItems.Count == 0)
            {
                return;
            }

            if (!BackGroundWorker.IsBusy)
            {
                BackGroundWorker.RunWorkerAsync();
            }
            List <MaintenanceCheck> orderedBySchedule =
                checkItems.OrderBy(c => c.Schedule)
                .OrderByDescending(c => c.Grouping)
                .OrderBy(c => c.Resource)
                .ToList();

            List <MaintenanceCheckGroupByType> checkGroups = new List <MaintenanceCheckGroupByType>();

            foreach (MaintenanceCheck check in orderedBySchedule)
            {
                MaintenanceCheckGroupByType group = checkGroups
                                                    .FirstOrDefault(g => g.Schedule == check.Schedule &&
                                                                    g.Grouping == check.Grouping &&
                                                                    g.Resource == check.Resource);
                if (group != null)
                {
                    group.Checks.Add(check);
                }
                else
                {
                    group = new MaintenanceCheckGroupByType(check.Schedule)
                    {
                        Grouping = check.Grouping,
                        Resource = check.Resource
                    };
                    group.Checks.Add(check);
                    checkGroups.Add(group);
                }
            }

            List <MaintenanceProgramControl> mpcs =
                flowLayoutPanel1.Controls.OfType <MaintenanceProgramControl>().ToList();

            for (int j = 0; j < mpcs.Count; j++)
            {
                if (j >= checkGroups.Count)
                {
                    //Если кол-во контролов превышает кол-во групп чеков
                    //то необходимо убрать лишние контролы
                    flowLayoutPanel1.Controls.Remove(mpcs[j]);
                    continue;
                }

                mpcs[j].SetParameters(checkGroups[j].Checks,
                                      checkGroups[j].Schedule,
                                      checkGroups[j].Grouping,
                                      checkGroups[j].Resource);
            }

            for (int j = mpcs.Count; j < checkGroups.Count; j++)
            {
                MaintenanceProgramControl mpc =
                    new MaintenanceProgramControl(checkGroups[j].Checks,
                                                  checkGroups[j].Schedule,
                                                  checkGroups[j].Grouping,
                                                  checkGroups[j].Resource)
                {
                    Extended = false
                };
                flowLayoutPanel1.Controls.Add(mpc);
                flowLayoutPanel1.Controls.SetChildIndex(mpc, j);
            }

            mpcs = flowLayoutPanel1.Controls.OfType <MaintenanceProgramControl>().ToList();
            if (mpcs.Count == 1)
            {
                mpcs[0].EnableExtendedControl = false;
            }
            else if (mpcs.Count >= 1)
            {
                mpcs[0].EnableExtendedControl = true;
            }

            maintenancePerformanceControl1.Reload(checkItems, aircraft);
        }
        ///<summary>
        ///</summary>
        ///<param name="checkItems"></param>
        ///<param name="aircraftDocuments"></param>
        ///<param name="aircraft"></param>
        ///<param name="schedule"></param>
        public void UpdateInformation(MaintenanceCheckCollection checkItems,
                                      IEnumerable <Document> aircraftDocuments,
                                      Aircraft aircraft,
                                      bool schedule)
        {
            _aircraftDocuments.Clear();
            _aircraftDocuments.AddRange(aircraftDocuments);
            _checkItems                = checkItems;
            _schedule                  = schedule;
            _currentAircraft           = aircraft;
            _complianceGroupCollection = _checkItems.GetNextComplianceCheckGroups(_schedule).OrderBy(c => c.GetNextComplianceDate());
            _aircraftLifelength        = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(aircraft);

            labelMSGValue.Text                       = aircraft.MSG.ToString();
            labelManufactureDateValue.Text           = SmartCore.Auxiliary.Convert.GetDateFormat(aircraft.ManufactureDate);
            labelOwnerValue.Text                     = aircraft.Owner;
            labelOperatorValue.Text                  = GlobalObjects.CasEnvironment.Operators.First(o => o.ItemId == _currentAircraft.OperatorId).Name;
            labelAircraftTypeCertificateNoValue.Text = aircraft.TypeCertificateNumber;
            labelCurrentValue.Text                   = _aircraftLifelength.ToHoursMinutesAndCyclesFormat("FH", "FC");

            labelBasicEmptyWeightValue.Text            = aircraft.BasicEmptyWeight.ToString();
            labelBasicEmptyWeightCargoConfigValue.Text = aircraft.BasicEmptyWeightCargoConfig.ToString();
            labelCargoCapacityContainerValue.Text      = aircraft.CargoCapacityContainer;
            labelCruiseValue.Text                = aircraft.Cruise;
            labelCruiseFuelFlowValue.Text        = aircraft.CruiseFuelFlow;
            labelFuelCapacityValue.Text          = aircraft.FuelCapacity;
            labelMaxCruiseAltitudeValue.Text     = aircraft.MaxCruiseAltitude;
            labelMaxLandingWeightValue.Text      = aircraft.MaxLandingWeight.ToString();
            labelMaxPayloadValue.Text            = aircraft.MaxPayloadWeight.ToString();
            labelMaxTakeOffCrossWeightValue.Text = aircraft.MaxTakeOffCrossWeight.ToString();
            labelMaxZeroFuelWeightValue.Text     = aircraft.MaxZeroFuelWeight.ToString();
            labelMaxTaxiWeightValue.Text         = aircraft.MaxTaxiWeight.ToString();
            labelOpertionalEmptyWeightValue.Text = aircraft.OperationalEmptyWeight.ToString();
            labelCockpitSeatingValue.Text        = aircraft.CockpitSeating;
            labelGalleysValue.Text               = aircraft.Galleys;
            labelLavatoryValue.Text              = aircraft.Lavatory;
            labelSeatingEconomyValue.Text        = aircraft.SeatingEconomy.ToString();
            labelSeatingBusinessValue.Text       = aircraft.SeatingBusiness.ToString();
            labelSeatingFirstValue.Text          = aircraft.SeatingFirst.ToString();
            labelOvenValue.Text          = aircraft.Oven;
            labelBoilerValue.Text        = aircraft.Boiler;
            labelAirStairDoorsValue.Text = aircraft.AirStairsDoors;

            var aircraftEquipment = _currentAircraft.AircraftEquipments.Where(a => a.AircraftEquipmetType == AircraftEquipmetType.Equipmet);
            var aircraftApproval  = _currentAircraft.AircraftEquipments.Where(a => a.AircraftEquipmetType == AircraftEquipmetType.TapeOfOperationApproval);

            var row = 4;

            foreach (var equipmentse in aircraftApproval)
            {
                var labelTitle = new Label
                {
                    Text      = equipmentse.AircraftOtherParameter + " :",
                    Font      = new Font("Verdana", 14, GraphicsUnit.Pixel),
                    ForeColor = Color.FromArgb(122, 122, 122),
                    Width     = 150
                };
                var labelValue = new Label
                {
                    Text      = equipmentse.Description,
                    Font      = new Font("Verdana", 14, GraphicsUnit.Pixel),
                    ForeColor = Color.FromArgb(122, 122, 122),
                    Width     = 150
                };
                row++;
                tableLayoutPanelMain.Controls.Add(labelTitle, 2, row);
                tableLayoutPanelMain.Controls.Add(labelValue, 3, row);
            }

            row = 4;
            foreach (var equipmentse in aircraftEquipment)
            {
                var labelTitle = new Label
                {
                    Text      = equipmentse.AircraftOtherParameter + " :",
                    Font      = new Font("Verdana", 14, GraphicsUnit.Pixel),
                    ForeColor = Color.FromArgb(122, 122, 122),
                    Width     = 150
                };
                var labelValue = new Label
                {
                    Text      = equipmentse.Description,
                    Font      = new Font("Verdana", 14, GraphicsUnit.Pixel),
                    ForeColor = Color.FromArgb(122, 122, 122),
                    Width     = 150
                };
                row++;
                tableLayoutPanelMain.Controls.Add(labelTitle, 6, row);
                tableLayoutPanelMain.Controls.Add(labelValue, 7, row);
            }

            //List<Document> operatorDocs =
            //    GlobalObjects.CasEnvironment.Loader.GetDocuments(aircraft.Operator, DocumentType.Certificate, true);
            //DocumentSubType aocType = (DocumentSubType)
            //    GlobalObjects.CasEnvironment.Dictionaries[typeof(DocumentSubType)].ToArray().FirstOrDefault(d => d.FullName == "AOC");
            //Document awDoc = aocType != null ? operatorDocs.FirstOrDefault(d => d.DocumentSubType == aocType) : null;
            //string aocUpTo = awDoc != null && awDoc.ValidTo
            //                    ? awDoc.DateValidTo.ToString(new GlobalTermsProvider()["DateFormat"].ToString())
            //                    : "";

            var aircraftDocs = GlobalObjects.DocumentCore.GetAircraftDocuments(aircraft);
            var awType       = (DocumentSubType)
                               GlobalObjects.CasEnvironment.GetDictionary <DocumentSubType>().ToArray().FirstOrDefault(d => d.FullName == "AW");
            var awDoc = awType != null?aircraftDocs.FirstOrDefault(d => d.DocumentSubType.ItemId == awType.ItemId) : null;

            string awUpTo = awDoc != null && awDoc.IssueValidTo
                                ? awDoc.IssueDateValidTo.ToString(new GlobalTermsProvider()["DateFormat"].ToString())
                                : "";

            labelAWCValue.Text = awUpTo;

            tableLayoutPanelLastChecks.RowCount = 1;
            tableLayoutPanelLastChecks.RowStyles.Clear();
            tableLayoutPanelLastChecks.RowStyles.Add(new RowStyle());
            tableLayoutPanelLastChecks.Controls.Clear();
            tableLayoutPanelLastChecks.Controls.Add(labelLastCheck, 0, 0);
            tableLayoutPanelLastChecks.Controls.Add(labelLastDate, 1, 0);
            tableLayoutPanelLastChecks.Controls.Add(labelLastTsnCsn, 2, 0);

            tableLayoutPanelNextChecks.RowCount = 1;
            tableLayoutPanelNextChecks.RowStyles.Clear();
            tableLayoutPanelNextChecks.RowStyles.Add(new RowStyle());
            tableLayoutPanelNextChecks.Controls.Clear();
            tableLayoutPanelNextChecks.Controls.Add(labelNextCheck, 0, 0);
            tableLayoutPanelNextChecks.Controls.Add(labelNextDate, 1, 0);
            tableLayoutPanelNextChecks.Controls.Add(labelNextTsnCan, 2, 0);
            tableLayoutPanelNextChecks.Controls.Add(labelRemains, 3, 0);

            tableLayoutPanelDocs.RowCount = 1;
            tableLayoutPanelDocs.RowStyles.Clear();
            tableLayoutPanelDocs.RowStyles.Add(new RowStyle());
            tableLayoutPanelDocs.Controls.Clear();
            tableLayoutPanelDocs.Controls.Add(labelDocDescription, 0, 0);
            tableLayoutPanelDocs.Controls.Add(labelDocNumber, 1, 0);
            tableLayoutPanelDocs.Controls.Add(labelDocIssue, 2, 0);
            tableLayoutPanelDocs.Controls.Add(labelDocValidTo, 3, 0);
            tableLayoutPanelDocs.Controls.Add(labelDocRemain, 4, 0);

            if (_checkItems.Count == 0)
            {
                return;
            }

            if (!BackGroundWorker.IsBusy)
            {
                BackGroundWorker.RunWorkerAsync();
            }
            List <MaintenanceCheck> orderedBySchedule =
                checkItems.OrderBy(c => c.Schedule)
                .ThenByDescending(c => c.Grouping)
                .OrderBy(c => c.Resource)
                .ToList();

            List <MaintenanceCheckGroupByType> checkGroups = new List <MaintenanceCheckGroupByType>();

            foreach (MaintenanceCheck check in orderedBySchedule)
            {
                MaintenanceCheckGroupByType group = checkGroups
                                                    .FirstOrDefault(g => g.Schedule == check.Schedule &&
                                                                    g.Grouping == check.Grouping &&
                                                                    g.Resource == check.Resource);
                if (group != null)
                {
                    group.Checks.Add(check);
                }
                else
                {
                    group = new MaintenanceCheckGroupByType(check.Schedule)
                    {
                        Grouping = check.Grouping,
                        Resource = check.Resource
                    };
                    group.Checks.Add(check);
                    checkGroups.Add(group);
                }
            }
        }
Beispiel #11
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            #region Загрузка элементов

            AnimatedThreadWorker.ReportProgress(0, "load directives");

            if (_preResult == null)
            {
                _preResult = new MaintenanceCheckCollection();
            }
            _preResult.Clear();
            _aircraftDocs.Clear();
            try
            {
                _preResult.AddRange(GlobalObjects.MaintenanceCore.GetMaintenanceCheck(CurrentAircraft));
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading directives", ex);
            }

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            AnimatedThreadWorker.ReportProgress(20, "load directives");

            List <Document> aircraftDocs = GlobalObjects.DocumentCore.GetDocuments(CurrentAircraft, DocumentType.Certificate);

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            #endregion

            #region Калькуляция состояния директив

            AnimatedThreadWorker.ReportProgress(40, "calculation of directives");

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            //прогнозируемый ресурс
            var current        = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(CurrentAircraft);
            var groupingChecks = _preResult.Where(c => c.Grouping);
            int?offsetMinutes  =
                groupingChecks.Select(c => c.Interval.GetSubresource(LifelengthSubResource.Minutes))
                .OrderBy(r => r)
                .LastOrDefault();
            int?offsetCycles =
                groupingChecks.Select(c => c.Interval.GetSubresource(LifelengthSubResource.Cycles))
                .OrderBy(r => r)
                .LastOrDefault();
            int?offsetDays =
                groupingChecks.Select(c => c.Interval.GetSubresource(LifelengthSubResource.Calendar))
                .OrderBy(r => r)
                .LastOrDefault();
            var offset        = new Lifelength(offsetDays, offsetCycles, offsetMinutes);
            var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(CurrentAircraft.AircraftFrameId);
            var approxDays    = Convert.ToDouble(AnalystHelper.GetApproximateDays(offset, aircraftFrame.AverageUtilization));
            var forecastData  = new ForecastData(DateTime.Now.AddDays(approxDays),
                                                 aircraftFrame.AverageUtilization,
                                                 current);
            GlobalObjects.MaintenanceCheckCalculator.GetNextPerformanceGroup(_preResult, CurrentAircraft.Schedule, forecastData);

            var cs = ConditionState.NotEstimated;
            foreach (MaintenanceCheck check in _preResult)
            {
                if (check.Condition == ConditionState.Satisfactory && cs == ConditionState.NotEstimated)
                {
                    cs = check.Condition;
                }
                if (check.Condition == ConditionState.Notify && cs != ConditionState.Notify)
                {
                    cs = check.Condition;
                }
                if (check.Condition == ConditionState.Overdue)
                {
                    cs = check.Condition;
                    break;
                }
            }
            e.Result = cs;

            AnimatedThreadWorker.ReportProgress(55, "calculation of documents");

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            foreach (Document aircraftDoc in aircraftDocs)
            {
                GlobalObjects.PerformanceCalculator.GetNextPerformance(aircraftDoc);

                if (!aircraftDoc.IsClosed &&
                    aircraftDoc.IssueValidTo &&
                    aircraftDoc.Condition != ConditionState.NotEstimated)
                {
                    _aircraftDocs.Add(aircraftDoc);
                }
            }

            #endregion

            #region Фильтрация директив
            AnimatedThreadWorker.ReportProgress(70, "filter directives");

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }
            #endregion

            #region Сравнение с рабочими пакетами

            AnimatedThreadWorker.ReportProgress(90, "comparison with the Work Packages");

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }
            #endregion

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Beispiel #12
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            #region Загрузка элементов

            AnimatedThreadWorker.ReportProgress(0, "load directives");

            if (_preResult == null)
            {
                _preResult = new MaintenanceCheckCollection();
            }
            _preResult.Clear();
            try
            {
                _preResult.AddRange(GlobalObjects.MaintenanceCore.GetMaintenanceCheck(CurrentAircraft));
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading directives", ex);
            }

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            AnimatedThreadWorker.ReportProgress(20, "load directives");

            if (_maintenanceDirectives != null)
            {
                _maintenanceDirectives.Clear();
            }
            try
            {
                _maintenanceDirectives = GlobalObjects.MaintenanceCore.GetMaintenanceDirectives(CurrentAircraft);
                var bindedItems = GlobalObjects.BindedItemsCore.GetBindedItemsFor(CurrentAircraft.ItemId,
                                                                                  _maintenanceDirectives.Where(m => m.WorkItemsRelationType == WorkItemsRelationType.CalculationDepend).Cast <IBindedItem>());

                foreach (var mpd in _maintenanceDirectives)
                {
                    GlobalObjects.PerformanceCalculator.GetNextPerformance(mpd);

                    if (bindedItems.ContainsKey(mpd))
                    {
                        var directives = bindedItems[mpd];
                        foreach (var componentDirective in directives)
                        {
                            if (componentDirective is ComponentDirective)
                            {
                                GlobalObjects.PerformanceCalculator.GetNextPerformance(componentDirective);

                                var firstNextPerformance =
                                    bindedItems[mpd].SelectMany(t => t.NextPerformances).OrderBy(n => n.NextPerformanceDate).FirstOrDefault();

                                if (firstNextPerformance == null)
                                {
                                    continue;
                                }
                                mpd.BindedItemNextPerformance       = firstNextPerformance;
                                mpd.BindedItemNextPerformanceSource = firstNextPerformance.NextPerformanceSource ?? Lifelength.Null;
                                mpd.BindedItemRemains             = firstNextPerformance.Remains ?? Lifelength.Null;
                                mpd.BindedItemNextPerformanceDate = firstNextPerformance.NextPerformanceDate;
                                mpd.BindedItemCondition           = firstNextPerformance.Condition ?? ConditionState.NotEstimated;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading directives", ex);
            }

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            #endregion

            #region Калькуляция состояния директив

            AnimatedThreadWorker.ReportProgress(40, "calculation of directives");

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            //прогнозируемый ресурс
            var current        = GlobalObjects.CasEnvironment.Calculator.GetCurrentFlightLifelength(CurrentAircraft);
            var groupingChecks = _preResult.Where(c => c.Grouping);
            int?offsetMinutes  =
                groupingChecks.Select(c => c.Interval.GetSubresource(LifelengthSubResource.Minutes))
                .OrderBy(r => r)
                .LastOrDefault();
            int?offsetCycles =
                groupingChecks.Select(c => c.Interval.GetSubresource(LifelengthSubResource.Cycles))
                .OrderBy(r => r)
                .LastOrDefault();
            int?offsetDays =
                groupingChecks.Select(c => c.Interval.GetSubresource(LifelengthSubResource.Calendar))
                .OrderBy(r => r)
                .LastOrDefault();
            var offset        = new Lifelength(offsetDays, offsetCycles, offsetMinutes);
            var aircraftFrame = GlobalObjects.ComponentCore.GetBaseComponentById(CurrentAircraft.AircraftFrameId);
            var approxDays    = Convert.ToDouble(AnalystHelper.GetApproximateDays(offset, aircraftFrame.AverageUtilization));
            var forecastData  = new ForecastData(DateTime.Now.AddDays(approxDays),
                                                 aircraftFrame.AverageUtilization,
                                                 current);
            GlobalObjects.MaintenanceCheckCalculator.GetNextPerformanceGroup(_preResult, CurrentAircraft.Schedule, forecastData);

            var cs = ConditionState.NotEstimated;
            foreach (MaintenanceCheck check in _preResult)
            {
                if (check.Condition == ConditionState.Satisfactory && cs == ConditionState.NotEstimated)
                {
                    cs = check.Condition;
                }
                if (check.Condition == ConditionState.Notify && cs != ConditionState.Notify)
                {
                    cs = check.Condition;
                }
                if (check.Condition == ConditionState.Overdue)
                {
                    cs = check.Condition;
                    break;
                }
            }
            e.Result = cs;
            #endregion

            #region Фильтрация директив
            AnimatedThreadWorker.ReportProgress(70, "filter directives");

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }
            #endregion

            #region Сравнение с рабочими пакетами

            AnimatedThreadWorker.ReportProgress(90, "comparison with the Work Packages");

            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }
            #endregion

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Beispiel #13
0
        private void GenerateRows()
        {
            listViewProgramChecks.Items.Clear();
            if (_grouping)
            {
                MaintenanceCheckCollection mcc = new MaintenanceCheckCollection(_maintenanceCheckItems);
                MaintenanceCheck           mc  = mcc.GetMinStepCheck(_maintenanceCheckItems[0].Schedule);
                if (mc == null)
                {
                    return;
                }
                MSG msg = mc.ParentAircraft != null && mc.ParentAircraft.MaintenanceProgramChangeRecords.Count > 0
                                  ? mc.ParentAircraft.MaintenanceProgramChangeRecords.GetLast().MSG
                                  : MSG.MSG2;
                if (msg < MSG.MSG3)
                {
                    MaintenanceCheckComplianceGroup mccg =
                        mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                        mc.Grouping, mc.Resource);

                    int lastPerformanceGroupNum = mccg != null
                        ? mccg.LastComplianceGroupNum
                        : 0;
                    int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource;
                    foreach (MaintenanceCheck t in _maintenanceCheckItems)
                    {
                        ListViewItem listViewItem = new ListViewItem {
                            Text = t.Name
                        };

                        listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                        listViewItem.SubItems.Add(t.Cost.ToString());
                        listViewItem.SubItems.Add(t.ManHours.ToString());

                        for (int j = 1; j <= _countColumns; j++)
                        {
                            MaintenanceNextPerformance mnp =
                                t.GetPergormanceGroupByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck);
                            listViewItem.SubItems.Add(mnp != null ? "X" : "");
                        }
                        listViewProgramChecks.Items.Add(listViewItem);
                    }
                }
                else
                {
                    MaintenanceCheckComplianceGroup mccg =
                        mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                        mc.Grouping, mc.Resource);

                    int lastPerformanceGroupNum = mccg != null
                        ? mccg.LastComplianceGroupNum
                        : 0;
                    int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource;
                    foreach (MaintenanceCheck t in _maintenanceCheckItems)
                    {
                        ListViewItem listViewItem = new ListViewItem {
                            Text = t.Name
                        };

                        listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                        listViewItem.SubItems.Add(t.Cost.ToString());
                        listViewItem.SubItems.Add(t.ManHours.ToString());

                        for (int j = 1; j <= _countColumns; j++)
                        {
                            MaintenanceNextPerformance mnp =
                                t.GetPergormanceGroupWhereCheckIsSeniorByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck);
                            listViewItem.SubItems.Add(mnp != null ? "X" : "");
                        }
                        listViewProgramChecks.Items.Add(listViewItem);
                    }
                }
                mcc.Clear();
            }
            else
            {
                foreach (MaintenanceCheck t in _maintenanceCheckItems)
                {
                    ListViewItem listViewItem = new ListViewItem {
                        Text = t.Name
                    };

                    listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                    listViewItem.SubItems.Add(t.Cost.ToString());
                    listViewItem.SubItems.Add(t.ManHours.ToString());

                    Lifelength lastPerformance = t.LastPerformance != null
                        ? new Lifelength(t.LastPerformance.OnLifelength)
                        : Lifelength.Null;
                    int?last = lastPerformance.GetSubresource(_subResource);

                    listViewItem.SubItems.Add(last != null ? lastPerformance.ToString(_subResource, true) : "");

                    if (t.Schedule == _schedule)
                    {
                        Lifelength nextPerformance = lastPerformance + t.Interval;
                        int?       next            = nextPerformance.GetSubresource(_subResource);
                        listViewItem.SubItems.Add(next != null ? nextPerformance.ToString(_subResource, true) : "");
                    }
                    else
                    {
                        listViewItem.SubItems.Add("N/A");
                    }
                    listViewProgramChecks.Items.Add(listViewItem);
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Выставляет колонки в списке чеков текущей программы обслуживания
        /// </summary>
        private void SetHeaders()
        {
            _min = Convert.ToInt32(_maintenanceCheckItems[0].Interval.GetSubresource(_subResource));

            foreach (MaintenanceCheck liminationItem in _maintenanceCheckItems)
            {
                _min = Math.Min(Convert.ToInt32(liminationItem.Interval.GetSubresource(_subResource)), _min);
                _max = Math.Max(Convert.ToInt32(liminationItem.Interval.GetSubresource(_subResource)), _max);
            }

            ColumnHeader column = new ColumnHeader {
                Text = "Name", TextAlign = HorizontalAlignment.Right, Width = 50
            };

            listViewProgramChecks.Columns.Add(column);
            column = new ColumnHeader {
                Text = "Interval", TextAlign = HorizontalAlignment.Left, Width = 130
            };
            listViewProgramChecks.Columns.Add(column);
            column = new ColumnHeader {
                Text = "Cost", TextAlign = HorizontalAlignment.Left, Width = 50
            };
            listViewProgramChecks.Columns.Add(column);
            column = new ColumnHeader {
                Text = "ManHours", TextAlign = HorizontalAlignment.Left, Width = 64
            };
            listViewProgramChecks.Columns.Add(column);

            if (_grouping)
            {
                //Определение кол-ва колонок списка
                if (_upperCheckTypeMinResource == -1)
                {
                    //Если это самая вышестоящий тип чеков
                    //то делится максимальный на минимальный интервал
                    _countColumns = _max / _min;
                }
                else
                {
                    //Если это самая НЕ вышестоящий тип чеков
                    //то делится минимальный ресурс вышестоящего типа на минимальный интервал
                    _countColumns = _upperCheckTypeMinResource / _min;
                }
                MaintenanceCheckCollection mcc = new MaintenanceCheckCollection(_maintenanceCheckItems);
                MaintenanceCheck           mc  = mcc.GetMinStepCheck(_maintenanceCheckItems[0].Schedule);
                if (mc == null)
                {
                    return;
                }
                MSG msg = mc.ParentAircraft != null && mc.ParentAircraft.MaintenanceProgramChangeRecords.Count > 0
                                  ? mc.ParentAircraft.MaintenanceProgramChangeRecords.GetLast().MSG
                                  : MSG.MSG2;
                if (msg < MSG.MSG3)
                {
                    for (int i = 1; i <= _countColumns; i++)
                    {
                        //ColumnHeader viewColumn = new ColumnHeader
                        //                              {
                        //                                  Text = i + " [" + (i*_min) + "]",
                        //                                  TextAlign = HorizontalAlignment.Center,
                        //                                  Width = 65
                        //
                        //                              };
                        //listViewProgramChecks.Columns.Add(viewColumn);
                        ColumnHeader viewColumn;
                        //выполняется проверка, достаточно ли расчитано "след.выполнений"
                        //что бы заполнить их данными названия колонок
                        if (mc.NextPerformances.Count >= i)
                        {
                            //Если кол-во расчитанных выполнений достаточно для заполнения
                            //названия тек. колонки, то название колонки берется из ресурса "след. выполнения"
                            int performanceSource =
                                Convert.ToInt32(mc.NextPerformances[i - 1].PerformanceSource.GetSubresource(mc.Resource));
                            MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance;
                            if (mnp != null)
                            {
                                string checkName = mnp.PerformanceGroup != null?mnp.PerformanceGroup.GetGroupName() : i.ToString();

                                viewColumn = new ColumnHeader
                                {
                                    Text      = checkName + " [" + performanceSource + "]",
                                    TextAlign = HorizontalAlignment.Center,
                                    Width     = 85
                                };
                            }
                            else
                            {
                                viewColumn = new ColumnHeader
                                {
                                    Text      = i + " [" + performanceSource + "]",
                                    TextAlign = HorizontalAlignment.Center,
                                    Width     = 85
                                };
                            }
                        }
                        else
                        {
                            //Если кол-во расчитанных выполнений недостаточно
                            //то название колонки расчитывается на освоне ресурса последнего выполнения
                            //данного чека и номера тек. колонки
                            viewColumn = new ColumnHeader
                            {
                                Text      = i + " [" + (i * _min) + "]",
                                TextAlign = HorizontalAlignment.Center,
                                Width     = 85
                            };
                        }
                        listViewProgramChecks.Columns.Add(viewColumn);
                    }
                }
                else
                {
                    MaintenanceCheckComplianceGroup mccg = mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                                                           mc.Grouping, mc.Resource);
                    if (mccg == null)
                    {
                        for (int i = 1; i <= _countColumns; i++)
                        {
                            MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance;
                            string checkName = mnp != null && mnp.PerformanceGroup != null
                                ? mnp.PerformanceGroup.GetGroupName()
                                : "";

                            ColumnHeader viewColumn = new ColumnHeader
                            {
                                Text      = checkName + " [" + (i * _min) + "]",
                                TextAlign = HorizontalAlignment.Center,
                                Width     = 65
                            };
                            listViewProgramChecks.Columns.Add(viewColumn);
                        }
                    }
                    else
                    {
                        MaintenanceCheck mic = mccg.GetMinIntervalCheck();
                        for (int i = 1; i <= _countColumns; i++)
                        {
                            ColumnHeader viewColumn;
                            //выполняется проверка, достаточно ли расчитано "след.выполнений"
                            //что бы заполнить их данными названия колонок
                            if (mic.NextPerformances.Count >= i)
                            {
                                //Если кол-во расчитанных выполнений достаточно для заполнения
                                //названия тек. колонки, то название колонки берется из ресурса "след. выполнения"
                                MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance;
                                string checkName = mnp != null && mnp.PerformanceGroup != null
                                    ? mnp.PerformanceGroup.GetGroupName()
                                    : "";

                                int performanceSource =
                                    Convert.ToInt32(mic.NextPerformances[i - 1].PerformanceSource.GetSubresource(mic.Resource));
                                viewColumn = new ColumnHeader
                                {
                                    Text      = checkName + " [" + performanceSource + "]",
                                    TextAlign = HorizontalAlignment.Center,
                                    Width     = 85
                                };
                            }
                            else
                            {
                                //Если кол-во расчитанных выполнений недостаточно
                                //то название колонки расчитывается на освоне ресурса последнего выполнения
                                //данного чека и номера тек. колонки
                                int lastPerformaceSource =
                                    Convert.ToInt32(mic.LastPerformance.CalculatedPerformanceSource.GetSubresource(mic.Resource));
                                if (lastPerformaceSource == 0)
                                {
                                    lastPerformaceSource =
                                        Convert.ToInt32(mic.LastPerformance.OnLifelength.GetSubresource(mic.Resource));
                                }

                                viewColumn = new ColumnHeader
                                {
                                    Text      = " [" + (lastPerformaceSource + i * _min) + "]",
                                    TextAlign = HorizontalAlignment.Center,
                                    Width     = 85
                                };
                            }
                            listViewProgramChecks.Columns.Add(viewColumn);
                        }
                    }
                }
                mcc.Clear();
            }
            else
            {
                _countColumns = 2;
                //Если чеки НЕ группируются по части порогового значения
                //то выводится ресурс пред. и след. выполнения
                column = new ColumnHeader {
                    Text = "Last", TextAlign = HorizontalAlignment.Left, Width = 100
                };
                listViewProgramChecks.Columns.Add(column);
                column = new ColumnHeader {
                    Text = "Next", TextAlign = HorizontalAlignment.Left, Width = 100
                };
                listViewProgramChecks.Columns.Add(column);
            }
        }
Beispiel #15
0
 /// <summary>
 /// Перезагружает данные с БД
 /// </summary>
 public void Reload(MaintenanceCheckCollection liminationItems, Aircraft currentAircraft)
 {
     CheckItems       = liminationItems;
     _currentAircraft = currentAircraft;
     UpdateInformation();
 }