Exemple #1
0
        void analysisEditor_DataSourceCreating(object sender, DataSourceCreatingEventArgs e)
        {
            CriteriaOperator userCriteria = null;

            if (e.AnalysisInfo != null)
            {
                if (!string.IsNullOrEmpty(e.AnalysisInfo.Criteria))
                {
                    using (ObjectSpace.CreateParseCriteriaScope()) {
                        userCriteria = CriteriaWrapper.ParseCriteriaWithReadOnlyParameters(e.AnalysisInfo.Criteria, e.AnalysisInfo.DataType);
                    }
                }

                var analysisEditorBase   = (AnalysisEditorBase)sender;
                var criteriaOperatorArgs = new CriteriaOperatorArgs(analysisEditorBase, e.AnalysisInfo);
                var analysisEditorArgs   = new AnalysisEditorArgs(analysisEditorBase, e.AnalysisInfo);
                InvokeDatasourceCreating(analysisEditorArgs);
                InvokeApplyingCollectionCriteria(criteriaOperatorArgs);
                e.DataSource = analysisEditorArgs.Handled
                                   ? analysisEditorArgs.DataSource
                                   : ObjectSpace.CreateCollection(e.AnalysisInfo.DataType,
                                                                  userCriteria & criteriaOperatorArgs.Criteria & _criteriaOperator);
                e.Handled = true;
                InvokeDataSourceCreated(analysisEditorArgs);
            }
        }
        private CriteriaOperator GetCriteriaFromView()
        {
            var criteriaWrapper = new CriteriaWrapper(View.ObjectTypeInfo.Type, View.Model.Filter, false);

            new FilterWithObjectsProcessor(ObjectSpace).Process(criteriaWrapper.CriteriaOperator,
                                                                FilterWithObjectsProcessorMode.StringToObject);
            return(criteriaWrapper.CriteriaOperator);
        }
Exemple #3
0
 private string GetCriteriaFromView()
 {
     using (ObjectSpace.CreateParseCriteriaScope()) {
         var criteriaWrapper = new CriteriaWrapper(View.ObjectTypeInfo.Type, View.Model.Filter, false);
         new FilterWithObjectsProcessor(ObjectSpace).Process(criteriaWrapper.CriteriaOperator, FilterWithObjectsProcessorMode.StringToObject);
         return(CriteriaOperator.ToString(criteriaWrapper.CriteriaOperator));
     }
 }
Exemple #4
0
 protected override void UpdateMasterObject(object masterObject)
 {
     if (_criteria != null)
     {
         CriteriaWrapper criteriaWrapper = new CriteriaWrapper(_criteria, masterObject);
         criteriaWrapper.UpdateParametersValues(masterObject);
         ((PropertyCollectionSource)View.CollectionSource).Criteria[nameof(FilteredMasterObjectViewController)] = criteriaWrapper.CriteriaOperator;
     }
 }
Exemple #5
0
        object GetObjectKey(ViewShortcut shortcut, Type type, IObjectSpace objectSpace)
        {
            var objectKey = GetObjectKey(objectSpace, type, shortcut);

            if (objectKey != null)
            {
                return(objectKey);
            }
            return(shortcut.ObjectKey.StartsWith("@")
                            ? ParametersFactory.CreateParameter(shortcut.ObjectKey.Substring(1)).CurrentValue
                            : CriteriaWrapper.ParseCriteriaWithReadOnlyParameters(shortcut.ObjectKey, type));
        }
Exemple #6
0
        private bool?IsObjectFitForCriteria(IModelDatabaseMaintanance databaseMaintanance, IObjectSpace objectSpace)
        {
            var user = objectSpace.GetObject(SecuritySystem.CurrentUser);
            CriteriaOperator criteriaOperator;
            var typeInfo         = databaseMaintanance.UserModelClass?.TypeInfo;
            var targetObjectType = typeInfo?.Type;

            using (objectSpace.CreateParseCriteriaScope()){
                criteriaOperator = CriteriaWrapper.ParseCriteriaWithReadOnlyParameters(databaseMaintanance.UserCriteria, targetObjectType);
            }

            var fit = objectSpace.GetExpressionEvaluator(new EvaluatorContextDescriptorDefault(typeInfo == null?typeof(object):targetObjectType), criteriaOperator).Fit(typeInfo == null?new object():user);

            return(fit);
        }
        //错误 提示
        //public static void NotFoundRecord(string filterString, Cell cell, IMemberInfo pi, int count)
        //{
        //    var msg = string.Format("错误,在查找“{0}”时,使用查找条件“{1}”,找到了{2}条记录!",
        //        pi.MemberType.Name,
        //        filterString,
        //        count);
        //    cell.SetValue(msg);
        //}

        public static CriteriaOperator ParseCriteriaWithReadOnlyParameters(string criteriaText, Type targetObjectType, object currentObject, object[] parameters)
        {
            var criteriaOperator = CriteriaOperator.Parse(criteriaText, parameters);

            var wrapper = new CriteriaWrapper(targetObjectType, criteriaOperator, currentObject);

            //if (wrapper.EditableParameters.Count > 0)
            //{
            //    string message = "Cannot process editable parameters:\n";
            //    foreach (string str2 in wrapper.EditableParameters.Keys)
            //    {
            //        message = message + "'@" + str2 + "'\n";
            //    }
            //    throw new InvalidOperationException(message);
            //}
            wrapper.UpdateParametersValues(currentObject);
            return(wrapper.CriteriaOperator);
        }
Exemple #8
0
        public static object GetValueRecursive(string format, object arg, out IMemberInfo memberInfo)
        {
            memberInfo = null;
            object propertyValue          = nullObject;
            object probableParameterValue = CriteriaWrapper.TryGetReadOnlyParameterValue(format);

            if (!(probableParameterValue is string) || (format != (string)probableParameterValue))
            {
                propertyValue = probableParameterValue;
            }
            else
            {
                object valueByPath;
                if (TryGetValueByPathDynamic(format, arg, out valueByPath, out memberInfo))
                {
                    propertyValue = valueByPath;
                }
            }
            if (propertyValue is string && format != (string)propertyValue)
            {
                if (((string)propertyValue).StartsWith(CriteriaWrapper.ParameterPrefix))
                {
                    object value = GetValueRecursive((string)propertyValue, arg, out memberInfo);
                    if (value != null)
                    {
                        propertyValue = value;
                    }
                }
                else
                {
                    if (((string)propertyValue).Contains("{@"))
                    {
                        propertyValue = Format((string)propertyValue, arg);
                    }
                }
            }
            return(propertyValue);
        }
 private void setCriteriaFromView(FilterControl filter)
 {
     var criteriaWrapper = new CriteriaWrapper(View.ObjectTypeInfo.Type, View.Info.GetAttributeValue(GridListEditor.ActiveFilterString), false);
     new FilterWithObjectsProcessor(ObjectSpace).Process(criteriaWrapper.CriteriaOperator,
                                                         FilterWithObjectsProcessorMode.StringToObject);
     filter.FilterCriteria =criteriaWrapper.CriteriaOperator;
 }
 public override CriteriaOperator GetCriteria()
 {
     return(CriteriaWrapper.ParseCriteriaWithReadOnlyParameters(
                "[Oid] = '@CurrentCompanyOid'", ReportDataType));
 }