Exemplo n.º 1
0
        /// <summary>
        /// Производит очистку ресурсов страницы
        /// </summary>
        public override void DisposeScreen()
        {
            CancelAsync();

            if (_performanceControl != null)
            {
                _performanceControl.CancelAsync();
            }
            if (_complianceControl != null)
            {
                _complianceControl.CalcelAsync();
            }

            AnimatedThreadWorker.Dispose();

            if (_itemPrintReportHistory != null)
            {
                _itemPrintReportHistory.Dispose();
            }
            if (_itemPrintReportRecords != null)
            {
                _itemPrintReportRecords.Dispose();
            }
            if (_itemPrintReportEngineRecords != null)
            {
                _itemPrintReportEngineRecords.Dispose();
            }
            if (_buttonPrintMenuStrip != null)
            {
                _buttonPrintMenuStrip.Dispose();
            }

            _currentComponent = null;

            if (_baseComponentComponents != null)
            {
                _baseComponentComponents.Clear();
            }
            _baseComponentComponents = null;

            Dispose(true);
        }
Exemplo n.º 2
0
        private void AnimatedThreadWorkerDoLoad(object sender, DoWorkEventArgs e)
        {
            if (_maintenanceDirective == null || _currentAircraft == null)
            {
                e.Cancel = true;
                return;
            }

            if (_bindedItems == null)
            {
                _bindedItems = new CommonCollection <BaseEntityObject>();
            }
            _bindedItems.Clear();

            if (_itemsForSelect == null)
            {
                _itemsForSelect = new CommonCollection <BaseEntityObject>();
            }
            _itemsForSelect.Clear();

            _animatedThreadWorker.ReportProgress(0, "load binded tasks");

            ComponentCollection dc = null;

            try
            {
                dc = GlobalObjects.ComponentCore.GetComponents(_currentAircraft.ItemId);


                var baseComp       = GlobalObjects.ComponentCore.GetAicraftBaseComponents(_currentAircraft.ItemId);
                var directivesIds  = baseComp.SelectMany(i => i.ComponentDirectives).Select(d => d.ItemId);
                var itemsRelations = GlobalObjects.ItemsRelationsDataAccess.GetRelations(directivesIds,
                                                                                         SmartCoreType.ComponentDirective.ItemId);

                if (itemsRelations.Count > 0)
                {
                    foreach (var directive in baseComp.SelectMany(i => i.ComponentDirectives))
                    {
                        directive.ItemRelations.Clear();
                        directive.ItemRelations.AddRange(itemsRelations.Where(i =>
                                                                              i.FirstItemId == directive.ItemId ||
                                                                              i.SecondItemId ==
                                                                              directive.ItemId)); //TODO:(Evgenii Babak)не использовать Where
                    }
                }

                dc.AddRange(baseComp);
                //Определение списка привязанных задач и компонентов

                List <ComponentDirective> bindedDirectives =
                    dc.SelectMany(d => d.ComponentDirectives.Where(dd => dd.ItemRelations.IsAnyRelationWith(_maintenanceDirective)))
                    .ToList();

                List <Component> bindedComponents =
                    bindedDirectives.Where(dd => dd.ParentComponent != null)
                    .Select(dd => dd.ParentComponent)
                    .Distinct()
                    .ToList();

                _bindedItems.AddRange(bindedDirectives.ToArray());
                _bindedItems.AddRange(bindedComponents.ToArray());

                //Определение списка непривязанных задач и компонентов

                List <ComponentDirective> directivesForSelect =
                    dc.SelectMany(d => d.ComponentDirectives.Where(dd => dd.ItemRelations.Count == 0 || !dd.ItemRelations.IsAllRelationWith(_maintenanceDirective)))
                    .ToList();

                List <Component> componentsForSelect = dc.ToList();

                _itemsForSelect.AddRange(directivesForSelect.ToArray());
                _itemsForSelect.AddRange(componentsForSelect.ToArray());
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load Maintenance directive bing details records", ex);
            }

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

            _animatedThreadWorker.ReportProgress(50, "calculation of Components");

            if (dc != null)
            {
                foreach (var component in dc)
                {
                    GlobalObjects.PerformanceCalculator.GetNextPerformance(component);
                    foreach (var dd in component.ComponentDirectives)
                    {
                        GlobalObjects.PerformanceCalculator.GetNextPerformance(dd);
                    }
                }

                dc.Clear();
            }

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

            _animatedThreadWorker.ReportProgress(75, "calculate directives for select");

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

            _animatedThreadWorker.ReportProgress(100, "binding complete");
        }
