Пример #1
0
        /// <summary>
        /// 处理sql业务
        /// </summary>
        /// <param name="sourceID"></param>
        /// <param name="frmID"></param>
        /// <param name="arr"></param>
        /// <param name="Db"></param>
        public static void execDataSource(string sourceID, string frmID, Dictionary <string, object> arr, Database Db)
        {
            FBDataSource model = getDSModel(sourceID, Db);

            Database ywDB = getModelDataSource(model.DsCode);
            var      type = model.DsType;
            var      sql  = model.SqlInfo;

            if (model.IsUpdate == "1")
            {
                ywDB.Execute(dealSQL(model.SqlInfo, arr));
            }
        }
Пример #2
0
        public static GridViewModel <dynamic> getDSPageList(string dsID, int currentPage, int perPage, string filter, string order, out long totalPages, out long totalItems, Database db)
        {
            FBDataSource model = getDSModel(dsID, db);
            Database     ywDB  = getModelDataSource(model.DsCode);

            var type = model.DsType;
            var sql  = model.SqlInfo;

            if (string.IsNullOrEmpty(sql))
            {
                throw new Exception(" DataSource didn't define SqlString ");
            }


            // 过滤条件
            if (!string.IsNullOrEmpty(filter) && filter != "[]")
            {
                //StringBuilder sbfilter = new StringBuilder();
                List <Condition> filters = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Condition> >(filter);


                sql += string.Format(" {0} ", ConditionParser.Serialize(filters));
                //参数改造?
            }
            Page <dynamic> page = ywDB.Page <dynamic>(currentPage, perPage, sql);

            totalPages = page.TotalPages;

            totalItems = page.TotalItems;

            GridViewModel <dynamic> result = new GridViewModel <dynamic>();

            result.Rows       = page.Items;
            result.TotalCount = totalItems;

            result.Total = totalItems;
            return(result);
        }
