예제 #1
0
 internal void NotifyOnJobRemoval(BitsJob job)
 {
     if (null != this.onJobRemoved)
     {
         this.onJobRemoved(this, new NotificationEventArgs(job));
     }
 }
예제 #2
0
 public void Start()
 {
     try {
         BitsJob downloadJob = GetDownloadManifestJob();
     } catch {
         // ignore
     }
 }
예제 #3
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));
     }
 }
예제 #4
0
 internal BitsError(BitsJob job, IBackgroundCopyError error)
 {
     if (null == error)
     {
         throw new ArgumentNullException("IBackgroundCopyError");
     }
     this.error = error;
     this.job   = job;
 }
예제 #5
0
 internal BitsFile(BitsJob job, IBackgroundCopyFile file)
 {
     if (null == file)
     {
         throw new ArgumentNullException("IBackgroundCopyFile");
     }
     this.file = file;
     this.job  = job;
 }
예제 #6
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 = new BitsJob(this, pJob);

            this.jobs.Add(guid, job);
            if (null != this.onJobAdded)
            {
                this.onJobAdded(this, new NotificationEventArgs(job));
            }
            return(job);
        }
예제 #7
0
        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 {
                }
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
        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));
            }
        }
예제 #11
0
        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)));
            }
        }
예제 #12
0
 public abstract void OnCreate(BitsJob jobToConfigure);
예제 #13
0
 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);
 }
예제 #14
0
 internal BitsFiles(BitsJob job, IEnumBackgroundCopyFiles fileList)
 {
     this.fileList = fileList;
     this.job      = job;
     this.Refresh();
 }
예제 #15
0
 internal NotificationEventArgs(BitsJob job)
 {
     this.job = job;
 }
예제 #16
0
 internal BitsInterfaceNotificationEventArgs(BitsJob job, COMException exception, string description)
     : base(job)
 {
     this.description = description;
     this.exception   = exception;
 }
예제 #17
0
 internal ErrorNotificationEventArgs(BitsJob job, BitsError error)
     : base(job)
 {
     this.error = error;
 }