Exemplo n.º 3
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDirectiveArray.Clear();
            _preResultDirectiveArray.Clear();
            _resultDirectiveArray.Clear();

            if (!string.IsNullOrEmpty(TextBoxFilter.Text))
            {
                ComponentCollection preResult           = new ComponentCollection();
                ComponentCollection componentCollection = new ComponentCollection();

                var temp = GlobalObjects.ComponentCore.GetComponentsAll(TextBoxFilter.Text).ToArray();

                foreach (var component in temp)
                {
                    var a = GlobalObjects.AircraftsCore.GetAircraftById(component.ParentBaseComponent?.ParentAircraftId ?? -1);
                    if (a != null)
                    {
                        componentCollection.Add(component);
                    }
                }

                var ids = new List <int>();

                foreach (var component in componentCollection)
                {
                    var lastTr = component.TransferRecords.GetLast();

                    if (lastTr?.DestinationObjectType == SmartCoreType.BaseComponent)
                    {
                        component.ParentBaseComponent = GlobalObjects.ComponentCore.GetBaseComponentById(lastTr.DestinationObjectId);
                    }

                    foreach (var componentDirective in component.ComponentDirectives)
                    {
                        foreach (var items in componentDirective.ItemRelations.Where(i =>
                                                                                     i.FirtsItemTypeId == SmartCoreType.MaintenanceDirective.ItemId ||
                                                                                     i.SecondItemTypeId == SmartCoreType.MaintenanceDirective.ItemId))
                        {
                            ids.Add(componentDirective.IsFirst == true ? items.SecondItemId : items.FirstItemId);
                        }
                    }
                }


                var mpd = GlobalObjects.MaintenanceCore.GetMaintenanceDirectiveList(ids);
                foreach (var component in componentCollection)
                {
                    foreach (var componentDirective in component.ComponentDirectives)
                    {
                        foreach (var items in componentDirective.ItemRelations.Where(i =>
                                                                                     i.FirtsItemTypeId == SmartCoreType.MaintenanceDirective.ItemId ||
                                                                                     i.SecondItemTypeId == SmartCoreType.MaintenanceDirective.ItemId))
                        {
                            var id = componentDirective.IsFirst == true ? items.SecondItemId : items.FirstItemId;
                            componentDirective.MaintenanceDirective = mpd.FirstOrDefault(i => i.ItemId == id);
                        }
                    }
                }


                AnimatedThreadWorker.ReportProgress(50, "filter components");

                InitialFilterItems(componentCollection, _initialDirectiveArray);

                preResult.Clear();

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

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

                AnimatedThreadWorker.ReportProgress(70, "calculation of components");

                var lldData = GlobalObjects.CasEnvironment.Loader
                              .GetObjectList <ComponentLLPCategoryData>(new ICommonFilter[]
                {
                    new CommonFilter <int>(ComponentLLPCategoryData.ComponentIdProperty,
                                           SmartCore.Filters.FilterType.In, _initialDirectiveArray.Select(i => i.ItemId).ToArray()),
                });

                var llpchangeRec = GlobalObjects.CasEnvironment.Loader
                                   .GetObjectList <ComponentLLPCategoryChangeRecord>(new ICommonFilter[]
                {
                    new CommonFilter <int>(ComponentLLPCategoryChangeRecord.ParentIdProperty,
                                           SmartCore.Filters.FilterType.In, _initialDirectiveArray.Select(i => i.ItemId).ToArray()),
                });

                foreach (Component detail in _initialDirectiveArray)
                {
                    detail.LLPData.Clear();
                    detail.LLPData.AddRange(lldData.Where(i => i.ComponentId == detail.ItemId));

                    detail.ChangeLLPCategoryRecords.Clear();
                    detail.ChangeLLPCategoryRecords.AddRange(llpchangeRec.Where(i => i.ParentId == detail.ItemId));

                    GlobalObjects.MTOPCalculator.CalculateDirectiveNew(detail);
                    _preResultDirectiveArray.Add(detail);

                    foreach (ComponentDirective detailDirective in detail.ComponentDirectives)
                    {
                        GlobalObjects.MTOPCalculator.CalculateDirectiveNew(detailDirective);
                        _preResultDirectiveArray.Add(detailDirective);
                    }
                }

                AdditionalFilterItems(_preResultDirectiveArray, _resultDirectiveArray);

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

                #endregion

                AnimatedThreadWorker.ReportProgress(100, "Complete");
            }
        }
