예제 #1
0
        /// <summary>
        /// 开始
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            EntityBuilder builder;

            foreach (object o in lbright.Items)
            {
                builder = new EntityBuilder(o.ToString(), txtNamaspace.Text, o.ToString().Trim().Replace(' ', '_'), Utils.GetColumnInfos(dbObject.GetColumnInfoList(DatabaseName, o.ToString())), tableview[o.ToString()], cbToupperFrstword.Checked, ConnectionModel.DbType);

                using (StreamWriter sw = new StreamWriter(Path.Combine(txtPath.Text, o.ToString().Trim().Replace(' ', '_') + ".cs"), false, Encoding.UTF8))
                {
                    sw.Write(builder.Builder());
                    sw.Close();
                }

                backgroundWorker1.ReportProgress(1);

                System.Threading.Thread.Sleep(1);
            }
        }
예제 #2
0
        /// <summary>
        /// 开始
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            EntityBuilder builder;

            foreach (string o in lbright.Items)
            {
                var ro = !string.IsNullOrWhiteSpace(txtTableStar.Text.Trim())
                    ? o.Trim().Replace(' ', '_').Replace(txtTableStar.Text.Trim(), "")
                    : o.Trim().Replace(' ', '_');
                //var wjj = string.IsNullOrWhiteSpace(txt_wjj.Text.Trim()) ? "" : "." + txt_wjj.Text.Trim();
                //修改原因:需要生成简写表名,同时类名也需要改 例 Com_aa 需要Com文件夹 aa类  命名空间Com.aa
                //修改后效果:根据txtTableStar文本框所填内容来识别去除内容  by kelyljk 2016-2-2
                builder = new EntityBuilder(o, txtNamaspace.Text, //+ wjj
                                            ro,
                                            Utils.GetColumnInfos(dbObject.GetColumnInfoList(DatabaseName, o)),
                                            tableview[o],
                                            cbToupperFrstword.Checked,
                                            ConnectionModel.DbType.ToString(),
                                            cbEntityTableName.Checked);
                var path = txtPath.Text + "\\" + txt_wjj.Text.Trim();
                //修改后效果:自动生成路劲文件夹 by kelyljk 2016-2-2
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                //修改原因:需要生成简写表名 例 Com_aa 需要Com文件夹 aa类
                //修改后效果:根据txtTableStar文本框所填内容来识别去除内容  by kelyljk 2016-2-2
                using (StreamWriter sw = new StreamWriter(Path.Combine(path,
                                                                       ro + ".cs"),
                                                          false,
                                                          Encoding.UTF8))
                {
                    sw.Write(builder.BuilderModelEntity());
                    sw.Close();
                }

                backgroundWorker1.ReportProgress(1);

                System.Threading.Thread.Sleep(1);
            }
        }
예제 #3
0
        /// <summary>
        /// 代码生成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtnamespace.Text))
            {
                MessageBox.Show("命名空间不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(txtClassName.Text))
            {
                MessageBox.Show("类名不能为空!");
                return;
            }

            Utils.WriteNamespace(txtnamespace.Text);

            List <Model.ColumnInfo> columns = Utils.GetColumnInfos(columnsdt);

            foreach (Model.ColumnInfo col in columns)
            {
                col.IsPK = false;

                foreach (object o in cbPrimarykey.Items)
                {
                    if (col.ColumnName.Equals(o.ToString()))
                    {
                        col.IsPK = true;
                        break;
                    }
                }
            }

            EntityBuilder builder = new EntityBuilder(TableName, txtnamespace.Text, txtClassName.Text, columns, IsView, cbToupperFrstword.Checked, ConnectionModel.DbType);

            txtContent.Text = builder.Builder();

            tabControl1.SelectedIndex = 1;
        }
예제 #4
0
        /// <summary>
        /// 代码生成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtnamespace.Text))
            {
                MessageBox.Show("命名空间不能为空!");
                return;
            }
            if (string.IsNullOrEmpty(txtClassName.Text))
            {
                MessageBox.Show("类名不能为空!");
                return;
            }

            Utils.WriteNamespace(txtnamespace.Text);

            List<Model.ColumnInfo> columns = Utils.GetColumnInfos(columnsdt);

            foreach (Model.ColumnInfo col in columns)
            {

                col.IsPK = false;

                foreach (object o in cbPrimarykey.Items)
                {
                    if (col.ColumnName.Equals(o.ToString()))
                    {
                        col.IsPK = true;
                        break;
                    }
                }
            }

            EntityBuilder builder = new EntityBuilder(TableName, txtnamespace.Text, txtClassName.Text, columns, IsView, cbToupperFrstword.Checked);

            txtContent.Text = builder.Builder();

            tabControl1.SelectedIndex = 1;
        }
예제 #5
0
        /// <summary>
        /// 开始
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {

            EntityBuilder builder;

            foreach (object o in lbright.Items)
            {
                builder = new EntityBuilder(o.ToString(), txtNamaspace.Text, o.ToString().Trim().Replace(' ', '_'), Utils.GetColumnInfos(dbObject.GetColumnInfoList(DatabaseName, o.ToString())), tableview[o.ToString()], cbToupperFrstword.Checked,ConnectionModel.DbType);

                string file_name = o.ToString().Trim().Replace(' ', '_') + ".cs";
                // 文件名首字母大写, snake_style 自动去下划线
                if (this.cbToupperFrstword.Checked) {
                    string file_name_tmp = String.Empty;
                    var filename_parts = file_name.Split('_');
                    foreach (var filename_part in filename_parts) {
                        file_name_tmp += Utils.ToUpperFirstword(filename_part);
                    }
                    file_name = file_name_tmp;
                }
                using (StreamWriter sw = new StreamWriter(Path.Combine(txtPath.Text, file_name), false, Encoding.UTF8)) {
                    sw.Write(builder.Builder());
                    sw.Close();
                }

                backgroundWorker1.ReportProgress(1);

                System.Threading.Thread.Sleep(1);

            }


        }
예제 #6
0
        /// <summary>
        /// 开始
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {

            EntityBuilder builder;

            foreach (object o in lbright.Items)
            {
                builder = new EntityBuilder(o.ToString(), txtNamaspace.Text, o.ToString().Trim().Replace(' ', '_'), Utils.GetColumnInfos(dbObject.GetColumnInfoList(DatabaseName, o.ToString())), tableview[o.ToString()], cbToupperFrstword.Checked);

                using (StreamWriter sw = new StreamWriter(Path.Combine(txtPath.Text, o.ToString().Trim().Replace(' ', '_') + ".cs"), false, Encoding.UTF8))
                {
                    sw.Write(builder.Builder());
                    sw.Close();
                }

                backgroundWorker1.ReportProgress(1);

                System.Threading.Thread.Sleep(1);

            }


        }