Пример #1
0
 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);
         }
     }
 }
Пример #2
0
        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;
        }
Пример #3
0
        public void UpdateJobList()
        {
            P2PEditor.GuiLogMessage(Properties.Resources.Requesting_new_job_list___, NotificationLevel.Debug);
            var updateWorker = new JobListUpdateWorker(JobListManager);

            updateWorker.RunWorkerCompleted += HandleRefreshedJobList;
            updateWorker.RunWorkerAsync();
        }
Пример #4
0
        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;
        }
Пример #5
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);
        }
Пример #6
0
        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));
        }
Пример #7
0
        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();
        }
Пример #8
0
        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);
        }
Пример #9
0
        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();
        }
Пример #10
0
        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);
        }
Пример #11
0
 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);
             }
         }
     }
 }
Пример #12
0
        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();
        }
Пример #13
0
        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();
        }
Пример #14
0
        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();
        }
Пример #15
0
        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();
        }