public void RaiseP2PConnectingEvent(bool b) { try { if (P2PEditor == null) { return; } if (b) { RoutedEventArgs newEventArgs = new RoutedEventArgs(ConnectTab.P2PConnectingTrueEvent); RaiseEvent(newEventArgs); } else { RoutedEventArgs newEventArgs = new RoutedEventArgs(ConnectTab.P2PConnectingFalseEvent); RaiseEvent(newEventArgs); } if (P2PEditor.Presentation != null) { ((P2PEditorPresentation)P2PEditor.Presentation).UpdateConnectionState(); } } catch (Exception ex) { if (P2PEditor != null) { P2PEditor.GuiLogMessage(string.Format("Exception during RaiseP2PConnectingEvent: {0}", ex.Message), NotificationLevel.Error); } } }
private void BackgroundCreationWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { P2PEditor.GuiLogMessage("Distributed job " + newDistributedJob.Guid, NotificationLevel.Debug); DataContext = new DistributedJob(); P2PEditorPresentation.ShowActiveJobs(); P2PEditorPresentation.ActiveJobsControl.JobListBox.SelectedIndex = 0; }
public void UpdateJobList() { P2PEditor.GuiLogMessage(Properties.Resources.Requesting_new_job_list___, NotificationLevel.Debug); var updateWorker = new JobListUpdateWorker(JobListManager); updateWorker.RunWorkerCompleted += HandleRefreshedJobList; updateWorker.RunWorkerAsync(); }
private void BackgroundCreationWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { P2PEditor.GuiLogMessage(String.Format(Properties.Resources.Distributed_job__0_, newDistributedJob.Guid), NotificationLevel.Debug); DataContext = new DistributedJob(); P2PEditorPresentation.ShowActiveJobsView(); P2PEditorPresentation.JobDisplay.JobListBox.SelectedIndex = 0; }
void UpdateJobDetailsTimerElapsed(object sender, EventArgs eventArgs) { if (updateTask != null) { return; } updateTask = new JobListDetailsUpdateWorker(Jobs, JobListManager); updateTask.RunWorkerCompleted += UpdateTaskRunWorkerCompleted; updateTask.RunWorkerAsync(); P2PEditor.GuiLogMessage(Properties.Resources.Running_update_task_, NotificationLevel.Debug); }
private void JobParticipationWorkerDoWork(object sender, DoWorkEventArgs e) { try { jobListManager.CompleteDistributedJob(jobToParticipateIn); } catch (Exception ex) { p2PEditor.GuiLogMessage("Error completing job: " + ex.Message, NotificationLevel.Error); return; } p2PEditor.GuiLogMessage("Local workspace: " + jobToParticipateIn.LocalFilePath, NotificationLevel.Debug); p2PEditor.GuiLogMessage( string.Format("Workspace {0} ready to participate, dispatching with CrypTool...", jobToParticipateIn.Name), NotificationLevel.Info); jobListManager.IncreaseDownloadCount(jobToParticipateIn); dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(DispatchOpenFileEvent)); }
public void UpdateJobList() { if (!P2PManager.IsConnected) { return; } P2PEditor.GuiLogMessage("Requesting new job list...", NotificationLevel.Debug); var updateWorker = new JobListUpdateWorker(JobListManager); updateWorker.RunWorkerCompleted += HandleRefreshedJobList; updateWorker.RunWorkerAsync(); }
void HandleRefreshedJobList(object sender, RunWorkerCompletedEventArgs e) { var updateWorker = sender as JobListUpdateWorker; if (updateWorker == null) { return; } P2PEditor.GuiLogMessage("Received new job list...", NotificationLevel.Debug); Jobs = updateWorker.RefreshedJobList; UpdateJobDetailsTimerElapsed(null, null); }
private void DeleteSelectedJob() { var jobToDelete = (DistributedJob)JobListBox.SelectedItem; P2PEditor.GuiLogMessage( string.Format(Properties.Resources.Deleting_job__0____1___, jobToDelete.Name, jobToDelete.Guid), NotificationLevel.Info); var backgroundCreationWorker = new JobDeletionWorker(JobListManager, jobToDelete); backgroundCreationWorker.RunWorkerCompleted += BackgroundDeletionWorkerCompleted; backgroundCreationWorker.RunWorkerAsync(); }
void UpdateJobDetailsTimerElapsed(object sender, EventArgs eventArgs) { if (!P2PManager.IsConnected || !IsVisible) { return; } if (updateTask != null) { return; } updateTask = new JobListDetailsUpdateWorker(Jobs, JobListManager); updateTask.RunWorkerCompleted += UpdateTaskRunWorkerCompleted; updateTask.RunWorkerAsync(); P2PEditor.GuiLogMessage("Running update task.", NotificationLevel.Debug); }
private void BrowseFileButton_OnClick(object sender, RoutedEventArgs e) { using (var dialog = new OpenFileDialog()) { if (dialog.ShowDialog() == DialogResult.OK) { try { ((DistributedJob)DataContext).LocalFilePath = dialog.FileName; } catch (FileNotFoundException) { P2PEditor.GuiLogMessage("File not found.", NotificationLevel.Error); } } } }
private void DeleteSelectedJob() { var jobToDelete = (DistributedJob)JobListBox.SelectedItem; if (jobToDelete == null || jobToDelete.Owner != P2PSettings.Default.PeerName) { return; } P2PEditor.GuiLogMessage( string.Format("Deleting job {0} ({1}).", jobToDelete.Name, jobToDelete.Guid), NotificationLevel.Info); var backgroundCreationWorker = new JobDeletionWorker(JobListManager, jobToDelete); backgroundCreationWorker.RunWorkerCompleted += BackgroundDeletionWorkerCompleted; backgroundCreationWorker.RunWorkerAsync(); }
private void ParticipateInSelectedJob() { var jobToParticipateIn = (DistributedJob)JobListBox.SelectedItem; if (jobToParticipateIn == null) { return; } Participating = true; P2PEditor.GuiLogMessage( string.Format("Preparing to participate in job {0} ({1}).", jobToParticipateIn.Name, jobToParticipateIn.Guid), NotificationLevel.Info); var jobParticipationWorker = new JobParticipationWorker(P2PEditor, JobListManager, jobToParticipateIn, Dispatcher); jobParticipationWorker.RunWorkerCompleted += JobParticipationWorkerRunWorkerCompleted; jobParticipationWorker.RunWorkerAsync(); }
private void ParticipateInSelectedJob() { var jobToParticipateIn = (DistributedJob)JobListBox.SelectedItem; if (jobToParticipateIn == null) { return; } Participating = true; P2PEditor.GuiLogMessage( string.Format(Properties.Resources.Preparing_to_participate_in_job__0____1___, jobToParticipateIn.Name, jobToParticipateIn.Guid), NotificationLevel.Info); var jobParticipationWorker = new JobParticipationWorker(P2PEditor, JobListManager, jobToParticipateIn, Dispatcher); jobParticipationWorker.RunWorkerCompleted += JobParticipationWorkerRunWorkerCompleted; jobParticipationWorker.RunWorkerAsync(); }
private void ShareButton_Click(object sender, RoutedEventArgs e) { // Validate input newDistributedJob = (DistributedJob)DataContext; if (newDistributedJob.Description == null || newDistributedJob.Name == null) { P2PEditor.GuiLogMessage("Please fill all fields.", NotificationLevel.Error); return; } if (!File.Exists(newDistributedJob.LocalFilePath)) { // TODO validate that selected file contains a workspace P2PEditor.GuiLogMessage("Selected workspace does not exist.", NotificationLevel.Error); return; } var backgroundCreationWorker = new JobCreationWorker(JobListManager, newDistributedJob); backgroundCreationWorker.RunWorkerCompleted += BackgroundCreationWorkerCompleted; backgroundCreationWorker.RunWorkerAsync(); }