internal void NotifyOnJobRemoval(BitsJob job) { if (null != this.onJobRemoved) { this.onJobRemoved(this, new NotificationEventArgs(job)); } }
public void Start() { try { BitsJob downloadJob = GetDownloadManifestJob(); } catch { // ignore } }
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 BitsError(BitsJob job, IBackgroundCopyError error) { if (null == error) { throw new ArgumentNullException("IBackgroundCopyError"); } 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; }
/// <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 = new BitsJob(this, pJob); this.jobs.Add(guid, job); if (null != this.onJobAdded) { this.onJobAdded(this, new NotificationEventArgs(job)); } return(job); }
public AutoUpdater(string productName, Uri patchUri) { _productName = productName; _downloadJob = null; _patchFile = patchUri; _bitsManager = new BitsManager(); // delete the downloaded patch file if it exists if (File.Exists(LocalPatchFile)) { try { File.Delete(LocalPatchFile); } catch { } } }
private void notificationHandler_OnJobErrorEvent(object sender, ErrorNotificationEventArgs e) { System.Threading.Thread.SpinWait(0); // route the event to the job BitsJob job = this.jobs[e.Job.JobId]; if (null != job) { job.OnJobError(sender, e); } //publish the event to other subscribers if (this.onJobErrored != null) { this.onJobErrored(sender, e); } }
private BitsJob GetDownloadManifestJob() { if (_downloadJob == null) { string jobName = string.Format( "{0} Patch Manifest", _productName ); // delete all relevant jobs foreach (BitsJob job in _bitsManager.EnumJobs(JobOwner.CurrentUser).Values) { if (job.DisplayName == jobName) { job.Cancel(); } } // if job is still null then create the job _downloadJob = _bitsManager.CreateJob( jobName, JobType.Download ); _downloadJob.NotificationFlags = NotificationFlags.JobTransferred | NotificationFlags.JobErrorOccured | NotificationFlags.JobModified; _downloadJob.ProxySettings.ProxyUsage = ProxyUsage.AutoDetect; if (File.Exists(LocalPatchFile)) { try { File.Delete(LocalPatchFile); } catch { } } _downloadJob.AddFile( _patchFile.ToString(), LocalPatchFile ); _downloadJob.Resume(); AddEventListenersToJob(_downloadJob); } return(_downloadJob); }
public void JobModification(IBackgroundCopyJob pJob, uint dwReserved) { BitsJob job; if (null != this.onJobModified) { Guid guid; pJob.GetId(out guid); if (manager.Jobs.ContainsKey(guid)) { job = manager.Jobs[guid]; } else { job = new BitsJob(manager, pJob); } this.onJobModified(this, new NotificationEventArgs(job)); } }
public void JobError(IBackgroundCopyJob pJob, IBackgroundCopyError pError) { BitsJob job; if (null != this.onJobErrored) { Guid guid; pJob.GetId(out guid); if (manager.Jobs.ContainsKey(guid)) { job = manager.Jobs[guid]; } else { job = new BitsJob(manager, pJob); } this.onJobErrored(this, new ErrorNotificationEventArgs(job, new BitsError(job, pError))); } }
public abstract void OnCreate(BitsJob jobToConfigure);
private void AddEventListenersToJob(BitsJob job) { job.OnJobErrorEvent += new EventHandler <JobErrorNotificationEventArgs>(downloadJob_OnJobErrorEvent); job.OnJobModifiedEvent += new EventHandler <JobNotificationEventArgs>(downloadJob_OnJobModifiedEvent); job.OnJobTransferredEvent += new EventHandler <JobNotificationEventArgs>(downloadJob_OnJobTransferredEvent); }
internal BitsFiles(BitsJob job, IEnumBackgroundCopyFiles fileList) { this.fileList = fileList; this.job = job; this.Refresh(); }
internal NotificationEventArgs(BitsJob job) { this.job = job; }
internal BitsInterfaceNotificationEventArgs(BitsJob job, COMException exception, string description) : base(job) { this.description = description; this.exception = exception; }
internal ErrorNotificationEventArgs(BitsJob job, BitsError error) : base(job) { this.error = error; }