/// <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);
        }
        public JsonResult GetDataModelData(string DataModelCode, string QueryCode, string SortBy, int ShowCount, string BoundFiledList, string LinkFormat)
        {
            ActionResult result = new ActionResult(true);

            if (string.IsNullOrEmpty(BoundFiledList))
            {
                result.Message = "未设置绑定数据";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            BizObjectSchema schema = Engine.BizObjectManager.GetPublishedSchema(DataModelCode);

            DataModel.BizQuery query = Engine.BizObjectManager.GetBizQuery(QueryCode);
            if (schema != null && query != null)
            {
                OThinker.H3.BizBus.Filter.Filter filter = GetFilter(schema, "GetList", query);
                filter.FromRowNum = 1;
                filter.ToRowNum   = ShowCount;
                if (ShowCount <= 0)
                {
                    filter.ToRowNum = 5;
                }
                //SORTBY是正常的语法 Column1,Column2 DESC
                if (string.IsNullOrEmpty(SortBy))
                {
                    SortBy = schema.GetPropertyNames()[0] + " DESC";
                }
                string[] arrSortKey = SortBy.Split(',');
                List <OThinker.H3.BizBus.Filter.SortBy> list = new List <OThinker.H3.BizBus.Filter.SortBy>();
                foreach (string str in arrSortKey)
                {
                    if (string.IsNullOrEmpty(str))
                    {
                        continue;
                    }
                    string   str2  = str.Trim();
                    string[] ssarr = str2.Split(' ');
                    if (ssarr.Length == 0 || string.IsNullOrEmpty(ssarr[0]))
                    {
                        continue;
                    }
                    string sortitem = ssarr[0];
                    OThinker.H3.BizBus.Filter.SortDirection sd = OThinker.H3.BizBus.Filter.SortDirection.Ascending;
                    for (var k = 1; k < ssarr.Length; k++)
                    {
                        if (string.IsNullOrEmpty(ssarr[k]))
                        {
                            continue;
                        }
                        if (ssarr[k].ToLower() == "asc")
                        {
                            break;
                        }
                        if (ssarr[k].ToLower() == "desc")
                        {
                            sd = OThinker.H3.BizBus.Filter.SortDirection.Descending;
                            break;
                        }
                    }
                    filter.AddSortBy(sortitem, sd);
                }
                DataModel.BizObject[] objs = schema.GetList(
                    this.Engine.Organization,
                    this.Engine.MetadataRepository,
                    this.Engine.BizObjectManager,
                    this.UserValidator.UserID,
                    "GetList",
                    filter);
                // 开始绑定数据源
                DataTable tablesource = DataModel.BizObjectUtility.ToTable(schema, objs);

                List <object> tr = new List <object>();
                foreach (DataRow dr in tablesource.Rows)
                {
                    List <object> td = new List <object>();
                    foreach (string field in BoundFiledList.Split(','))
                    {
                        string[] arrFields = field.Split('|');
                        string   column    = arrFields[0];
                        int      len       = 0;
                        int.TryParse(arrFields[1], out len);
                        string format = arrFields[2];
                        if (!tablesource.Columns.Contains(column))
                        {
                            continue;
                        }
                        string fv = dr[column].ToString();
                        //格式化
                        if (!string.IsNullOrEmpty(format))
                        {
                            if (format.StartsWith("{0:"))
                            {   //{0:****}格式
                                if (tablesource.Columns[column].DataType == typeof(Decimal))
                                {
                                    fv = String.Format(format, Convert.ToDecimal(dr[column]));
                                }
                                if (tablesource.Columns[column].DataType == typeof(DateTime))
                                {
                                    fv = String.Format(format, Convert.ToDateTime(dr[column]));
                                }
                            }
                            else
                            {//****格式
                                if (tablesource.Columns[column].DataType == typeof(Decimal))
                                {
                                    fv = Convert.ToDecimal(dr[column]).ToString(format);
                                }
                                if (tablesource.Columns[column].DataType == typeof(DateTime))
                                {
                                    fv = Convert.ToDateTime(dr[column]).ToString(format);
                                }
                            }
                        }
                        //截取长度
                        if (len > 0 && fv.Length > len)
                        {
                            fv = fv.Substring(0, len);
                        }
                        string datalink = "";
                        //匹配链接参数
                        if (!string.IsNullOrEmpty(LinkFormat))
                        {
                            string[] paras    = LinkFormat.Split('{');
                            string   currlink = LinkFormat;
                            //如果包含有{}, pcol就是要找的替换格式字段
                            for (var p = 1; p < paras.Length; p++)
                            {
                                string pcol = paras[p].Split('}')[0];
                                if (tablesource.Columns.Contains(pcol))
                                {
                                    currlink = currlink.Replace("{" + pcol + "}", Convert.ToString(dr[pcol]));
                                }
                                else
                                {
                                    currlink = currlink.Replace("{" + pcol + "}", "");
                                }
                            }
                            //datalink = "href=\"" + currlink + "\"  target=\"_blank\"";
                            datalink = currlink;
                        }
                        var newRow = new
                        {
                            Text = fv,
                            Href = string.IsNullOrEmpty(datalink) ? "#" : datalink
                        };
                        td.Add(newRow);
                    }
                    tr.Add(td);
                }
                result.Extend = tr;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }