internal BitsError(BitsJob job, IBackgroundCopyError error) { if (null == error) throw new ArgumentNullException("IBackgroundCopyError"); this.error = error; this.job = job; }
/// <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)); } }
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; }
internal BitsFile(BitsJob job, IBackgroundCopyFile file) { if (null == file) throw new ArgumentNullException("IBackgroundCopyFile"); this.file = file; this.job = job; }
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)); } }
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; }
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; }
/// <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; }
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; }
private static void ManageJobState(string button, BitsJob job) { switch (button) { case "Resume": job.Resume(); break; case "Cancel": job.Cancel(); break; } }
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); } }
/// <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); } }
/// <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); }
internal NotificationEventArgs(BitsJob job) { this.job = job; }
internal ErrorNotificationEventArgs(BitsJob job, BitsError error) : base(job) { this.error = error; }
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; }
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)); } } }; }
/// <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; }
internal BitsFiles(BitsJob job, IEnumBackgroundCopyFiles fileList) { this.fileList = fileList; this.job = job; this.Refresh(); }
internal BitsInterfaceNotificationEventArgs(BitsJob job, COMException exception, string description) : base(job) { this.description = description; this.exception = exception; }
/// <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; }
/// <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; }
internal void NotifyOnJobRemoval(BitsJob job) { if (null != this.onJobRemoved) this.onJobRemoved(this, new NotificationEventArgs(job)); }
private string getButtonText(BitsJob job) { switch (job.State) { case JobState.Suspended: return "Resume"; case JobState.Transferred: case JobState.Acknowledged: return "Done"; default: return "Cancel"; } }