Exemplo n.º 1
0
        private void buildButton_Click(object sender, RoutedEventArgs e)
        {
            if (templetBox.SelectedIndex < 0) {
                MessageBox.Show("请选择模板!");
                return;
            }

            int count = 0;
            foreach (ObjectModel p in viewModel.ObjectList) {
                foreach (ObjectModel obj in p.Children) {
                    if (obj.IsSelected) {
                        DoBuild(obj, true);
                        count++;

                        currentObject = obj;
                    }
                }
            }

            if (count == 0) {
                MessageBox.Show("请选择要生成的[表/视图/存储过程]!");
            }
            else {
                viewModel.loadPropertys(currentSource, currentObject);
                MessageBox.Show("相关文件已成功生成...");
            }
        }
Exemplo n.º 2
0
        public void Add(ObjectModel item)
        {
            if (Children == null)
                Children = new List<ObjectModel>();

            Children.Add(item);
        }
Exemplo n.º 3
0
        private void DoBuild(ObjectModel obj, bool isBatch)
        {
            var cols = viewModel.getPropertyList(currentSource, obj);

            WeedBuilder sdqBuilder = new WeedBuilder(currentSource);

            if (Directory.Exists(Config.DIR_OUT) == false) {
                Directory.CreateDirectory(Config.DIR_OUT);
            }

            sdqBuilder.TargetFolder = Config.DIR_OUT;
            sdqBuilder.NameSpace = "noear.weed.studio";
            sdqBuilder.TableName = obj.Name;
            sdqBuilder.Columns = cols;

            sdqBuilder.TempletFile = (string)templetBox.SelectedItem;

            sdqBuilder.Build();
        }
Exemplo n.º 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;
        }
Exemplo n.º 5
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");
        }
Exemplo n.º 6
0
        public void loadPropertys(DbContextEx db, ObjectModel obj)
        {
            var popList = getPropertyList(db, obj);

            PropertyList.Clear();
            foreach (var p in popList)
                PropertyList.Add(p);
        }
Exemplo n.º 7
0
 private void objectList_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<Object> e)
 {
     currentObject = (ObjectModel)e.NewValue;
     if (currentObject.Type > 0) {
         viewModel.loadPropertys(currentSource, currentObject);
     }
 }