コード例 #1
0
        private void startCeneraterCode()
        {
            string doc = string.Empty;

            if (javaRb.IsChecked == true)
            {
                JavaGenerater jg = new JavaGenerater(currDbschema, mConnection);
                doc = jg.CeneraterClass();
            }
            else if (csharpRb.IsChecked == true)
            {
                CSharpCenerater generater = new CSharpCenerater(currDbschema, mConnection);
                doc = generater.CeneraterClass();
            }
            else if (javaEnumRb.IsChecked == true)
            {
                JavaEnumGenerare generater = new JavaEnumGenerare(mConnection);
                doc = generater.tableEnumGenerater(currDbschema);
            }
            else if (csharpEnumRb.IsChecked == true)
            {
                CsharpEnumGenerare generater = new CsharpEnumGenerare(mConnection);
                doc = generater.tableEnumGenerater(currDbschema);
            }
            else if (createSqlb.IsChecked == true)
            {
                SqlGenerater generater = new SqlGenerater(currDbschema.TableName, mConnection.connStr, mConnection.type);
                doc = generater.GeneraterSql();
            }
            else
            {
                doc = "\r\n 请告诉我你需要什么代码?\r\n ";
            }
            this.CodeTb.Text = doc;
        }
コード例 #2
0
        private void generaterCode(List <MyHelper.DbSchema> list)
        {
            if (list == null || list.Count <= 0)
            {
                return;
            }
            string fileName = string.Empty;

            for (int i = 0; i < needThreadGeneraters.Count; i++)
            {
                //java class
                MyHelper.DbSchema schema = needThreadGeneraters[i];
                if (!string.IsNullOrEmpty(mConnection.javaClassPath))
                {
                    if (MyHelper.FileHelper.FolderExistsCreater(mConnection.javaClassPath))
                    {
                        string javaClass = new JavaGenerater(schema, mConnection).CeneraterClass();
                        String suffix    = string.Empty;
                        if (!String.IsNullOrEmpty(mConnection.classSuffix))
                        {
                            suffix = MyHelper.StringHelper.upperCaseFirstLetter(mConnection.classSuffix);
                        }
                        fileName = "\\" + MyHelper.StringHelper.upperCaseFirstLetter(MyHelper.StringHelper.DBNamingToCamelCase(schema.TableName)) + suffix + ".java";
                        MyHelper.FileHelper.Write(mConnection.javaClassPath + fileName, javaClass);
                    }
                }

                //java enum
                if (!string.IsNullOrEmpty(mConnection.javaEnumPath))
                {
                    if (MyHelper.FileHelper.FolderExistsCreater(mConnection.javaEnumPath))
                    {
                        string javaEnum = new JavaEnumGenerare(mConnection).tableEnumGenerater(schema);
                        String suffix   = string.Empty;
                        if (!String.IsNullOrEmpty(mConnection.enumSuffi))
                        {
                            suffix = MyHelper.StringHelper.upperCaseFirstLetter(mConnection.enumSuffi);
                        }
                        fileName = "\\" + MyHelper.StringHelper.upperCaseFirstLetter(MyHelper.StringHelper.DBNamingToCamelCase(schema.TableName)) + suffix + ".java";
                        MyHelper.FileHelper.Write(mConnection.javaEnumPath + fileName, javaEnum);
                    }
                }

                //Csharp class
                if (!string.IsNullOrEmpty(mConnection.cSharpClassPath))
                {
                    if (MyHelper.FileHelper.FolderExistsCreater(mConnection.cSharpClassPath))
                    {
                        string csharpClass = new CSharpCenerater(schema, mConnection).CeneraterClass();
                        String suffix      = string.Empty;
                        if (!String.IsNullOrEmpty(mConnection.classSuffix))
                        {
                            suffix = MyHelper.StringHelper.upperCaseFirstLetter(mConnection.classSuffix);
                        }
                        fileName = "\\" + MyHelper.StringHelper.upperCaseFirstLetter(MyHelper.StringHelper.DBNamingToCamelCase(schema.TableName)) + suffix + ".cs";
                        MyHelper.FileHelper.Write(mConnection.cSharpClassPath + fileName, csharpClass);
                    }
                }

                //Csharp enum
                if (!string.IsNullOrEmpty(mConnection.cSharpEnumPath))
                {
                    if (MyHelper.FileHelper.FolderExistsCreater(mConnection.cSharpEnumPath))
                    {
                        string csharpEnum = new CsharpEnumGenerare(mConnection).tableEnumGenerater(schema);
                        String suffix     = string.Empty;
                        if (!String.IsNullOrEmpty(mConnection.enumSuffi))
                        {
                            suffix = MyHelper.StringHelper.upperCaseFirstLetter(mConnection.enumSuffi);
                        }
                        fileName = "\\" + MyHelper.StringHelper.upperCaseFirstLetter(MyHelper.StringHelper.DBNamingToCamelCase(schema.TableName)) + suffix + ".cs";
                        MyHelper.FileHelper.Write(mConnection.cSharpEnumPath + fileName, csharpEnum);
                    }
                }
                //Csharp all enum
                if (!string.IsNullOrEmpty(mConnection.cSharpEnumAllPath))
                {
                    if (MyHelper.FileHelper.FolderExistsCreater(mConnection.cSharpEnumAllPath))
                    {
                        string csharpEnum = new CsharpEnumGenerare(mConnection).dbEnumGenerater();
                        fileName = "\\" + MyHelper.StringHelper.upperCaseFirstLetter(MyHelper.StringHelper.DBNamingToCamelCase(mConnection.dbName)) + ".cs";
                        MyHelper.FileHelper.Write(mConnection.cSharpEnumAllPath + fileName, csharpEnum);
                    }
                }
                //crete sql
                if (!string.IsNullOrEmpty(mConnection.sqlPath))
                {
                    if (MyHelper.FileHelper.FolderExistsCreater(mConnection.sqlPath))
                    {
                        string createSQl = new CsharpEnumGenerare(mConnection).tableEnumGenerater(schema);
                        fileName = "\\" + schema.TableName + ".sql";
                        MyHelper.FileHelper.Write(mConnection.sqlPath + fileName, createSQl);
                    }
                }
            }
        }