wfrm_BackUp.cs
上传用户:horngjaan
上传日期:2009-12-12
资源大小:2882k
文件大小:7k
- using System;
- using System.Data;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- namespace LumiSoft.MailServer
- {
- /// <summary>
- /// Summary description for BackUp.
- /// </summary>
- public class wfrm_BackUp : System.Windows.Forms.Form
- {
- private System.Windows.Forms.GroupBox mt_backup;
- private LumiSoft.UI.Controls.WButton m_pLoadConf;
- private LumiSoft.UI.Controls.WButton m_pSaveConf;
- private LumiSoft.UI.Controls.WLabel mt_reload;
- private LumiSoft.UI.Controls.WLabel mt_save;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- private ServerAPI m_ServerAPI = null;
- private wfrm_Main m_pManager = null;
- private DataSet m_dsSettings = null;
- /// <summary>
- /// Default constructor.
- /// </summary>
- /// <param name="serverAPI"></param>
- /// <param name="manager"></param>
- /// <param name="dsSettings"></param>
- public wfrm_BackUp(ServerAPI serverAPI,wfrm_Main manager,DataSet dsSettings)
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
- m_ServerAPI = serverAPI;
- m_pManager = manager;
- m_dsSettings = dsSettings;
- }
- #region function Dispose
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #endregion
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.mt_backup = new System.Windows.Forms.GroupBox();
- this.m_pLoadConf = new LumiSoft.UI.Controls.WButton();
- this.m_pSaveConf = new LumiSoft.UI.Controls.WButton();
- this.mt_reload = new LumiSoft.UI.Controls.WLabel();
- this.mt_save = new LumiSoft.UI.Controls.WLabel();
- this.mt_backup.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.m_pLoadConf)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pSaveConf)).BeginInit();
- this.SuspendLayout();
- //
- // mt_backup
- //
- this.mt_backup.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.m_pLoadConf,
- this.m_pSaveConf,
- this.mt_reload,
- this.mt_save});
- this.mt_backup.Location = new System.Drawing.Point(8, 24);
- this.mt_backup.Name = "mt_backup";
- this.mt_backup.Size = new System.Drawing.Size(600, 72);
- this.mt_backup.TabIndex = 8;
- this.mt_backup.TabStop = false;
- this.mt_backup.Text = "Setup Backup";
- //
- // m_pLoadConf
- //
- this.m_pLoadConf.Location = new System.Drawing.Point(440, 40);
- this.m_pLoadConf.Name = "m_pLoadConf";
- this.m_pLoadConf.Size = new System.Drawing.Size(144, 22);
- this.m_pLoadConf.TabIndex = 13;
- this.m_pLoadConf.Text = "Restore Configuration";
- this.m_pLoadConf.UseStaticViewStyle = true;
- this.m_pLoadConf.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pLoadConf_Click);
- //
- // m_pSaveConf
- //
- this.m_pSaveConf.Location = new System.Drawing.Point(440, 16);
- this.m_pSaveConf.Name = "m_pSaveConf";
- this.m_pSaveConf.Size = new System.Drawing.Size(144, 22);
- this.m_pSaveConf.TabIndex = 12;
- this.m_pSaveConf.Text = "Save Configuration";
- this.m_pSaveConf.UseStaticViewStyle = true;
- this.m_pSaveConf.ButtonPressed += new LumiSoft.UI.Controls.ButtonPressedEventHandler(this.m_pSaveConf_Click);
- //
- // mt_reload
- //
- this.mt_reload.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
- this.mt_reload.Location = new System.Drawing.Point(16, 40);
- this.mt_reload.Name = "mt_reload";
- this.mt_reload.Size = new System.Drawing.Size(400, 24);
- this.mt_reload.TabIndex = 11;
- this.mt_reload.Text = "Click Reload to restore previous settings from a file.";
- this.mt_reload.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
- this.mt_reload.UseStaticViewStyle = true;
- //
- // mt_save
- //
- this.mt_save.Font = new System.Drawing.Font("Microsoft Sans Serif", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
- this.mt_save.Location = new System.Drawing.Point(16, 16);
- this.mt_save.Name = "mt_save";
- this.mt_save.Size = new System.Drawing.Size(400, 24);
- this.mt_save.TabIndex = 10;
- this.mt_save.Text = "Click Save Configuraton to save all current settings to a file, including Users.";
- this.mt_save.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
- this.mt_save.UseStaticViewStyle = true;
- //
- // BackUp
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(616, 221);
- this.Controls.AddRange(new System.Windows.Forms.Control[] {
- this.mt_backup});
- this.Name = "BackUp";
- this.Text = "BackUp";
- this.mt_backup.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.m_pLoadConf)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.m_pSaveConf)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- #region function m_pSaveConf_Click
- private void m_pSaveConf_Click(object sender, System.EventArgs e)
- {
- try
- {
- string file = DateTime.Today.Year.ToString() + "_";
- file += DateTime.Today.Month.ToString() + "_";
- file += DateTime.Today.Day.ToString();
- System.Windows.Forms.SaveFileDialog filedlg = new System.Windows.Forms.SaveFileDialog();
- filedlg.Filter = "(*.bcp)|*.bcp";
- filedlg.InitialDirectory = Application.StartupPath + "\BackUP";
- filedlg.RestoreDirectory = true;
- filedlg.FileName = file;
-
- if(filedlg.ShowDialog() == DialogResult.OK){
- m_ServerAPI.CreateBackUp(filedlg.FileName,m_dsSettings);
- }
- }
- catch(Exception x)
- {
- wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
- frm.ShowDialog(this);
- }
- }
- #endregion
- #region function m_pLoadConf_Click
- private void m_pLoadConf_Click(object sender, System.EventArgs e)
- {
- try
- {
- if(MessageBox.Show(this,"Warning: Restore overwrites current settings. BackUp Recommended !!!","Restore confirmation",MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- System.Windows.Forms.OpenFileDialog filedlg = new System.Windows.Forms.OpenFileDialog();
- filedlg.Filter = "(*.bcp)|*.bcp";
- filedlg.InitialDirectory = Application.StartupPath + "\BackUP";
- filedlg.RestoreDirectory = true;
-
- if(filedlg.ShowDialog() == DialogResult.OK){
- m_pSaveConf.Enabled = false;
- m_pManager.DisableTabs();
- m_ServerAPI.RestoreBackUp(filedlg.FileName);
- MessageBox.Show("Please close manager and open it agian to apply settings !");
- }
- }
- }
- catch(Exception x)
- {
- wfrm_Error frm = new wfrm_Error(x,new System.Diagnostics.StackTrace());
- frm.ShowDialog(this);
- }
- }
- #endregion
- }
- }