public DetailsWindow(SyncPair initialPair) { InitializeComponent(); cbMonitoring.DataContext = SyncMonitoring.Strategies; cbBackup.DataContext = SyncBackup.BackupModes; this.EditedPair = initialPair; }
/// <summary> /// Returns true if the specified syncpair exists in the /// repository, or false if it is not. /// </summary> /// <param name="syncpair"></param> /// <returns></returns> public bool ContainsSyncPair(SyncPair syncpair) { if (syncpair == null) { throw new ArgumentNullException("syncpair"); } return(_syncPairs.Contains(syncpair)); }
public SchedulerTask() { Pair = null; Event = SchedulerEvent.Manually; TimeSpan = 0; LastRunTime = DateTime.MinValue; NextRunTime = 1; Precedence = Precedence.None; SilentSync = false; }
private void UpdateTask_BTN_Click(object sender, EventArgs e) { try { if (Calendars_LB.SelectedIndex >= 0 && Calendars_LB.SelectedIndex < m_scheduler.Count) { SchedulerTask task = m_scheduler[Calendars_LB.SelectedIndex]; if (Event_CB.SelectedIndex >= 0 && Event_CB.SelectedIndex <= 6) { task.Event = (SchedulerEvent)Event_CB.SelectedIndex; } if (GoogleCal_CB.SelectedIndex >= 0 && OutlookCal_CB.SelectedIndex >= 0) { var pair = new SyncPair(); var googleCal = m_googleFolders.Items[GoogleCal_CB.SelectedIndex]; var outlookCal = m_outlookFolders[OutlookCal_CB.SelectedIndex]; pair.GoogleName = googleCal.Summary; pair.GoogleId = googleCal.Id; pair.OutlookName = outlookCal.Name; pair.OutlookId = outlookCal.EntryID; task.Pair = pair; } else { MessageBox.Show(this, "You need to select a calendar from both lists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (task.Event == SchedulerEvent.CustomTime) { task.TimeSpan = int.Parse(Time_TB.Text); } if (SilentSync_CB.Checked) { task.SilentSync = true; task.Precedence = (Precedence)Precedence_CB.SelectedIndex; } m_scheduler.UpdateTask(task, Calendars_LB.SelectedIndex); } } catch (ArgumentOutOfRangeException ex) { Log.Write(ex); MessageBox.Show(this, "There was an invalid index selected in the application. Unable to update the task.", ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Constructor created from supplied args. /// </summary> /// <param name="p_syncPair"></param> /// <param name="p_syncPairRepository"></param> /// <param name="wsCommands"></param> public SyncPairViewModel(SyncPair p_syncPair, SyncPairRepository p_syncPairRepository, IWorkspaceCommands wsCommands) { // Create local commands. _wsCommands = wsCommands; // Check sync pair exists. if (p_syncPair == null) { throw new ArgumentNullException("p_syncPair"); } // Check sync repository exists. if (p_syncPairRepository == null) { throw new ArgumentNullException("p_syncPairRepository"); } // Set sync pair. _syncPair = p_syncPair; // Set sync pair repository. _syncPairRepository = p_syncPairRepository; // Set sync type if specified. if (_syncPair.SyncType == null) { _syncPairType = Strings.SyncPairViewModel_SyncPairTypeOption_NotSpecified; } else { _syncPairType = _syncPair.SyncType; } // Initialise source root retrieval. GetSrcRootCommand = new SharpToolsMVVMRelayCommand(GetSrcRoot); // Initialise destination root retrieval. GetDstRootCommand = new SharpToolsMVVMRelayCommand(GetDstRoot); // Initialise source root browser. BrowseSrcRootCommand = new SharpToolsMVVMRelayCommand(BrowseSrcRoot); // Initialise destination root browser. BrowseDstRootCommand = new SharpToolsMVVMRelayCommand(BrowseDstRoot); // Initialise delete sync pair. DeleteSyncPairCommand = new SharpToolsMVVMRelayCommand(Delete); SharpToolsMVVMMediator.Register("update", AddUpdate); // Listener for change events // LOG _log.Debug("Mediator Registered"); // ResultLog = new ObservableCollection <string>(); }
public void AddSyncPairToList() { ISyncPair syncPair = new SyncPair { Source = _sourceFolder, Destination = _destinationFolder }; _kontrol.Settings.SyncPairs.Add(syncPair); Assert.AreSame(syncPair, _settings.SyncPairs.Last()); }
/// <summary> /// Adds a workspace for creating a Sync Pair /// </summary> void CreateNewSyncPair() { // Create sync pair. SyncPair newSyncPair = SyncPair.CreateNewSyncPair(); // Create new sync pair model passing sync pair, repository and itself??? TODO Fix this. SyncPairViewModel workspace = new SyncPairViewModel(newSyncPair, _syncPairRepository, this); // Add sync pair view model to workspaces. Workspaces.Add(workspace); // Give workspace focus. SetActiveWorkspace(workspace); }
/// <summary> /// Places the specified syncpair into the repository. /// If the syncpair is already in the repository, an /// event is not triggered. /// </summary> /// <param name="p_syncPair"></param> public void AddSyncPair(SyncPair p_syncPair) { if (p_syncPair == null) { throw new ArgumentNullException("syncpair"); } if (!_syncPairs.Contains(p_syncPair)) { _syncPairs.Add(p_syncPair); SyncPairAdded?.Invoke(this, new SyncPairAddedEventArgs(p_syncPair)); } }
/// <summary> /// Removes the syncpair from the repository and /// if successful, raise an event. /// </summary> /// <param name="p_syncPair"></param> public void DeleteSyncPair(SyncPair p_syncPair) { if (p_syncPair == null) { throw new ArgumentNullException("syncpair"); } if (_syncPairs.Contains(p_syncPair)) { _syncPairs.Remove(p_syncPair); SyncPairRemoved?.Invoke(this, new SyncPairRemovedEventArgs(p_syncPair)); } }
private void AddTask_BTN_Click(object sender, EventArgs e) { SchedulerTask task = new SchedulerTask(); if (Event_CB.SelectedIndex >= 0 && Event_CB.SelectedIndex <= 6) { task.Event = (SchedulerEvent)Event_CB.SelectedIndex; } if (GoogleCal_CB.SelectedIndex >= 0 && OutlookCal_CB.SelectedIndex >= 0) { var pair = new SyncPair(); var googleCal = m_googleFolders.Items[GoogleCal_CB.SelectedIndex]; var outlookCal = m_outlookFolders[OutlookCal_CB.SelectedIndex]; pair.GoogleName = googleCal.Summary; pair.GoogleId = googleCal.Id; pair.OutlookName = outlookCal.Name; pair.OutlookId = outlookCal.EntryID; task.Pair = pair; } else { MessageBox.Show(this, "You need to select a calendar from both lists.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (task.Event == SchedulerEvent.CustomTime) { task.TimeSpan = int.Parse(Time_TB.Text); } if (SilentSync_CB.Checked) { task.SilentSync = true; task.Precedence = (Precedence)Precedence_CB.SelectedIndex; } task.LastRunTime = DateTime.MinValue; m_scheduler.AddTask(task); Calendars_LB.Items.Add(task.ToString()); }
int sortsync(SyncPair xb, SyncPair xc) { return(xb.ID.CompareTo(xc.ID)); }
public AutoSyncEvent() { Pair = null; EntryId = null; Action = CalendarItemAction.Nothing; }
public Task Start(SyncPair sync, Api api, bool isTestRun = false, SyncMode?mode = null) { return(Start(new SyncPair[] { sync }, api, isTestRun, mode)); }
public static ObservableCollection<SyncPair> LoadPairs() { object listLock = new object(); try { RegistryKey pairsBranch = Registry.CurrentUser.OpenSubKey(sPairsBranch, true); ObservableCollection<SyncPair> pairs = new ObservableCollection<SyncPair>(); if (pairsBranch != null) { Parallel.ForEach(pairsBranch.GetValueNames(), key => { try { SyncPair pair = new SyncPair(pairsBranch.GetValue(key, String.Empty).ToString()); lock (listLock) { pairs.Add(pair); } } catch (Exception ex) { Log.Write(ex); } }); } return pairs; } catch (Exception ex) { Log.Write(ex); return null; } }
public SyncPairAddedEventArgs(SyncPair p_newSyncPair) { NewSyncPair = p_newSyncPair; }
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { if (e.Command.Equals(ApplicationCommands.Save)) { if (!Directory.Exists(tbSourceFolder.Text)) { if (MessageBox.Show(String.Format(Properties.Resources.SourceFolderDoesNotExistFormat, tbSourceFolder.Text), Properties.Resources.FolderDoesNotExistTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) { return; } } if (!Directory.Exists(tbDestinationFolder.Text)) { if (MessageBox.Show(String.Format(Properties.Resources.DestinationFolderDoesNotExistFormat, tbDestinationFolder.Text), Properties.Resources.FolderDoesNotExistTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) { return; } } if ((!(cbBackup.SelectedItem as SyncBackupMode).ID.Equals(SyncBackup.BACKUP_NOBACKUPS)) && (!Directory.Exists(tbBackupFolder.Text))) { if (MessageBox.Show(String.Format(Properties.Resources.BackupFolderDoesNotExistFormat, tbBackupFolder.Text), Properties.Resources.FolderDoesNotExistTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No) { return; } } SyncMonitoringStrategy strategy = cbMonitoring.SelectedItem as SyncMonitoringStrategy; SyncBackupMode backupMode = cbBackup.SelectedItem as SyncBackupMode; if (this.EditedPair == null) { this.DialogResult = true; this.EditedPair = new SyncPair(tbSourceFolder.Text, tbDestinationFolder.Text, strategy.ID, backupMode.ID, tbBackupFolder.Text); } else { if ((!tbSourceFolder.Text.Equals(this.EditedPair.LocalPath)) || (!tbDestinationFolder.Text.Equals(this.EditedPair.RemotePath)) || (!strategy.Equals(this.EditedPair.Strategy)) || (!backupMode.Equals(this.EditedPair.BackupMode)) || ((String.IsNullOrEmpty(tbBackupFolder.Text)) && (!String.IsNullOrEmpty(this.EditedPair.BackupPath))) || (!tbBackupFolder.Text.Equals(this.EditedPair.BackupPath))) { // there are changes in definitions, need to recreate the pair this.EditedPair.IsEnabled = false; // stopping original pair this.EditedPair.ClearMetadata(); // remove old metadata files this.DialogResult = true; this.EditedPair = new SyncPair(tbSourceFolder.Text, tbDestinationFolder.Text, strategy.ID, backupMode.ID, tbBackupFolder.Text); } } this.EditedPair.IsEnabled = (cbEnabled.IsChecked.HasValue ? cbEnabled.IsChecked.Value : false); this.Close(); } else if (e.Command.Equals(ApplicationCommands.Close)) { this.Close(); } else if (e.Command.Equals(ApplicationCommands.Open)) { TextBox target = e.Parameter as TextBox; System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { target.Text = dialog.SelectedPath; } } }
public SyncPairRemovedEventArgs(SyncPair p_oldSyncPair) { OldSyncPair = p_oldSyncPair; }