Esempio n. 1
0
        private bool DoSave()
        {
            string sql  = FrmDataBaseConfig.GetFileSql("smartaccess_createbackupjob.sql");
            string path = this.tbPath.Text.Trim();

            path = path.TrimEnd('\\', '/');
            sql  = sql.Replace("${PATH}", path);
            sql  = sql.Replace("${ENABLE}", cbAutoBk.Checked ? "1" : "0");
            sql  = sql.Replace("${DAYS}", iiDays.Value.ToString());
            var         sqls    = sql.Split(new string[] { "GO\r" }, StringSplitOptions.RemoveEmptyEntries);
            bool        b       = false;
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    foreach (var item in sqls)
                    {
                        Maticsoft.DBUtility.DbHelperSQL.ExecuteSql(item);
                    }
                    b = true;
                }
                catch (System.Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "保存自动备份配置异常!" + ex.Message);
                    log.Error("保存自动备份配置异常:", ex);
                }
            });

            waiting.ShowDialog(this);
            return(b);
        }
Esempio n. 2
0
        private void DoExcute()
        {
            string sql  = FrmDataBaseConfig.GetFileSql("smartaccess_excutebackup.sql");
            string path = this.tbPath.Text.Trim();

            path = path.TrimEnd('\\', '/');
            sql  = sql.Replace("${PATH}", path);
            var         sqls    = sql.Split(new string[] { "GO\r" }, StringSplitOptions.RemoveEmptyEntries);
            CtrlWaiting waiting = new CtrlWaiting(() =>
            {
                try
                {
                    foreach (var item in sqls)
                    {
                        Maticsoft.DBUtility.DbHelperSQL.ExecuteSql(item);
                    }
                    this.Invoke(new Action(() =>
                    {
                        WinInfoHelper.ShowInfoWindow(this, "立即备份成功!");
                    }));
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    if (ex.ErrorCode == -2146232060)//
                    {
                        WinInfoHelper.ShowInfoWindow(this, "备份异常,请启动Sql Server服务器中服务“SQL Server 代理 (MSSQLSERVER)”!");
                    }
                    else
                    {
                        WinInfoHelper.ShowInfoWindow(this, "立即备份异常!" + ex.Message);
                    }
                    log.Error("立即备份异常:", ex);
                }
                catch (System.Exception ex)
                {
                    WinInfoHelper.ShowInfoWindow(this, "立即备份异常!" + ex.Message);
                    log.Error("立即备份异常:", ex);
                }
            });

            waiting.Show(this);
        }