Inheritance: Noear.Weed.DbContext
Beispiel #1
0
        public void loadObjects(DbContextEx db)
        {
            ObjectList.Clear();

            //1.获取配置里的执行代码
            //
            ObjectItem exeCode = SourceConfig.GetObject(db.builder, db);

            ObjectModel dataTableRoot = new ObjectModel("数据表", 0);
            ObjectModel dataViewRoot = new ObjectModel("数据视图", 0);
            ObjectModel dataSPRoot = new ObjectModel("存储过程", 0);

            //2.执行代码,获取数据
            //
            List<ObjectModel> tableList = db.sql(exeCode.Table).getList(new ObjectModel(1));
            List<ObjectModel> viewList = db.sql(exeCode.View).getList(new ObjectModel(2));
            List<ObjectModel> spList = db.sql(exeCode.StoredProcedure).getList(new ObjectModel(3));

            //3.绑定到树控件上
            //
            dataTableRoot.AddRange(tableList);
            dataViewRoot.AddRange(viewList);
            dataSPRoot.AddRange(spList);

            if (dataTableRoot.Children.Count > 0)
                ObjectList.Add(dataTableRoot);

            if (dataViewRoot.Children.Count > 0)
                ObjectList.Add(dataViewRoot);

            if (dataSPRoot.Children.Count > 0)
                ObjectList.Add(dataSPRoot);

            NotifyPropertyChanged("ObjectList");
        }
Beispiel #2
0
        static DbManager() {
            cache = new Dictionary<string, DbContextEx>();

            var list = ConfigurationManager.ConnectionStrings;

            for (int i = 0, len = list.Count; i < len; i++) {
                ConnectionStringSettings p = list[i];

                DbContextEx temp = new DbContextEx(p.Name, p.Name);
                cache.Add(p.Name, temp);
            }
        }
Beispiel #3
0
        static DbManager()
        {
            cache = new Dictionary<string, DbContextEx>();

            var list = ConfigurationManager.ConnectionStrings;

            for (int i = 0, len = list.Count; i < len; i++) {
                ConnectionStringSettings p = list[i];

                DbContextEx temp = new DbContextEx(p.Name, p.Name);
                cache.Add(p.Name, temp);
            }
        }
Beispiel #4
0
        public List<PropertyModel> getPropertyList(DbContextEx db, ObjectModel obj)
        {
            PropertyItem exeCode = SourceConfig.GetProperty(db.builder, db);

            List<PropertyModel> popList = null;

            string sql = null;
            if (obj.Type < 3) {
                sql = exeCode.Table.Replace("{ID}", obj.ID).Replace("{NAME}", obj.Name);
            }
            else {
                sql = exeCode.StoredProcedure.Replace("{ID}", obj.ID).Replace("{NAME}", obj.Name).Trim();

                if (sql[0] == '@')
                    popList = Weed.Addin.Eval<IParamsBuilder>(sql.Substring(1)).GetParams(obj.Name, db);
            }

            if (popList == null)
                popList = db.sql(sql).getList(new PropertyModel());

            return popList;
        }
Beispiel #5
0
        public void loadPropertys(DbContextEx db, ObjectModel obj)
        {
            var popList = getPropertyList(db, obj);

            PropertyList.Clear();
            foreach (var p in popList)
                PropertyList.Add(p);
        }
Beispiel #6
0
 private void sourceBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     currentSource = DbManager.get((string)sourceBox.SelectedItem);
     viewModel.loadObjects(currentSource);
 }
Beispiel #7
0
        public static PropertyItem GetProperty(string name, DbContextEx db)
        {
            PropertyItem temp = new PropertyItem();

            string opsXml = __Config[name]["Property"].OuterText;

            if (opsXml.IndexOf("{db}") > 0)
                opsXml = opsXml.Replace("{db}", db.getSchema());

            XDom.Bind(temp, opsXml);

            if (temp.View.Trim().IndexOf(" ") < 0)
                temp.View = temp.Table;

            return temp;
        }
Beispiel #8
0
        public static ObjectItem GetObject(string name, DbContextEx db)
        {
            ObjectItem temp = new ObjectItem();

            string opsXml = __Config[name]["Object"].OuterText;

            if (opsXml.IndexOf("{db}") > 0)
                opsXml = opsXml.Replace("{db}", db.getSchema());

            XDom.Bind(temp, opsXml);

            return temp;
        }
Beispiel #9
0
 public WeedBuilder(DbContextEx db)
 {
     this.db = db;
 }