aboutsummaryrefslogtreecommitdiffstats
path: root/Software
diff options
context:
space:
mode:
Diffstat (limited to 'Software')
-rw-r--r--Software/Android_Studio/ColorCapture/app/build.gradle5
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java6
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java1
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java4
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java52
-rw-r--r--Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java11
-rw-r--r--Software/DB/PPC/Tango.mdfbin75497472 -> 75497472 bytes
-rw-r--r--Software/DB/PPC/Tango_log.ldfbin53673984 -> 53673984 bytes
-rw-r--r--Software/DB/TCC/TCC.mdfbin8388608 -> 8388608 bytes
-rw-r--r--Software/DB/TCC/TCC_log.ldfbin8388608 -> 8388608 bytes
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Card.cs34
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Result.cs13
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCContext.cs16
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCEntityBase.cs3
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/ExtensionMethods/DetectionColorExtensions.cs22
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj2
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.BL/Web/ColorDetectionResponse.cs1
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs70
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs10
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Tango.TCC.Service.csproj2
-rw-r--r--Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config4
-rw-r--r--Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs7
-rw-r--r--Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Events.xlsxbin53426 -> 53458 bytes
23 files changed, 239 insertions, 24 deletions
diff --git a/Software/Android_Studio/ColorCapture/app/build.gradle b/Software/Android_Studio/ColorCapture/app/build.gradle
index 1fed98dc3..500c9cfce 100644
--- a/Software/Android_Studio/ColorCapture/app/build.gradle
+++ b/Software/Android_Studio/ColorCapture/app/build.gradle
@@ -6,8 +6,8 @@ android {
applicationId "com.twine.colorcapture"
minSdkVersion 22
targetSdkVersion 27
- versionCode 9
- versionName "1.9"
+ versionCode 10
+ versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
@@ -160,6 +160,7 @@ dependencies {
implementation 'com.github.florent37:shapeofview:1.3.2'
compile 'com.google.android.gms:play-services-gcm:16.1.0'
compile 'com.google.android.gms:play-services-auth:16.0.1'
+ compile 'com.microsoft.azure.android:azure-storage-android:2.0.0@aar'
}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java
index 6e5773e1b..5ce70e284 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/capture/CaptureFragmentVM.java
@@ -151,15 +151,13 @@ public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implement
view.onFrameResult(frameBitmap, sampleBitmap, barcode);
view.stopCamera();
- ThreadingUtils.sleep(1000);
-
isDetecting.set(true);
AtomicBoolean abort = new AtomicBoolean(false);
notificationProvider.showDialog(new ProcessingDialog(), (vm) ->
{
- //TODO: Cancel and return to capture
+ //TODO: Cancel and return to capture.
abort.set(true);
});
@@ -168,7 +166,7 @@ public class CaptureFragmentVM extends ViewModelBase<ICaptureFragment> implement
try
{
- response = tccService.detect(sampleBitmap, barcode);
+ response = tccService.detect(sampleBitmap, frameBitmap, barcode);
success = true;
}
catch (Exception ex)
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java
index f2bbd6413..02e2d8d15 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/views/loading/LoadingActivityVM.java
@@ -60,7 +60,6 @@ public class LoadingActivityVM extends ViewModelBase<ILoadingActivity>
new Task.TaskBuilder().setAction(() ->
{
tccService.getDefinition();
- ThreadingUtils.sleep(1000);
}).setContinueWith(() ->
{
initialized = true;
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java
index 9cca30b73..a386e51ba 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/ITCCService.java
@@ -16,9 +16,9 @@ public interface ITCCService
{
DefinitionResponse getDefinition() throws Exception;
- DetectionResponse detect(Bitmap bitmap, String barcode) throws Exception;
+ DetectionResponse detect(Bitmap sampleBitmap, Bitmap frameBitmap, String barcode) throws Exception;
MachineRegistrationResponse register(String serialNumber) throws Exception;
- ResultByEmailResponse sendResultByEmail(ResultByEmailRequest request) throws Exception;
+ ResultByEmailResponse sendResultByEmail(ResultByEmailRequest request) throws Exception;
}
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java
index 59fa6f3b5..ea1c8e0a9 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/TCCService.java
@@ -6,7 +6,11 @@ import android.os.Build;
import android.provider.Settings;
import android.util.Base64;
+import com.microsoft.azure.storage.blob.CloudBlobClient;
+import com.microsoft.azure.storage.blob.CloudBlockBlob;
+import com.twine.colorcapture.App;
import com.twine.colorcapture.BuildConfig;
+import com.twine.colorcapture.core.Task;
import com.twine.colorcapture.logging.LogManager;
import com.twine.colorcapture.utils.BitmapUtils;
import com.twine.colorcapture.web.messages.DefinitionRequest;
@@ -21,6 +25,7 @@ import com.twine.colorcapture.web.messages.ResultByEmailRequest;
import com.twine.colorcapture.web.messages.ResultByEmailResponse;
import java.io.IOException;
+import java.net.URI;
import java.util.List;
import java.util.UUID;
@@ -72,7 +77,7 @@ public class TCCService implements ITCCService
}
@Override
- public DetectionResponse detect(Bitmap bitmap, String barcode) throws Exception
+ public DetectionResponse detect(Bitmap sampleBitmap, Bitmap frameBitmap, String barcode) throws Exception
{
LogManager.log("Sending detection request...");
@@ -80,7 +85,7 @@ public class TCCService implements ITCCService
DetectionRequest request = new DetectionRequest();
- request.setBitmapString(BitmapUtils.getBitmapBase64String(bitmap));
+ request.setBitmapString(BitmapUtils.getBitmapBase64String(sampleBitmap));
request.setBarcode(barcode);
LogManager.log("Detection Request:", request);
@@ -89,7 +94,28 @@ public class TCCService implements ITCCService
if (response.isSuccessful())
{
- LogManager.log("Detection Response:", response.body());
+ DetectionResponse r = response.body();
+
+ new Task.TaskBuilder().setAction(() ->
+ {
+
+ //Upload source bitmap.
+ try
+ {
+ LogManager.log("Uploading source image to storage blob at " + r.getSourceImageBlobAddress());
+ CloudBlockBlob blob = new CloudBlockBlob(new URI(r.getSourceImageBlobAddress()));
+ byte[] frameData = BitmapUtils.getBitmapBytes(frameBitmap);
+ blob.uploadFromByteArray(frameData, 0, frameData.length);
+ LogManager.log("Source image upload successfully");
+ }
+ catch (Exception ex)
+ {
+ LogManager.log(ex, "Error uploading source image to storage.");
+ }
+
+ }).build().start();
+
+ LogManager.log("Detection Response:", r);
return response.body();
}
else
@@ -167,12 +193,24 @@ public class TCCService implements ITCCService
LoginRequest request = new LoginRequest();
request.setAppId(BuildConfig.WEB_SERVICE_APP_ID);
- String deviceId;
+ String deviceId = null;
- LogManager.log("Getting device id from shared preferences...");
+ try
+ {
+ LogManager.log("Getting device id from phone factory...");
+ deviceId = Settings.Secure.getString(App.getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
+ }
+ catch (Exception ex)
+ {
+ LogManager.log(ex,"Error getting unique device id.");
+ }
- SharedPreferences prefs = getContext().getSharedPreferences(DEVICE_ID_PREF_NAME, MODE_PRIVATE);
- deviceId = prefs.getString("DeviceId", null);
+ if (deviceId == null)
+ {
+ LogManager.log("Getting device id from shared preferences...");
+ SharedPreferences prefs = getContext().getSharedPreferences(DEVICE_ID_PREF_NAME, MODE_PRIVATE);
+ deviceId = prefs.getString("DeviceId", null);
+ }
if (deviceId == null)
{
diff --git a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java
index 2e33a04b5..674d49b50 100644
--- a/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java
+++ b/Software/Android_Studio/ColorCapture/app/src/main/java/com/twine/colorcapture/web/messages/DetectionResponse.java
@@ -4,6 +4,7 @@ public class DetectionResponse
{
private DetectionColor rawColor;
private DetectionColor processedColor;
+ private String sourceImageBlobAddress;
public DetectionColor getRawColor()
{
@@ -24,4 +25,14 @@ public class DetectionResponse
{
this.processedColor = processedColor;
}
+
+ public String getSourceImageBlobAddress()
+ {
+ return sourceImageBlobAddress;
+ }
+
+ public void setSourceImageBlobAddress(String sourceImageBlobAddress)
+ {
+ this.sourceImageBlobAddress = sourceImageBlobAddress;
+ }
}
diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf
index dd6bb02b9..46d9c26ab 100644
--- a/Software/DB/PPC/Tango.mdf
+++ b/Software/DB/PPC/Tango.mdf
Binary files differ
diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf
index 4183eba07..cb14fa1d3 100644
--- a/Software/DB/PPC/Tango_log.ldf
+++ b/Software/DB/PPC/Tango_log.ldf
Binary files differ
diff --git a/Software/DB/TCC/TCC.mdf b/Software/DB/TCC/TCC.mdf
index e7bfd2bb8..dd9ec692d 100644
--- a/Software/DB/TCC/TCC.mdf
+++ b/Software/DB/TCC/TCC.mdf
Binary files differ
diff --git a/Software/DB/TCC/TCC_log.ldf b/Software/DB/TCC/TCC_log.ldf
index 54b73e34c..3f0c645fd 100644
--- a/Software/DB/TCC/TCC_log.ldf
+++ b/Software/DB/TCC/TCC_log.ldf
Binary files differ
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Card.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Card.cs
new file mode 100644
index 000000000..e4abca436
--- /dev/null
+++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Card.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.TCC.BL.Entities
+{
+ [Table("CARDS")]
+ public class Card : TCCEntityBase
+ {
+ [Column("CODE")]
+ public String Code { get; set; }
+
+ [Column("COLUMNS")]
+ public int Columns { get; set; }
+
+ [Column("ROWS")]
+ public int Rows { get; set; }
+
+ [Column("TARGET_INDEX")]
+ public int TargetIndex { get; set; }
+
+ [Column("VERSION")]
+ public double Version { get; set; }
+
+ [Column("BATCH")]
+ public double Batch { get; set; }
+
+ [Column("HOME_PRINTED")]
+ public bool IsHomePrinted { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Result.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Result.cs
index 8e36f7f1b..e68282c84 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Result.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/Result.cs
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace Tango.TCC.BL.Entities
{
[Table("RESULTS")]
- public class Result
+ public class Result : TCCEntityBase
{
[Column("DATE")]
public DateTime Date { get; set; }
@@ -18,6 +18,7 @@ namespace Tango.TCC.BL.Entities
public String DeviceGuid { get; set; }
[Column("CARD_GUID")]
+ [ForeignKey("Card")]
public String CardGuid { get; set; }
[Column("RAW_COLOR")]
@@ -29,12 +30,14 @@ namespace Tango.TCC.BL.Entities
[Column("PROCESS_TIME")]
public int ProcessTime { get; set; }
- [Column("RECTIFIED_IMAGE_ADDRESS")]
- public String RectifiedImageAddress { get; set; }
+ [Column("SAMPLE_IMAGE_BLOB_NAME")]
+ public String SampleImageBlobName { get; set; }
- [Column("SOURCE_IMAGE_ADDRESS")]
- public String SourceImageAddress { get; set; }
+ [Column("SOURCE_IMAGE_BLOB_NAME")]
+ public String SourceImageBlobName { get; set; }
public virtual Device Device { get; set; }
+
+ public virtual Card Card { get; set; }
}
}
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCContext.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCContext.cs
index 5770bf1d0..45719f0be 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCContext.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCContext.cs
@@ -38,5 +38,21 @@ namespace Tango.TCC.BL.Entities
{
get; set;
}
+
+ /// <summary>
+ /// Gets or sets the results.
+ /// </summary>
+ public DbSet<Result> Results
+ {
+ get; set;
+ }
+
+ /// <summary>
+ /// Gets or sets the results.
+ /// </summary>
+ public DbSet<Card> Cards
+ {
+ get; set;
+ }
}
}
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCEntityBase.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCEntityBase.cs
index f003bf6f0..18d441e94 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCEntityBase.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Entities/TCCEntityBase.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
@@ -10,9 +11,11 @@ namespace Tango.TCC.BL.Entities
public class TCCEntityBase
{
[Column("ID")]
+ [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
[Column("GUID")]
+ [Key]
public String Guid { get; set; }
public TCCEntityBase()
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/ExtensionMethods/DetectionColorExtensions.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/ExtensionMethods/DetectionColorExtensions.cs
new file mode 100644
index 000000000..0ad4ed53c
--- /dev/null
+++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/ExtensionMethods/DetectionColorExtensions.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+using Tango.Core.Helpers;
+using Tango.PMR.TCC;
+
+public static class DetectionColorExtensions
+{
+ /// <summary>
+ /// Gets an int 32 representation of this color.
+ /// </summary>
+ /// <param name="detectionColor">Color of the detection.</param>
+ /// <returns></returns>
+ public static int ToInt32(this DetectionColor detectionColor)
+ {
+ return ColorHelper.ColorToInteger(Color.FromRgb((byte)detectionColor.R, (byte)detectionColor.G, (byte)detectionColor.B));
+ }
+}
+
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj b/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj
index 0fe3fcf5d..04b008be6 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj
+++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Tango.TCC.BL.csproj
@@ -63,10 +63,12 @@
<Compile Include="CardDetector.cs" />
<Compile Include="ColorDetector.cs" />
<Compile Include="CardDetectionHistogramMethods.cs" />
+ <Compile Include="Entities\Card.cs" />
<Compile Include="Entities\Device.cs" />
<Compile Include="Entities\Result.cs" />
<Compile Include="Entities\TCCContext.cs" />
<Compile Include="Entities\TCCEntityBase.cs" />
+ <Compile Include="ExtensionMethods\DetectionColorExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Web\ColorDetectionRequest.cs" />
<Compile Include="Web\ColorDetectionResponse.cs" />
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/ColorDetectionResponse.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/ColorDetectionResponse.cs
index afc53b26c..f7ec6322c 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/ColorDetectionResponse.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/ColorDetectionResponse.cs
@@ -12,5 +12,6 @@ namespace Tango.TCC.BL.Web
{
public DetectionColor RawColor { get; set; }
public DetectionColor ProcessedColor { get; set; }
+ public String SourceImageBlobAddress { get; set; }
}
}
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs
index 2ad2b4fea..c8df9f5ae 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs
@@ -23,6 +23,9 @@ using SendGrid;
using SendGrid.Helpers.Mail;
using System.Web;
using System.Web.Hosting;
+using Tango.Web.Storage;
+using System.Threading.Tasks;
+using System.Diagnostics;
namespace Tango.TCC.Service.Controllers
{
@@ -45,11 +48,12 @@ namespace Tango.TCC.Service.Controllers
device.DeviceID = request.DeviceID;
device.DeviceModel = request.Device;
device.Email = request.Email;
- device.LastLogin = DateTime.UtcNow;
device.OSVersion = request.OSVersion;
db.Devices.Add(device);
- db.SaveChanges();
}
+
+ device.LastLogin = DateTime.UtcNow;
+ db.SaveChanges();
}
response.AccessToken = WebToken<DeviceTokenObject>.CreateNew(TCCServiceConfig.JWT_TOKEN_SECRET, new DeviceTokenObject()
@@ -109,6 +113,8 @@ namespace Tango.TCC.Service.Controllers
[HttpPost]
public ColorDetectionResponse Detect(ColorDetectionRequest request)
{
+ Stopwatch watch = Stopwatch.StartNew();
+
byte[] bitmapBytes = Convert.FromBase64String(request.BitmapString);
using (MemoryStream ms = new MemoryStream(bitmapBytes))
@@ -145,10 +151,51 @@ namespace Tango.TCC.Service.Controllers
var output = detector.Detect(input);
+ watch.Stop();
+
+ String sourceBlobName = "source_" + Guid.NewGuid().ToString() + ".png";
+ String sampleBlobName = "sample_" + Guid.NewGuid().ToString() + ".png";
+
+ var manager = new BlobStorageManager();
+ var source_container = manager.GetContainer(TCCServiceConfig.TCC_SOURCE_CONTAINER);
+ var sourceBlob = source_container.CreateEmptyBlob(sourceBlobName);
+
+ Task.Factory.StartNew(() =>
+ {
+ var sample_container = manager.GetContainer(TCCServiceConfig.TCC_SAMPLE_CONTAINER);
+ using (MemoryStream ms = new MemoryStream(bitmapBytes))
+ {
+ sample_container.UploadNewBlob(ms, sampleBlobName);
+ }
+
+ using (var db = TccDbContext.CreateTCC())
+ {
+ Card card = db.Cards.SingleOrDefault(x => x.Code == request.Barcode);
+ if (card == null)
+ {
+ card = db.Cards.First();
+ }
+
+ Result r = new Result();
+ r.Date = DateTime.UtcNow;
+ r.DeviceGuid = db.Devices.SingleOrDefault(x => x.DeviceID == RequestToken.Object.DeviceID).Guid;
+ r.CardGuid = card.Guid;
+ r.ProcessTime = (int)watch.ElapsedMilliseconds;
+ r.ProcessedColor = output.ProcessedColor.ToInt32();
+ r.RawColor = output.RawColor.ToInt32();
+ r.SourceImageBlobName = sourceBlobName;
+ r.SampleImageBlobName = sampleBlobName;
+
+ db.Results.Add(r);
+ db.SaveChanges();
+ }
+ });
+
return new ColorDetectionResponse()
{
ProcessedColor = output.ProcessedColor,
RawColor = output.RawColor,
+ SourceImageBlobAddress = sourceBlob.GenerateWriteSignature(TimeSpan.FromMinutes(10)),
};
}
}
@@ -200,6 +247,25 @@ namespace Tango.TCC.Service.Controllers
{
ResultByEmailResponse response = new ResultByEmailResponse();
+ //Opportunity to attach email to device..
+ Task.Factory.StartNew(() =>
+ {
+ using (var db = TccDbContext.CreateTCC())
+ {
+ try
+ {
+ var device = db.Devices.SingleOrDefault(x => x.DeviceID == RequestToken.Object.DeviceID);
+
+ if (device != null)
+ {
+ device.Email = request.From;
+ db.SaveChanges();
+ }
+ }
+ catch { }
+ }
+ });
+
var client = new SendGridClient(TCCServiceConfig.SEND_GRID_API_KEY);
SendGridMessage msg = new SendGridMessage();
msg.SetFrom(request.From);
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs
index 00a0f19f0..70c38f589 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs
@@ -86,5 +86,15 @@ namespace Tango.TCC.Service
/// Gets the Send Grid API key.
/// </summary>
public static String SEND_GRID_API_KEY => ConfigurationManager.AppSettings[nameof(SEND_GRID_API_KEY)].ToString();
+
+ /// <summary>
+ /// Gets the TCC source images container.
+ /// </summary>
+ public static String TCC_SOURCE_CONTAINER => ConfigurationManager.AppSettings[nameof(TCC_SOURCE_CONTAINER)].ToString();
+
+ /// <summary>
+ /// Gets the TCC sample images container.
+ /// </summary>
+ public static String TCC_SAMPLE_CONTAINER => ConfigurationManager.AppSettings[nameof(TCC_SAMPLE_CONTAINER)].ToString();
}
} \ 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 12fe5e8ec..5ba15e965 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
@@ -59,6 +59,8 @@
<HintPath>..\..\packages\JWT.5.0.0\lib\net46\JWT.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
+ <Reference Include="Microsoft.SqlServer.AzureStorageEnum, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
+ <Reference Include="Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="SendGrid, Version=9.11.0.0, Culture=neutral, PublicKeyToken=4f047e93159395ca, processorArchitecture=MSIL">
<HintPath>..\..\packages\Sendgrid.9.11.0\lib\net452\SendGrid.dll</HintPath>
</Reference>
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config b/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config
index aa50e5b14..65a537625 100644
--- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config
+++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config
@@ -20,7 +20,7 @@
<add key="DB_PASSWORD" value="Aa123456" />
<add key="DB_CATALOG" value="TCC" />
<add key="TANGO_DB_CATALOG" value="Tango_TEST" />
- <add key="STORAGE_ACCOUNT" value="DefaultEndpointsProtocol=https;AccountName=tangostorage;AccountKey=S4z/D+Yg6mwMis+bs/VpcDLA9yE1iZaYq23shQlRIi2KmM9E7JY8zdZjeAPOPdG3gONHoNDEpsgH6D4cqQ/bsA==;EndpointSuffix=core.windows.net" />
+ <add key="STORAGE_ACCOUNT" value="DefaultEndpointsProtocol=https;AccountName=twinetccstorage;AccountKey=Kls2bDJyqFpuCvTTLE4ZUvDcs+MhThN/0Vy/fUTqSXj9CSc2M1BaAxwASvcVb9OQUuHKjzttR9LzwhSGNCVGew==;EndpointSuffix=core.windows.net" />
<add key="TENANT_ID" value="2ebd63a5-bc2f-41dc-9066-4409ed5e5dd4" />
<add key="CLIENT_ID" value="ec612854-7abc-457b-808a-5d0c5ba80c57" />
<add key="APP_SECRET" value="54)019A7wv+#86l*PQcQWYKu%fd4Dv!@G=VhCiDI5rD+H4BTH" />
@@ -42,6 +42,8 @@
<add key="ENFORCE_BARCODE_DETECTION" value="True" />
<add key="APP_ID" value="Tdf793i4ughsiduf8749509237885ehgfdlkghlT" />
<add key="SEND_GRID_API_KEY" value="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" />
+ <add key="TCC_SOURCE_CONTAINER" value="source-images" />
+ <add key="TCC_SAMPLE_CONTAINER" value="sample-images" />
</appSettings>
diff --git a/Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs b/Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs
index 4acd10082..e9e361f21 100644
--- a/Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs
+++ b/Software/Visual_Studio/Tango.Web/Storage/ExtensionMethods.cs
@@ -21,6 +21,13 @@ namespace Tango.Web.Storage
return emptyBlob;
}
+ public static CloudBlockBlob UploadNewBlob(this CloudBlobContainer container, Stream stream, String name)
+ {
+ CloudBlockBlob emptyBlob = container.GetBlockBlobReference(name);
+ emptyBlob.UploadFromStream(stream);
+ return emptyBlob;
+ }
+
public static String GenerateReadSignature(this CloudBlockBlob blob, TimeSpan duration)
{
String signature = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy()
diff --git a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Events.xlsx b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Events.xlsx
index 44d8fa99a..a89765a30 100644
--- a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Events.xlsx
+++ b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Events.xlsx
Binary files differ