Пример #3
0
        //public static List<FBDataSourceCols> getColList(string frmID, Database db)
        //{
        //    List<FBDataSourceCols> collits = new List<FBDataSourceCols>();
        //    List<FBDataSource> list = new List<FBDataSource>();
        //    list = db.Fetch<FBDataSource>(@"select FBDataSource.* from FBFormDS  where 1=1 and FBFormDS.FormID=@0", frmID);

        //    if (list.Count == 1)
        //    {
        //        var type = list[0].DsType;
        //        var sql = list[0].SqlInfo;
        //        List<dynamic> list1 = db.Fetch<dynamic>(new Sql(sql));

        //    }


        //    return collits;
        //}


        #region 获取自定义数据源基本模型
        public static FBDataSource getDSModel(string dsID, Database db)
        {
            try
            {
                FBDataSource model = new FBDataSource();
                model = db.Single <FBDataSource>(@"select FBDataSource.* from FBDataSource  where 1=1 and FBDataSource.ID=@0", dsID);

                if (model == null)
                {
                    throw new Exception(" DataSouceID is not found on the platform");
                }
                if (!string.IsNullOrEmpty(model.Tree))
                {
                    //获取树形结构
                    model.treeInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <JFBTreeStruct>(model.Tree);
                }
                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public JsonResult createMetaData(string data, string type)
        {
            try
            {
                var lastTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                var lastUser = SessionProvider.Provider.Current().UserName;
                var entity   = Newtonsoft.Json.JsonConvert.DeserializeObject <FBMetaModel>(data);
                switch (type)
                {
                case "0":
                {
                    FBDataObject model = new FBDataObject();
                    model.ID        = Guid.NewGuid().ToString();
                    model.Code      = entity.Code;
                    model.AiasName  = entity.Name;
                    model.TableName = entity.TableName;
                    model.ParentID  = entity.ParentID;
                    this._serviceDO.AddObject(model);
                }
                break;

                case "1":
                {
                    FBDataModel model = new FBDataModel();
                    model.ID          = Guid.NewGuid().ToString();
                    model.Name        = entity.Name;
                    model.Code        = entity.Code;
                    model.MainObectID = entity.ModelID;
                    model.parentID    = entity.ParentID;
                    this._serviceDM.AddModel(model);
                }
                break;

                case "2":
                {
                    FBSmartHelp model = new FBSmartHelp();
                    model.ID       = Guid.NewGuid().ToString();
                    model.Code     = entity.Code;
                    model.Name     = entity.Name;
                    model.ModelID  = entity.ModelID;
                    model.parentID = entity.ParentID;
                    this._serviceHP.addData(model);
                }
                break;

                case "3":
                {
                    FBForm model = new FBForm();
                    model.ID       = Guid.NewGuid().ToString();
                    model.Code     = entity.Code;
                    model.Name     = entity.Name;
                    model.ModelID  = entity.ModelID;
                    model.parentID = entity.ParentID;
                    model.Type     = entity.FormType;
                    this._serviceFrm.addData(model);
                }
                break;

                case "5":
                {
                    FBDataSource model = new FBDataSource();
                    model.ID       = Guid.NewGuid().ToString();
                    model.Code     = entity.Code;
                    model.Name     = entity.Name;
                    model.parentID = entity.ParentID;
                    this._serviceDS.addData(model);
                }
                break;

                default:
                    break;
                }


                return(Json(new { res = true, mes = "删除成功!" }));
            }
            catch (Exception ex)
            {
                return(Json(new { res = false, mes = "重命名失败" + ex.Message }));
            }
        }
Пример #5
0
        public static List <Dictionary <string, object> > getDSTreeDataALL(string dsID, string keyWord, string filter, string order, Dictionary <string, object> formstate, Database Db)
        {
            FBDataSource model = getDSModel(dsID, Db);

            Database ywDB = getModelDataSource(model.DsCode);

            var type = model.DsType;
            var sql  = model.SqlInfo;



            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();

            // 获取树形取数的Sql信息
            StringBuilder sb = new StringBuilder();

            sb.Append(sql);

            string sbInit = sb.ToString();

            //过滤条件
            if (!string.IsNullOrEmpty(filter))
            {
                StringBuilder    sbfilter = new StringBuilder();
                List <Condition> filters  = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Condition> >(filter);
                sb.AppendFormat(" {0} ", ConditionParser.Serialize(filters));
            }



            JFBTreeStruct treeInfo = model.treeInfo;

            //排序
            if (!string.IsNullOrEmpty(order))
            {
                List <SortCondition> orders = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SortCondition> >(order);
                if (orders.Count > 0)
                {
                    sb.AppendFormat(" order by {0} ", SortConditionParser.Serialize(orders));
                }
            }
            result = ywDB.Fetch <Dictionary <string, object> >(dealSQL(sb.ToString(), formstate));



            if (!string.IsNullOrEmpty(keyWord))
            {
                string qrySql     = string.Format(" and  {0} like '{1}%'", model.treeInfo.treename, keyWord);
                var    resultList = ywDB.Fetch <Dictionary <string, object> >(dealSQL(sbInit, formstate).Append(new Sql(qrySql)));

                foreach (var item in result)
                {
                    // 获取命中信息
                    var res = resultList.Where(p => p[model.treeInfo.grade].ToString().StartsWith(item[model.treeInfo.grade].ToString()));
                    if (res.ToList().Count > 0)
                    {
                        item["_istarget"] = "1";
                        item["isexpand"]  = true;
                    }
                }
            }


            return(result);
        }
Пример #6
0
        public static List <Dictionary <string, object> > getDSTreeData(string dsID, string level, string path, string parentID, string keyWord, string filter, string order, Database Db)
        {
            FBDataSource model = getDSModel(dsID, Db);

            Database ywDB = getModelDataSource(model.DsCode);

            var type = model.DsType;
            var sql  = model.SqlInfo;
            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();

            // 获取树形取数的Sql信息
            StringBuilder sb = new StringBuilder();

            sb.Append(sql);

            //过滤条件
            if (!string.IsNullOrEmpty(filter))
            {
                StringBuilder    sbfilter = new StringBuilder();
                List <Condition> filters  = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Condition> >(filter);
                sb.AppendFormat(" {0} ", ConditionParser.Serialize(filters));
            }

            JFBTreeStruct treeInfo      = model.treeInfo;
            var           isParentModel = true;

            if (string.IsNullOrEmpty(treeInfo.parentid))
            {
                isParentModel = false;
            }

            #region 获取子节点数据
            if (isParentModel)
            {
                if (string.IsNullOrEmpty(parentID) && !string.IsNullOrEmpty(treeInfo.rootvalue))
                {
                    parentID = treeInfo.rootvalue;
                }
                sb.AppendFormat(" and {0}='{1}'", model.treeInfo.parentid, parentID);
            }
            else
            {
                if (string.IsNullOrEmpty(level))
                {
                    level = model.treeInfo.rootlevel;
                }
                else
                {
                    level = (Convert.ToInt32(level) + 1).ToString();
                }
                if (string.IsNullOrEmpty(path))
                {
                    sb.AppendFormat(" and {0}='{1}' ", model.treeInfo.level, level);
                }
                else
                {
                    sb.AppendFormat(" and  {0}='{1}' and {2} like '{3}%'", model.treeInfo.level, level, model.treeInfo.grade, path);
                }
            }
            #endregion



            //排序
            if (!string.IsNullOrEmpty(order))
            {
                List <SortCondition> orders = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SortCondition> >(order);
                if (orders.Count > 0)
                {
                    sb.AppendFormat(" order by {0} ", SortConditionParser.Serialize(orders));
                }
            }
            result = ywDB.Fetch <Dictionary <string, object> >(sb.ToString());



            if (!string.IsNullOrEmpty(keyWord))
            {
                string qrySql     = string.Format(" and {0} like '{1}%'", model.treeInfo.treename, keyWord);
                var    resultList = ywDB.Fetch <Dictionary <string, object> >(new Sql(sql).Append(new Sql(qrySql)));

                foreach (var item in result)
                {
                    // 获取命中信息
                    var res = resultList.Where(p => p[model.treeInfo.grade].ToString().StartsWith(item[model.treeInfo.grade].ToString()));
                    if (res.ToList().Count > 0)
                    {
                        item["_istarget"] = "1";
                    }
                }
            }


            return(result);
        }