📄 codeexport.cs
字号:
this.groupBox4.Controls.Add(this.txtDbHelper);
this.groupBox4.Controls.Add(this.label6);
this.groupBox4.Controls.Add(this.txtNamespace);
this.groupBox4.Controls.Add(this.label4);
this.groupBox4.Controls.Add(this.txtFolder);
this.groupBox4.Controls.Add(this.label5);
this.groupBox4.Location = new Point(12, 0xc7);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new Size(0x250, 0x4d);
this.groupBox4.TabIndex = 0x30;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "参数设定";
this.label8.AutoSize = true;
this.label8.Location = new Point(0x143, 0x35);
this.label8.Name = "label8";
this.label8.Size = new Size(0x59, 12);
this.label8.TabIndex = 4;
this.label8.Text = "(留空表示不变)";
this.txtTabNamepre.Location = new Point(0xdf, 0x31);
this.txtTabNamepre.Name = "txtTabNamepre";
this.txtTabNamepre.Size = new Size(100, 0x15);
this.txtTabNamepre.TabIndex = 3;
this.label7.AutoSize = true;
this.label7.Location = new Point(11, 0x35);
this.label7.Name = "label7";
this.label7.Size = new Size(0xd1, 12);
this.label7.TabIndex = 2;
this.label7.Text = "表名直接变为类名后,去掉表名前缀:";
this.txtDbHelper.Location = new Point(0x1d7, 0x15);
this.txtDbHelper.Name = "txtDbHelper";
this.txtDbHelper.Size = new Size(100, 0x15);
this.txtDbHelper.TabIndex = 1;
this.txtDbHelper.Text = "DbHelperSQL";
this.label6.AutoSize = true;
this.label6.Location = new Point(0x17e, 0x1a);
this.label6.Name = "label6";
this.label6.Size = new Size(0x59, 12);
this.label6.TabIndex = 0;
this.label6.Text = "数据访问类名:";
this.txtNamespace.Location = new Point(0x4a, 0x16);
this.txtNamespace.Name = "txtNamespace";
this.txtNamespace.Size = new Size(0x56, 0x15);
this.txtNamespace.TabIndex = 1;
this.txtNamespace.Text = "CodematicDemo";
this.label4.AutoSize = true;
this.label4.Location = new Point(10, 0x18);
this.label4.Name = "label4";
this.label4.Size = new Size(0x41, 12);
this.label4.TabIndex = 0;
this.label4.Text = "命名空间:";
this.txtFolder.Location = new Point(0x107, 0x16);
this.txtFolder.Name = "txtFolder";
this.txtFolder.Size = new Size(100, 0x15);
this.txtFolder.TabIndex = 1;
this.label5.AutoSize = true;
this.label5.Location = new Point(0xbc, 0x1a);
this.label5.Name = "label5";
this.label5.Size = new Size(0x4d, 12);
this.label5.TabIndex = 0;
this.label5.Text = "子文件夹名:";
this.groupBox5.Location = new Point(8, 0x146);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new Size(0x250, 0x3f);
this.groupBox5.TabIndex = 0x31;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "代码模板组件类型";
this.groupBox6.Controls.Add(this.radBtn_One);
this.groupBox6.Controls.Add(this.radBtn_F3);
this.groupBox6.Controls.Add(this.radBtn_S3);
this.groupBox6.Location = new Point(12, 0x117);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new Size(0x24c, 0x2c);
this.groupBox6.TabIndex = 50;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "架构";
this.radBtn_One.AutoSize = true;
this.radBtn_One.Location = new Point(0x3f, 0x12);
this.radBtn_One.Name = "radBtn_One";
this.radBtn_One.Size = new Size(0x47, 0x10);
this.radBtn_One.TabIndex = 0;
this.radBtn_One.Text = "单类结构";
this.radBtn_One.UseVisualStyleBackColor = true;
this.radBtn_F3.AutoSize = true;
this.radBtn_F3.Checked = true;
this.radBtn_F3.Location = new Point(300, 0x12);
this.radBtn_F3.Name = "radBtn_F3";
this.radBtn_F3.Size = new Size(0x5f, 0x10);
this.radBtn_F3.TabIndex = 0;
this.radBtn_F3.TabStop = true;
this.radBtn_F3.Text = "工厂模式三层";
this.radBtn_F3.UseVisualStyleBackColor = true;
this.radBtn_S3.AutoSize = true;
this.radBtn_S3.Location = new Point(180, 0x12);
this.radBtn_S3.Name = "radBtn_S3";
this.radBtn_S3.Size = new Size(0x47, 0x10);
this.radBtn_S3.TabIndex = 0;
this.radBtn_S3.Text = "简单三层";
this.radBtn_S3.UseVisualStyleBackColor = true;
this.AutoScaleBaseSize = new Size(6, 14);
base.ClientSize = new Size(0x264, 0x1fb);
base.Controls.Add(this.groupBox6);
base.Controls.Add(this.groupBox5);
base.Controls.Add(this.groupBox4);
base.Controls.Add(this.groupBox3);
base.Controls.Add(this.btn_Export);
base.Controls.Add(this.groupBox2);
base.Controls.Add(this.groupBox1);
base.Controls.Add(this.btn_Cancle);
base.Controls.Add(this.labelNum);
base.Controls.Add(this.progressBar1);
base.Icon = (Icon) manager.GetObject("$this.Icon");
base.MaximizeBox = false;
base.MinimizeBox = false;
base.Name = "CodeExport";
base.StartPosition = FormStartPosition.CenterScreen;
this.Text = "导出代码文件";
base.Load += new EventHandler(this.CodeExport_Load);
this.groupBox2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
((ISupportInitialize) this.pictureBox1).EndInit();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
base.ResumeLayout(false);
}
private void IsHasItem()
{
if (this.listTable1.Items.Count > 0)
{
this.btn_Add.Enabled = true;
this.btn_Addlist.Enabled = true;
}
else
{
this.btn_Add.Enabled = false;
this.btn_Addlist.Enabled = false;
}
if (this.listTable2.Items.Count > 0)
{
this.btn_Del.Enabled = true;
this.btn_Dellist.Enabled = true;
this.btn_Export.Enabled = true;
}
else
{
this.btn_Del.Enabled = false;
this.btn_Dellist.Enabled = false;
this.btn_Export.Enabled = false;
}
}
private void listTable1_DoubleClick(object sender, EventArgs e)
{
if (this.listTable1.SelectedItem != null)
{
this.listTable2.Items.Add(this.listTable1.SelectedItem);
this.listTable1.Items.Remove(this.listTable1.SelectedItem);
this.IsHasItem();
}
}
private void listTable2_DoubleClick(object sender, EventArgs e)
{
if (this.listTable2.SelectedItem != null)
{
this.listTable1.Items.Add(this.listTable2.SelectedItem);
this.listTable2.Items.Remove(this.listTable2.SelectedItem);
this.IsHasItem();
}
}
private void ReplaceNamespace(string filename, string spacename)
{
StreamReader reader = new StreamReader(filename, Encoding.Default);
string str = reader.ReadToEnd();
reader.Close();
str = str.Replace("<$$namespace$$>", spacename);
StreamWriter writer = new StreamWriter(filename, false, Encoding.Default);
writer.Write(str);
writer.Flush();
writer.Close();
}
private void ReplaceNamespaceProj(string filename, string spacename)
{
StreamReader reader = new StreamReader(filename, Encoding.Default);
string str = reader.ReadToEnd();
reader.Close();
str = str.Replace("<AssemblyName>Maticsoft.", "<AssemblyName>" + spacename + ".").Replace("<RootNamespace>Maticsoft.", "<RootNamespace>" + spacename + ".");
StreamWriter writer = new StreamWriter(filename, false, Encoding.Default);
writer.Write(str);
writer.Flush();
writer.Close();
}
public void SetBtnDisable()
{
if (this.btn_Export.InvokeRequired)
{
SetBtnDisableCallback method = new SetBtnDisableCallback(this.SetBtnDisable);
base.Invoke(method, null);
}
else
{
this.btn_Export.Enabled = false;
this.btn_Cancle.Enabled = false;
}
}
public void SetBtnEnable()
{
if (this.btn_Export.InvokeRequired)
{
SetBtnEnableCallback method = new SetBtnEnableCallback(this.SetBtnEnable);
base.Invoke(method, null);
}
else
{
this.btn_Export.Enabled = true;
this.btn_Cancle.Enabled = true;
}
}
public void SetlblStatuText(string text)
{
if (this.labelNum.InvokeRequired)
{
SetlblStatuCallback method = new SetlblStatuCallback(this.SetlblStatuText);
base.Invoke(method, new object[] { text });
}
else
{
this.labelNum.Text = text;
}
}
public void SetprogressBar1Max(int val)
{
if (this.progressBar1.InvokeRequired)
{
SetProBar1MaxCallback method = new SetProBar1MaxCallback(this.SetprogressBar1Max);
base.Invoke(method, new object[] { val });
}
else
{
this.progressBar1.Maximum = val;
}
}
public void SetprogressBar1Val(int val)
{
if (this.progressBar1.InvokeRequired)
{
SetProBar1ValCallback method = new SetProBar1ValCallback(this.SetprogressBar1Val);
base.Invoke(method, new object[] { val });
}
else
{
this.progressBar1.Value = val;
}
}
private void ThreadWork()
{
this.SetBtnDisable();
string str = this.txtNamespace.Text.Trim();
string str2 = this.txtFolder.Text.Trim();
int count = this.listTable2.Items.Count;
this.SetprogressBar1Max(count);
this.SetprogressBar1Val(1);
this.SetlblStatuText("0");
this.cb.DbName = this.dbname;
if (str != "")
{
this.cb.NameSpace = str;
this.setting.Namepace = str;
}
this.cb.Folder = str2;
this.setting.Folder = str2;
this.cb.DbHelperName = this.txtDbHelper.Text.Trim();
this.cb.ProcPrefix = this.setting.ProcPrefix;
this.setting.DbHelperName = this.txtDbHelper.Text.Trim();
ModuleConfig.SaveSettings(this.setting);
for (int i = 0; i < count; i++)
{
string tableName = this.listTable2.Items[i].ToString();
this.cb.TableName = tableName;
this.cb.ModelName = tableName;
string str4 = this.txtTabNamepre.Text.Trim();
if ((str4 != "") && tableName.StartsWith(str4))
{
this.cb.ModelName = tableName.Substring(str4.Length);
}
this.cb.ModelName = this.namerule.GetModelClass(this.cb.ModelName);
this.cb.BLLName = this.namerule.GetBLLClass(this.cb.ModelName);
this.cb.DALName = this.namerule.GetDALClass(this.cb.ModelName);
DataTable keyName = this.dbobj.GetKeyName(this.dbname, tableName);
List<LTP.CodeHelper.ColumnInfo> columnInfoList = this.dbobj.GetColumnInfoList(this.dbname, tableName);
this.cb.Fieldlist = columnInfoList;
this.cb.Keys = CodeCommon.GetColumnInfos(keyName);
this.CreatCS();
this.SetprogressBar1Val(i + 1);
this.SetlblStatuText((i + 1).ToString());
}
this.SetBtnEnable();
MessageBox.Show(this, "文档生成成功!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
private void WriteFile(string Filename, string strCode)
{
StreamWriter writer = new StreamWriter(Filename, false, Encoding.Default);
writer.Write(strCode);
writer.Flush();
writer.Close();
}
private delegate void SetBtnDisableCallback();
private delegate void SetBtnEnableCallback();
private delegate void SetlblStatuCallback(string text);
private delegate void SetProBar1MaxCallback(int val);
private delegate void SetProBar1ValCallback(int val);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -