private void backup_BackupStarted(object sender, BackupStartedEventArgs e) { i = 0; success = 0; failure = 0; outOfLabel.Text = e.ContainersCount.ToString(); progressBar.Maximum = e.ContainersCount + 1; progressBar.Value = 0; startAll = DateTime.Now; }
static void backup_BackupStarted(object sender, BackupStartedEventArgs e) { if (backupArgs.WriteToConsole) { Console.WriteLine(e.ToString()); } if (backupArgs.SendEmailOnSuccess) { Send(backupArgs.Emails, "Backup Started", e.ToString()); } }
public void Backup(StartBackupEventHandler startBackupCallback, EndBackupEventHandler endBackupCallback, StartBackupContainerEventHandler startBackupContainerCallback, EndBackupContainerEventHandler endBackupContainerCallback, StorageCred storageCred = null, StorageCred backupStorageCred = null, int copies = 14, string containersPrefix = "duradosappsys") { Dictionary <string, Exception> exceptions = new Dictionary <string, Exception>(); try { BackupStartedEventArgs e = new BackupStartedEventArgs() { Occured = DateTime.Now, StorageName = storageCred.Name }; Storage storage = GetStorage(storageCred); Storage backupStorage = GetStorage(backupStorageCred); var containers = storage.ListContainers(containersPrefix); if (startBackupCallback != null) { e.ContainersCount = containers.Count(); startBackupCallback(this, e); } foreach (var container in containers) { if (startBackupContainerCallback != null) { startBackupContainerCallback(this, new BackupContainerStartedEventArgs() { Occured = DateTime.Now, Container = container }); } try { DateTime?lastModified = null; bool modified = BackupContainer(container, backupStorage, storage, copies, out lastModified); if (endBackupContainerCallback != null) { endBackupContainerCallback(this, new BackupContainerEndedEventArgs() { Occured = DateTime.Now, Container = container, LastModified = lastModified, Modified = modified }); } } catch (Exception exception) { exceptions.Add(container.Name, exception); if (endBackupContainerCallback != null) { endBackupContainerCallback(this, new BackupContainerEndedEventArgs() { Occured = DateTime.Now, Container = container, Exception = exception }); } } } } catch (Exception exception) { exceptions.Add("general", exception); } finally { if (endBackupCallback != null) { endBackupCallback(this, new BackupEndedEventArgs() { Occured = DateTime.Now, StorageName = storageCred.Name, Exceptions = exceptions }); } } }