private async void ExecuteBackupAsync() { try { if (BackupModel.Path == null) { return; } using (GeneralDBContext db = new GeneralDBContext()) { try { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; string fileName = BackupModel.Path + "\\RestaurantDB " + DateTime.Now.ToShortDateString().Replace('/', '-') + " - " + DateTime.Now.ToLongTimeString().Replace(':', '-'); string dbname = db.Database.Connection.Database; string sqlCommand = @"BACKUP DATABASE [{0}] TO DISK = N'" + fileName + ".bak' WITH NOFORMAT, NOINIT,NAME = N'MyAir-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"; db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, string.Format(sqlCommand, dbname)); BackupModel = new BackupDataModel(); } catch { Mouse.OverrideCursor = null; await currentWindow.HideMetroDialogAsync(backupDialog); await currentWindow.ShowMessageAsync("فشل الحفظ", "يجب إختيار مكان آخر لحفظ النسخة الإحتياطية", MessageDialogStyle.Affirmative, new MetroDialogSettings() { AffirmativeButtonText = "موافق", DialogMessageFontSize = 25, DialogTitleFontSize = 30 }); await currentWindow.ShowMetroDialogAsync(backupDialog); return; } finally { Mouse.OverrideCursor = null; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
void UCDataBackupItemNew_Click(object sender, EventArgs e) { UCBackupItem ucBackup = (UCBackupItem)sender; BackupDataModel tag = (BackupDataModel)(ucBackup.Tag); btnRetore.Tag = tag; foreach (Control ctr in flpDataDetail.Controls) { if (ctr.BackColor == Color.FromArgb(0, 153, 51)) { ctr.BackColor = Color.FromArgb(255, 255, 255); ctr.ForeColor = Color.FromArgb(51, 51, 51); } } ucBackup.BackColor = Color.FromArgb(0, 153, 51); ucBackup.ForeColor = Color.FromArgb(255, 255, 255); }
public ActionResult Information() { var user = CurrentUser; var model = new BackupDataModel { UserId = user.Id }; if (user.InfusionSoftAccount != null && user.InfusionSoftAccount.Enabled) { model.Sources.Add(AccountEnum.InfusionSoft.ToString()); } if (user.ActiveCampaignAccount != null && user.ActiveCampaignAccount.Enabled) { model.Sources.Add(AccountEnum.ActiveCampaign.ToString()); } if (user.AweberAccount != null && user.AweberAccount.Enabled) { model.Sources.Add(AccountEnum.Aweber.ToString()); } if (user.MailChimpAccount != null && user.MailChimpAccount.Enabled) { model.Sources.Add(AccountEnum.MailChimp.ToString()); } if (user.OntraportAccount != null && user.OntraportAccount.Enabled) { model.Sources.Add(AccountEnum.Ontraport.ToString()); } if (user.GetResponseAccount != null && user.GetResponseAccount.Enabled) { model.Sources.Add(AccountEnum.GetResponse.ToString()); } if (user.DropboxAccount != null && user.DropboxAccount.Enabled) { model.Receivers.Add(AccountEnum.Dropbox.ToString()); } if (user.GoogleDriveAccount != null && user.GoogleDriveAccount.Enabled) { model.Receivers.Add(AccountEnum.GoogleDrive.ToString()); } return(Json(model)); }
public async void NavigateToViewMethodAsync(string destination) { try { switch (destination) { case "Backup": BackupModel = new BackupDataModel(); backupDialog.DataContext = this; await currentWindow.ShowMetroDialogAsync(backupDialog); break; case "BackupRestore": RestoreBackupModel = new RestoreBackupDataModel(); restoreBackupDialog.DataContext = this; await currentWindow.ShowMetroDialogAsync(restoreBackupDialog); break; case "User": currentWindow.Hide(); new UserWindow().ShowDialog(); currentWindow.Show(); break; case "Shifts": currentWindow.Hide(); new ShiftWindow().ShowDialog(); currentWindow.Show(); break; case "SignOut": LoginModel = new LoginDataModel(); loginDialog.DataContext = this; await currentWindow.ShowMetroDialogAsync(loginDialog); break; case "Item": currentWindow.Hide(); new ItemWindow().ShowDialog(); currentWindow.Show(); break; case "Cashier": currentWindow.Hide(); new BillItemsWindow().ShowDialog(); currentWindow.Show(); if (IsSignOut) { LoginModel = new LoginDataModel(); loginDialog.DataContext = this; await currentWindow.ShowMetroDialogAsync(loginDialog); } break; case "Bill": currentWindow.Hide(); new BillWindow().ShowDialog(); currentWindow.Show(); break; case "Spending": currentWindow.Hide(); new SpendingWindow().ShowDialog(); currentWindow.Show(); break; case "Safe": currentWindow.Hide(); new SafeWindow().ShowDialog(); currentWindow.Show(); break; default: break; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }