Esempio n. 1
0
        private void TestConnection()
        {
            var         isTest     = false;
            IsqlAdapter sqlAdapter = SetSqlAdapter();

            new Action(() =>
            {
                isTest = sqlAdapter.TestConnection();
                if (connectionEvent != null)
                {
                    connectionEvent(isTest);
                }
            }).BeginInvoke(null, null);
        }
Esempio n. 2
0
        private IsqlAdapter SetSqlAdapter()
        {
            IsqlAdapter sqlAdapter = null;
            var         connInfo   = new ConnInfo
            {
                server       = server_txt.Text,
                userName     = userName_txt.Text,
                password     = password_txt.Text,
                databaseName = database_cmb.SelectedText,
            };

            switch (dataSource_cmb.Text)
            {
            case "mysql":
                sqlAdapter = new mysqlAdapter(connInfo); break;

            case "mssql":
                sqlAdapter = new mssqlAdapter(connInfo); break;

            default: MessageBox.Show("匹配不到适合的数据源"); break;
            }
            return(sqlAdapter);
        }
Esempio n. 3
0
 public codeGenerator_frm(IsqlAdapter sqlAdapter)
 {
     InitializeComponent();
     this.sqlAdapter = sqlAdapter;
 }
        /// <summary>
        /// 生成实体内容
        /// </summary>
        /// <param name="content">未转换内容</param>
        /// <param name="generator">代码生成参数</param>
        /// <param name="tableName">表名</param>
        /// <returns>转换后内容</returns>
        public static string GenerateEntity(string content, GenerateParam generator, string tableName, IsqlAdapter sqlAdapter)
        {
            var forRegex = new Regex(@"(?<={{yx-columns}})[\s\S]*(?={{yx-end}})");

            content = content.Replace("{{yx-namespace}}", generator.nameSpace)
                      .Replace("{{yx-modifier}}", generator.modifier)
                      .Replace("{{yx-tableName}}", tableName);
            if (forRegex.IsMatch(content))
            {
                var columns         = sqlAdapter.GetColumnsByTableName(tableName);
                var matchCollection = forRegex.Matches(content);
                foreach (Match match in matchCollection)
                {
                    foreach (var column in columns)
                    {
                        match.Value.Replace("{{yx-columnType}}", TypeConvertorOper.Convert(column.columnType));
                    }
                }
            }
        }