📄 frmoptimize.cs
字号:
this.dgConfig.DisplayLayout.Override.BorderStyleRow = DS.Win.UIElementBorderStyle.Dotted;
appearance7.BackColor = System.Drawing.SystemColors.Window;
this.dgConfig.DisplayLayout.Override.CardAreaAppearance = appearance7;
appearance8.BorderColor = System.Drawing.Color.Silver;
appearance8.TextTrimming = DS.Win.TextTrimming.EllipsisCharacter;
this.dgConfig.DisplayLayout.Override.CellAppearance = appearance8;
this.dgConfig.DisplayLayout.Override.CellClickAction = DS.Win.UltraWinGrid.CellClickAction.EditAndSelectText;
this.dgConfig.DisplayLayout.Override.CellPadding = 0;
appearance9.BackColor = System.Drawing.SystemColors.Control;
appearance9.BackColor2 = System.Drawing.SystemColors.ControlDark;
appearance9.BackGradientAlignment = DS.Win.GradientAlignment.Element;
appearance9.BackGradientStyle = DS.Win.GradientStyle.Horizontal;
appearance9.BorderColor = System.Drawing.SystemColors.Window;
this.dgConfig.DisplayLayout.Override.GroupByRowAppearance = appearance9;
appearance10.TextHAlign = DS.Win.HAlign.Left;
this.dgConfig.DisplayLayout.Override.HeaderAppearance = appearance10;
this.dgConfig.DisplayLayout.Override.HeaderClickAction = DS.Win.UltraWinGrid.HeaderClickAction.SortMulti;
this.dgConfig.DisplayLayout.Override.HeaderStyle = DS.Win.HeaderStyle.WindowsXPCommand;
appearance11.BackColor = System.Drawing.SystemColors.Window;
appearance11.BorderColor = System.Drawing.Color.Silver;
this.dgConfig.DisplayLayout.Override.RowAppearance = appearance11;
this.dgConfig.DisplayLayout.Override.RowSelectors = DS.Win.DefaultableBoolean.False;
appearance12.BackColor = System.Drawing.SystemColors.ControlLight;
this.dgConfig.DisplayLayout.Override.TemplateAddRowAppearance = appearance12;
this.dgConfig.DisplayLayout.ScrollBounds = DS.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
this.dgConfig.DisplayLayout.ScrollStyle = DS.Win.UltraWinGrid.ScrollStyle.Immediate;
this.dgConfig.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgConfig.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.dgConfig.Location = new System.Drawing.Point(0, 0);
this.dgConfig.Name = "dgConfig";
this.dgConfig.Size = new System.Drawing.Size(570, 176);
this.dgConfig.TabIndex = 0;
this.dgConfig.DoubleClickRow += new DS.Win.UltraWinGrid.DoubleClickRowEventHandler(this.dgConfig_DoubleClickRow);
//
// panel4
//
this.panel4.Controls.Add(this.btnOpen);
this.panel4.Controls.Add(this.txtConfigPath);
this.panel4.Controls.Add(this.label1);
this.panel4.Dock = System.Windows.Forms.DockStyle.Top;
this.panel4.Location = new System.Drawing.Point(3, 17);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(570, 39);
this.panel4.TabIndex = 0;
//
// btnOpen
//
this.btnOpen.Location = new System.Drawing.Point(488, 8);
this.btnOpen.Name = "btnOpen";
this.btnOpen.TabIndex = 2;
this.btnOpen.Text = "打开";
this.btnOpen.Visible = false;
this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
//
// txtConfigPath
//
this.txtConfigPath.Location = new System.Drawing.Point(104, 8);
this.txtConfigPath.Name = "txtConfigPath";
this.txtConfigPath.ReadOnly = true;
this.txtConfigPath.Size = new System.Drawing.Size(368, 21);
this.txtConfigPath.TabIndex = 1;
this.txtConfigPath.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 23);
this.label1.TabIndex = 0;
this.label1.Text = "优化配置文件";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// FrmOptimize
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(576, 478);
this.Controls.Add(this.panel3);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Name = "FrmOptimize";
this.Text = "优化数据库";
this.Load += new System.EventHandler(this.FrmOptimize_Load);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.panel7.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.panel5.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgConfig)).EndInit();
this.panel4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void FrmOptimize_Load(object sender, System.EventArgs e)
{
this.Populate();
FrmSetConfig frmSetConfig = new FrmSetConfig();
frmSetConfig.ConfigChangEvent += new FrmSetConfig.ConfigChangHandler(FrmSetConfig_OnEvent);
}
private void FrmSetConfig_OnEvent(string fileName)
{
if(fileName.ToUpper() == opManager.OptConfig.ToUpper())
{
this.dgConfig.DataSource = opManager.GetOptimizeDt(opManager.OptConfig);
this.dgConfig.DataBind();
}
}
private void Populate()
{
this.dgConfig.DataSource = opManager.GetOptimizeDt(opManager.OptConfig);
this.dgConfig.DataBind();
string currPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase+"\\Configs\\";
this.txtConfigPath.Text = System.IO.Path.Combine(currPath,opManager.OptConfig);
opManager.ResultView = this.ctrlResultPanel1;
SetButtonEnable();
}
private void dgConfig_InitializeLayout(object sender, DS.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
e.Layout.Bands[0].Columns["Select"].Style =DS.Win.UltraWinGrid.ColumnStyle.CheckBox ;
e.Layout.Bands[0].Columns["StateImage"].Editor = new DS.Win.EmbeddableImageRenderer();
}
/// <summary>
/// 打开
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOpen_Click(object sender, System.EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "XML文件|*.xml";
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
this.txtConfigPath.Text = openFileDialog1.FileName;
this.dgConfig.DataSource = opManager.GetOptimizeDt(openFileDialog1.FileName);
}
}
/// <summary>
/// 检测
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCheck_Click(object sender, System.EventArgs e)
{
}
/// <summary>
/// 执行
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnExecute_Click(object sender, System.EventArgs e)
{
this.ShowProgress("数据库优化",true);
IList entityList = new ArrayList();
foreach(DS.Win.UltraWinGrid.UltraGridRow row in this.dgConfig.Rows)
{
if((Boolean)row.Cells["Select"].Value == true)
{
OptScriptEntity entity = new OptScriptEntity();
entity.DisplayName = row.Cells["DisplayName"].Value.ToString().Trim();
string currAppPath = Application.StartupPath;
currAppPath += ".\\Resources\\Script\\";
entity.ScriptFile = currAppPath+ row.Cells["FileName"].Value.ToString().Trim();
//entity.updateTime = (DateTime)row.Cells["UpdateTime"].Value;
entityList.Add(entity);
//sqlFileNames.Add(row.Cells["FileName"].Value.ToString().Trim());
}
}
this.ctrlResultPanel1.LogCreateTime = DateTime.Now;
try
{
opManager.ExecuteOptimizeScript(entityList);
MessageBox.Show("执行成功!");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"执行失败",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
//设置按钮状态
this.ShowProgress("数据库优化",false);
SetButtonEnable();
}
/// <summary>
/// 完成
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnFinish_Click(object sender, System.EventArgs e)
{
//更改状态配置文件
GlobalObject.Instance.LocalSession.UpdateConfig("DBTask.config","task","TaskState","1","TaskName","OptiDBTask");
GlobalObject.Instance.LocalSession.SendMessage("OptiDBTask","FrmOptimize","TaskStepState",TaskStepState.Done);
}
private void ImageStateChanged(DataRow row,bool state)
{
try
{
if(state)
{
Image image = new Bitmap(this.imageList1.Images[1]);
row["StateImage"] = image;
}
else
{
Image image = new Bitmap(this.imageList1.Images[0]);
row["StateImage"] = image;
}
}
catch
{
}
}
private void dgConfig_DoubleClickRow(object sender, DS.Win.UltraWinGrid.DoubleClickRowEventArgs e)
{
FrmOptimizeDetail optDetail = new FrmOptimizeDetail();
//string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
optDetail.FileName = e.Row.Cells["FileName"].Value.ToString();
optDetail.Text = e.Row.Cells["DisPlayName"].Value.ToString() + ": " +e.Row.Cells["FileName"].Value.ToString();
//对话框相对居中
optDetail.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
optDetail.ShowInTaskbar = false;
optDetail.ShowDialog(this);
}
private void SetButtonEnable()
{
bool isExecute = false;
DataTable dt = GlobalObject.Instance.LocalSession.GetConfigs("DBTask.config","task");
DataRow[] drs = dt.Select(" taskName= '"+taskName+"'");
try
{
foreach(DataRow row in drs)
{
if(Convert.ToInt32(row["TaskState"].ToString()) == (int)TaskStepState.Done)
{
isExecute = true;
}
else
{
isExecute = false;
}
}
}
catch
{
isExecute = false;
}
if(isExecute)
{
this.btnExecute.Enabled = false;
}
else
{
this.btnExecute.Enabled = true;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -