/// <summary> /// Run backup program if neccessary /// </summary> void ThisAddIn_Quit() { try { BackupSettings config = BackupSettingsDao.loadSettings(); //if configuration was done and backup program was configured if (config != null && !String.IsNullOrEmpty(config.BackupProgram)) { //and if not yet backuped or if backup too old, then run program if (config.LastRun == null || config.LastRun.AddDays(config.Interval).AddHours(config.IntervalHours) <= DateTime.Now) { bool configChanged = false; if (config.BackupAll) { //If alles pdf-files should be saved, enumerate them and save to config-file //Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); config.Items.Clear(); var list = BackupUtils.GetStoreLocations(config, Application.Session.Stores); config.Items.AddRange(list.ToArray()); configChanged = true; } if (config.ProfileName != Application.Session.CurrentProfileName) { config.ProfileName = Application.Session.CurrentProfileName; configChanged = true; } if (configChanged) { BackupSettingsDao.saveSettings(config); } try { Process.Start(config.BackupProgram); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(config.BackupProgram + " not found! " + e.Message); } } }//config loaded } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); } }
/// <summary> /// Populate form and display saved settings (if available) /// </summary> /// <param name="sender">not used</param> /// <param name="e">OnLoad-Event-Args</param> private void FBackupSettings_Load(object sender, EventArgs e) { //cleanup txtDestination.Text = ""; lvStores.Items.Clear(); config = BackupSettingsDao.loadSettings(); //Add pst-files to list var list = BackupUtils.GetStoreLocations(config, stores); ListViewItem[] lItem = list.Select(f => new ListViewItem(f + " (" + GetHumanReadableFileSize(f) + ")")) .ToArray(); lvStores.Items.AddRange(lItem); lvStores.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); applySettings(); }
/// <summary> /// Populate form and display saved settings (if available) /// </summary> /// <param name="sender">not used</param> /// <param name="e">OnLoad-Event-Args</param> private void FBackupSettings_Load(object sender, EventArgs e) { //cleanup txtDestination.Text = ""; lvStores.Items.Clear(); config = BackupSettingsDao.loadSettings(); //Add pst-files to list var list = BackupUtils.GetStoreLocations(config, stores); ListViewItem[] lItem = list.Select(X => new ListViewItem(X)).ToArray(); lvStores.Items.AddRange(lItem); /* * for (int i = 1; i <= 20; i++) * lvStores.Items.Add("test test test test test testes testes testest " + i); */ lvStores.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); applySettings(); }