/// <summary>
        /// 获取查询条件
        /// </summary>
        /// <param name="Schema"></param>
        /// <param name="ListMethod"></param>
        /// <param name="Query"></param>
        /// <returns></returns>
        private OThinker.H3.BizBus.Filter.Filter GetFilter(DataModel.BizObjectSchema Schema, string ListMethod, DataModel.BizQuery Query)
        {
            // 构造查询条件
            OThinker.H3.BizBus.Filter.Filter filter = new OThinker.H3.BizBus.Filter.Filter();

            OThinker.H3.BizBus.Filter.And and = new OThinker.H3.BizBus.Filter.And();
            filter.Matcher = and;
            ItemMatcher propertyMatcher = null;

            if (Query.QueryItems != null)
            {
                foreach (DataModel.BizQueryItem queryItem in Query.QueryItems)
                { // 增加系统参数条件
                    if (queryItem.FilterType == DataModel.FilterType.SystemParam)
                    {
                        propertyMatcher = new OThinker.H3.BizBus.Filter.ItemMatcher(queryItem.PropertyName,
                                                                                    OThinker.Data.ComparisonOperatorType.Equal,
                                                                                    SheetUtility.GetSystemParamValue(this.UserValidator, queryItem.SelectedValues));
                        and.Add(propertyMatcher);
                    }
                    else if (queryItem.Visible == OThinker.Data.BoolMatchValue.False)
                    {
                        and.Add(new ItemMatcher(queryItem.PropertyName,
                                                queryItem.FilterType == DataModel.FilterType.Contains ? OThinker.Data.ComparisonOperatorType.Contain
                                : OThinker.Data.ComparisonOperatorType.Equal,
                                                queryItem.DefaultValue));
                    }
                }
            }
            return(filter);
        }
예제 #2
0
        /// <summary>
        /// 获取联动规则的数据,数据源来自 BizBus
        /// </summary>
        protected void GetLinkageData()
        {
            string targetId           = Request["TargetID"];
            string schemaCode         = Request["SchemaCode"];
            string filterMethod       = Request["FilterMethod"];
            string queryCode          = Request["QueryCode"];
            string queryPropertyName  = Request["QueryPropertyName"];
            string queryPropertyValue = Request["QueryPropertyValue"];
            string textDataField      = Request["TextDataField"];
            string valueDataField     = Request["ValueDataField"];

            // 获取查询对象
            //BizQuery query = OThinker.H3.WorkSheet.AppUtility.Engine.BizBus.GetBizQuery(schemaCode, queryCode);
            DataModel.BizQuery query = AppUtility.Engine.BizObjectManager.GetBizQuery(queryCode);
            // 构造查询条件
            OThinker.H3.BizBus.Filter.Filter filter = new BizBus.Filter.Filter();
            OThinker.H3.BizBus.Filter.And    and    = new And();
            filter.Matcher = and;
            ItemMatcher propertyMatcher = null;

            if (query.QueryItems != null)
            {
                string[] values = queryPropertyValue.Split(new string[] { "," }, StringSplitOptions.None);
                int      i      = 0;
                foreach (DataModel.BizQueryItem queryItem in query.QueryItems)
                { // 增加系统参数条件
                    if (queryItem.FilterType == DataModel.FilterType.SystemParam)
                    {
                        propertyMatcher = new OThinker.H3.BizBus.Filter.ItemMatcher(queryItem.PropertyName,
                                                                                    OThinker.Data.ComparisonOperatorType.Equal,
                                                                                    SheetUtility.GetSystemParamValue(UserValidatorFactory.CurrentUser, queryItem.SelectedValues));
                        and.Add(propertyMatcher);
                        continue;
                    }
                    else if (values.Length > 1)
                    {
                        if (values.Length > i)
                        {
                            propertyMatcher = new OThinker.H3.BizBus.Filter.ItemMatcher(queryItem.PropertyName,
                                                                                        queryItem.FilterType == DataModel.FilterType.Contains ? OThinker.Data.ComparisonOperatorType.Contain : OThinker.Data.ComparisonOperatorType.Equal,
                                                                                        values[i]);
                            and.Add(propertyMatcher);
                        }
                    }
                    else if (queryItem.PropertyName == queryPropertyName)
                    {
                        propertyMatcher = new OThinker.H3.BizBus.Filter.ItemMatcher(queryPropertyName,
                                                                                    queryItem.FilterType == DataModel.FilterType.Contains ? OThinker.Data.ComparisonOperatorType.Contain : OThinker.Data.ComparisonOperatorType.Equal,
                                                                                    queryPropertyValue);
                        and.Add(propertyMatcher);
                    }
                    i++;
                }
            }
            DataModel.BizObjectSchema   schema      = AppUtility.Engine.BizObjectManager.GetPublishedSchema(schemaCode);
            Dictionary <string, string> SelectItems = new Dictionary <string, string>();

            if (schema != null)
            {
                // 调用查询获取数据源
                //OThinker.H3.DataModel.BizObject[] objs = schema.GetList(OThinker.H3.WorkSheet.AppUtility.Engine.BizBus,
                //    this.UserValidator.UserID,
                //    filterMethod,
                //    filter);
                DataModel.BizObject[] objs = schema.GetList(
                    AppUtility.Engine.Organization,
                    AppUtility.Engine.MetadataRepository,
                    AppUtility.Engine.BizObjectManager,
                    UserValidatorFactory.CurrentUser != null ? UserValidatorFactory.CurrentUser.UserID : string.Empty,
                    filterMethod,
                    filter);

                DataTable dtSource = DataModel.BizObjectUtility.ToTable(schema, objs);
                foreach (DataRow row in dtSource.Rows)
                {
                    SelectItems.Add(row[valueDataField] + string.Empty, row[textDataField] + string.Empty);
                }
            }

            Response.Clear();
            Response.Write(JSSerializer.Serialize(SelectItems));
            Response.Buffer = true;
        }