示例#1
0
        void loadCheckedTab(ObservableCollection <TreeNodeInfo> Nodes)
        {
            ServiceComm sc = new ServiceComm();

            foreach (var item in Nodes)
            {
                if (item.IsChecked == true)
                {
                    string     name = CodeGeneratorUtil.toHump(item.Name);
                    TableModel tm   = new TableModel()
                    {
                        DbContextName = "qdbEntities", TableName = item.Name, ModelName = name, NameSpace = "CodeGenerator.Model", Comment = string.IsNullOrEmpty(item.Mark) ? item.Name : name
                    };

                    column[] columns = sc.queryColumns(item.Name);
                    foreach (column col in columns)
                    {
                        string varname      = CodeGeneratorUtil.toHump(col.column_name);
                        string varnamelocal = CodeGeneratorUtil.startLower(varname);
                        string VarType      = DbTypeConvertMethod.GetVarTypeFromSqlDbType(col.data_type);
                        tm.Fields.Add(new FieldModel()
                        {
                            FieldName = col.column_name, DbType = col.data_type, VarType = VarType, ColumnKey = col.column_key, Mark = string.IsNullOrEmpty(col.column_comment) ? col.column_name : col.column_comment, VarName = varname, VarNameLocal = varnamelocal, DefaultValueVar = ""
                        });
                    }

                    //Directory.GetCurrentDirectory();
                    CodeGeneratorUtil.TransferXml(CodeGeneratorUtil.object2xml <TableModel>(tm), AppDomain.CurrentDomain.BaseDirectory + "template/mode.xslt", "D:/CodeGenerator/model/" + name + ".cs");
                    CodeGeneratorUtil.TransferXml(CodeGeneratorUtil.object2xml <TableModel>(tm), AppDomain.CurrentDomain.BaseDirectory + "template/iservice.xslt", "D:/CodeGenerator/service/IService" + name + ".cs");
                    CodeGeneratorUtil.TransferXml(CodeGeneratorUtil.object2xml <TableModel>(tm), AppDomain.CurrentDomain.BaseDirectory + "template/service.xslt", "D:/CodeGenerator/service/Service" + name + ".svc.cs");
                    CodeGeneratorUtil.TransferXml(CodeGeneratorUtil.object2xml <TableModel>(tm), AppDomain.CurrentDomain.BaseDirectory + "template/service.svc.xslt", "D:/CodeGenerator/service/Service" + name + ".svc");
                    CodeGeneratorUtil.TransferXml(CodeGeneratorUtil.object2xml <TableModel>(tm), AppDomain.CurrentDomain.BaseDirectory + "template/dao.xslt", "D:/CodeGenerator/dao/" + name + "Dao.cs");

                    CodeGeneratorUtil.TransferXml(CodeGeneratorUtil.object2xml <TableModel>(tm), AppDomain.CurrentDomain.BaseDirectory + "template/view.xslt", "D:/CodeGenerator/Views/" + name + "View.xaml.cs");
                    CodeGeneratorUtil.TransferXml(CodeGeneratorUtil.object2xml <TableModel>(tm), AppDomain.CurrentDomain.BaseDirectory + "template/view.xaml.xslt", "D:/CodeGenerator/Views/" + name + "View.xaml");
                    CodeGeneratorUtil.TransferXml(CodeGeneratorUtil.object2xml <TableModel>(tm), AppDomain.CurrentDomain.BaseDirectory + "template/view.model.xslt", "D:/CodeGenerator/ViewModel/" + name + "ViewModel.cs");
                }
            }
        }