public static async Task <bool> CreateBackUp(string dbName, string fileName, BackUpSettingBussines cls) { try { var path = Path.Combine(cls.BackUpAddress, fileName); var command = @"BACKUP DATABASE " + dbName + " TO Disk='" + path + "'"; var dataConnection = new SqlConnection(Properties.Resources.ConnectionString); if (dataConnection.State != ConnectionState.Open) { dataConnection.Open(); } var cmd = new SqlCommand { Connection = dataConnection, CommandText = command }; cmd.ExecuteNonQuery(); cls.LastBackUpDate = DateConvertor.M2SH(DateTime.Now); cls.LastBackUpTime = DateTime.Now.Hour + ":" + DateTime.Now.Minute; await cls.SaveAsync(); RaiseEvent(); if (cls.IsSendInTelegram) { await SendBackUpToTelegram(path); } return(true); } catch (Exception e) { WebErrorLog.ErrorInstence.StartErrorLog(e); return(false); } }
public frmBackUpSetting() { InitializeComponent(); var a = BackUpSettingBussines.GetAll(); cls = a.Count > 0 ? a[0] : new BackUpSettingBussines(); TelegramBot.SubmitEvent -= TelegramBotOnSubmitEvent; TelegramBot.SubmitEvent += TelegramBotOnSubmitEvent; }
private void SetBackUpLables() { try { var a = BackUpSettingBussines.GetAll(); var cls = a.Count > 0 ? a[0] : new BackUpSettingBussines(); lblLastBackUp.Text = cls.LastBackUpTime + " " + cls.LastBackUpDate; } catch (Exception e) { WebErrorLog.ErrorInstence.StartErrorLog(e); } }