aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-11-29 13:15:09 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-11-29 13:15:09 +0200
commit9e6d1ddfb42c4e8357bd75c2b1d6f84df1ea1966 (patch)
tree131c98a3b19bfca2ce81259f8921c409fda7bee7 /Software/Visual_Studio/Tango.Integration
parentac3c227bb5d12339fee6fb4c243f3a5f67217915 (diff)
downloadTango-9e6d1ddfb42c4e8357bd75c2b1d6f84df1ea1966.tar.gz
Tango-9e6d1ddfb42c4e8357bd75c2b1d6f84df1ea1966.zip
Working on machine studio storage module.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Storage/StorageDrive.cs4
-rw-r--r--Software/Visual_Studio/Tango.Integration/Storage/StorageFile.cs2
-rw-r--r--Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs23
-rw-r--r--Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandlerStatus.cs17
-rw-r--r--Software/Visual_Studio/Tango.Integration/Storage/StorageItem.cs15
-rw-r--r--Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs23
-rw-r--r--Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj1
7 files changed, 67 insertions, 18 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageDrive.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageDrive.cs
index c313ac0cb..28f390bc9 100644
--- a/Software/Visual_Studio/Tango.Integration/Storage/StorageDrive.cs
+++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageDrive.cs
@@ -9,8 +9,8 @@ namespace Tango.Integration.Storage
{
public class StorageDrive : ExtendedObject
{
- public int Capacity { get; set; }
- public int FreeSpace { get; set; }
+ public long Capacity { get; set; }
+ public long FreeSpace { get; set; }
public String Root { get; set; }
}
}
diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageFile.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageFile.cs
index 069b1743d..06c966649 100644
--- a/Software/Visual_Studio/Tango.Integration/Storage/StorageFile.cs
+++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageFile.cs
@@ -9,6 +9,6 @@ namespace Tango.Integration.Storage
{
public class StorageFile : StorageItem
{
- public int Length { get; set; }
+ public long Length { get; set; }
}
}
diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs
index 72a4b2c87..6a9c5cae4 100644
--- a/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs
+++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandler.cs
@@ -21,9 +21,19 @@ namespace Tango.Integration.Storage
}
- internal StorageFileHandler(Action cancelAction)
+ internal StorageFileHandler(StorageFile storageFile, Action cancelAction)
{
_cancelAction = cancelAction;
+ StorageFile = storageFile;
+ }
+
+ public StorageFile StorageFile { get; set; }
+
+ private StorageFileHandlerStatus _status;
+ public StorageFileHandlerStatus Status
+ {
+ get { return _status; }
+ private set { _status = value; RaisePropertyChangedAuto(); }
}
private long _current;
@@ -38,6 +48,11 @@ namespace Tango.Integration.Storage
Current = _current,
Total = _total,
});
+
+ if (Status != StorageFileHandlerStatus.Active)
+ {
+ Status = StorageFileHandlerStatus.Active;
+ }
}
}
@@ -53,21 +68,25 @@ namespace Tango.Integration.Storage
return Task.Factory.StartNew(() =>
{
_cancelAction.Invoke();
- });
+ Status = StorageFileHandlerStatus.Canceled;
+ });
}
internal void RaiseCompleted()
{
+ Status = StorageFileHandlerStatus.Completed;
Completed?.Invoke(this, new EventArgs());
}
internal void RaiseCanceled()
{
+ Status = StorageFileHandlerStatus.Canceled;
Canceled?.Invoke(this, new EventArgs());
}
internal void RaiseFailed(Exception ex)
{
+ Status = StorageFileHandlerStatus.Failed;
Failed?.Invoke(this, ex);
}
}
diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandlerStatus.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandlerStatus.cs
new file mode 100644
index 000000000..7fb30dd16
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageFileHandlerStatus.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Integration.Storage
+{
+ public enum StorageFileHandlerStatus
+ {
+ Pending,
+ Active,
+ Canceled,
+ Failed,
+ Completed,
+ }
+}
diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageItem.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageItem.cs
index e8a725277..3881dd528 100644
--- a/Software/Visual_Studio/Tango.Integration/Storage/StorageItem.cs
+++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageItem.cs
@@ -26,8 +26,21 @@ namespace Tango.Integration.Storage
{
get
{
+ String root = System.IO.Path.GetPathRoot(Path);
var parent = Directory.GetParent(Path);
- return parent.FullName.Replace(parent.Root.FullName, "/").Replace("\\", "/");
+
+ if (root == "\\")
+ {
+ return parent.FullName.Replace(parent.Root.FullName, "/").Replace("\\", "/");
+ }
+ else if (parent != null)
+ {
+ return parent.FullName;
+ }
+ else
+ {
+ return null;
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs b/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs
index bb880f1bd..d640ba0c6 100644
--- a/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs
+++ b/Software/Visual_Studio/Tango.Integration/Storage/StorageManager.cs
@@ -213,10 +213,14 @@ namespace Tango.Integration.Storage
long max_length = fileUploadResponse.Message.MaxChunkLength;
bool canceled = false;
- StorageFileHandler handler = new StorageFileHandler(() =>
+ StorageFileHandler handler = new StorageFileHandler(new StorageFile()
{
- canceled = true;
- });
+ Path = path,
+ Length = (int)stream.Length,
+ }, () =>
+ {
+ canceled = true;
+ });
handler.Total = stream.Length;
@@ -284,10 +288,10 @@ namespace Tango.Integration.Storage
long max_length = fileDownloadResponse.Message.MaxChunkLength;
bool canceled = false;
- StorageFileHandler handler = new StorageFileHandler(() =>
- {
- canceled = true;
- });
+ StorageFileHandler handler = new StorageFileHandler(file, () =>
+ {
+ canceled = true;
+ });
handler.Total = file.Length;
@@ -320,11 +324,6 @@ namespace Tango.Integration.Storage
}
else
{
- var a = _transporter.SendRequest<FileChunkDownloadRequest, FileChunkDownloadResponse>(new FileChunkDownloadRequest()
- {
- IsCanceled = true,
- }).Result;
-
handler.RaiseCanceled();
return;
}
diff --git a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj
index d96191191..8498219bc 100644
--- a/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj
+++ b/Software/Visual_Studio/Tango.Integration/Tango.Integration.csproj
@@ -106,6 +106,7 @@
<Compile Include="Storage\StorageFile.cs" />
<Compile Include="Storage\StorageFileHandler.cs" />
<Compile Include="Storage\StorageFileHandlerProgressEventArgs.cs" />
+ <Compile Include="Storage\StorageFileHandlerStatus.cs" />
<Compile Include="Storage\StorageFolder.cs" />
<Compile Include="Storage\StorageItem.cs" />
<Compile Include="Storage\StorageManager.cs" />