Наследование: IDisposable
Пример #1
0
 internal BitsError(BitsJob job, IBackgroundCopyError error)
 {
     if (null == error)
         throw new ArgumentNullException("IBackgroundCopyError");
     this.error = error;
     this.job = job;
 }
Пример #2
0
 /// <summary>Notifies the on job removal.</summary>
 /// <param name="job">The job to remove.</param>
 internal void NotifyOnJobRemoval(BitsJob job)
 {
     if (null != this.jobRemoved)
     {
         this.jobRemoved(this, new NotificationEventArgs(job));
     }
 }
Пример #3
0
 internal BitsError(BitsJob job, IBackgroundCopyError error)
 {
     if (null == error)
         throw new ArgumentNullException("error", "Parameter IBackgroundCopyError cannot be a null reference");
     this.error = error;
     this.job = job;
 }
Пример #4
0
 internal BitsFile(BitsJob job, IBackgroundCopyFile file)
 {
     if (null == file)
         throw new ArgumentNullException("IBackgroundCopyFile");
     this.file = file;
     this.job = job;
 }
Пример #5
0
 internal void PublishException(BitsJob job, COMException exception)
 {
     if (this.onInterfaceError != null)
     {
         string description = this.GetErrorDescription(exception.ErrorCode);
         this.onInterfaceError(this, new BitsInterfaceNotificationEventArgs(job, exception, description));
     }
 }
Пример #6
0
 internal BitsFile(BitsJob job, IBackgroundCopyFile file)
 {
     if (null == file)
         throw new ArgumentNullException("file", "Parameter IBackgroundCopyFile cannot be a null reference");
     this.file = file;
     this.file2 = file as IBackgroundCopyFile2;
     this.job = job;
 }
Пример #7
0
 internal BitsError(BitsJob job, IBackgroundCopyError error)
 {
     if (null == error)
     {
         throw new ArgumentNullException("error", "Parameter IBackgroundCopyError cannot be a null reference");
     }
     this.error = error;
     this.job   = job;
 }
Пример #8
0
        /// <summary>Initializes a new instance of the <see cref="BitsError" /> class.</summary>
        /// <param name="job">The job the error occurred on.</param>
        /// <param name="error">The error that occurred.</param>
        internal BitsError(BitsJob job, IBackgroundCopyError error)
        {
            if (null == error)
            {
                throw new ArgumentNullException(@"error");
            }

            this.error = error;
            this.job   = job;
        }
Пример #9
0
 internal BitsFile(BitsJob job, IBackgroundCopyFile file)
 {
     if (null == file)
     {
         throw new ArgumentNullException("file", "Parameter IBackgroundCopyFile cannot be a null reference");
     }
     this.file  = file;
     this.file2 = file as IBackgroundCopyFile2;
     this.job   = job;
 }
Пример #10
0
 private static void ManageJobState(string button, BitsJob job)
 {
     switch (button)
     {
         case "Resume":
             job.Resume();
             break;
         case "Cancel":
             job.Cancel();
             break;
     }
 }
Пример #11
0
 private void notificationHandler_OnJobErrorEvent(object sender, ErrorNotificationEventArgs e)
 {
     // route the event to the job
     if (this.jobs.ContainsKey(e.Job.JobId))
     {
         BitsJob job = this.jobs[e.Job.JobId];
         job.JobError(sender, e);
     }
     //publish the event to other subscribers
     if (this.onJobErrored != null)
     {
         this.onJobErrored(sender, e);
     }
 }
Пример #12
0
        /// <summary>Notifications the handler on job transferred event.</summary>
        /// <param name="sender">The object that called the event.</param>
        /// <param name="e">The <c>NotificationEventArgs</c> instance containing the event data.</param>
        void NotificationHandlerOnJobTransferredEvent(object sender, NotificationEventArgs e)
        {
            // route the event to the job
            if (this.Jobs.ContainsKey(e.Job.JobId))
            {
                BitsJob job = this.Jobs[e.Job.JobId];
                job.JobTransferred(sender);
            }

            // publish the event to other subscribers
            if (this.jobTransferred != null)
            {
                this.jobTransferred(sender, e);
            }
        }
Пример #13
0
        /// <summary>
        /// Creates a new transfer job.
        /// </summary>
        /// <param name="displayName">Null-terminated string that contains a display name for the job.
        /// Typically, the display name is used to identify the job in a user interface.
        /// Note that more than one job may have the same display name. Must not be NULL.
        /// The name is limited to 256 characters, not including the null terminator.</param>
        /// <param name="jobType"> Type of transfer job, such as JobType.Download. For a list of transfer types, see the JobType enumeration</param>
        /// <returns></returns>
        public BitsJob CreateJob(string displayName, JobType jobType)
        {
            Guid guid;
            IBackgroundCopyJob pJob;

            this.manager.CreateJob(displayName, (BG_JOB_TYPE)jobType, out guid, out pJob);
            BitsJob job;

            lock (this.jobs)
            {
                job = new BitsJob(this, pJob);
                this.jobs.Add(guid, job);
            }
            if (null != this.onJobAdded)
            {
                this.onJobAdded(this, new NotificationEventArgs(job));
            }
            return(job);
        }
Пример #14
0
 internal NotificationEventArgs(BitsJob job)
 {
     this.job = job;
 }
Пример #15
0
 internal NotificationEventArgs(BitsJob job)
 {
     this.job = job;
 }
Пример #16
0
 internal ErrorNotificationEventArgs(BitsJob job, BitsError error)
     : base(job)
 {
     this.error = error;
 }
Пример #17
0
 private DataGridViewRow MakeRow(BitsJob job)
 {
     var row = new DataGridViewRow();
     row.CreateCells(dataGridView1);
     row.Cells[_colIDs.FileName].Value = job.JobId; // TODO: change this to get the filename rather then the download ID
     row.Cells[_colIDs.Button].Value = getButtonText(job);
     if (row.Cells[_colIDs.Button].Value.ToString() == "Done")
         row.Cells[_colIDs.Button].ReadOnly = true;
     row.Cells[_colIDs.Progress].Value = String.Format("{0}/{1}", job.Progress.BytesTransferred, job.Progress.BytesTotal);
     row.Cells[_colIDs.Status].Value = job.State.ToString();
     row.Cells[_colIDs.ID].Value = job.JobId.ToString();
     return row;
 }
Пример #18
0
        private void RegisterEvents(BitsJob job)
        {
            job.OnJobError += (s, e) =>
                {
                    _status.NextVersion = new Version();
                    _status.BitsJobId = Guid.Empty;
                    _status.Save();
                    OnUpdateDownloadError(new UpdateErrorEventArgs(e.Error));
                    job.Cancel();
                    job.Dispose();
                };

            job.OnJobTransferred += (s, e) =>
                {
                    job.Complete();
                    job.Dispose();
                    OnUpdateDownloaded(new UpdateDownloadedEventArgs());
                };

            job.OnJobModified += (s, e) =>
                {
                    if (job != null && job.State == JobState.Transferring)
                    {
                        if (job.Progress != null)
                        {
                            OnUpdateDownloadProgressChanged(new UpdateProgressEventArgs(job.Progress.BytesTransferred, job.Progress.BytesTotal));
                        }
                    }
                };
        }
Пример #19
0
 /// <summary>
 /// Creates a new transfer job.
 /// </summary>
 /// <param name="displayName">Null-terminated string that contains a display name for the job. 
 /// Typically, the display name is used to identify the job in a user interface. 
 /// Note that more than one job may have the same display name. Must not be NULL. 
 /// The name is limited to 256 characters, not including the null terminator.</param>
 /// <param name="jobType"> Type of transfer job, such as JobType.Download. For a list of transfer types, see the JobType enumeration</param>
 /// <returns></returns>
 public BitsJob CreateJob(string displayName, JobType jobType)
 {
     Guid guid;
     IBackgroundCopyJob pJob;
     this.manager.CreateJob(displayName, (BG_JOB_TYPE)jobType, out guid, out pJob);
     BitsJob job;
     lock (this.jobs)
     {
         job = new BitsJob(this, pJob);
         this.jobs.Add(guid, job);
     }
     if (null != this.onJobAdded)
         this.onJobAdded(this, new NotificationEventArgs(job));
     return job;
 }
Пример #20
0
 internal BitsFiles(BitsJob job, IEnumBackgroundCopyFiles fileList)
 {
     this.fileList = fileList;
     this.job      = job;
     this.Refresh();
 }
Пример #21
0
 internal BitsInterfaceNotificationEventArgs(BitsJob job, COMException exception, string description)
     : base(job)
 {
     this.description = description;
     this.exception   = exception;
 }
Пример #22
0
        /// <summary>Creates a new transfer job.</summary>
        /// <param name="displayName">Null-terminated string that contains a display name for the job. Typically, the display name is used to identify the job in a user interface. Note that more than one job may have the same display name. Must not be <c>null</c>.The name is limited to 256 characters, not including the <c>null</c> terminator.</param>
        /// <param name="jobType">Type of transfer job, such as <c>JobType</c>.Download. For a list of transfer types,
        /// see the <see cref="JobType" /> enumeration.</param>
        /// <returns>The <c>BitsJob</c> created.</returns>
        public BitsJob CreateJob(string displayName, JobType jobType)
        {
            Guid guid;
            IBackgroundCopyJob copyJob;
            this.BackgroundCopyManager.CreateJob(displayName, (BGJobType)jobType, out guid, out copyJob);
            BitsJob job;
            lock (this.Jobs)
            {
                job = new BitsJob(this, copyJob);
                this.Jobs.Add(guid, job);
            }

            if (null != this.jobAdded)
            {
                this.jobAdded(this, new NotificationEventArgs(job));
            }

            return job;
        }
Пример #23
0
 /// <summary>
 /// Sets the necessary flags on a BitsJob to fire the events we want.
 /// </summary>
 /// <param name="job">The BitsJob whom to apply the flags.</param>
 private static void AddJobFlags(BitsJob job)
 {
     job.NotificationFlags = NotificationFlags.JobModified | NotificationFlags.JobTransferred |
                             NotificationFlags.JobErrorOccured;
 }
Пример #24
0
 internal ErrorNotificationEventArgs(BitsJob job, BitsError error)
     : base(job)
 {
     this.error = error;
 }
Пример #25
0
 internal BitsInterfaceNotificationEventArgs(BitsJob job, COMException exception, string description)
     : base(job)
 {
     this.description = description;
     this.exception = exception;
 }
Пример #26
0
 internal void NotifyOnJobRemoval(BitsJob job)
 {
     if (null != this.onJobRemoved)
         this.onJobRemoved(this, new NotificationEventArgs(job));
 }
Пример #27
0
 internal void PublishException(BitsJob job, COMException exception)
 {
     if (this.onInterfaceError != null)
     {
         string description = this.GetErrorDescription(exception.ErrorCode);
         this.onInterfaceError(this, new BitsInterfaceNotificationEventArgs(job, exception, description));
     }
 }
Пример #28
0
 private string getButtonText(BitsJob job)
 {
     switch (job.State)
     {
         case JobState.Suspended:
             return "Resume";
         case JobState.Transferred:
         case JobState.Acknowledged:
             return "Done";
         default:
             return "Cancel";
     }
 }