public P2PEditorPresentation(P2PEditor p2PEditor, JobListManager jobListManager)
        {
            P2PEditor             = p2PEditor;
            JobListManager        = jobListManager;
            P2PEditorPresentation = this;


            InitializeComponent();

            UpdateDisplay();

            this.Connect.P2PEditorPresentation           = this;
            this.GetNewCertificate.P2PEditorPresentation = this;
            this.JobCreation.P2PEditorPresentation       = this;
            this.JobDisplay.P2PEditorPresentation        = this;

            if (this.IsP2PConnecting || !this.IsP2PConnected)
            {
                ShowConnectView();
            }
            else
            {
                ShowActiveJobsView();
            }
        }
Exemple #2
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);
         }
     }
 }
        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;
        }
Exemple #4
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;
        }
        public void UpdateJobList()
        {
            P2PEditor.GuiLogMessage(Properties.Resources.Requesting_new_job_list___, NotificationLevel.Debug);
            var updateWorker = new JobListUpdateWorker(JobListManager);

            updateWorker.RunWorkerCompleted += HandleRefreshedJobList;
            updateWorker.RunWorkerAsync();
        }
Exemple #6
0
        public JobParticipationWorker(P2PEditor p2PEditor, JobListManager jobListManager, DistributedJob jobToParticipateIn, Dispatcher dispatcher)
        {
            this.p2PEditor          = p2PEditor;
            this.jobListManager     = jobListManager;
            this.jobToParticipateIn = jobToParticipateIn;
            this.dispatcher         = dispatcher;

            DoWork += JobParticipationWorkerDoWork;
        }
        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);
        }
Exemple #8
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();
        }
Exemple #9
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);
        }
        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();
        }
Exemple #11
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);
        }
Exemple #12
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);
             }
         }
     }
 }
Exemple #13
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();
        }
Exemple #14
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();
        }
        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();
        }
Exemple #16
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();
        }
Exemple #17
0
 public JobListManager(P2PEditor p2PEditor)
 {
     this.p2PEditor = p2PEditor;
 }