示例#1
0
 public CopyFileWorker(OneDriveSyncItem item, string dispatchFolder, string destinationFolder) : base()
 {
     this.SyncItem          = item;
     this.DestinationFolder = destinationFolder;
     this.DispathFolder     = dispatchFolder;
     Status += " copy";
 }
示例#2
0
 public DownloadFileWorker(OneDriveSyncItem item, string destination, ICloudStreamProvider provider) : base()
 {
     this.SyncItem        = item;
     this.downloadLimiter = provider.GetDownloadSrteamLimiter();
     this.Destination     = destination;
     this.streamProvider  = provider;
     Status += " download";
 }
示例#3
0
        private Worker MakeNextWorker(OneDriveSyncItem syncItem = null)
        {
            while (!itemsForSync.IsEmpty || syncItem != null)
            {
                if (Suspended)
                {
                    return(null);
                }
                while (syncItem == null && !itemsForSync.IsEmpty)
                {
                    var success = itemsForSync.TryDequeue(out syncItem);
                    if (success == false)
                    {
                        Thread.Sleep(20);
                    }
                }
                string   destinationPath = Path.Combine(PathToDispathFolder, syncItem.Name);
                FileInfo info            = new FileInfo(destinationPath);
                if (syncItem.CurrentState == SyncState.New && info.Exists && (info.Length == syncItem.Size))
                {
                    logger.Warn("File already exist. Name = {0}", info.FullName);
                    syncItem.CurrentState = SyncState.Loaded;
                }

                Worker nextWorker = null;
                switch (syncItem.CurrentState)
                {
                case SyncState.New:
                    nextWorker          = new DownloadFileWorker(syncItem, destinationPath, Owner);
                    nextWorker.TaskName = String.Format("{0} ({1})", syncItem.Name, syncItem.FormattedSize);
                    logger.Trace("New download worker ready for file {0} save to {1}", syncItem.Name, destinationPath);
                    break;

                case SyncState.Loaded:
                    nextWorker            = new CopyFileWorker(syncItem, PathToDispathFolder, PathToSync);
                    nextWorker.TaskName   = String.Format("Copy {0} ({1})", syncItem.Name, syncItem.FormattedSize);
                    nextWorker.Completed += (Worker w, ProgressableEventArgs args) =>
                    {
                    };
                    logger.Trace("New copy worker ready for file {0} save to {1}", syncItem.Name, PathToSync);
                    break;

                case SyncState.MovedToStorage:
                    nextWorker          = new DeleteOneDriveFileWorker(syncItem, Owner);
                    nextWorker.TaskName = String.Format("Request for delete {0} ({1})", syncItem.Name, syncItem.FormattedSize);
                    logger.Trace("New delete worker ready for file {0}", syncItem.Name);
                    break;

                default:
                    break;
                }
                nextWorker.Completed += OnWorkerCompleted;
                return(nextWorker);
            }
            return(null);
        }
 public DeleteOneDriveFileWorker(OneDriveSyncItem syncItem, IDeleteSyncItemProvider connectionProvider)
 {
     SyncItem = syncItem;
     this.connectionProvider = connectionProvider;
 }
示例#5
0
 public ForceCanceledException(OneDriveSyncItem syncItem) : base(string.Format("Item {0} force canceled", syncItem.Name))
 {
     SyncItem = syncItem;
 }