Esempio n. 1
0
        public bool ValidatePmMethods(string operationCode, PmConfiguratorData data)
        {
            if (data == null)
            {
                return(false);
            }

            var result = GetAllowedPmMethods(operationCode: operationCode, objectEntityCode: data.OjectEntityCode, objectName: data.ObjectName);

            return(result.Any());
        }
Esempio n. 2
0
        private void OnNewCommand()
        {
            if (!CanNewCommand())
            {
                return;
            }

            if (!ItemsSource.Any(p => p.IsNewRow))
            {
                var item = new PmConfiguratorData(this);
                item.AcceptChanges(true);
                ItemsSource.Add(item);
            }
            OnNewRowAdded();
        }
Esempio n. 3
0
        public PmConfiguratorData Clone()
        {
            try
            {
                BeginDataUpdate();
                var result = new PmConfiguratorData(Owner)
                {
                    PmCode          = PmCode,
                    OjectEntityCode = OjectEntityCode,
                    ObjectName      = ObjectName,
                    PmMethodCodes   = new Dictionary <string, EditableBusinessObjectCollection <object> >((PmMethodCodes))
                };

                return(result);
            }
            finally
            {
                EndDataUpdate();
            }
        }
Esempio n. 4
0
        private async Task <IEnumerable <PmConfiguratorData> > GetDataAsync()
        {
            var now = DateTime.Now;
            IEnumerable <BillOperation>      operations      = null;
            IEnumerable <decimal>            entityids       = null;
            IEnumerable <SysObject>          attributes      = null;
            IEnumerable <PM>                 pms             = null;
            IEnumerable <PMMethod>           pmMethods       = null;
            IEnumerable <PMMethod2Operation> detailsPmMethod = null;
            DataTable pmdatatable = null;
            DataTable pmMethod2OperationsAlloweddatatable = null;
            double    lastQueryExecutionTime = 0;

            return(await Task.Factory.StartNew(() =>
            {
                try
                {
                    //System.Threading.Thread.Sleep(10000);
                    using (var mng = IoC.Instance.Resolve <IBPProcessManager>())
                    {
                        mng.GetPmConfiguratorData(ref operations, ref entityids, ref attributes,
                                                  ref pms, ref pmMethods,
                                                  ref detailsPmMethod, ref pmdatatable, ref pmMethod2OperationsAlloweddatatable);

                        lastQueryExecutionTime = ((IBaseManager)mng).LastQueryExecutionTime;
                    }

                    //Получаем операции
                    _operations = null;
                    if (operations != null)
                    {
                        _operations = operations.ToArray();
                    }

                    //Получаем PM
                    Pms = null;
                    if (pms != null)
                    {
                        Pms = new ObservableCollection <PM>(pms.ToArray());
                    }

                    //Получаем сущности
                    _entityIds = null;
                    if (entityids != null)
                    {
                        _entityIds = entityids.Cast <object>().ToArray();
                    }

                    //Получаем атрибуты
                    _attributes = null;
                    if (attributes != null)
                    {
                        _attributes = attributes.ToArray();
                    }

                    //Методы
                    PmMethods = null;
                    if (pmMethods != null)
                    {
                        var pmMethodsInternal = pmMethods.ToList();
                        var method = new PMMethod
                        {
                            PMMETHODNAME = Properties.Resources.PmMethodIsUnavailable
                        };
                        method.SetKey(method.PMMETHODNAME);
                        pmMethodsInternal.Insert(0, method);
                        PmMethods = new BaseObservableCollection <PMMethod>(pmMethodsInternal);
                    }

                    //Получаем детализацию настройки методов
                    AllowedDetailsPmMethod.Clear();
                    if (detailsPmMethod != null)
                    {
                        foreach (PMMethod2Operation p2O in detailsPmMethod)
                        {
                            var key = ConfiguratorHelper.CreateAllowedDetailsPmMethodKey(
                                operationCode: p2O.PMMETHOD2OPERATIONOPERATIONCODE,
                                objectEntityCode: p2O.VOBJECTENTITYCODE,
                                objectName: p2O.VOBJECTNAME,
                                methodCode: p2O.PMMETHOD2OPERATIONPMMETHODCODE,
                                property: PMConfig.PMCONFIGBYPRODUCTPropertyName);
                            AllowedDetailsPmMethod[key] = p2O.PMMETHOD2OPERATIONBYPRODUCT == true;

                            key = ConfiguratorHelper.CreateAllowedDetailsPmMethodKey(
                                operationCode: p2O.PMMETHOD2OPERATIONOPERATIONCODE,
                                objectEntityCode: p2O.VOBJECTENTITYCODE,
                                objectName: p2O.VOBJECTNAME,
                                methodCode: p2O.PMMETHOD2OPERATIONPMMETHODCODE,
                                property: PMConfig.PMCONFIGINPUTMASKPropertyName);
                            AllowedDetailsPmMethod[key] = p2O.PMMETHOD2OPERATIONINPUTMASK == true;

                            key = ConfiguratorHelper.CreateAllowedDetailsPmMethodKey(
                                operationCode: p2O.PMMETHOD2OPERATIONOPERATIONCODE,
                                objectEntityCode: p2O.VOBJECTENTITYCODE,
                                objectName: p2O.VOBJECTNAME,
                                methodCode: p2O.PMMETHOD2OPERATIONPMMETHODCODE,
                                property: PMConfig.PMCONFIGINPUTMASSPropertyName);
                            AllowedDetailsPmMethod[key] = p2O.PMMETHOD2OPERATIONINPUTMASS == true;
                        }
                    }

                    _allowedPmMethods = null;
                    if (pmMethod2OperationsAlloweddatatable != null)
                    {
                        _allowedPmMethods =
                            pmMethod2OperationsAlloweddatatable.AsEnumerable()
                            .ToLookup(
                                key =>
                                ConfiguratorHelper.CreatePmAllowedMethodsKey(key.Field <string>("OperationCode"),
                                                                             key.Field <string>("ObjectEntityCode"),
                                                                             key.Field <string>("ObjectName")),
                                g => g.Field <string>("PmMethodCode"));
                    }

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

                    //Поготовка ItemsSource
                    var data = pmdatatable.AsEnumerable()
                               .Select(p => new
                    {
                        PMCODE = p.Field <string>("PMCODE"),
                        PM2OPERATIONCODE = p.Field <string>("PM2OPERATIONCODE"),
                        OPERATIONCODE = p.Field <string>("OPERATIONCODE"),
                        OBJECTENTITYCODE = p.Field <string>("OBJECTENTITYCODE"),
                        OBJECTNAME = p.Field <string>("OBJECTNAME"),
                        PMMETHODCODE = p.Field <string>("PMMETHODCODE"),
                        BYPRODUCT = (p.Field <short?>("PMCONFIGBYPRODUCT") >= 1),
                        INPUTMASK = (p.Field <string>("PMCONFIGINPUTMASK")),
                        INPUTMASS = (p.Field <short?>("PMCONFIGINPUTMASS") >= 1)
                    })
                               //.Where(p => !string.IsNullOrEmpty(p.OBJECTENTITYCODE) && !string.IsNullOrEmpty(p.OBJECTNAME))
                               .GroupBy(key => GetKey(key.PMCODE, key.OBJECTENTITYCODE, key.OBJECTNAME))
                               .Select(g =>
                    {
                        var lkmethods = g
                                        .Where(p => !string.IsNullOrEmpty(p.OPERATIONCODE))
                                        .ToLookup(lk => lk.OPERATIONCODE, lv => lv.PMMETHODCODE);
                        var methodsdict = new Dictionary <string, EditableBusinessObjectCollection <object> >();
                        foreach (var l in lkmethods)
                        {
                            methodsdict[l.Key] =
                                new EditableBusinessObjectCollection <object>(l.Select(lv => (object)lv));
                            methodsdict[l.Key].AcceptChanges();
                        }

                        var pmConfiguratorData = new PmConfiguratorData(this);

                        try
                        {
                            pmConfiguratorData.BeginDataUpdate();
                            pmConfiguratorData.PmCode = g.First().PMCODE;
                            pmConfiguratorData.OjectEntityCode = g.First().OBJECTENTITYCODE;
                            pmConfiguratorData.ObjectName = g.First().OBJECTNAME;
                            pmConfiguratorData.PmMethodCodes = methodsdict;

                            foreach (var bp in g.Where(p => p.BYPRODUCT))
                            {
                                pmConfiguratorData.PmMethodByProduct[
                                    pmConfiguratorData.GetPmMethodDetailsKey(operationCode: bp.OPERATIONCODE,
                                                                             methodCode: bp.PMMETHODCODE)] = true;
                            }

                            foreach (var bp in g.Where(p => !string.IsNullOrEmpty(p.INPUTMASK)))
                            {
                                pmConfiguratorData.PmMethodByInputMask[
                                    pmConfiguratorData.GetPmMethodDetailsKey(operationCode: bp.OPERATIONCODE,
                                                                             methodCode: bp.PMMETHODCODE)] = bp.INPUTMASK;
                            }

                            foreach (var bp in g.Where(p => p.INPUTMASS))
                            {
                                pmConfiguratorData.PmMethodByInputMass[
                                    pmConfiguratorData.GetPmMethodDetailsKey(operationCode: bp.OPERATIONCODE,
                                                                             methodCode: bp.PMMETHODCODE)] = true;
                            }
                        }
                        finally
                        {
                            pmConfiguratorData.EndDataUpdate();
                        }
                        return pmConfiguratorData;
                    }).ToList();

                    return data;
                }
                finally
                {
                    TotalRowItemAdditionalInfo =
                        string.Format(StringResources.ListViewModelBaseTotalRowItemAdditionalInfo,
                                      (DateTime.Now - now).TotalSeconds, lastQueryExecutionTime);
                }
            }));
        }