📄 frmsqlscript.cs
字号:
//
this.TreeImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this.TreeImageList.ImageSize = new System.Drawing.Size(20, 20);
this.TreeImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("TreeImageList.ImageStream")));
this.TreeImageList.TransparentColor = System.Drawing.Color.Transparent;
//
// _FrmSqlScript_Toolbars_Dock_Area_Left
//
this._FrmSqlScript_Toolbars_Dock_Area_Left.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._FrmSqlScript_Toolbars_Dock_Area_Left.BackColor = System.Drawing.SystemColors.Control;
this._FrmSqlScript_Toolbars_Dock_Area_Left.DockedPosition = DS.Win.UltraWinToolbars.DockedPosition.Left;
this._FrmSqlScript_Toolbars_Dock_Area_Left.ForeColor = System.Drawing.SystemColors.ControlText;
this._FrmSqlScript_Toolbars_Dock_Area_Left.Location = new System.Drawing.Point(0, 62);
this._FrmSqlScript_Toolbars_Dock_Area_Left.Name = "_FrmSqlScript_Toolbars_Dock_Area_Left";
this._FrmSqlScript_Toolbars_Dock_Area_Left.Size = new System.Drawing.Size(0, 377);
this._FrmSqlScript_Toolbars_Dock_Area_Left.ToolbarsManager = this.MainUltraToolbarsManager;
//
// _FrmSqlScript_Toolbars_Dock_Area_Right
//
this._FrmSqlScript_Toolbars_Dock_Area_Right.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._FrmSqlScript_Toolbars_Dock_Area_Right.BackColor = System.Drawing.SystemColors.Control;
this._FrmSqlScript_Toolbars_Dock_Area_Right.DockedPosition = DS.Win.UltraWinToolbars.DockedPosition.Right;
this._FrmSqlScript_Toolbars_Dock_Area_Right.ForeColor = System.Drawing.SystemColors.ControlText;
this._FrmSqlScript_Toolbars_Dock_Area_Right.Location = new System.Drawing.Point(760, 62);
this._FrmSqlScript_Toolbars_Dock_Area_Right.Name = "_FrmSqlScript_Toolbars_Dock_Area_Right";
this._FrmSqlScript_Toolbars_Dock_Area_Right.Size = new System.Drawing.Size(0, 377);
this._FrmSqlScript_Toolbars_Dock_Area_Right.ToolbarsManager = this.MainUltraToolbarsManager;
//
// _FrmSqlScript_Toolbars_Dock_Area_Top
//
this._FrmSqlScript_Toolbars_Dock_Area_Top.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._FrmSqlScript_Toolbars_Dock_Area_Top.BackColor = System.Drawing.SystemColors.Control;
this._FrmSqlScript_Toolbars_Dock_Area_Top.DockedPosition = DS.Win.UltraWinToolbars.DockedPosition.Top;
this._FrmSqlScript_Toolbars_Dock_Area_Top.ForeColor = System.Drawing.SystemColors.ControlText;
this._FrmSqlScript_Toolbars_Dock_Area_Top.Location = new System.Drawing.Point(0, 0);
this._FrmSqlScript_Toolbars_Dock_Area_Top.Name = "_FrmSqlScript_Toolbars_Dock_Area_Top";
this._FrmSqlScript_Toolbars_Dock_Area_Top.Size = new System.Drawing.Size(760, 62);
this._FrmSqlScript_Toolbars_Dock_Area_Top.ToolbarsManager = this.MainUltraToolbarsManager;
//
// _FrmSqlScript_Toolbars_Dock_Area_Bottom
//
this._FrmSqlScript_Toolbars_Dock_Area_Bottom.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
this._FrmSqlScript_Toolbars_Dock_Area_Bottom.BackColor = System.Drawing.SystemColors.Control;
this._FrmSqlScript_Toolbars_Dock_Area_Bottom.DockedPosition = DS.Win.UltraWinToolbars.DockedPosition.Bottom;
this._FrmSqlScript_Toolbars_Dock_Area_Bottom.ForeColor = System.Drawing.SystemColors.ControlText;
this._FrmSqlScript_Toolbars_Dock_Area_Bottom.Location = new System.Drawing.Point(0, 439);
this._FrmSqlScript_Toolbars_Dock_Area_Bottom.Name = "_FrmSqlScript_Toolbars_Dock_Area_Bottom";
this._FrmSqlScript_Toolbars_Dock_Area_Bottom.Size = new System.Drawing.Size(760, 0);
this._FrmSqlScript_Toolbars_Dock_Area_Bottom.ToolbarsManager = this.MainUltraToolbarsManager;
//
// ultraStatusBar1
//
this.ultraStatusBar1.Location = new System.Drawing.Point(0, 439);
this.ultraStatusBar1.Name = "ultraStatusBar1";
ultraStatusPanel1.ProgressBarInfo.Maximum = 600;
ultraStatusPanel1.Style = DS.Win.UltraWinStatusBar.PanelStyle.Progress;
ultraStatusPanel1.Visible = false;
ultraStatusPanel1.Width = 300;
this.ultraStatusBar1.Panels.AddRange(new DS.Win.UltraWinStatusBar.UltraStatusPanel[] {
ultraStatusPanel1,
ultraStatusPanel2});
this.ultraStatusBar1.Size = new System.Drawing.Size(760, 23);
this.ultraStatusBar1.TabIndex = 5;
//
// FrmSqlScript
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(760, 462);
this.Controls.Add(this.FrmSqlScript_Fill_Panel);
this.Controls.Add(this._FrmSqlScript_Toolbars_Dock_Area_Left);
this.Controls.Add(this._FrmSqlScript_Toolbars_Dock_Area_Right);
this.Controls.Add(this._FrmSqlScript_Toolbars_Dock_Area_Top);
this.Controls.Add(this._FrmSqlScript_Toolbars_Dock_Area_Bottom);
this.Controls.Add(this.ultraStatusBar1);
this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
this.MaximizeBox = false;
this.Name = "FrmSqlScript";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "脚本执行工具";
this.Load += new System.EventHandler(this.FrmSqlScript_Load);
((System.ComponentModel.ISupportInitialize)(this.MainUltraToolbarsManager)).EndInit();
this.FrmSqlScript_Fill_Panel.ResumeLayout(false);
this.pnlMiddle.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.tabControlSql.ResumeLayout(false);
this.tabPageResult.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#endregion
#region ### CTOR & Dispose ###
#region CTOR
public FrmSqlScript()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
Initialise();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
#endregion
#region Dispose
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#endregion
#region ### 自定义变量 ###
public string[] keystr =
{
"insert ", "update ", "into ", " set ", " delete ", " from ", " join ", "create ","TABLESPACE ",
"select ", "from ", "where ", " and ", " or ", " order ", " by ", " desc ", " null ",
" when ", " case "," then ", " end ", " on ", " in ", " is ", " else ", " left ",
" join ", " not ", " table ", " user ", " database " };
private System.Threading.Timer timer = null;
#endregion
#region ### 自定义属性 ###
private bool keyWordColorOn = false;
public bool KeyWordColorOn
{
get{return this.keyWordColorOn;}
set{this.keyWordColorOn = value;}
}
private string filePath = string.Empty;
public string FilePath
{
get{return this.filePath;}
set{this.filePath = value;}
}
#endregion
#region ### 自定义方法 ###
public void Initialise()
{
OnKeyWordColor();
Init();
}
#region 给关键字上色
/// <summary>
/// 给关键字上色
/// </summary>
/// <param name="p">关键字</param>
/// <param name="s">全部文本文件</param>
/// <returns></returns>
public int getbunch(string p, string s)
{
//p = p.ToUpper();
int cnt = 0; int M = p.Length; int N = s.Length;
char[] ss = s.ToCharArray(), pp = p.ToCharArray();
// char[] ppp = p.ToUpper().ToCharArray();
if (M > N) return 0;
for (int i = 0; i < N - M + 1; i++)
{
int j;
for (j = 0; j < M; j++)
{
if ( (ss[i + j] != pp[j]))
break;
}
if (j == p.Length)
{
this.TxtBoxSql.Select(i, p.Length);
this.TxtBoxSql.SelectionColor = Color.Blue;
cnt++;
}
}
return cnt;
}
#endregion
#region 读取配置文件
public void OnKeyWordColor()
{
string on =
DS.EMIS.StartPrepare.Common.GlobalObject.Instance.LocalSession.GetConfig("KeyWordColor","DBTask.Config");
if(on.Equals(string.Empty))
on = "false";
else
this.KeyWordColorOn = Convert.ToBoolean(on);
this.FilePath = DS.EMIS.StartPrepare.Common.GlobalObject.Instance.LocalSession.GetConfig("SqlFilePath","DBTask.Config");
}
#endregion
#region //
// #region 加载SQL文件
// public string LoadSqlToText(OpenFileDialog dialog)
// {
// string str = String.Empty;
// try
// {
//
// {
// FileStream fs =
// new FileStream(dialog.FileName,FileMode.Open,FileAccess.Read);
// StreamReader m_streamReader = new StreamReader(fs) ;
// //使用StreamReader类来读取文件
// m_streamReader.BaseStream.Seek(0,SeekOrigin.Begin) ;
// // 从数据流中读取每一行,直到文件的最后一行
// string strLine = m_streamReader.ReadLine() ;
// while(strLine!=null)
// {
// str += strLine + "\n" ;
// strLine = m_streamReader.ReadLine() ;
// }
// //关闭此StreamReader对象
// m_streamReader.Close();
// }
// return str;
// }
// catch( Exception em )
// {
// Console.WriteLine(em.Message.ToString());
// return str;
// }
// }
// #endregion
//
// #region 打开文件
// public void OpenFile()
// {
// OpenFileDialog openFileDialog1 = new OpenFileDialog();
// openFileDialog1.InitialDirectory = System.IO.Directory.GetCurrentDirectory()+this.FilePath;
// openFileDialog1.Filter = "SQL文件(*.sql)|*.sql|All files (*.*)|*.*";
// if(openFileDialog1.ShowDialog() == DialogResult.OK)
// {
//
// LoadFileToTextDelegate dlgt = new LoadFileToTextDelegate(this.LoadSqlToText);
// AsyncCallback callback = new AsyncCallback(SynchOpenFile);
// IAsyncResult ar = dlgt.BeginInvoke(openFileDialog1,callback,null);
// ar.AsyncWaitHandle.WaitOne();//
// }
// }
// #endregion
//
// #region SynchOpenFile
// public void SynchOpenFile(IAsyncResult ar)
// {
// LoadFileToTextDelegate dlgt = (LoadFileToTextDelegate)ar.AsyncState;
// this.TxtBoxSql.Text = dlgt.EndInvoke(ar);
// }
// #endregion
#endregion
#region 读取/SAVE文件
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -