Ejemplo n.º 1
0
        static WanJiangAuth()
        {
            ServiceConfig serviceConfig = GetServiceConfig(WANGJIANG_USER_TABLE);

            if (serviceConfig != null && !string.IsNullOrEmpty(serviceConfig.model.dbName))
            {
                //根据数据库连接名称,查询数据,获取连接字符串,生成链接
                dbWanJiang = SysContext.GetOtherDB(serviceConfig.model.dbName);
            }
        }
Ejemplo n.º 2
0
        public static string GetModeEntityText(DbContext db, string model, string id)
        {
            string dbName = ServiceHelper.GetServiceConfig(model)?.model.dbName;

            if (!string.IsNullOrEmpty(dbName))
            {
                db = SysContext.GetOtherDB(dbName);
            }
            string key = model + "_" + id;

            if (dicValues.ContainsKey(key))
            {
                return(dicValues[key]);
            }
            string modeTextField = GetModeTextField(model);

            dicValues[key] = db.ExecuteScalar <string>(string.Format("select {0} from {1} where ID = @0", modeTextField, model), new object[1]
            {
                id
            });
            return(dicValues[key]);
        }
Ejemplo n.º 3
0
 public static object GetTreeData(DbContext db, FilterTree tree)
 {
     if (!string.IsNullOrEmpty(tree.sourceModel))
     {
         if (tree.sourceModel2 == tree.sourceModel)
         {
             tree.sourceModel2 = null;
         }
         ServiceConfig serviceConfig = ServiceHelper.GetServiceConfig(tree.sourceModel);
         string        textField     = tree.textField;
         if (string.IsNullOrEmpty(textField))
         {
             textField = serviceConfig.model.textField;
         }
         //lyl update at 2018-12-28
         DbContext db2find = db;
         if (!string.IsNullOrEmpty(serviceConfig.model.dbName))
         {
             db2find = SysContext.GetOtherDB(serviceConfig.model.dbName);
         }
         List <Dictionary <string, object> > dic = GetAllProperty(db2find, tree.filter, tree.sourceModel, tree.parentField, "ID", textField, tree.fields, tree.orderBy);
         IList list = FillTreeChild(db2find, dic, "ID", textField, tree.parentField, null, tree.sourceModel, tree);
         if (!string.IsNullOrEmpty(tree.rootText))
         {
             return(new object[1]
             {
                 new
                 {
                     text = tree.rootText,
                     rootNode = true,
                     children = list
                 }
             });
         }
         return(list);
     }
     return(null);
 }
Ejemplo n.º 4
0
        public static object GetSearchDataset(string model, string key)
        {
            if (string.IsNullOrEmpty(model))
            {
                return(null);
            }
            DbContext     currentDb                = SysContext.GetCurrentDb();
            ServiceConfig serviceConfig            = GetServiceConfig(model);
            List <object> list                     = new List <object>();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary["model"] = new
            {
                serviceConfig.model.name,
                serviceConfig.model.title
            };
            List <object> list2 = new List <object>();
            List <Field>  list3 = serviceConfig.fields.Where(f => f.enabledSearch == "Y").ToList();

            foreach (Field item in list3)
            {
                if (string.IsNullOrEmpty(item.relationModel))
                {
                    list.Add(new
                    {
                        field = item.name,
                        text  = "搜索 " + item.title + ":" + key
                    });
                    list2.Add(new
                    {
                        item.name,
                        item.title,
                        item.type
                    });
                }
                else if (item.type == "many2one")
                {
                    ServiceConfig serviceConfig2 = GetServiceConfig(item.relationModel);

                    if (serviceConfig2 != null)
                    {
                        var    qDB       = string.IsNullOrEmpty(serviceConfig2.model.dbName) ? currentDb : SysContext.GetOtherDB(serviceConfig2.model.dbName);
                        string title     = serviceConfig2.model.title;
                        string textField = serviceConfig2.model.textField;
                        if (textField != null)
                        {
                            string nvSql = string.Format("select ID as 'Value',{0} as 'Text' from {1} where {0} like '%{2}%'", textField, item.relationModel, key);
                            if (string.IsNullOrEmpty(key))
                            {
                                nvSql = string.Format("select ID as 'Value',{0} as 'Text' from {1} where {0}", textField, item.relationModel);
                            }
                            List <SearchResultItem> list4 = qDB.Query <SearchResultItem>(nvSql, new object[0]).ToList();
                            if (list4 != null && list4.Any())
                            {
                                list.Add(new
                                {
                                    text        = title,
                                    isGroupItem = true
                                });
                                foreach (SearchResultItem item2 in list4)
                                {
                                    list.Add(new
                                    {
                                        id             = item2.Value,
                                        field          = item.name,
                                        isRelationItem = true,
                                        text           = item2.Text
                                    });
                                }
                                list2.Add(new
                                {
                                    item.name,
                                    item.title,
                                    item.type
                                });
                            }
                        }
                    }
                }
            }
            dictionary["fields"] = list2;
            return(new
            {
                dataset = dictionary,
                result = list
            });
        }