From afca405892ace809c498c010a2d4484bec5adf11 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 24 Apr 2019 14:01:40 +0300 Subject: Implemented USB adapter finalizer. Added exception logging for USB adapter disconnection error. Added Volume color space icon to PPC. Implemented KeepAlive suppression on StorageAPI. Suppressed KeepAlive when uploading job. Implemented keep alive skipping when arrived responses queue is busy. --- .../Tango.Integration/Storage/StorageManager.cs | 81 +++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) (limited to 'Software/Visual_Studio/Tango.Integration/Storage') diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs index 6f04cd0f3..623e331d0 100644 --- a/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs +++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs @@ -32,6 +32,9 @@ namespace Tango.Integration.Storage } private StorageFolder _currentFolder; + /// + /// Gets or sets the current folder. + /// public StorageFolder CurrentFolder { get { return _currentFolder; } @@ -39,12 +42,20 @@ namespace Tango.Integration.Storage } private StorageDrive _storageDrive; + /// + /// Gets or sets the storage drive. + /// public StorageDrive StorageDrive { get { return _storageDrive; } set { _storageDrive = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets a value indicating whether to disable the transporter keep alive mechanism while a file is being uploaded. + /// + public bool SuppressKeepAliveWhileFileUploads { get; set; } + #endregion #region Constructor @@ -107,6 +118,12 @@ namespace Tango.Integration.Storage #endregion + #region Public Methods + + /// + /// Gets the storage drive information. + /// + /// public async Task GetStorageDrive() { EnsureTransporter(); @@ -134,6 +151,10 @@ namespace Tango.Integration.Storage return StorageDrive; } + /// + /// Gets the root folder of the current storage driver. + /// + /// public Task GetRootFolder() { return GetFolder(new StorageFolder() @@ -142,11 +163,21 @@ namespace Tango.Integration.Storage }); } + /// + /// Gets the specified folder information. + /// + /// The folder. + /// public Task GetFolder(StorageFolder folder) { return GetFolder(folder.Path); } + /// + /// Gets the specified path folder information. + /// + /// The path. + /// public async Task GetFolder(String path) { EnsureTransporter(); @@ -201,6 +232,13 @@ namespace Tango.Integration.Storage return sf; } + /// + /// Uploads the specified file stream to the specified destination path. + /// Returns a file handler for keeping track on the upload progress. + /// + /// The path. + /// The stream. + /// public async Task UploadFile(String path, Stream stream) { FileUploadRequest request = new FileUploadRequest(); @@ -226,8 +264,15 @@ namespace Tango.Integration.Storage ThreadFactory.StartNew(() => { + bool oldKeepAlive = _transporter.UseKeepAlive; + try { + if (SuppressKeepAliveWhileFileUploads) + { + _transporter.UseKeepAlive = false; + } + while (stream.Position < stream.Length) { if (!canceled) @@ -267,23 +312,36 @@ namespace Tango.Integration.Storage { handler.RaiseFailed(ex); } + finally + { + if (SuppressKeepAliveWhileFileUploads) + { + _transporter.UseKeepAlive = oldKeepAlive; + } + } }); return handler; } + /// + /// Uploads the specified file stream to the specified destination path. + /// + /// The path. + /// The stream. + /// public async Task UploadFileSync(String path, Stream stream) { TaskCompletionSource source = new TaskCompletionSource(); var handler = await UploadFile(path, stream); - handler.Completed += (_, __) => + handler.Completed += (_, __) => { source.SetResult(true); }; - handler.Failed += (_, ex) => + handler.Failed += (_, ex) => { source.SetException(ex); }; @@ -291,6 +349,13 @@ namespace Tango.Integration.Storage await source.Task; } + /// + /// Downloads the specified storage file to the specified stream. + /// Returns a file handler for keeping track on the download progress. + /// + /// The file. + /// The stream. + /// public async Task DownloadFile(StorageFile file, Stream stream) { FileDownloadRequest request = new FileDownloadRequest(); @@ -359,6 +424,11 @@ namespace Tango.Integration.Storage return handler; } + /// + /// Deletes the specified storage item. + /// + /// The item. + /// public async Task DeleteItem(StorageItem item) { await _transporter.SendRequest(new DeleteRequest() @@ -368,6 +438,11 @@ namespace Tango.Integration.Storage }); } + /// + /// Creates a new folder on the specified destination path. + /// + /// The path. + /// public async Task CreateFolder(String path) { await _transporter.SendRequest(new CreateRequest() @@ -376,5 +451,7 @@ namespace Tango.Integration.Storage Attribute = FileAttribute.Directory, }); } + + #endregion } } -- cgit v1.3.1