Exemplo n.º 4
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDirectiveArray.Clear();
            _resultDirectiveArray.Clear();
            _preResultDirectiveArray.Clear();

            var transfer = new List <TransferRecord>();

            transfer.AddRange(GlobalObjects.TransferRecordCore.GetPreTransferRecordsFrom(_currentBaseComponent));

            var preResult = new List <Component>();

            preResult.AddRange(transfer.Select(i => i.ParentComponent).ToList());

            AnimatedThreadWorker.ReportProgress(50, "filter components");

            InitialFilterItems(preResult, _initialDirectiveArray);

            preResult.Clear();

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

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

            AnimatedThreadWorker.ReportProgress(70, "calculation of components");

            foreach (Component detail in _initialDirectiveArray)
            {
                GlobalObjects.PerformanceCalculator.GetNextPerformance(detail);
                _preResultDirectiveArray.Add(detail);

                foreach (ComponentDirective detailDirective in detail.ComponentDirectives)
                {
                    GlobalObjects.PerformanceCalculator.GetNextPerformance(detailDirective);
                    _preResultDirectiveArray.Add(detailDirective);
                }
            }

            AdditionalFilterItems(_preResultDirectiveArray, _resultDirectiveArray);

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

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

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

            //загрузка рабочих пакетов для определения
            //перекрытых ими выполнений задач
            if (_openPubWorkPackages == null)
            {
                _openPubWorkPackages = new CommonCollection <WorkPackage>();
            }

            _openPubWorkPackages.Clear();
            _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(CurrentAircraft, WorkPackageStatus.Opened));
            _openPubWorkPackages.AddRange(GlobalObjects.WorkPackageCore.GetWorkPackagesLite(CurrentAircraft, WorkPackageStatus.Published));
            //сбор всех записей рабочих пакетов для удобства фильтрации
            List <WorkPackageRecord> openWPRecords = new List <WorkPackageRecord>();
            foreach (WorkPackage openWorkPackage in _openPubWorkPackages)
            {
                openWPRecords.AddRange(openWorkPackage.WorkPakageRecords);
            }

            foreach (IDirective dir in _resultDirectiveArray)
            {
                if (dir.NextPerformances == null || dir.NextPerformances.Count <= 0)
                {
                    continue;
                }
                BaseEntityObject baseObject = (BaseEntityObject)dir;
                //Проход по всем след. выполнениям чека и записям в рабочих пакетах
                //для поиска перекрывающихся выполнений
                List <NextPerformance> performances = dir.NextPerformances;
                foreach (NextPerformance np in performances)
                {
                    //поиск записи в рабочих пакетах по данному чеку
                    //чей номер группы выполнения (по записи) совпадает с расчитанным
                    WorkPackageRecord wpr =
                        openWPRecords.FirstOrDefault(r => r.PerformanceNumFromStart == np.PerformanceNum &&
                                                     r.WorkPackageItemType == baseObject.SmartCoreObjectType.ItemId &&
                                                     r.DirectiveId == baseObject.ItemId);
                    if (wpr != null)
                    {
                        np.BlockedByPackage = _openPubWorkPackages.GetItemById(wpr.WorkPakageId);
                    }
                }
            }

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

            #region Загрузка Котировочных ордеров

            AnimatedThreadWorker.ReportProgress(95, "Load Quotations");

            //загрузка рабочих пакетов для определения
            //перекрытых ими выполнений задач
            if (_openPubQuotations == null)
            {
                _openPubQuotations = new CommonCollection <RequestForQuotation>();
            }

            _openPubQuotations.Clear();
            _openPubQuotations.AddRange(GlobalObjects.PurchaseCore.GetRequestForQuotation(CurrentAircraft, new[] { WorkPackageStatus.Opened, WorkPackageStatus.Published }));

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

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Exemplo n.º 5
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            AnimatedThreadWorker.ReportProgress(0, "load components");

            var resultCollection = new ComponentCollection();

            _preResultDirectiveArray.Clear();
            _resultDirectiveArray.Clear();
            _removedComponents.Clear();
            _removedTransfers.Clear();
            _waitRemoveConfirmComponents.Clear();
            _waitRemoveConfirmTransfers.Clear();
            _installedComponents.Clear();
            _installedTransfers.Clear();

            #region Загрузка всех компонентов

            resultCollection = GlobalObjects.ComponentCore.GetSupplierProcessing();


            //////////////////////////////////////////////////////
            //     проверка на установленные компоненты         //
            //////////////////////////////////////////////////////
            var lastInstalledDetails = resultCollection.GetLastInstalledComponentsOnProcessing();
            foreach (var component in lastInstalledDetails)
            {
                _installedComponents.Add(component);
                _installedTransfers.Add(component.TransferRecords.GetLast());

                //удаление данного компонента из коллекции
                //т.к. его отображать не нужно
                resultCollection.Remove(component);
            }

            //////////////////////////////////////////////////////
            //        проверка на удаленные компоненты          //
            //////////////////////////////////////////////////////

            //извлечение из базы данных всех записей о перемещении
            //компонентов с данного базового агрегата
            var records = new TransferRecordCollection();
            records.AddRange(GlobalObjects.TransferRecordCore.GetLastTransferRecordsFromSuppliers().ToArray());
            records.AddRange(GlobalObjects.TransferRecordCore.GetLastTransferRecordsFromSpecialist().ToArray());

            foreach (var record in records)
            {
                //загрузка и БД детали, которой пренадлежит данная запись о перемещении
                var component = GlobalObjects.ComponentCore.GetComponentById(record.ParentId);

                if (component == null)
                {
                    continue;
                }

                if (record.DODR)
                {
                    //если перемещение подтверждено, то деталь записывается в "перемещенные"
                    //окна "TransferedDetails"
                    if (_removedComponents.CompareAndAdd(component))
                    {
                        _removedTransfers.Add(record);
                    }
                }
                else
                {
                    //если перемещение не подтверждено, то деталь записывается в
                    //"ожидабщие подтверждения" окна "TransferedDetails"
                    if (_waitRemoveConfirmComponents.CompareAndAdd(component))
                    {
                        _waitRemoveConfirmTransfers.Add(record);
                    }
                }
            }


            #endregion

            #region Слияние компонентов в одну коллекцию

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

            foreach (var component in resultCollection)
            {
                _preResultDirectiveArray.Add(component);
            }

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

            AdditionalFilterItems(_preResultDirectiveArray, _resultDirectiveArray);

            AnimatedThreadWorker.ReportProgress(100, "calculation over");
        }