コード例 #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
ファイル: BitsError.cs プロジェクト: Sphere10/Framework
 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;
 }