diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-04-11 11:25:01 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-04-11 11:25:01 +0300 |
| commit | 50672cf57739bac3c0ddefcd40563d0fbed3db80 (patch) | |
| tree | c6d5bbedc8210c6004ee49db416457ccd488d983 /Software/Visual_Studio | |
| parent | 64aeeb1d2784569e4ebf7c72c660458cf4432eee (diff) | |
| parent | d5553e30f41ba83cf4a5d9366114a64136fcb504 (diff) | |
| download | Tango-50672cf57739bac3c0ddefcd40563d0fbed3db80.tar.gz Tango-50672cf57739bac3c0ddefcd40563d0fbed3db80.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio')
21 files changed, 198 insertions, 50 deletions
diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk Binary files differindex ff9db3779..34c82a731 100644 --- a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk +++ b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs index 9f54837cb..0b74f2b3f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Models/CaptureConfig.cs @@ -103,6 +103,13 @@ namespace Tango.MachineStudio.ColorCapture.Models set { _enableDoubleChecking = value; RaisePropertyChangedAuto(); } } + private bool _enforceBarcodeDetection; + public bool EnforceBarcodeDetection + { + get { return _enforceBarcodeDetection; } + set { _enforceBarcodeDetection = value; RaisePropertyChangedAuto(); } + } + public CaptureConfig() { diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs index 21bb0baf0..5ea5747d5 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/ViewModels/MainViewVM.cs @@ -140,6 +140,14 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels set { _similarity = value; RaisePropertyChangedAuto(); } } + private String _barcode; + public String Barcode + { + get { return _barcode; } + set { _barcode = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand ImportBenchmarksCommand { get; set; } public RelayCommand ExportBenchmarksCommand { get; set; } @@ -373,6 +381,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels DetectedSource = null; CaptureDeltaEController.Clear(); Similarity = 0; + Barcode = String.Empty; } private void OnSelectedVideoDeviceChanged(CaptureDevice previousDevice, CaptureDevice newDevice) @@ -407,6 +416,7 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels SimilarityTolerance = Config.SimilarityTolerance, HistogramMethod = Config.HistogramComparison, EnableDoubleChecking = Config.EnableDoubleChecking, + EnforceBarcodeDetection = Config.EnforceBarcodeDetection, }); if (result.Similarity > 0) @@ -442,6 +452,8 @@ namespace Tango.MachineStudio.ColorCapture.ViewModels CapturedColor = Color.FromArgb(255, (byte)result.ColorDetectionOutput.RawColor.R, (byte)result.ColorDetectionOutput.RawColor.G, (byte)result.ColorDetectionOutput.RawColor.B); ProcessedColor = Color.FromArgb(255, (byte)result.ColorDetectionOutput.ProcessedColor.R, (byte)result.ColorDetectionOutput.ProcessedColor.G, (byte)result.ColorDetectionOutput.ProcessedColor.B); + Barcode = result.Barcode; + //calculate delta E. Lab measureLab = new Lab(MeasureL, MeasureA, MeasureB); DeltaE = measureLab.Compare(new Rgb(ProcessedColor.R, ProcessedColor.G, ProcessedColor.B), GetDeltaEComparison()); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml index d6f4890d7..ba8e3f281 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ColorCapture/Views/MainView.xaml @@ -276,6 +276,11 @@ </Border> </DockPanel> </DockPanel> + + <TextBlock Margin="0 0 0 -20" VerticalAlignment="Bottom"> + <Run>Barcode:</Run> + <Run Text="{Binding Barcode}" FontWeight="SemiBold" FontStyle="Italic"></Run> + </TextBlock> </Grid> <DockPanel VerticalAlignment="Bottom" Grid.ColumnSpan="2" TextElement.FontSize="16"> @@ -582,6 +587,7 @@ <RowDefinition Height="40"/> <RowDefinition Height="40"/> <RowDefinition Height="40"/> + <RowDefinition Height="40"/> </Grid.RowDefinitions> <TextBlock VerticalAlignment="Bottom" Height="27">Columns</TextBlock> @@ -637,6 +643,9 @@ <TextBlock Grid.Row="12" Grid.Column="0" VerticalAlignment="Bottom" Height="27">Double Checking</TextBlock> <ToggleButton IsChecked="{Binding Config.EnableDoubleChecking}" Grid.Row="12" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom"></ToggleButton> + + <TextBlock Grid.Row="13" Grid.Column="0" VerticalAlignment="Bottom" Height="27">Enforce Barcode Detection</TextBlock> + <ToggleButton IsChecked="{Binding Config.EnforceBarcodeDetection}" Grid.Row="13" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom"></ToggleButton> </Grid> </Border> </TabItem> diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs index e63e0bdd1..b2b2bc197 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetectionConfig.cs @@ -19,6 +19,7 @@ namespace Tango.TCC.BL public double SimilarityTolerance { get; set; } public CardDetectionHistogramMethods HistogramMethod { get; set; } public bool EnableDoubleChecking { get; set; } + public bool EnforceBarcodeDetection { get; set; } public CardDetectionConfig() { diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs index 50bcceeba..221659868 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/CardDetector.cs @@ -66,6 +66,7 @@ namespace Tango.TCC.BL SimilarityTolerance = config.SimilarityTolerance, HistogramMethod = (int)config.HistogramMethod, EnableDoubleChecking = config.EnableDoubleChecking, + EnforceBarcodeDetection = config.EnforceBarcodeDetection, }); detectionResult.Similarity = result.Similarity; diff --git a/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/DefinitionResponse.cs b/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/DefinitionResponse.cs index d6161e738..5ab6cfd6d 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/DefinitionResponse.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.BL/Web/DefinitionResponse.cs @@ -17,6 +17,7 @@ namespace Tango.TCC.BL.Web public double SimilarityTolerance { get; set; } public CardDetectionHistogramMethods HistogramMethod { get; set; } public bool EnableDoubleChecking { get; set; } + public bool EnforceBarcodeDetection { get; set; } public DefinitionResponse() { @@ -27,6 +28,7 @@ namespace Tango.TCC.BL.Web SimilarityTolerance = 50; HistogramMethod = CardDetectionHistogramMethods.Chi_Square; EnableDoubleChecking = true; + EnforceBarcodeDetection = true; } } } diff --git a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp Binary files differindex 174d2d549..25b523e58 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp +++ b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetection.cpp diff --git a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h index 86d44ca34..90f3239be 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h +++ b/Software/Visual_Studio/TCC/Tango.TCC.CardDetector/CardDetectionConfig.h @@ -17,6 +17,7 @@ namespace Tango property double SimilarityTolerance; property int HistogramMethod; property bool EnableDoubleChecking; + property bool EnforceBarcodeDetection; }; } } diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/App_Start/WebApiConfig.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/App_Start/WebApiConfig.cs index a7e994f9c..f3519205b 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.Service/App_Start/WebApiConfig.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/App_Start/WebApiConfig.cs @@ -16,7 +16,7 @@ namespace Tango.TCC.Service config.Routes.MapHttpRoute( name: "DefaultApi", - routeTemplate: "api/{controller}/{id}", + routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } ); } 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 b3a4d4808..eb4600788 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Controllers/ColorDetectionController.cs @@ -1,28 +1,52 @@ using Google.Protobuf; using System; using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; using System.Linq; using System.Net; using System.Net.Http; +using System.Security.Authentication; using System.Web.Http; using Tango.PMR.TCC; using Tango.TCC.BL; using Tango.TCC.BL.Web; +using Tango.TCC.Service.Filters; +using Tango.TCC.Service.Security; using Tango.Web.Controllers; +using Tango.Web.Security; namespace Tango.TCC.Service.Controllers { - public class ColorDetectionController : TangoController + public class ColorDetectionController : TangoController<TokenObject> { [HttpPost] public LoginResponse Login(LoginRequest request) { - return new LoginResponse(); + LoginResponse response = new LoginResponse(); + + if (request.AppID == TCCServiceConfig.APP_ID) + { + response.AccessToken = WebToken<TokenObject>.CreateNew(TCCServiceConfig.JWT_TOKEN_SECRET, new TokenObject() + { + DeviceID = request.DeviceID, + }).AccessToken; + } + else + { + throw new AuthenticationException("Invalid application ID provided."); + } + + return response; } + [JwtTokenFilter] [HttpPost] public DefinitionResponse GetDefinition(DefinitionRequest request) { + String s = RequestToken.Object.DeviceID; + return new DefinitionResponse() { TemplateString = TCCServiceConfig.TEMPLATE_STRING, @@ -33,6 +57,7 @@ namespace Tango.TCC.Service.Controllers HistogramMethod = TCCServiceConfig.HISTOGRAM_METHOD, SimilarityTolerance = TCCServiceConfig.SIMILARITY_TOLERANCE, EnableDoubleChecking = TCCServiceConfig.ENABLE_DOUBLE_CHECKING, + EnforceBarcodeDetection = TCCServiceConfig.ENFORCE_BARCODE_DETECTION, }; } @@ -41,6 +66,26 @@ namespace Tango.TCC.Service.Controllers { byte[] bitmapBytes = Convert.FromBase64String(request.BitmapString); + using (MemoryStream ms = new MemoryStream(bitmapBytes)) + { + using (Bitmap bmp = new Bitmap(ms)) + { + if (bmp.PixelFormat != System.Drawing.Imaging.PixelFormat.Format24bppRgb) + { + using (Bitmap bmp24 = bmp.ConvertTo24Bit()) + { + using (MemoryStream outms = new MemoryStream()) + { + bmp24.Save(outms, ImageFormat.Bmp); + bitmapBytes = outms.ToArray(); + + String base64 = Convert.ToBase64String(bitmapBytes); + } + } + } + } + } + using (ColorDetector detector = new ColorDetector()) { var output = detector.Detect(new DetectionInput() diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Filters/JwtTokenFilter.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/Filters/JwtTokenFilter.cs new file mode 100644 index 000000000..d68a11ac3 --- /dev/null +++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Filters/JwtTokenFilter.cs @@ -0,0 +1,61 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Security.Authentication; +using System.Web; +using System.Web.Http; +using System.Web.Http.Controllers; +using System.Web.Http.Filters; +using Tango.Transport.Web; +using Tango.Web.Security; + +namespace Tango.TCC.Service.Filters +{ + public class JwtTokenFilter : ActionFilterAttribute + { + public bool AllowExpired { get; private set; } + + public JwtTokenFilter() + { + + } + + public JwtTokenFilter(bool allowExpired) + { + AllowExpired = allowExpired; + } + + public override void OnActionExecuting(HttpActionContext actionContext) + { + var authorizationHeader = actionContext.Request.Headers.Authorization; + + if (authorizationHeader != null) + { + try + { + WebToken.Validate(TCCServiceConfig.JWT_TOKEN_SECRET, authorizationHeader.Parameter != null ? authorizationHeader.Parameter : authorizationHeader.ToString()); + } + catch (JWT.TokenExpiredException) + { + if (!AllowExpired) + { + throw new TokenExpiredException("Token expired."); + } + } + catch (JWT.SignatureVerificationException) + { + throw new InvalidTokenException("Invalid token."); + } + } + else + { + throw new AuthenticationException("No token specified."); + } + + base.OnActionExecuting(actionContext); + } + } +}
\ No newline at end of file diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Security/TokenObject.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/Security/TokenObject.cs new file mode 100644 index 000000000..545688451 --- /dev/null +++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Security/TokenObject.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Tango.TCC.Service.Security +{ + public class TokenObject + { + public String DeviceID { get; set; } + } +}
\ No newline at end of file diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs b/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs index 8bedaefe9..14e9ef8cc 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs +++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/TCCServiceConfig.cs @@ -68,6 +68,11 @@ namespace Tango.TCC.Service public static bool ENABLE_DOUBLE_CHECKING => bool.Parse(ConfigurationManager.AppSettings[nameof(ENABLE_DOUBLE_CHECKING)].ToString()); /// <summary> + /// Gets a value indicating whether the card will be detected only when barcode detection is successful. + /// </summary> + public static bool ENFORCE_BARCODE_DETECTION => bool.Parse(ConfigurationManager.AppSettings[nameof(ENFORCE_BARCODE_DETECTION)].ToString()); + + /// <summary> /// Gets the mobile application ID. /// </summary> public static String APP_ID => ConfigurationManager.AppSettings[nameof(APP_ID)].ToString(); 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 78e13e6d4..f5ec44630 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 @@ -55,6 +55,9 @@ <Reference Include="Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <HintPath>..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll</HintPath> </Reference> + <Reference Include="JWT, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>..\..\packages\JWT.5.0.0\lib\net46\JWT.dll</HintPath> + </Reference> <Reference Include="Microsoft.CSharp" /> <Reference Include="System" /> <Reference Include="System.Data" /> @@ -194,10 +197,12 @@ <Compile Include="Controllers\ColorDetectionController.cs" /> <Compile Include="Controllers\HomeController.cs" /> <Compile Include="Controllers\ValuesController.cs" /> + <Compile Include="Filters\JwtTokenFilter.cs" /> <Compile Include="Global.asax.cs"> <DependentUpon>Global.asax</DependentUpon> </Compile> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Security\TokenObject.cs" /> <Compile Include="TCCServiceConfig.cs" /> </ItemGroup> <ItemGroup> @@ -261,6 +266,10 @@ <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> <Name>Tango.PMR</Name> </ProjectReference> + <ProjectReference Include="..\..\Tango.Transport\Tango.Transport.csproj"> + <Project>{74e700b0-1156-4126-be40-ee450d3c3026}</Project> + <Name>Tango.Transport</Name> + </ProjectReference> <ProjectReference Include="..\..\Tango.Web\Tango.Web.csproj"> <Project>{5001990f-977b-48ff-b217-0236a5022ad8}</Project> <Name>Tango.Web</Name> @@ -309,8 +318,7 @@ <Error Condition="!Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" /> </Target> <PropertyGroup> - <PostBuildEvent> - </PostBuildEvent> + <PostBuildEvent>del $(TargetDir)Tango.TCC.CardDetector.dll</PostBuildEvent> </PropertyGroup> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config b/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config index d2433dc9b..9ef7bc67d 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config +++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/Web.config @@ -29,7 +29,7 @@ <add key="CARD_COLUMNS" value="10" /> <add key="CARD_ROWS" value="11" /> - <add key="CARD_TARGET_INDEX" value="99" /> + <add key="CARD_TARGET_INDEX" value="89" /> <add key="TEMPLATE_STRING" value="PUT TEMPLATE STRING HERE!" /> <add key="SAMPLE_WIDTH" value="300" /> <add key="SAMPLE_HEIGHT" value="330" /> @@ -38,12 +38,15 @@ <add key="SIMILARITY_TOLERANCE" value="50" /> <add key="HISTOGRAM_METHOD" value="Chi_Square" /> <add key="ENABLE_DOUBLE_CHECKING" value="True" /> + <add key="ENFORCE_BARCODE_DETECTION" value="True" /> <add key="APP_ID" value="Tdf793i4ughsiduf8749509237885ehgfdlkghlT" /> </appSettings> <system.web> - <compilation debug="true" targetFramework="4.6.1" /> + <compilation debug="true" targetFramework="4.6.1"> + + </compilation> <httpRuntime targetFramework="4.6.1" maxRequestLength="4096" /> <httpModules> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> diff --git a/Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config b/Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config index 115c40d26..39d7af46a 100644 --- a/Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config +++ b/Software/Visual_Studio/TCC/Tango.TCC.Service/packages.config @@ -5,6 +5,7 @@ <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> <package id="Google.Protobuf" version="3.4.1" targetFramework="net461" /> <package id="jQuery" version="3.3.1" targetFramework="net461" /> + <package id="JWT" version="5.0.0" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights" version="2.5.1" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights.Agent.Intercept" version="2.4.0" targetFramework="net461" /> <package id="Microsoft.ApplicationInsights.DependencyCollector" version="2.5.1" targetFramework="net461" /> diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/BitmapExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/BitmapExtensions.cs index 3cca605e9..34e3d9ea2 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/BitmapExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/BitmapExtensions.cs @@ -20,5 +20,13 @@ public static class BitmapExtensions var encParams = new EncoderParameters() { Param = new[] { new EncoderParameter(Encoder.Quality, quality) } }; bitmap.Save(filePath, encoder, encParams); } + + public static Bitmap ConvertTo24Bit(this Bitmap bitmap) + { + var bmp = new Bitmap(bitmap.Width, bitmap.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); + using (var gr = Graphics.FromImage(bmp)) + gr.DrawImage(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); + return bmp; + } } diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineService/MachineStudio_Controller_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineService/MachineStudio_Controller_TST.cs index d4585388a..e30cd6d77 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService/MachineStudio_Controller_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineService/MachineStudio_Controller_TST.cs @@ -22,14 +22,14 @@ namespace Tango.UnitTesting.MachineService IWebTransportClient client = new WebTransportClient(); - var res1 = client.PostJson<LoginRequest, LoginResponse>($"{address}/api/MachineStudio/Login", new LoginRequest() - { - Email = "TestUser@twine-s.com", - Password = "ASJH_asdjkl1234", - Version = "1.0.0.0" - }).Result; + //var res1 = client.PostJson<LoginRequest, LoginResponse>($"{address}/api/MachineStudio/Login", new LoginRequest() + //{ + // Email = "TestUser@twine-s.com", + // Password = "ASJH_asdjkl1234", + // Version = "1.0.0.0" + //}).Result; - String token = res1.AccessToken; + String token = "1234"; client.AuthenticationToken = token; var res2 = client.PostJson<CheckForUpdatesRequest, CheckForUpdatesResponse>($"{address}/api/MachineStudio/CheckForUpdates", new CheckForUpdatesRequest() diff --git a/Software/Visual_Studio/Tango.Web/Controllers/TangoController.cs b/Software/Visual_Studio/Tango.Web/Controllers/TangoController.cs index 32cc3f83c..5d96a7249 100644 --- a/Software/Visual_Studio/Tango.Web/Controllers/TangoController.cs +++ b/Software/Visual_Studio/Tango.Web/Controllers/TangoController.cs @@ -109,11 +109,11 @@ namespace Tango.Web.Controllers var authorizationHeader = request.Headers.Authorization; - if (authorizationHeader != null && authorizationHeader.Parameter != null) + if (authorizationHeader != null) { try { - RequestToken = WebToken<T>.FromToken(authorizationHeader.Parameter); + RequestToken = WebToken<T>.FromToken(authorizationHeader.Parameter != null ? authorizationHeader.Parameter : authorizationHeader.ToString()); } catch (Exception ex) { diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 399ca9aa7..2dc6e80b2 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -124,8 +124,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Updater EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.ILMerge.UI", "Utilities\Tango.ILMerge.UI\Tango.ILMerge.UI.csproj", "{9A477128-25A1-4B27-AAAB-7421F8ED2B9D}" EndProject -Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Tango.Stubs.Installer", "Utilities\Tango.Stubs.Installer\Tango.Stubs.Installer.vdproj", "{6B399B28-83AE-4AD2-8438-25799B65086F}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Embroidery", "Embroidery", "{34839F9A-61D3-4ED3-B3F7-7DA3424CB0B6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libEmbroidery", "Embroidery\project-files\visualstudio\libEmbroideryVS2008.vcxproj", "{BD30C7BD-9230-4ED7-B581-11F14041909D}" @@ -2272,31 +2270,6 @@ Global {9A477128-25A1-4B27-AAAB-7421F8ED2B9D}.Release|x64.Build.0 = Release|Any CPU {9A477128-25A1-4B27-AAAB-7421F8ED2B9D}.Release|x86.ActiveCfg = Release|Any CPU {9A477128-25A1-4B27-AAAB-7421F8ED2B9D}.Release|x86.Build.0 = Release|Any CPU - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|Any CPU.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|Any CPU.Build.0 = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|ARM.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|ARM.Build.0 = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|ARM64.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|ARM64.Build.0 = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|x64.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|x64.Build.0 = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|x86.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.AppVeyor|x86.Build.0 = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.Debug|Any CPU.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.Debug|ARM.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.Debug|ARM64.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.Debug|x64.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.Debug|x86.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.DefaultBuild|Any CPU.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.DefaultBuild|ARM.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.DefaultBuild|ARM64.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.DefaultBuild|x64.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.DefaultBuild|x86.ActiveCfg = Debug - {6B399B28-83AE-4AD2-8438-25799B65086F}.Release|Any CPU.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.Release|ARM.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.Release|ARM64.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.Release|x64.ActiveCfg = Release - {6B399B28-83AE-4AD2-8438-25799B65086F}.Release|x86.ActiveCfg = Release {BD30C7BD-9230-4ED7-B581-11F14041909D}.AppVeyor|Any CPU.ActiveCfg = Release|Win32 {BD30C7BD-9230-4ED7-B581-11F14041909D}.AppVeyor|Any CPU.Build.0 = Release|Win32 {BD30C7BD-9230-4ED7-B581-11F14041909D}.AppVeyor|ARM.ActiveCfg = Release|Win32 @@ -5302,7 +5275,6 @@ Global {FC337A7F-1214-41D8-9992-78092A3B961E} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} {844787CE-F409-4F18-BCCC-F3809ECB86F3} = {57DF2A95-5DDD-4830-A4AF-B484B59C7C2B} {9A477128-25A1-4B27-AAAB-7421F8ED2B9D} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} - {6B399B28-83AE-4AD2-8438-25799B65086F} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {BD30C7BD-9230-4ED7-B581-11F14041909D} = {34839F9A-61D3-4ED3-B3F7-7DA3424CB0B6} {0565AEEC-ED1B-4F0E-A277-D33F852207BC} = {34839F9A-61D3-4ED3-B3F7-7DA3424CB0B6} {69DB0564-268C-4B3C-B5D6-A3CDC7D14EAE} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} @@ -5366,12 +5338,12 @@ Global {B0EFE7A0-7039-4DC4-8B39-465E521299F6} = {3D750293-C243-48F6-9112-A6B3FF650C0D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal |
