internal void DeactivateJob(ListedJob item)
 {
     Job.JobStatus status = item.Job.Status;
     if (status == Job.JobStatus.Active ||
         status == Job.JobStatus.WaitingForRemoteAcceptance)
     {
         item.Stopped    = true;
         item.Job.Status = Job.JobStatus.StoppedByLocal; // It was me to stop this job
         //item.Completed = true;
         //item.Error = false;
         //item.Message = "In cancellazione...";
     }
     else if (status == Job.JobStatus.Completed ||
              status == Job.JobStatus.ConnectionError ||
              status == Job.JobStatus.NotAcceptedByRemote ||
              status == Job.JobStatus.StoppedByLocal ||
              status == Job.JobStatus.StoppedByRemote)
     {
         // We need to remove the ListedJob from the list
         if (item.Job is SendingJob)
         {
             sendingJobs.Remove(item);
         }
         else
         {
             receivingJobs.Remove(item);
         }
     }
 }
Ejemplo n.º 2
0
        private void OnStatusUpdated(Job.JobStatus status)
        {
            switch (status)
            {
            case Job.JobStatus.Aborted:
                StatusPanelForeground = RedBrush;
                StatusPanelIcon       = CloseIcon;
                StatusPanelIconSize   = 12;
                StatusPanelLabel      = new ObservableCollection <Inline> {
                    new Run("Cancelled"),
                };
                Retryable = true;
                OnFinished();
                break;

            case Job.JobStatus.Completed:
                StatusPanelForeground = GreenBrush;
                StatusPanelIcon       = CheckIcon;
                StatusPanelIconSize   = 16;
                StatusPanelLabel      = new ObservableCollection <Inline> {
                    new Run("Successfully downloaded "),
                    new Run(Job.TransferredBytes.Bytes().ToString("#.0") + " ")
                    {
                        FontWeight = FontWeights.Bold
                    },
                    new Run(Job.FinishedAt.Humanize(false)),
                    new Run(" at "),
                    new Run(Job.TransferBytesPerSecond.Bytes().ToString("#.0") + "/s")
                    {
                        FontWeight = FontWeights.Bold
                    }
                };
                Retryable = false;
                OnFinished();
                break;

            case Job.JobStatus.Failed:
                StatusPanelForeground = RedBrush;
                StatusPanelIcon       = WarningIcon;
                StatusPanelIconSize   = 18;
                StatusPanelLabel      = new ObservableCollection <Inline> {
                    new Run("Error: "),
                    new Run(Job.ErrorMessage)
                };
                Retryable = true;
                OnFinished();
                break;

            case Job.JobStatus.Queued:
                StatusPanelForeground = GreyBrush;
                StatusPanelIcon       = ClockIcon;
                StatusPanelIconSize   = 16;
                StatusPanelLabel      = new ObservableCollection <Inline> {
                    new Run("Transfer queued")
                };
                Retryable    = false;
                Transferring = false;
                break;

            case Job.JobStatus.Transferring:
                StatusPanelForeground = Brushes.Transparent;
                Transferring          = true;
                Retryable             = false;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }