Esempio n. 1
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (_parent == null)
            {
                return;
            }
            _initialArray.Clear();
            _resultArray.Clear();

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

            try
            {
                if (filter != null)
                {
                    _initialArray.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <InitialOrderDTO, InitialOrder>(filter));
                }
                else
                {
                    _initialArray.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <InitialOrderDTO, InitialOrder>());
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load Quotations", ex);
            }

            AnimatedThreadWorker.ReportProgress(20, "calculation Quotations");

            AnimatedThreadWorker.ReportProgress(70, "filter Quotations");
            FilterItems(_initialArray, _resultArray);
            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 2
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialProductArray.Clear();
            _resultProductArray.Clear();
            _initialOrders.Clear();
            _requestForQuotations.Clear();

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

            try
            {
                _initialOrders.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <InitialOrderDTO, InitialOrder>(new Filter("Status", 1)));
                _requestForQuotations.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <RequestForQuotationDTO, RequestForQuotation>(new Filter("Status", 1)));
                _initialProductArray.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <AccessoryDescriptionDTO, Product>(new Filter("ModelingObjectTypeId", -1), loadChild: true));
                _initialProductArray.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <AccessoryDescriptionDTO, ComponentModel>(new Filter("ModelingObjectTypeId", 5), loadChild: true));

                var ids = _initialProductArray.SelectMany(i => i.SupplierRelations).Select(i => i.SupplierID).Distinct();
                if (ids.Count() > 0)
                {
                    var suppliers = GlobalObjects.CasEnvironment.NewLoader.GetObjectListAll <SupplierDTO, Supplier>(new Filter("ItemId", ids));
                    if (suppliers.Count > 0)
                    {
                        foreach (var product in _initialProductArray)
                        {
                            foreach (var relation in product.SupplierRelations)
                            {
                                var currentSup = suppliers.FirstOrDefault(i => i.ItemId == relation.SupplierID);
                                if (currentSup != null)
                                {
                                    relation.Supplier = currentSup;
                                    if (!product.Suppliers.Contains(currentSup))
                                    {
                                        product.Suppliers.Add(currentSup);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load documents", ex);
            }

            AnimatedThreadWorker.ReportProgress(70, "filter products");
            FilterItems(_initialProductArray, _resultProductArray);

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 3
0
        private void AnimatedThreadWorkerDoFilteringWork(object sender, DoWorkEventArgs e)
        {
            _resultDirectiveArray.Clear();

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

            AdditionalFilterItems(_preResultDirectiveArray, _resultDirectiveArray);

            var component = new List <Component>();

            if (_resultDirectiveArray.All(c => c is ComponentDirective))
            {
                foreach (ComponentDirective cd in _resultDirectiveArray)
                {
                    component.Add(cd.ParentComponent);
                }
            }

            _resultDirectiveArray.AddRange(component.ToArray());

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

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 4
0
        /// <summary>
        /// Заполняет поля для редактирования директивы
        /// </summary>
        private void UpdateInformation()
        {
            if (_currentItem == null)
            {
                return;
            }

            _initialDocumentArray.Clear();
            _resultDocumentArray.Clear();

            _initialDocumentArray.AddRange(_currentItem.EmployeeDocuments.ToArray());


            if (GlobalObjects.CasEnvironment != null)
            {
                foreach (Document document in _initialDocumentArray)
                {
                    GlobalObjects.PerformanceCalculator.GetNextPerformance(document);
                }
            }

            FilterItems(_initialDocumentArray, _resultDocumentArray);

            documentationListView.SetItemsArray(_resultDocumentArray.ToArray());

            documentationListView.Focus();
        }
Esempio n. 5
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (_parent == null)
            {
                return;
            }
            _initialDocumentArray.Clear();
            _resultDocumentArray.Clear();

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

            try
            {
                GlobalObjects.CaaEnvironment.NewLoader.ReloadDictionary(typeof(DocumentSubType), typeof(ServiceType), typeof(Nomenclatures), typeof(Department), typeof(Occupation));

                _initialDocumentArray.AddRange(GlobalObjects
                                               .CaaEnvironment
                                               .NewLoader
                                               .GetObjectListAll <DocumentDTO, SmartCore.Entities.General.Document>(new Filter("OperatorId", FilterType.Equal, _operatorId), true));
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load documents", ex);
            }

            AnimatedThreadWorker.ReportProgress(20, "calculation documents");

            AnimatedThreadWorker.ReportProgress(70, "filter documents");
            FilterItems(_initialDocumentArray, _resultDocumentArray);

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 6
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (_parent == null)
            {
                return;
            }
            _initialDocumentArray.Clear();
            _resultDocumentArray.Clear();

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

            try
            {
                GlobalObjects.CasEnvironment.Loader.ReloadDictionary(typeof(DocumentSubType), typeof(ServiceType), typeof(Nomenclatures), typeof(Department), typeof(Specialization));
                if (_filters == null)
                {
                    if (_parent is Aircraft)
                    {
                        _initialDocumentArray.AddRange(GlobalObjects.DocumentCore.GetAircraftDocuments((Aircraft)_parent, _docType).ToArray());
                    }
                    if (_parent is Operator)
                    {
                        _initialDocumentArray.AddRange(GlobalObjects.DocumentCore.GetOperatorDocuments((Operator)_parent).ToArray());
                    }
                }
                else
                {
                    _initialDocumentArray.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectListAll <DocumentDTO, Document>(_filters, true));
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load documents", ex);
            }

            AnimatedThreadWorker.ReportProgress(20, "calculation documents");

            foreach (Document document in _initialDocumentArray)
            {
                GlobalObjects.PerformanceCalculator.GetNextPerformance(document);
            }

            AnimatedThreadWorker.ReportProgress(70, "filter documents");
            FilterItems(_initialDocumentArray, _resultDocumentArray);

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

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

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

            if (ViewedType.IsSubclassOf(typeof(StaticDictionary)))
            {
                PropertyInfo p = ViewedType.GetProperty("Items");

                ConstructorInfo  ci       = ViewedType.GetConstructor(new Type[0]);
                StaticDictionary instance = (StaticDictionary)ci.Invoke(null);

                InitialDirectiveArray.AddRange((IDictionaryCollection)p.GetValue(instance, null));
                InitialDirectiveArray.RemoveById(-1);
            }
            else
            {
                var dto = (CAADtoAttribute)ViewedType.GetCustomAttributes(typeof(CAADtoAttribute), false).FirstOrDefault();
                var res = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList(dto.Type, ViewedType, loadChild: true, filter: _filters);
                InitialDirectiveArray.AddRange((IEnumerable <IBaseEntityObject>)res);
            }

            AnimatedThreadWorker.ReportProgress(40, "filter directives");

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

            FilterItems(InitialDirectiveArray, ResultDirectiveArray);

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

            AnimatedThreadWorker.ReportProgress(100, "Complete");
            #endregion
        }
Esempio n. 8
0
        public void LoadAllAircrafts()
        {
            if (_aircrafts.Count > 0)
            {
                _aircrafts.Clear();
            }

            _aircrafts.AddRange(_loader.GetObjectListAll <Aircraft>(loadChild: true));
        }
Esempio n. 9
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDocumentArray.Clear();

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

            _initialDocumentArray.AddRange(GlobalObjects.CasEnvironment.BaseComponents.Where(c => c.BaseComponentType == BaseComponentType.Engine));

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 10
0
        ///<summary>
        ///</summary>
        ///<param name="initialCollection"></param>
        ///<param name="resultCollection"></param>
        private void FilterZeroItems(IEnumerable <IMtopCalc> initialCollection,
                                     ICommonCollection <IMtopCalc> resultCollection)
        {
            if (_filterZero == null || _filterZero.All(i => i.Values.Length == 0))
            {
                resultCollection.Clear();
                resultCollection.AddRange(initialCollection);
                return;
            }

            resultCollection.Clear();

            foreach (var pd in initialCollection)
            {
                if (_filterZero.FilterTypeAnd)
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _filterZero)
                    {
                        acceptable = filter.Acceptable((BaseEntityObject)pd);
                        if (!acceptable)
                        {
                            break;
                        }
                    }

                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
                else
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _filterZero)
                    {
                        if (filter.Values == null || filter.Values.Length == 0)
                        {
                            continue;
                        }
                        acceptable = filter.Acceptable((BaseEntityObject)pd);
                        if (acceptable)
                        {
                            break;
                        }
                    }

                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
            }
        }
Esempio n. 11
0
        ///<summary>
        ///</summary>
        ///<param name="initialCollection"></param>
        ///<param name="resultCollection"></param>
        private void FilterItems(IEnumerable <AccessoryRequired> initialCollection, ICommonCollection <AccessoryRequired> resultCollection)
        {
            if (_filter == null || _filter.All(i => i.Values.Length == 0))
            {
                resultCollection.Clear();
                resultCollection.AddRange(initialCollection);
                return;
            }

            resultCollection.Clear();

            foreach (AccessoryRequired pd in initialCollection)
            {
                //if (pd.Parent != null && pd.Parent is MaintenanceCheck && ((MaintenanceCheck)pd.Parent).Name == "C02")
                //{
                //    pd.ToString();
                //}
                if (_filter.FilterTypeAnd)
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _filter)
                    {
                        acceptable = filter.Acceptable(pd); if (!acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
                else
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _filter)
                    {
                        if (filter.Values == null || filter.Values.Length == 0)
                        {
                            continue;
                        }
                        acceptable = filter.Acceptable(pd); if (acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
            }
        }
Esempio n. 12
0
        ///<summary>
        ///</summary>
        ///<param name="initialCollection"></param>
        ///<param name="resultCollection"></param>
        private void FilterItems(IEnumerable <Discrepancy> initialCollection, ICommonCollection <Discrepancy> resultCollection)
        {
            if (_filter == null || _filter.All(i => i.Values.Length == 0))
            {
                resultCollection.Clear();
                resultCollection.AddRange(initialCollection);
                return;
            }

            resultCollection.Clear();

            foreach (Discrepancy pd in initialCollection)
            {
                //if (pd.MaintenanceCheck != null && pd.MaintenanceCheck.Name == "2C")
                //{
                //    pd.MaintenanceCheck.ToString();
                //}
                if (_filter.FilterTypeAnd)
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _filter)
                    {
                        acceptable = filter.Acceptable(pd); if (!acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
                else
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _filter)
                    {
                        if (filter.Values == null || filter.Values.Length == 0)
                        {
                            continue;
                        }
                        acceptable = filter.Acceptable(pd); if (acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
            }
        }
Esempio n. 13
0
        ///<summary>
        ///</summary>
        ///<param name="initialCollection"></param>
        ///<param name="resultCollection"></param>
        private void AdditionalFilterItems(IEnumerable <BaseEntityObject> initialCollection, ICommonCollection <BaseEntityObject> resultCollection)
        {
            if (_additionalfilter == null || _additionalfilter.Count == 0)
            {
                resultCollection.Clear();
                resultCollection.AddRange(initialCollection);
                return;
            }

            resultCollection.Clear();

            foreach (BaseEntityObject pd in initialCollection)
            {
                //if (pd.MaintenanceCheck != null && pd.MaintenanceCheck.Name == "2C")
                //{
                //    pd.MaintenanceCheck.ToString();
                //}
                if (_additionalfilter.FilterTypeAnd)
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _additionalfilter)
                    {
                        acceptable = filter.Acceptable(pd); if (!acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
                else
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _additionalfilter)
                    {
                        if (filter.Values == null || filter.Values.Length == 0)
                        {
                            continue;
                        }
                        acceptable = filter.Acceptable(pd); if (acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
            }
        }
Esempio n. 14
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (_parent == null)
            {
                return;
            }
            _purchaseArray.Clear();
            _resultArray.Clear();

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

            try
            {
                if (filter != null)
                {
                    _purchaseArray.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <PurchaseOrderDTO, PurchaseOrder>(filter));
                }
                else
                {
                    _purchaseArray.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <PurchaseOrderDTO, PurchaseOrder>());
                }

                var supplierShipper = GlobalObjects.CasEnvironment.Loader.GetObjectList <Supplier>(new ICommonFilter[] { new CommonFilter <int>(Supplier.SupplierClassProperty, SupplierClass.Shipper.ItemId) });
                foreach (var order in _purchaseArray)
                {
                    order.ShipCompany = supplierShipper.FirstOrDefault(i => i.ItemId == order.ShipCompanyId) ?? Supplier.Unknown;
                    order.ShipTo      = supplierShipper.FirstOrDefault(i => i.ItemId == order.ShipToId) ?? Supplier.Unknown;
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load Quotations", ex);
            }

            AnimatedThreadWorker.ReportProgress(20, "calculation Quotations");

            AnimatedThreadWorker.ReportProgress(70, "filter Quotations");
            FilterItems(_purchaseArray, _resultArray);
            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 15
0
        ///<summary>
        ///</summary>
        ///<param name="initialCollection"></param>
        ///<param name="resultCollection"></param>
        private void FilterItems(IEnumerable <ILogistic> initialCollection, ICommonCollection <ILogistic> resultCollection)
        {
            if (_filter == null || _filter.All(i => i.Values.Length == 0))
            {
                resultCollection.Clear();
                resultCollection.AddRange(initialCollection);
                return;
            }

            resultCollection.Clear();

            foreach (var pd in initialCollection)
            {
                if (_filter.FilterTypeAnd)
                {
                    var acceptable = true;
                    foreach (var filter in _filter)
                    {
                        acceptable = filter.Acceptable(pd as BaseEntityObject);
                    }
                    if (!acceptable)
                    {
                        break;
                    }

                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
                else
                {
                    var acceptable = true;
                    foreach (var filter in _filter)
                    {
                        if (filter.Values == null || filter.Values.Length == 0)
                        {
                            continue;
                        }
                        acceptable = filter.Acceptable(pd as BaseEntityObject); if (acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
            }
        }
Esempio n. 16
0
        ///<summary>
        ///</summary>
        ///<param name="initialCollection"></param>
        ///<param name="resultCollection"></param>
        private void FilterItems(IEnumerable <MailRecords> initialCollection, ICommonCollection <MailRecords> resultCollection)
        {
            if (_filter == null || _filter.All(i => i.Values.Length == 0))
            {
                resultCollection.Clear();
                resultCollection.AddRange(initialCollection);
                return;
            }

            resultCollection.Clear();

            foreach (var pd in initialCollection)
            {
                if (_filter.FilterTypeAnd)
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _filter)
                    {
                        acceptable = filter.Acceptable(pd); if (!acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
                else
                {
                    bool acceptable = true;
                    foreach (ICommonFilter filter in _filter)
                    {
                        if (filter.Values == null || filter.Values.Length == 0)
                        {
                            continue;
                        }
                        acceptable = filter.Acceptable(pd); if (acceptable)
                        {
                            break;
                        }
                    }
                    if (acceptable)
                    {
                        resultCollection.Add(pd);
                    }
                }
            }
        }
        private void UpdateInformation()
        {
            if (_currentItem == null)
            {
                return;
            }

            _initialDocumentArray.Clear();
            _resultDocumentArray.Clear();

            _initialDocumentArray.AddRange(_currentItem.SpecialistWorkPackages);
            FilterItems(_initialDocumentArray, _resultDocumentArray);

            employeeWorkPackageListView.CurrentSpecialist = _currentItem;
            employeeWorkPackageListView.SetItemsArray(_resultDocumentArray.ToArray());
            employeeWorkPackageListView.Focus();
        }
Esempio n. 18
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDocumentArray.Clear();
            _resultDocumentArray.Clear();

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

            try
            {
                _initialDocumentArray.AddRange(GlobalObjects.CasEnvironment.Loader.GetObjectListAll <MailRecords>(new CommonFilter <int>(MailRecords.MailChatIdProperty, _mailChat.ItemId), true).ToArray());
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load inbox mail", ex);
            }

            AnimatedThreadWorker.ReportProgress(70, "filter mail");
            FilterItems(_initialDocumentArray, _resultDocumentArray);

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 19
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDocumentArray.Clear();
            _resultDocumentArray.Clear();

            AnimatedThreadWorker.ReportProgress(0, "load mail chats");

            try
            {
                _initialDocumentArray.AddRange(GlobalObjects.CasEnvironment.Loader.GetObjectListAll <MailChats>(loadChild: true).ToArray());
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load mail chats", ex);
            }

            AnimatedThreadWorker.ReportProgress(70, "filter mail chats");
            FilterItems(_initialDocumentArray, _resultDocumentArray);

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDirectiveArray.Clear();

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

            try
            {
                if (_currentForecast == null)
                {
                    AnimatedThreadWorker.ReportProgress(0, "load items");

                    if (DirectiveSource is Aircraft)
                    {
                        var aircraft        = DirectiveSource as Aircraft;
                        var aircraftModelId = aircraft.Model?.ItemId ?? -1;
                        if (MpdIds.Count > 0)
                        {
                            _initialDirectiveArray.AddRange(GlobalObjects.KitsCore.GetMpdKits(aircraft.ItemId, MpdIds).ToArray());
                        }
                        else
                        {
                            _initialDirectiveArray.AddRange(GlobalObjects.KitsCore.GetAllAircraftKits(aircraft.ItemId, aircraftModelId).ToArray());
                        }
                    }
                    else
                    {
                        _initialDirectiveArray.AddRange(GlobalObjects.KitsCore.GetAllWorkPackageKits(((WorkPackage)DirectiveSource).ItemId).ToArray());
                    }

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

                    AnimatedThreadWorker.ReportProgress(20, "calculation of items");


                    IDirective[] directives =
                        _initialDirectiveArray.Where(i => i.ParentObject is IDirective)
                        .Select(i => i.ParentObject as IDirective)
                        .Distinct()
                        .ToArray();
                    double step = 75.0 / directives.Count();

                    for (int i = 0; i < directives.Length; i++)
                    {
                        if (AnimatedThreadWorker.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }
                        AnimatedThreadWorker.ReportProgress(20 + (int)(step * i), "calculation of items");

                        GlobalObjects.PerformanceCalculator.GetNextPerformance(directives[i]);
                    }
                }
                else
                {
                    _currentForecast.Kits.Clear();

                    AnimatedThreadWorker.ReportProgress(0, "calc. Maint. Checks kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetMaintenanceChecksKits(_currentForecast));

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

                    AnimatedThreadWorker.ReportProgress(9, "calc. Maint. Directives kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetMaintenanceDirectivesKits(_currentForecast));

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

                    AnimatedThreadWorker.ReportProgress(19, "calc. Base details kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetBaseComponentsAndComponentDirectivesKits(_currentForecast));

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

                    AnimatedThreadWorker.ReportProgress(29, "calc. Components kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetComponentsAndComponentDirectivesKits(_currentForecast));

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

                    AnimatedThreadWorker.ReportProgress(39, "calc. AD kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetDirectivesKits(_currentForecast, DirectiveType.AirworthenessDirectives));

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

                    AnimatedThreadWorker.ReportProgress(49, "calc. Damages kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetDirectivesKits(_currentForecast, DirectiveType.DamagesRequiring));

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

                    AnimatedThreadWorker.ReportProgress(59, "calc. Deffered kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetDirectivesKits(_currentForecast, DirectiveType.DeferredItems));

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

                    AnimatedThreadWorker.ReportProgress(69, "calc. Engineering orders kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetEngineeringOrdersKits(_currentForecast));

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

                    AnimatedThreadWorker.ReportProgress(79, "calc. Service bulletins kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetServiceBulletinsKits(_currentForecast));

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

                    AnimatedThreadWorker.ReportProgress(89, "calc. Out of phase kits");
                    _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetDirectivesKits(_currentForecast, DirectiveType.OutOfPhase));

                    if (AnimatedThreadWorker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                    _initialDirectiveArray.AddRange(_currentForecast.Kits.ToArray());
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading data", ex);
            }

            AnimatedThreadWorker.ReportProgress(95, "Filter kits");

            FilterItems(_initialDirectiveArray, _resultDirectiveArray);

            #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, "calc. kits over");
        }
Esempio n. 21
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (_parent == null)
            {
                return;
            }
            _initialArray.Clear();
            _resultArray.Clear();

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

            try
            {
                if (!checkBoxAll.Checked)
                {
                    if (initialfilter != null)
                    {
                        _initialArray.AddRange(
                            GlobalObjects.CasEnvironment.NewLoader.GetObjectList <InitialOrderDTO, InitialOrder>(new[]
                        {
                            initialfilter,
                            new Filter("Status", WorkPackageStatus.Opened)
                        }));
                    }
                    else
                    {
                        _initialArray.AddRange(
                            GlobalObjects.CasEnvironment.NewLoader.GetObjectList <InitialOrderDTO, InitialOrder>(
                                new Filter("Status", WorkPackageStatus.Opened)));
                    }

                    if (quotationfilter != null)
                    {
                        _initialArray.AddRange(
                            GlobalObjects.CasEnvironment.NewLoader
                            .GetObjectList <RequestForQuotationDTO, RequestForQuotation>(new[]
                        {
                            quotationfilter,
                            new Filter("Status", WorkPackageStatus.Opened)
                        }));
                    }
                    else
                    {
                        _initialArray.AddRange(
                            GlobalObjects.CasEnvironment.NewLoader
                            .GetObjectList <RequestForQuotationDTO, RequestForQuotation>(new Filter("Status",
                                                                                                    WorkPackageStatus.Opened)));
                    }

                    if (purchasefilter != null)
                    {
                        _initialArray.AddRange(
                            GlobalObjects.CasEnvironment.NewLoader.GetObjectList <PurchaseOrderDTO, PurchaseOrder>(new[]
                        {
                            purchasefilter,
                            new Filter("Status", WorkPackageStatus.Published)
                        }));
                        _initialArray.AddRange(
                            GlobalObjects.CasEnvironment.NewLoader.GetObjectList <PurchaseOrderDTO, PurchaseOrder>(new[]
                        {
                            purchasefilter,
                            new Filter("Status", WorkPackageStatus.Opened),
                        }));
                    }
                    else
                    {
                        _initialArray.AddRange(
                            GlobalObjects.CasEnvironment.NewLoader.GetObjectList <PurchaseOrderDTO, PurchaseOrder>(new[]
                        {
                            new Filter("Status", WorkPackageStatus.Published)
                        }));
                        _initialArray.AddRange(
                            GlobalObjects.CasEnvironment.NewLoader.GetObjectList <PurchaseOrderDTO, PurchaseOrder>(new[]
                        {
                            new Filter("Status", WorkPackageStatus.Opened),
                        }));
                    }
                }
                else
                {
                    _initialArray.AddRange(
                        GlobalObjects.CasEnvironment.NewLoader.GetObjectList <InitialOrderDTO, InitialOrder>());
                    _initialArray.AddRange(
                        GlobalObjects.CasEnvironment.NewLoader.GetObjectList <RequestForQuotationDTO, RequestForQuotation>());
                    _initialArray.AddRange(
                        GlobalObjects.CasEnvironment.NewLoader.GetObjectList <PurchaseOrderDTO, PurchaseOrder>());
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load Orders", ex);
            }

            AnimatedThreadWorker.ReportProgress(70, "filter Orders");
            FilterItems(_initialArray, _resultArray);
            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 22
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDirectiveArray.Clear();
            _resultDirectiveArray.Clear();

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

            try
            {
                if (_currentForecast == null)
                {
                    var aircrafts = GlobalObjects.AircraftsCore.GetAllAircrafts();
                    foreach (var aircraft in aircrafts)
                    {
                        _initialDirectiveArray.AddRange(GlobalObjects.DirectiveCore.GetDeferredItems(null, aircraft));
                    }
                }
                else
                {
                    AnimatedThreadWorker.ReportProgress(20, "calculation directives");

                    GlobalObjects.AnalystCore.GetDirectives(_currentForecast, _currentPrimaryDirectiveType);
                    DirectiveCollection dirC = _currentForecast.DirectiveCollections[_currentPrimaryDirectiveType];
                    foreach (Directive directive in dirC)
                    {
                        _initialDirectiveArray.Add(directive);
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading directives", ex);
            }
            AnimatedThreadWorker.ReportProgress(40, "filter directives");
            if (_adType != ADType.None)
            {
                List <Directive> forDeleting =
                    _initialDirectiveArray.Where(primaryDirective => primaryDirective.ADType != _adType).ToList();

                foreach (Directive directive in forDeleting)
                {
                    _initialDirectiveArray.Remove(_initialDirectiveArray.GetItemById(directive.ItemId));
                }
            }

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

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

            foreach (Directive pd in _initialDirectiveArray)
            {
                //GlobalObjects.PerformanceCalculator.GetNextPerformance(pd);
                GlobalObjects.MTOPCalculator.CalculateDirectiveNew(pd);
            }

            AnimatedThreadWorker.ReportProgress(70, "filter directives");

            FilterItems(_initialDirectiveArray, _resultDirectiveArray);

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


            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.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 (Directive task in _resultDirectiveArray)
            {
                if (task == null || task.NextPerformances == null || task.NextPerformances.Count <= 0)
                {
                    continue;
                }
                //Проход по всем след. выполнениям чека и записям в рабочих пакетах
                //для поиска перекрывающихся выполнений
                List <NextPerformance> performances = task.NextPerformances;
                foreach (NextPerformance np in performances)
                {
                    //поиск записи в рабочих пакетах по данному чеку
                    //чей номер группы выполнения (по записи) совпадает с расчитанным
                    WorkPackageRecord wpr =
                        openWPRecords.Where(r => r.PerformanceNumFromStart == np.PerformanceNum &&
                                            r.WorkPackageItemType == task.SmartCoreObjectType.ItemId &&
                                            r.DirectiveId == task.ItemId).FirstOrDefault();
                    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");
        }
Esempio n. 23
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _initialDirectiveArray.Clear();
            _resultDirectiveArray.Clear();

            #region Загрузка элементов

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

            try
            {
                _initialDirectiveArray.AddRange(GlobalObjects.CaaEnvironment.NewLoader.GetObjectListAll <CAASupplierDTO, SmartCore.Purchase.Supplier>(new List <Filter>()
                {
                    new Filter("OperatorId", _operatorId)
                }, true));
            }
            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;
            }
            #endregion

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

            FilterItems(_initialDirectiveArray, _resultDirectiveArray);

            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");
        }
Esempio n. 24
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (_parent == null)
            {
                return;
            }
            _purchaseArray.Clear();
            _resultArray.Clear();
            _addedQuatationOrderRecords.Clear();

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

            try
            {
                _purchaseArray.AddRange(
                    GlobalObjects.CasEnvironment.NewLoader.GetObjectList <PurchaseOrderDTO, PurchaseOrder>(
                        new Filter("Status", WorkPackageStatus.Published)));
                var orderIds = _purchaseArray.Select(i => i.ItemId);
                if (orderIds.Count() > 0)
                {
                    var records = GlobalObjects.CasEnvironment.Loader.GetObjectList <PurchaseRequestRecord>(
                        new ICommonFilter[]
                    {
                        new CommonFilter <int>(PurchaseRequestRecord.ParentPackageIdProperty, FilterType.In,
                                               orderIds.ToArray())
                    });
                    var ids        = records.Select(s => s.SupplierId).Distinct().ToArray();
                    var productIds = records.Select(s => s.PackageItemId).Distinct().ToArray();
                    var suppliers  = GlobalObjects.CasEnvironment.Loader.GetObjectList <Supplier>(new ICommonFilter[]
                    {
                        new CommonFilter <int>(BaseEntityObject.ItemIdProperty, SmartCore.Filters.FilterType.In, ids),
                    });
                    var products = GlobalObjects.CasEnvironment.Loader.GetObjectList <Product>(new ICommonFilter[]
                    {
                        new CommonFilter <int>(BaseEntityObject.ItemIdProperty, SmartCore.Filters.FilterType.In,
                                               productIds),
                    });

                    var _supplierShipper = GlobalObjects.CasEnvironment.Loader.GetObjectList <Supplier>(
                        new ICommonFilter[]
                        { new CommonFilter <int>(Supplier.SupplierClassProperty, SupplierClass.Shipper.ItemId) });

                    var stationIds = _purchaseArray.Select(i => i.StationId);
                    var station    =
                        GlobalObjects.CasEnvironment.NewLoader.GetObjectList <AirportCodeDTO, AirportsCodes>(
                            new Filter("ItemId", stationIds));

                    foreach (var purchase in _purchaseArray)
                    {
                        purchase.Station     = station.FirstOrDefault(i => i.ItemId == purchase.StationId);
                        purchase.ShipCompany =
                            _supplierShipper.FirstOrDefault(i => i.ItemId == purchase.ShipCompanyId) ??
                            Supplier.Unknown;
                    }

                    foreach (var order in records.GroupBy(i => i.ParentPackageId))
                    {
                        var parentInitialId = (int)GlobalObjects.CasEnvironment.Execute(
                            $@"select i.ItemId from PurchaseOrders p
			left join RequestsForQuotation q on q.ItemID = p.ParentID
			left join InitialOrders i on i.ItemID = q.ParentID where p.ItemId = {order.Key}"            ).Tables[0].Rows[0][0];
                        var initialRecords =
                            GlobalObjects.CasEnvironment.NewLoader
                            .GetObjectList <InitialOrderRecordDTO, InitialOrderRecord>(new Filter("ParentPackageId",
                                                                                                  parentInitialId));
                        var initial =
                            GlobalObjects.CasEnvironment.NewLoader.GetObject <InitialOrderDTO, InitialOrder>(
                                new Filter("ItemId", parentInitialId));
                        foreach (var record in order)
                        {
                            record.ParentPackage       = _purchaseArray.FirstOrDefault(i => i.ItemId == order.Key);
                            record.ParentInitialRecord =
                                initialRecords.FirstOrDefault(i => i.ProductId == record.PackageItemId);
                            if (record.ParentInitialRecord != null)
                            {
                                record.ParentInitialRecord.ParentPackage = initial;
                            }
                            record.Product  = products.FirstOrDefault(i => i.ItemId == record.PackageItemId);
                            record.Supplier = suppliers.FirstOrDefault(i => i.ItemId == record.SupplierId);
                        }
                    }

                    _resultArray.AddRange(records);
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load Quotations", ex);
            }

            AnimatedThreadWorker.ReportProgress(20, "calculation Quotations");

            AnimatedThreadWorker.ReportProgress(70, "filter Quotations");

            AnimatedThreadWorker.ReportProgress(100, "Complete");
        }
Esempio n. 25
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            _currentForecast.Kits.Clear();

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

            try
            {
                AnimatedThreadWorker.ReportProgress(0, "calc. Maint. Checks kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetMaintenanceChecksKits(_currentForecast));

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

                AnimatedThreadWorker.ReportProgress(9, "calc. Maint. Directives kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetMaintenanceDirectivesKits(_currentForecast));

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

                AnimatedThreadWorker.ReportProgress(19, "calc. Base details kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetBaseComponentsAndComponentDirectivesKits(_currentForecast));

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

                AnimatedThreadWorker.ReportProgress(29, "calc. Components kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetComponentsAndComponentDirectivesKits(_currentForecast));

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

                AnimatedThreadWorker.ReportProgress(39, "calc. AD kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetDirectivesKits(_currentForecast, DirectiveType.AirworthenessDirectives));

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

                AnimatedThreadWorker.ReportProgress(49, "calc. Damages kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetDirectivesKits(_currentForecast, DirectiveType.DamagesRequiring));

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

                AnimatedThreadWorker.ReportProgress(59, "calc. Deffered kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetDirectivesKits(_currentForecast, DirectiveType.DeferredItems));

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

                AnimatedThreadWorker.ReportProgress(69, "calc. Engineering orders kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetEngineeringOrdersKits(_currentForecast));

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

                AnimatedThreadWorker.ReportProgress(79, "calc. Service bulletins kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetServiceBulletinsKits(_currentForecast));

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

                AnimatedThreadWorker.ReportProgress(89, "calc. Out of phase kits");
                _currentForecast.Kits.AddRange(GlobalObjects.AnalystCore.GetDirectivesKits(_currentForecast, DirectiveType.OutOfPhase));

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

                AnimatedThreadWorker.ReportProgress(90, "Filter kits");

                _initialDirectiveArray.Clear();
                _initialDirectiveArray.AddRange(_currentForecast.Kits.ToArray());

                FilterItems(_initialDirectiveArray, _resultDirectiveArray);

                #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
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading data", ex);
            }

            AnimatedThreadWorker.ReportProgress(100, "calc. kits over");
        }
Esempio n. 26
0
        protected override void AnimatedThreadWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            if (_parent == null)
            {
                return;
            }
            _quotatioArray.Clear();
            _resultArray.Clear();
            _addedQuatationOrderRecords.Clear();
            _data.Clear();

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

            try
            {
                _quotatioArray.AddRange(GlobalObjects.CasEnvironment.NewLoader.GetObjectList <RequestForQuotationDTO, RequestForQuotation>(new Filter("Status", WorkPackageStatus.Opened)));
                var quotaIds = _quotatioArray.Select(i => i.ItemId);

                if (quotaIds.Count() > 0)
                {
                    var _quotationCosts =
                        GlobalObjects.CasEnvironment.NewLoader.GetObjectList <QuotationCostDTO, QuotationCost>(
                            new Filter("QuotationId", quotaIds));
                    _addedQuatationOrderRecords =
                        GlobalObjects.CasEnvironment.NewLoader
                        .GetObjectList <RequestForQuotationRecordDTO, RequestForQuotationRecord>(
                            new Filter("ParentPackageId", quotaIds), true);
                    var ids = _addedQuatationOrderRecords.Select(i => i.PackageItemId);


                    if (ids.Count() > 0)
                    {
                        var products = GlobalObjects.CasEnvironment.Loader.GetObjectList <Product>(
                            new CommonFilter <int>(BaseEntityObject.ItemIdProperty, FilterType.In, ids.ToArray()), true);
                        var supplierId = _addedQuatationOrderRecords.SelectMany(i => i.SupplierPrice)
                                         .Select(i => i.SupplierId);
                        var suppliers =
                            GlobalObjects.CasEnvironment.NewLoader.GetObjectList <SupplierDTO, Supplier>(new Filter(
                                                                                                             "ItemId",
                                                                                                             supplierId));

                        foreach (var record in _addedQuatationOrderRecords.GroupBy(i => i.ParentPackageId))
                        {
                            var parentInitialId = (int)GlobalObjects.CasEnvironment.Execute(
                                $@"select i.ItemId from RequestsForQuotation q
			left join InitialOrders i on i.ItemID = q.ParentID where q.ItemId = {record.Key}"            ).Tables[0]
                                                  .Rows[0][0];
                            var initialOrderRecords =
                                GlobalObjects.CasEnvironment.NewLoader
                                .GetObjectList <InitialOrderRecordDTO, InitialOrderRecord>(
                                    new Filter("ParentPackageId", parentInitialId));
                            var initial = GlobalObjects.CasEnvironment.NewLoader.GetObject <InitialOrderDTO, InitialOrder>(new Filter("ItemId", parentInitialId));


                            foreach (var addedInitialOrderRecord in record)
                            {
                                addedInitialOrderRecord.ParentInitialRecord =
                                    initialOrderRecords.FirstOrDefault(i =>
                                                                       i.ProductId == addedInitialOrderRecord.PackageItemId);
                                addedInitialOrderRecord.ParentPackage = _quotatioArray.FirstOrDefault(i =>
                                                                                                      i.ItemId == addedInitialOrderRecord.ParentPackageId);
                                if (addedInitialOrderRecord.ParentInitialRecord != null)
                                {
                                    addedInitialOrderRecord.ParentInitialRecord.ParentPackage = initial;
                                }
                                var product = products.FirstOrDefault(i =>
                                                                      i.ItemId == addedInitialOrderRecord.PackageItemId);
                                foreach (var relation in product.SupplierRelations)
                                {
                                    var findCost = _quotationCosts.FirstOrDefault(i =>
                                                                                  i.ProductId == product.ItemId && i.SupplierId == relation.Supplier.ItemId);
                                    if (findCost != null)
                                    {
                                        findCost.SupplierName = relation.Supplier.Name;
                                        product.QuatationCosts.Add(findCost);
                                    }
                                }

                                addedInitialOrderRecord.Product = product;

                                foreach (var price in addedInitialOrderRecord.SupplierPrice)
                                {
                                    price.Parent   = addedInitialOrderRecord;
                                    price.Supplier = suppliers.FirstOrDefault(i => i.ItemId == price.SupplierId);


                                    _data.Add(new SupplierPriceCustom
                                    {
                                        Record = addedInitialOrderRecord,
                                        Price  = price,
                                    });
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while load Quotations", ex);
            }

            AnimatedThreadWorker.ReportProgress(20, "calculation Quotations");

            AnimatedThreadWorker.ReportProgress(70, "filter Quotations");

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

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

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

            if (ViewedType.IsSubclassOf(typeof(StaticDictionary)))
            {
                PropertyInfo p = ViewedType.GetProperty("Items");

                ConstructorInfo  ci       = ViewedType.GetConstructor(new Type[0]);
                StaticDictionary instance = (StaticDictionary)ci.Invoke(null);

                InitialDirectiveArray.AddRange((IDictionaryCollection)p.GetValue(instance, null));
                InitialDirectiveArray.RemoveById(-1);
            }
            else
            {
                //TODO:(Evgenii Babak) нужен Helper
                if (ViewedType.Name == nameof(NonRoutineJob))
                {
                    InitialDirectiveArray.AddRange(GlobalObjects.NonRoutineJobCore.GetNonRoutineJobs().ToArray());
                }
                else
                {
                    if (GlobalObjects.CasEnvironment != null)
                    {
                        InitialDirectiveArray.AddRange(GlobalObjects.CasEnvironment?.Loader.GetObjectCollection(ViewedType, loadChild: true));
                    }
                    else
                    {
                        var dto = (CAADtoAttribute)ViewedType.GetCustomAttributes(typeof(CAADtoAttribute), false).FirstOrDefault();
                        var res = GlobalObjects.CaaEnvironment.NewLoader.GetObjectList(dto.Type, ViewedType, loadChild: true);
                        InitialDirectiveArray.AddRange((IEnumerable <IBaseEntityObject>)res);
                    }
                }
            }

            AnimatedThreadWorker.ReportProgress(40, "filter directives");

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

            FilterItems(InitialDirectiveArray, ResultDirectiveArray);

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

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

                if (GlobalObjects.CasEnvironment != null)
                {
                    //загрузка рабочих пакетов для определения
                    //перекрытых ими выполнений задач
                    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));
                }
            }

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

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

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

            if (GlobalObjects.CasEnvironment != null)
            {
                _openPubQuotations.Clear();
                _openPubQuotations.AddRange(GlobalObjects.PurchaseCore.
                                            GetRequestForQuotation(CurrentOperator, new[] { WorkPackageStatus.Opened, WorkPackageStatus.Published }));
            }

            #endregion
            if (AnimatedThreadWorker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }
            AnimatedThreadWorker.ReportProgress(100, "Complete");
            #endregion
        }