Beispiel #1
0
        public static void GetDBName(string viewName, out string tblname, out string colname)
        {
            if (viewName.Length != 5 || viewName.IndexOf('_') != 2)
            {
                throw new ArgumentException("modelName");
            }
            string[] modelarr = viewName.Split('_');
            tblname = "";
            colname = "";
            var        cacheManager   = EngineContext.Current.ContainerManager.Resolve <ICacheManager>("wei_cache_static");
            var        tblStructCatch = cacheManager.Get <ICollection <DBTblModel> >(DBStructCaching.DBCACHETABLES);
            DBTblModel model          = tblStructCatch.First(x => x.ViewName == modelarr[0]);

            tblname = model.Name;
            colname = model.Columns.First(x => x.ViewName == modelarr[1]).Name;
        }
Beispiel #2
0
        public static string GetViewName(string tblname, string colname)
        {
            if (string.IsNullOrEmpty(tblname) || string.IsNullOrEmpty(colname))
            {
                throw new ArgumentException("tblname or colname");
            }

            var        cacheManager   = EngineContext.Current.ContainerManager.Resolve <ICacheManager>("wei_cache_static");
            var        tblStructCatch = cacheManager.Get <ICollection <DBTblModel> >(DBStructCaching.DBCACHETABLES);
            DBTblModel model          = tblStructCatch.First(x => x.Name == tblname);

            string result = model.ViewName;

            result += model.Columns.First(x => x.Name == colname).ViewName;
            return(result);
        }
Beispiel #3
0
        public static void RegisterDBTables()
        {
            var cache = EngineContext.Current.ContainerManager.Resolve <ICacheManager>("wei_cache_static");

            // a:97   z:122
            if (!cache.IsSet(DBStructCaching.DBCACHETABLES))
            {
                DBHelp  help = new DBHelp();
                string  sql1 = " select name, id from sysobjects where type='u' ";
                string  sql2 = " select name, id, xusertype from syscolumns where id in (select id from sysobjects where type='u') ";
                DataSet set  = help.Select(sql1 + sql2, CommandType.Text);
                ICollection <DBTblModel> list = new List <DBTblModel>();
                if (set != null && set.Tables.Count > 0)
                {
                    DataTable table  = set.Tables[0];
                    DataTable coltbl = set.Tables[1];
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        DataRow    row      = table.Rows[0];
                        DBTblModel tblModel = new DBTblModel()
                        {
                            Name     = row["name"].ToString(),
                            TId      = row["id"].ToInt(),
                            ViewName = GetViewName(i)
                        };
                        int j = 0;
                        foreach (DataRow colRow in coltbl.Rows)
                        {
                            if (colRow["id"].ToInt() == tblModel.TId)
                            {
                                DBColModel colModel = new DBColModel()
                                {
                                    Name     = colRow["name"].ToString(),
                                    Type     = colRow["xusertype"].ToInt(),
                                    ViewName = GetViewName(j)
                                };
                                tblModel.Columns.Add(colModel);
                                j++;
                            }
                        }
                        list.Add(tblModel);
                    }
                }
                cache.Set(DBStructCaching.DBCACHETABLES, list, int.MaxValue);
            }
        }