internal DownloadJob(Guid id, IBackgroundCopyJob bitsJob) { this.id = id; string name; bitsJob.GetDisplayName(out name); DisplayName = name; string description; bitsJob.GetDescription(out description); Description = description; BG_JOB_PRIORITY priority; bitsJob.GetPriority(out priority); Priority = (DownloadPriority)(int)priority; bitsJob.GetMinimumRetryDelay(out minimumRetryDelay); bitsJob.GetNoProgressTimeout(out noProgressTimeout); BG_JOB_STATE state; bitsJob.GetState(out state); Status = (DownloadStatus)(int)state; _BG_JOB_PROGRESS progress; bitsJob.GetProgress(out progress); BytesTotal = progress.BytesTotal; BytesTransferred = progress.BytesTransferred; bitsJob.SetNotifyInterface(this); IEnumBackgroundCopyFiles enumFiles = null; try { bitsJob.EnumFiles(out enumFiles); uint fetched; IBackgroundCopyFile file; enumFiles.Next(1, out file, out fetched); if (fetched == 1) { string remoteUrl; file.GetRemoteName(out remoteUrl); RemoteUrl = remoteUrl; string localName; file.GetLocalName(out localName); LocalFile = localName; } } finally { if (enumFiles != null) { Marshal.ReleaseComObject(enumFiles); } } }
private void RefreshFileProperties() { IEnumBackgroundCopyFiles files; _job.EnumFiles(out files); uint filesCount; files.GetCount(out filesCount); if (filesCount < 1) { return; } IBackgroundCopyFile file; uint filesFetched; files.Next(1, out file, out filesFetched); file.GetLocalName(out _fileName); _fileName = _fileName.Substring(_fileName.LastIndexOf("\\") + 1); file.GetRemoteName(out _url); }
private IEnumerable <BitsFile> GetFiles() { IEnumBackgroundCopyFiles files; _job.EnumFiles(out files); if (files != null) { uint fileCount; files.GetCount(out fileCount); for (uint i = 0; i < fileCount; i++) { IBackgroundCopyFile file; uint fetchCount; files.Next(i, out file, out fetchCount); if (fetchCount == 1) { yield return(new BitsFile(this, file)); } } } }