aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-06-05 14:16:41 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-06-05 14:16:41 +0300
commit44c2abcbc60357ed282cae20c8476de2b50cbe25 (patch)
tree9fe500d087c67d8cba81233d95b509a7e457c561
parent79151cd5f05a8c66ae0e570602a350cd1f78d598 (diff)
downloadTango-44c2abcbc60357ed282cae20c8476de2b50cbe25.tar.gz
Tango-44c2abcbc60357ed282cae20c8476de2b50cbe25.zip
Implemented image get methods on TCC service.
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ResultsController.cs17
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Storage/TCCStorageManager.cs27
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj1
3 files changed, 43 insertions, 2 deletions
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ResultsController.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ResultsController.cs
index ce92bb269..ab431f4e0 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ResultsController.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ResultsController.cs
@@ -11,6 +11,8 @@ using Tango.TCC.Service.Security;
using Tango.Web.Controllers;
using System.Data.Entity;
using Tango.TCC.BL.Web;
+using Tango.TCC.Service.Storage;
+using System.Web.Http.Results;
namespace Tango.TCC.Service.Controllers
{
@@ -45,14 +47,15 @@ namespace Tango.TCC.Service.Controllers
DeviceID = DEVICES2.DeviceID
}).ToList(); ;//.Where(x => (request.Email == null || x.Email == request.Email) && (request.DeviceModel == null || x.DeviceModel.Contains(request.DeviceModel))).ToList();
+
foreach (var item in dbResults)
{
ResultDTO dto = new ResultDTO();
dto.Date = item.Result.Date;
dto.RawColor = item.Result.RawColor;
dto.ProcessedColor = item.Result.ProcessedColor;
- dto.SampleImageBlobName = item.Result.SampleImageBlobName;
- dto.SourceImageBlobName = item.Result.SourceImageBlobName;
+ dto.SampleImageBlobName = TCCStorageManager.CreateSampleImageURL(item.Result.SampleImageBlobName);
+ dto.SourceImageBlobName = TCCStorageManager.CreateSourceImageURL(item.Result.SourceImageBlobName);
dto.ProcessTime = item.Result.ProcessTime;
dto.CardGuid = item.Result.CardGuid;
dto.CardCode = item.CardCode;
@@ -66,6 +69,16 @@ namespace Tango.TCC.Service.Controllers
return results;
}
+ [HttpGet]
+ public RedirectResult GetResultSampleImage(String blobName)
+ {
+ return Redirect(TCCStorageManager.CreateSampleImageURL(blobName));
+ }
+ [HttpGet]
+ public RedirectResult GetResultSourceImage(String blobName)
+ {
+ return Redirect(TCCStorageManager.CreateSourceImageURL(blobName));
+ }
}
}
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Storage/TCCStorageManager.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/Storage/TCCStorageManager.cs
new file mode 100644
index 000000000..a2f70328a
--- /dev/null
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Storage/TCCStorageManager.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Tango.Web.Storage;
+
+namespace Tango.TCC.Service.Storage
+{
+ public class TCCStorageManager
+ {
+ public static String CreateSampleImageURL(String blobName)
+ {
+ var manager = new BlobStorageManager();
+ var source_container = manager.GetContainer(TCCServiceConfig.TCC_SAMPLE_CONTAINER);
+ var blob = source_container.GetBlockBlobReference(blobName);
+ return blob.GenerateReadSignature(TimeSpan.FromMinutes(5));
+ }
+
+ public static String CreateSourceImageURL(String blobName)
+ {
+ var manager = new BlobStorageManager();
+ var source_container = manager.GetContainer(TCCServiceConfig.TCC_SOURCE_CONTAINER);
+ var blob = source_container.GetBlockBlobReference(blobName);
+ return blob.GenerateReadSignature(TimeSpan.FromMinutes(5));
+ }
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj b/Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj
index 9cd9e5968..8244464db 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj
@@ -214,6 +214,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Security\DeviceTokenObject.cs" />
<Compile Include="Security\TokenObject.cs" />
+ <Compile Include="Storage\TCCStorageManager.cs" />
<Compile Include="TCCServiceConfig.cs" />
</ItemGroup>
<ItemGroup>