Example #1
0
        public string[] GetAllowedPmMethods(string operationCode, string objectEntityCode, string objectName)
        {
            var emptyresult = new string[0];

            if (_allowedPmMethods == null || !_allowedPmMethods.Any())
            {
                return(emptyresult);
            }

            var key = ConfiguratorHelper.CreatePmAllowedMethodsKey(operationCode, objectEntityCode, objectName);

            return(_allowedPmMethods.Contains(key) ? _allowedPmMethods[key].ToArray() : emptyresult);
        }
Example #2
0
        public void ValidatePmDetail()
        {
            IsEnabledByProduct   = false;
            IsEnabledByInputMask = false;
            IsEnabledByInputMass = false;
            if (SelectedMethod != null)
            {
                if (SelectedMethod.Method != null && _owner != null)
                {
                    var methodCode = SelectedMethod.Method.GetKey <string>();
                    if (!string.IsNullOrEmpty(OperationCode) &&
                        SelectedItem != null && !string.IsNullOrEmpty(SelectedItem.OjectEntityCode) &&
                        !string.IsNullOrEmpty(SelectedItem.ObjectName) && !string.IsNullOrEmpty(methodCode))
                    {
                        var key = ConfiguratorHelper.CreateAllowedDetailsPmMethodKey(operationCode: OperationCode,
                                                                                     objectEntityCode: SelectedItem.OjectEntityCode, objectName: SelectedItem.ObjectName,
                                                                                     methodCode: methodCode, property: PMConfig.PMCONFIGBYPRODUCTPropertyName);
                        VisibilityByProduct = _owner.AllowedDetailsPmMethod.ContainsKey(key) &&
                                              _owner.AllowedDetailsPmMethod[key];
                        IsEnabledByProduct = VisibilityByProduct && SelectedMethod.IsChecked;

                        key = ConfiguratorHelper.CreateAllowedDetailsPmMethodKey(operationCode: OperationCode,
                                                                                 objectEntityCode: SelectedItem.OjectEntityCode, objectName: SelectedItem.ObjectName,
                                                                                 methodCode: methodCode, property: PMConfig.PMCONFIGINPUTMASKPropertyName);
                        VisibilityByInputMask = _owner.AllowedDetailsPmMethod.ContainsKey(key) &&
                                                _owner.AllowedDetailsPmMethod[key];
                        IsEnabledByInputMask = VisibilityByInputMask && SelectedMethod.IsChecked;

                        key = ConfiguratorHelper.CreateAllowedDetailsPmMethodKey(operationCode: OperationCode,
                                                                                 objectEntityCode: SelectedItem.OjectEntityCode, objectName: SelectedItem.ObjectName,
                                                                                 methodCode: methodCode, property: PMConfig.PMCONFIGINPUTMASSPropertyName);
                        VisibilityByInputMass = _owner.AllowedDetailsPmMethod.ContainsKey(key) &&
                                                _owner.AllowedDetailsPmMethod[key];
                        IsEnabledByInputMass = VisibilityByInputMass && SelectedMethod.IsChecked;
                    }
                }
            }
        }
Example #3
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);
                }
            }));
        }