예제 #1
0
        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);
                }
            }
        }
예제 #2
0
 /// <summary>Moves the enumerator index to the next object in the collection.</summary>
 /// <returns></returns>
 public bool MoveNext()
 {
     try
     {
         icurrentfile = ienum.Next(1)?.FirstOrDefault();
         return(icurrentfile != null);
     }
     catch { return(false); }
 }
예제 #3
0
 public MsBitsFiles(IEnumBackgroundCopyFiles files)
     : base(() => files.Reset(),
            () =>
 {
     IBackgroundCopyFile file = null;
     uint fetched             = 0;
     files.Next(1, out file, out fetched);
     return(fetched == 1 ? file : null);
 },
            () =>
 {
     uint count;
     files.GetCount(out count);
     return((int)count);
 })
 {
 }