private async Task Sync(SyncConfig syncConfig) { bool shouldLog = syncConfig.ShouldLogDebug; //do a sanity check on the config to avoid exceptions while processing if (ValidateConfigCreateMissingConfigMessage(syncConfig).HasValidConfig == false) { return; } Stopwatch stopwatch = new Stopwatch(); try { ShowBalloon("Finding items..."); LastRunOn = DateTime.Now; lastRunToolStripMenuItem.Text = "Syncing."; stopwatch.Start(); var fileSync = new FileSyncer(syncConfig); var copyResult = new SyncCopyResult(); List <CopyTask> copyTasks = fileSync.BuildFileCopyTasks().ToList(); if (shouldLog) { await FileHelper.WriteToErrLogAsync("Found {0} items to sync.".FormatWith(copyTasks.Count)); } if (copyTasks.Any()) { ShowBalloon("Copying {0} items...".FormatWith(copyTasks.Count)); copyResult = await fileSync.ExecuteFileCopyTasks(copyTasks); if (shouldLog) { await FileHelper.WriteToErrLogAsync("Completed file copy tasks"); } await DeleteSourceFilesIfRequired(syncConfig, copyTasks); } stopwatch.Stop(); copyResult.TimeElapsedMsg = "Total sync time was {0}:{1}".FormatWith( stopwatch.Elapsed.Minutes.ToString("00"), stopwatch.Elapsed.Seconds.ToString("00")); if (shouldLog) { await FileHelper.WriteToErrLogAsync(copyResult.TimeElapsedMsg); } ShowCompletionBalloon(copyResult, syncConfig.DestinationDir); } catch (Exception ex) { var fileIOHelper = new FileIOHelper(); fileIOHelper.WriteToErrLog(ex.Message); ShowBalloon("Sorry we had a problem when syncing. The log file has more details. " + FileIOHelper.OutputLogFile, 10); } }
public FormOptions() { InitializeComponent(); FileHelper = new FileIOHelper(); }
public FileSyncer(SyncConfig config) { Config = config; FileHelper = new FileIOHelper(); }
public FormTray() { InitializeComponent(); SetSyncCommandEnabledIfConfigValid(); FileHelper = new FileIOHelper(); }
private async Task Sync(SyncConfig syncConfig) { bool shouldLog = syncConfig.ShouldLogDebug; //do a sanity check on the config to avoid exceptions while processing if (ValidateConfigCreateMissingConfigMessage(syncConfig).HasValidConfig == false) { return; } Stopwatch stopwatch = new Stopwatch(); try { ShowBalloon("Finding items..."); LastRunOn = DateTime.Now; lastRunToolStripMenuItem.Text = "Syncing."; stopwatch.Start(); var fileSync = new FileSyncer(syncConfig); var copyResult = new SyncCopyResult(); List<CopyTask> copyTasks = fileSync.BuildFileCopyTasks().ToList(); if (shouldLog) { await FileHelper.WriteToErrLogAsync("Found {0} items to sync.".FormatWith(copyTasks.Count)); } if (copyTasks.Any()) { ShowBalloon("Copying {0} items...".FormatWith(copyTasks.Count)); copyResult = await fileSync.ExecuteFileCopyTasks(copyTasks); if (shouldLog) { await FileHelper.WriteToErrLogAsync("Completed file copy tasks"); } await DeleteSourceFilesIfRequired(syncConfig, copyTasks); } stopwatch.Stop(); copyResult.TimeElapsedMsg = "Total sync time was {0}:{1}".FormatWith( stopwatch.Elapsed.Minutes.ToString("00"), stopwatch.Elapsed.Seconds.ToString("00")); if (shouldLog) { await FileHelper.WriteToErrLogAsync(copyResult.TimeElapsedMsg); } ShowCompletionBalloon(copyResult, syncConfig.DestinationDir); } catch (Exception ex) { var fileIOHelper = new FileIOHelper(); fileIOHelper.WriteToErrLog(ex.Message); ShowBalloon("Sorry we had a problem when syncing. The log file has more details. " + FileIOHelper.OutputLogFile, 10); } }