예제 #1
0
	    private static void QueueForUpload(FileInfo file, string folder)
	    {
		    var operation = new AsyncOperationModel
			                    {
				                    Description = "Uploading " + file.Name + " to " + folder,
			                    };

            var stream = file.OpenRead();
            var fileSize = stream.Length;

	    	var fileName = file.Name;

			if (folder != "/")
				fileName = folder + "/" + file.Name;

	        ApplicationModel.Current.Client.UploadAsync(
	            fileName,
	            new NameValueCollection(),
	            stream,
	            (_, bytesUploaded) => operation.ProgressChanged(bytesUploaded, fileSize, GetProgressText(bytesUploaded, fileSize)))
                .UpdateOperationWithOutcome(operation)
	            .ContinueOnUIThread(task => stream.Dispose());

	        ApplicationModel.Current.AsyncOperations.RegisterOperation(operation);
	    }
        /// <summary>
        /// Add the specified operation to the tracker.
        /// </summary>
        /// <param name="asyncOperation">The operation to track.</param>
        public void AddTrackedOperation(AsyncOperationModel asyncOperation)
        {
            lock (this.trackedOperationsLock)
            {
                //Check the current size of the collection and remove items if needed
                while (this.trackedOperations.Count >= OptionsModel.Instance.MaxTrackedOperations)
                {
                    this.trackedOperations.RemoveLast();
                }

                this.trackedOperations.AddFirst(asyncOperation);
            }
            Messenger.Default.Send(new Messages.AsyncOperationListChangedMessage());
        }
예제 #3
0
 public AsyncOperationDetailsViewModel(AsyncOperationModel model)
 {
     this.AsyncOperation = model;
 }
예제 #4
0
 public ShowAsyncOperationDetailWindow(AsyncOperationModel asyncOperation)
 {
     this.AsyncOperation = asyncOperation;
 }
 public void RegisterOperation(AsyncOperationModel operation)
 {
     operations.Add(operation);
     operation.PropertyChanged += HandleOperationPropertyChanged;
 }
 private void RemoveOperation(AsyncOperationModel operation)
 {
     operation.PropertyChanged -= HandleOperationPropertyChanged;
     operations.Remove(operation);
 }
        public void Do(Func<Task> taskGenerator, string description)
        {
            var operation = new AsyncOperationModel() {Description = description};

            var task = taskGenerator();
            task.UpdateOperationWithOutcome(operation);

            RegisterOperation(operation);
        }