Ejemplo n.º 1
0
        internal void CancelUpload(FileItemInfo item)
        {
            var cloud = Model.Clouds.SingleOrDefault(c => c.CloudInfo.Id == item.CloudId);

            if (cloud == null)
            {
                return;
            }

            cloud.Provider.CancelUpload(item.Id);
        }
Ejemplo n.º 2
0
        public void OnProviderDownloadStatisticsUpdated(CloudMount mount, StatisticUpdateReason reason, AStatisticFileInfo info)
        {
            var cloud = mount.CloudInfo;

            switch (reason)
            {
            case StatisticUpdateReason.DownloadAdded:
            {
                var item = new FileItemInfo(cloud.Id, info.Id)
                {
                    CloudIcon    = mount.Instance.CloudServiceIcon,
                    FileName     = info.FileName,
                    FullPath     = $"{mount.MountLetter}:{info.Path}",
                    ErrorMessage = info.ErrorMessage,
                    Total        = info.Total,
                    CloudName    = cloud.Name
                };
                DownloadFiles.Remove(item);
                DownloadFiles.Add(item);
            }

            break;

            case StatisticUpdateReason.DownloadFinished:
            {
                DownloadFiles.Remove(new FileItemInfo(cloud.Id, info.Id));
            }

            break;

            case StatisticUpdateReason.DownloadFailed:
            {
                var item = UploadFiles.Single(f => f.Id == info.Id && f.CloudId == cloud.Id);
                item.ErrorMessage = info.ErrorMessage;
                DownloadFiles.Remove(item);
                DownloadFailedFiles.Add(item);
                if (DownloadFailedFiles.Count > 10)
                {
                    DownloadFailedFiles.RemoveAt(DownloadFailedFiles.Count - 1);
                }
            }

            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 3
0
        public void OnProviderUploadStatisticsUpdated(CloudMount mount, StatisticUpdateReason reason, UploadStatisticInfo info)
        {
            var cloud = mount.CloudInfo;

            if (reason == StatisticUpdateReason.UploadAdded)
            {
                var newitem = new FileItemInfo(cloud.Id, info.Id)
                {
                    CloudIcon    = mount.Instance.CloudServiceIcon,
                    FileName     = info.FileName,
                    FullPath     = $"{mount.MountLetter}:{info.Path}",
                    ErrorMessage = info.ErrorMessage,
                    Total        = info.Total,
                    CloudName    = cloud.Name
                };
                UploadFiles.Remove(newitem);
                UploadFiles.Add(newitem);
                return;
            }

            var item = UploadFiles.SingleOrDefault(f => f.Id == info.Id && f.CloudId == cloud.Id);

            if (item == null)
            {
                return;
            }

            switch (reason)
            {
            case StatisticUpdateReason.UploadFinished:
                UploadFiles.Remove(new FileItemInfo(cloud.Id, info.Id));
                break;

            case StatisticUpdateReason.UploadFailed:
            {
                item.ErrorMessage = info.ErrorMessage;
                UploadFiles.Remove(item);
                UploadFiles.Add(item);
            }

            break;

            case StatisticUpdateReason.UploadAborted:
            {
                item.ErrorMessage = info.ErrorMessage;
                item.DismissOnly  = true;
                UploadFiles.Remove(item);
                UploadFiles.Add(item);
            }

            break;

            case StatisticUpdateReason.Progress:
            {
                item.Done = info.Done;
            }

            break;

            case StatisticUpdateReason.UploadState:
            {
                item.State = info.State;
            }

            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }