aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-02-12 16:44:17 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-02-12 16:44:17 +0200
commit18477c8dc7e7971f2cfb08d0e11ca483944f79f2 (patch)
tree22a7c735184c5df6a84d2182d3ff9b2222cc53b5 /Software/Visual_Studio/Web
parent48ceaabee98371376e606361f396a61c479ce031 (diff)
downloadTango-18477c8dc7e7971f2cfb08d0e11ca483944f79f2.tar.gz
Tango-18477c8dc7e7971f2cfb08d0e11ca483944f79f2.zip
Added project Tango.MachineService.Gateway
Diffstat (limited to 'Software/Visual_Studio/Web')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/BundleConfig.cs14
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/FilterConfig.cs13
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/RouteConfig.cs23
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/WebApiConfig.cs24
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/ApplicationInsights.config106
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/HomeController.cs16
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Global.asax1
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Global.asax.cs48
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Properties/AssemblyInfo.cs35
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Tango.MachineService.Gateway.csproj243
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/TangoController.cs126
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Views/Web.config43
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Views/_ViewStart.cshtml3
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.Debug.config30
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.Release.config31
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.config85
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/WebToken.cs192
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService.Gateway/packages.config30
18 files changed, 1063 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/BundleConfig.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/BundleConfig.cs
new file mode 100644
index 000000000..68d6937d9
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/BundleConfig.cs
@@ -0,0 +1,14 @@
+using System.Web;
+using System.Web.Optimization;
+
+namespace Tango.MachineService.Gateway
+{
+ public class BundleConfig
+ {
+ // For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
+ public static void RegisterBundles(BundleCollection bundles)
+ {
+
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/FilterConfig.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/FilterConfig.cs
new file mode 100644
index 000000000..a915cef9e
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/FilterConfig.cs
@@ -0,0 +1,13 @@
+using System.Web;
+using System.Web.Mvc;
+
+namespace Tango.MachineService.Gateway
+{
+ public class FilterConfig
+ {
+ public static void RegisterGlobalFilters(GlobalFilterCollection filters)
+ {
+ filters.Add(new HandleErrorAttribute());
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/RouteConfig.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/RouteConfig.cs
new file mode 100644
index 000000000..1adc877c0
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/RouteConfig.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using System.Web.Routing;
+
+namespace Tango.MachineService.Gateway
+{
+ public class RouteConfig
+ {
+ public static void RegisterRoutes(RouteCollection routes)
+ {
+ routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
+
+ routes.MapRoute(
+ name: "Default",
+ url: "{controller}/{action}/{id}",
+ defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
+ );
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/WebApiConfig.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/WebApiConfig.cs
new file mode 100644
index 000000000..ca49db782
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/App_Start/WebApiConfig.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web.Http;
+
+namespace Tango.MachineService.Gateway
+{
+ public static class WebApiConfig
+ {
+ public static void Register(HttpConfiguration config)
+ {
+ // Web API configuration and services
+
+ // Web API routes
+ config.MapHttpAttributeRoutes();
+
+ config.Routes.MapHttpRoute(
+ name: "DefaultApi",
+ routeTemplate: "api/{controller}/{id}",
+ defaults: new { id = RouteParameter.Optional }
+ );
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/ApplicationInsights.config b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/ApplicationInsights.config
new file mode 100644
index 000000000..3fced9161
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/ApplicationInsights.config
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
+ <TelemetryInitializers>
+ <Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector"/>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureWebAppRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.WebTestTelemetryInitializer, Microsoft.AI.Web"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.SyntheticUserAgentTelemetryInitializer, Microsoft.AI.Web">
+ <!-- Extended list of bots:
+ search|spider|crawl|Bot|Monitor|BrowserMob|BingPreview|PagePeeker|WebThumb|URL2PNG|ZooShot|GomezA|Google SketchUp|Read Later|KTXN|KHTE|Keynote|Pingdom|AlwaysOn|zao|borg|oegp|silk|Xenu|zeal|NING|htdig|lycos|slurp|teoma|voila|yahoo|Sogou|CiBra|Nutch|Java|JNLP|Daumoa|Genieo|ichiro|larbin|pompos|Scrapy|snappy|speedy|vortex|favicon|indexer|Riddler|scooter|scraper|scrubby|WhatWeb|WinHTTP|voyager|archiver|Icarus6j|mogimogi|Netvibes|altavista|charlotte|findlinks|Retreiver|TLSProber|WordPress|wsr-agent|http client|Python-urllib|AppEngine-Google|semanticdiscovery|facebookexternalhit|web/snippet|Google-HTTP-Java-Client-->
+ <Filters>search|spider|crawl|Bot|Monitor|AlwaysOn</Filters>
+ </Add>
+ <Add Type="Microsoft.ApplicationInsights.Web.ClientIpHeaderTelemetryInitializer, Microsoft.AI.Web"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.OperationNameTelemetryInitializer, Microsoft.AI.Web"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer, Microsoft.AI.Web"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.UserTelemetryInitializer, Microsoft.AI.Web"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.AuthenticatedUserIdTelemetryInitializer, Microsoft.AI.Web"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.AccountIdTelemetryInitializer, Microsoft.AI.Web"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.SessionTelemetryInitializer, Microsoft.AI.Web"/>
+ </TelemetryInitializers>
+ <TelemetryModules>
+ <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
+ <ExcludeComponentCorrelationHttpHeadersOnDomains>
+ <!--
+ Requests to the following hostnames will not be modified by adding correlation headers.
+ Add entries here to exclude additional hostnames.
+ NOTE: this configuration will be lost upon NuGet upgrade.
+ -->
+ <Add>core.windows.net</Add>
+ <Add>core.chinacloudapi.cn</Add>
+ <Add>core.cloudapi.de</Add>
+ <Add>core.usgovcloudapi.net</Add>
+ <Add>localhost</Add>
+ <Add>127.0.0.1</Add>
+ </ExcludeComponentCorrelationHttpHeadersOnDomains>
+ <IncludeDiagnosticSourceActivities>
+ <Add>Microsoft.Azure.EventHubs</Add>
+ <Add>Microsoft.Azure.ServiceBus</Add>
+ </IncludeDiagnosticSourceActivities>
+ </Add>
+ <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
+ <!--
+ Use the following syntax here to collect additional performance counters:
+
+ <Counters>
+ <Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
+ ...
+ </Counters>
+
+ PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName
+
+ NOTE: performance counters configuration will be lost upon NuGet upgrade.
+
+ The following placeholders are supported as InstanceName:
+ ??APP_WIN32_PROC?? - instance name of the application process for Win32 counters.
+ ??APP_W3SVC_PROC?? - instance name of the application IIS worker process for IIS/ASP.NET counters.
+ ??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
+ -->
+ </Add>
+ <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer"/>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer">
+ <!--</Add>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer">-->
+ </Add>
+ <Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web">
+ <Handlers>
+ <!--
+ Add entries here to filter out additional handlers:
+
+ NOTE: handler configuration will be lost upon NuGet upgrade.
+ -->
+ <Add>Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler</Add>
+ <Add>System.Web.StaticFileHandler</Add>
+ <Add>System.Web.Handlers.AssemblyResourceLoader</Add>
+ <Add>System.Web.Optimization.BundleHandler</Add>
+ <Add>System.Web.Script.Services.ScriptHandlerFactory</Add>
+ <Add>System.Web.Handlers.TraceHandler</Add>
+ <Add>System.Web.Services.Discovery.DiscoveryRequestHandler</Add>
+ <Add>System.Web.HttpDebugHandler</Add>
+ </Handlers>
+ </Add>
+ <Add Type="Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web"/>
+ <Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web"/>
+ </TelemetryModules>
+ <TelemetryProcessors>
+ <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
+ <Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
+ <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
+ <ExcludedTypes>Event</ExcludedTypes>
+ </Add>
+ <Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
+ <MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
+ <IncludedTypes>Event</IncludedTypes>
+ </Add>
+ </TelemetryProcessors>
+ <TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
+<!--
+ Learn more about Application Insights configuration with ApplicationInsights.config here:
+ http://go.microsoft.com/fwlink/?LinkID=513840
+
+ Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
+ --></ApplicationInsights> \ No newline at end of file
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/HomeController.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/HomeController.cs
new file mode 100644
index 000000000..f510f360c
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Controllers/HomeController.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+
+namespace Tango.MachineService.Gateway.Controllers
+{
+ public class HomeController : Controller
+ {
+ public String Index()
+ {
+ return "Twine Gateway Service";
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Global.asax b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Global.asax
new file mode 100644
index 000000000..badf913e2
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Global.asax
@@ -0,0 +1 @@
+<%@ Application Codebehind="Global.asax.cs" Inherits="Tango.MachineService.Gateway.WebApiApplication" Language="C#" %>
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Global.asax.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Global.asax.cs
new file mode 100644
index 000000000..20df6c0bb
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Global.asax.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Http;
+using System.Web.Http.Filters;
+using System.Web.Mvc;
+using System.Web.Optimization;
+using System.Web.Routing;
+using Tango.Logging;
+
+namespace Tango.MachineService.Gateway
+{
+ public class WebApiApplication : System.Web.HttpApplication
+ {
+ protected void Application_Start()
+ {
+ LogManager.Default.Categories.Add(LogCategory.Debug);
+ //LogManager.Default.RegisterLogger(new AzureCloudLogger());
+ GlobalConfiguration.Configuration.Filters.Add(new LogExceptionFilterAttribute());
+
+ LogManager.Default.Log("Application Started!");
+
+ //AreaRegistration.RegisterAllAreas();
+ GlobalConfiguration.Configure(WebApiConfig.Register);
+ FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
+ RouteConfig.RegisterRoutes(RouteTable.Routes);
+ BundleConfig.RegisterBundles(BundleTable.Bundles);
+ }
+
+ public class LogExceptionFilterAttribute : ExceptionFilterAttribute
+ {
+ public override void OnException(HttpActionExecutedContext context)
+ {
+ LogManager.Default.Log(context.Exception);
+ }
+ }
+
+ protected void Application_Error(object sender, EventArgs e)
+ {
+ Exception exception = Server.GetLastError();
+ if (exception != null)
+ {
+ LogManager.Default.Log(exception, "Global Exception!");
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..4824c819c
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tango.MachineService.Gateway")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tango.MachineService.Gateway")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("94dd0e87-1130-44cf-8b3d-befbcb5aa4a3")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Tango.MachineService.Gateway.csproj b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Tango.MachineService.Gateway.csproj
new file mode 100644
index 000000000..70977fbc7
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Tango.MachineService.Gateway.csproj
@@ -0,0 +1,243 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>
+ </ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{D28CED90-9660-4282-9F9D-1F248AFA3F6D}</ProjectGuid>
+ <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tango.MachineService.Gateway</RootNamespace>
+ <AssemblyName>Tango.MachineService.Gateway</AssemblyName>
+ <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+ <MvcBuildViews>false</MvcBuildViews>
+ <UseIISExpress>true</UseIISExpress>
+ <Use64BitIISExpress />
+ <IISExpressSSLPort />
+ <IISExpressAnonymousAuthentication />
+ <IISExpressWindowsAuthentication />
+ <IISExpressUseClassicPipelineMode />
+ <UseGlobalApplicationHostFile />
+ <NuGetPackageImportStamp>
+ </NuGetPackageImportStamp>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="JWT, Version=6.0.0.0, Culture=neutral, PublicKeyToken=6f98bca0f40f2ecf, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\JWT.6.1.0\lib\net46\JWT.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Web.Entity" />
+ <Reference Include="System.Web.ApplicationServices" />
+ <Reference Include="System.ComponentModel.DataAnnotations" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Abstractions" />
+ <Reference Include="System.Web.Routing" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Configuration" />
+ <Reference Include="System.Runtime.Serialization" />
+ <Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
+ </Reference>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http">
+ </Reference>
+ <Reference Include="System.Net.Http.Formatting, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.4\lib\net45\System.Net.Http.Formatting.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Net.Http.WebRequest">
+ </Reference>
+ <Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.4\lib\net45\System.Web.Helpers.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Http, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.4\lib\net45\System.Web.Http.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Http.WebHost, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.4\lib\net45\System.Web.Http.WebHost.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\..\packages\Microsoft.AspNet.Mvc.5.2.4\lib\net45\System.Web.Mvc.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Optimization">
+ <HintPath>..\..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\..\packages\Microsoft.AspNet.Razor.3.2.4\lib\net45\System.Web.Razor.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.4\lib\net45\System.Web.WebPages.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.4\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <Private>True</Private>
+ <HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.2.4\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
+ </Reference>
+ <Reference Include="WebGrease">
+ <Private>True</Private>
+ <HintPath>..\..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
+ </Reference>
+ <Reference Include="Antlr3.Runtime">
+ <Private>True</Private>
+ <HintPath>..\..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="System.Diagnostics.DiagnosticSource">
+ <HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.4.1\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.AspNet.TelemetryCorrelation">
+ <HintPath>..\..\packages\Microsoft.AspNet.TelemetryCorrelation.1.0.0\lib\net45\Microsoft.AspNet.TelemetryCorrelation.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.ApplicationInsights">
+ <HintPath>..\..\packages\Microsoft.ApplicationInsights.2.5.1\lib\net46\Microsoft.ApplicationInsights.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.AI.Agent.Intercept">
+ <HintPath>..\..\packages\Microsoft.ApplicationInsights.Agent.Intercept.2.4.0\lib\net45\Microsoft.AI.Agent.Intercept.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.AI.DependencyCollector">
+ <HintPath>..\..\packages\Microsoft.ApplicationInsights.DependencyCollector.2.5.1\lib\net45\Microsoft.AI.DependencyCollector.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.AI.PerfCounterCollector">
+ <HintPath>..\..\packages\Microsoft.ApplicationInsights.PerfCounterCollector.2.5.1\lib\net45\Microsoft.AI.PerfCounterCollector.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.AI.ServerTelemetryChannel">
+ <HintPath>..\..\packages\Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.2.5.1\lib\net45\Microsoft.AI.ServerTelemetryChannel.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.AI.WindowsServer">
+ <HintPath>..\..\packages\Microsoft.ApplicationInsights.WindowsServer.2.5.1\lib\net45\Microsoft.AI.WindowsServer.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.AI.Web">
+ <HintPath>..\..\packages\Microsoft.ApplicationInsights.Web.2.5.1\lib\net45\Microsoft.AI.Web.dll</HintPath>
+ </Reference>
+ <Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
+ <HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="App_Start\BundleConfig.cs" />
+ <Compile Include="App_Start\FilterConfig.cs" />
+ <Compile Include="App_Start\RouteConfig.cs" />
+ <Compile Include="App_Start\WebApiConfig.cs" />
+ <Compile Include="Controllers\HomeController.cs" />
+ <Compile Include="Global.asax.cs">
+ <DependentUpon>Global.asax</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TangoController.cs" />
+ <Compile Include="WebToken.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Global.asax" />
+ <Content Include="ApplicationInsights.config">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Web.config" />
+ <Content Include="Web.Debug.config">
+ <DependentUpon>Web.config</DependentUpon>
+ </Content>
+ <Content Include="Web.Release.config">
+ <DependentUpon>Web.config</DependentUpon>
+ </Content>
+ <Content Include="Views\Web.config" />
+ <Content Include="Views\_ViewStart.cshtml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="App_Data\" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj">
+ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
+ <Name>Tango.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\Tango.Logging\Tango.Logging.csproj">
+ <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project>
+ <Name>Tango.Logging</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\Tango.Transport\Tango.Transport.csproj">
+ <Project>{74E700B0-1156-4126-BE40-EE450D3C3026}</Project>
+ <Name>Tango.Transport</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <PropertyGroup>
+ <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
+ <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+ </PropertyGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
+ <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
+ <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
+ </Target>
+ <ProjectExtensions>
+ <VisualStudio>
+ <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
+ <WebProjectProperties>
+ <UseIIS>True</UseIIS>
+ <AutoAssignPort>True</AutoAssignPort>
+ <DevelopmentServerPort>53221</DevelopmentServerPort>
+ <DevelopmentServerVPath>/</DevelopmentServerVPath>
+ <IISUrl>http://localhost:2222/</IISUrl>
+ <NTLMAuthentication>False</NTLMAuthentication>
+ <UseCustomServer>False</UseCustomServer>
+ <CustomServerUrl>
+ </CustomServerUrl>
+ <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
+ </WebProjectProperties>
+ </FlavorProperties>
+ </VisualStudio>
+ </ProjectExtensions>
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+ <PropertyGroup>
+ <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+ </PropertyGroup>
+ <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>
+ <!-- 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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target> -->
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/TangoController.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/TangoController.cs
new file mode 100644
index 000000000..3fd3d469e
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/TangoController.cs
@@ -0,0 +1,126 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Security.Authentication;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Web;
+using System.Web.Http;
+using System.Web.Http.Controllers;
+using Tango.Logging;
+using Tango.Transport.Web;
+using Tango.Web.Security;
+
+namespace Tango.Web.Controllers
+{
+ public class TangoController : ApiController
+ {
+ protected LogManager LogManager { get; private set; }
+
+ public TangoController()
+ {
+ LogManager = LogManager.Default;
+ }
+
+ public override async Task<HttpResponseMessage> ExecuteAsync(HttpControllerContext context, CancellationToken cancellationToken)
+ {
+ string controllerName = String.Empty;
+ string actionName = String.Empty;
+
+ try
+ {
+ var routeData = HttpContext.Current.Request.RequestContext.RouteData;
+ actionName = routeData.Values["action"].ToString();
+ controllerName = routeData.Values["controller"].ToString();
+ }
+ catch { }
+
+ try
+ {
+ String request = String.Empty;
+
+ try
+ {
+ request = context.Request.Content.ReadAsStringAsync().Result;
+ }
+ catch { }
+
+ LogManager.Log($"Request Received on {controllerName + "/" + actionName}: \n{request}");
+
+ OnRequestArrived(context.Request);
+
+ var result = await base.ExecuteAsync(context, cancellationToken);
+ return result;
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, $"An error occurred while processing the request message on {controllerName + "/" + actionName}.");
+
+ HttpStatusCode code = HttpStatusCode.InternalServerError;
+
+ if (ex is ArgumentException || ex is InvalidDataException)
+ {
+ code = HttpStatusCode.BadRequest;
+ }
+ else if (ex is AuthenticationException || ex is TokenExpiredException)
+ {
+ code = HttpStatusCode.Unauthorized;
+ }
+
+ var httpException = new HttpResponseException(Request.CreateErrorResponse(code, ex.FlattenMessage(), ex));
+
+#if DEBUG
+ throw httpException;
+#else
+ //Remove Stack trace
+ var expandedException = httpException.Response.Content as System.Net.Http.ObjectContent<System.Web.Http.HttpError>;
+
+ if (expandedException != null)
+ {
+ var expandedExceptionValues = expandedException.Value as HttpError;
+
+ if (expandedExceptionValues != null)
+ {
+ expandedExceptionValues["StackTrace"] = "StackTrace not provided.";
+ }
+ }
+#endif
+
+
+ throw httpException;
+ }
+ }
+
+ protected virtual void OnRequestArrived(HttpRequestMessage request)
+ {
+ //Do nothing.
+ }
+ }
+
+ public class TangoController<T> : TangoController where T : class
+ {
+ public WebToken<T> RequestToken { get; set; }
+
+ protected override void OnRequestArrived(HttpRequestMessage request)
+ {
+ base.OnRequestArrived(request);
+
+ var authorizationHeader = request.Headers.Authorization;
+
+ if (authorizationHeader != null)
+ {
+ try
+ {
+ RequestToken = WebToken<T>.FromToken(authorizationHeader.Parameter != null ? authorizationHeader.Parameter : authorizationHeader.ToString());
+ }
+ catch (Exception ex)
+ {
+ throw new HttpParseException("Could not parse the provided token embedded object.", ex);
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Views/Web.config b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Views/Web.config
new file mode 100644
index 000000000..ecea3014b
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Views/Web.config
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+
+<configuration>
+ <configSections>
+ <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
+ <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
+ <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
+ </sectionGroup>
+ </configSections>
+
+ <system.web.webPages.razor>
+ <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
+ <pages pageBaseType="System.Web.Mvc.WebViewPage">
+ <namespaces>
+ <add namespace="System.Web.Mvc" />
+ <add namespace="System.Web.Mvc.Ajax" />
+ <add namespace="System.Web.Mvc.Html" />
+ <add namespace="System.Web.Optimization"/>
+ <add namespace="System.Web.Routing" />
+ <add namespace="Tango.MachineService.Gateway" />
+ </namespaces>
+ </pages>
+ </system.web.webPages.razor>
+
+ <appSettings>
+ <add key="webpages:Enabled" value="false" />
+ </appSettings>
+
+ <system.webServer>
+ <handlers>
+ <remove name="BlockViewHandler"/>
+ <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
+ </handlers>
+ </system.webServer>
+
+ <system.web>
+ <compilation>
+ <assemblies>
+ <add assembly="System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
+ </assemblies>
+ </compilation>
+ </system.web>
+</configuration>
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Views/_ViewStart.cshtml b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Views/_ViewStart.cshtml
new file mode 100644
index 000000000..2de62418c
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
+@{
+ Layout = "~/Views/Shared/_Layout.cshtml";
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.Debug.config b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.Debug.config
new file mode 100644
index 000000000..d7712aaf1
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.Debug.config
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+
+<!-- For more information on using Web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=301874 -->
+
+<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
+ <!--
+ In the example below, the "SetAttributes" transform will change the value of
+ "connectionString" to use "ReleaseSQLServer" only when the "Match" locator
+ finds an attribute "name" that has a value of "MyDB".
+
+ <connectionStrings>
+ <add name="MyDB"
+ connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
+ xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
+ </connectionStrings>
+ -->
+ <system.web>
+ <!--
+ In the example below, the "Replace" transform will replace the entire
+ <customErrors> section of your Web.config file.
+ Note that because there is only one customErrors section under the
+ <system.web> node, there is no need to use the "xdt:Locator" attribute.
+
+ <customErrors defaultRedirect="GenericError.htm"
+ mode="RemoteOnly" xdt:Transform="Replace">
+ <error statusCode="500" redirect="InternalError.htm"/>
+ </customErrors>
+ -->
+ </system.web>
+</configuration>
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.Release.config b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.Release.config
new file mode 100644
index 000000000..28a4d5fcc
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.Release.config
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+
+<!-- For more information on using Web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=301874 -->
+
+<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
+ <!--
+ In the example below, the "SetAttributes" transform will change the value of
+ "connectionString" to use "ReleaseSQLServer" only when the "Match" locator
+ finds an attribute "name" that has a value of "MyDB".
+
+ <connectionStrings>
+ <add name="MyDB"
+ connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
+ xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
+ </connectionStrings>
+ -->
+ <system.web>
+ <compilation xdt:Transform="RemoveAttributes(debug)" />
+ <!--
+ In the example below, the "Replace" transform will replace the entire
+ <customErrors> section of your Web.config file.
+ Note that because there is only one customErrors section under the
+ <system.web> node, there is no need to use the "xdt:Locator" attribute.
+
+ <customErrors defaultRedirect="GenericError.htm"
+ mode="RemoteOnly" xdt:Transform="Replace">
+ <error statusCode="500" redirect="InternalError.htm"/>
+ </customErrors>
+ -->
+ </system.web>
+</configuration>
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.config b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.config
new file mode 100644
index 000000000..2854c8c7c
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/Web.config
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ For more information on how to configure your ASP.NET application, please visit
+ https://go.microsoft.com/fwlink/?LinkId=301879
+ -->
+<configuration>
+ <appSettings>
+ <add key="webpages:Version" value="3.0.0.0" />
+ <add key="webpages:Enabled" value="false" />
+ <add key="ClientValidationEnabled" value="true" />
+ <add key="UnobtrusiveJavaScriptEnabled" value="true" />
+ </appSettings>
+ <system.web>
+ <compilation debug="true" targetFramework="4.6.1" />
+ <httpRuntime targetFramework="4.6.1" />
+ <httpModules>
+ <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
+ </httpModules>
+ </system.web>
+ <system.webServer>
+ <handlers>
+ <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
+ <remove name="OPTIONSVerbHandler" />
+ <remove name="TRACEVerbHandler" />
+ <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
+ </handlers>
+ <modules>
+ <remove name="TelemetryCorrelationHttpModule" />
+ <add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler" />
+ <remove name="ApplicationInsightsWebTracking" />
+ <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
+ </modules>
+ <validation validateIntegratedModeConfiguration="false" />
+ </system.webServer>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
+ <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.2.1" newVersion="4.0.2.1" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
+ <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
+ <bindingRedirect oldVersion="1.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+ <system.codedom>
+ <compilers>
+ <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
+ <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
+ </compilers>
+ </system.codedom>
+</configuration>
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/WebToken.cs b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/WebToken.cs
new file mode 100644
index 000000000..7aa4860ab
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/WebToken.cs
@@ -0,0 +1,192 @@
+using JWT;
+using JWT.Algorithms;
+using JWT.Builder;
+using JWT.Serializers;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Web.Security
+{
+ public class WebToken
+ {
+ public DateTime Issued { get; protected set; }
+ public DateTime? Expiration { get; protected set; }
+ public String AccessToken { get; protected set; }
+ public String RefreshToken { get; protected set; }
+
+ public WebToken()
+ {
+
+ }
+
+ public static WebToken CreateNew(String secret, DateTime? expiration = null)
+ {
+ DateTime issued = DateTime.UtcNow;
+
+ var builder = new JwtBuilder()
+ .WithAlgorithm(new HMACSHA256Algorithm())
+ .WithSecret(secret)
+ .IssuedAt(issued);
+
+ if (expiration != null)
+ {
+ builder = builder.ExpirationTime(expiration.Value);
+ }
+
+ String refreshToken = Guid.NewGuid().ToString();
+
+ builder = builder.AddClaim("object", null);
+ builder = builder.AddClaim("refresh-token", refreshToken);
+
+ return new WebToken()
+ {
+ AccessToken = builder.Build(),
+ RefreshToken = refreshToken,
+ Expiration = expiration,
+ Issued = issued,
+ };
+ }
+
+ public static void Validate(String secret, String token)
+ {
+ var json = new JwtBuilder()
+ .WithSecret(secret)
+ .MustVerifySignature()
+ .Decode(token);
+ }
+
+ public void Validate(String secret)
+ {
+ var json = new JwtBuilder()
+ .WithSecret(secret)
+ .MustVerifySignature()
+ .Decode(AccessToken);
+ }
+
+ public WebToken Renew(String secret)
+ {
+ var newToken = CreateNew(secret, DateTime.UtcNow.Add(Expiration.Value - Issued));
+ newToken.RefreshToken = RefreshToken;
+ return newToken;
+ }
+
+ public static WebToken FromToken(String token)
+ {
+ WebToken webToken = new WebToken();
+
+ var payload = new JwtBuilder()
+ .WithValidator(null)
+ .Decode<IDictionary<string, object>>(token);
+
+ webToken.AccessToken = token;
+
+ if (payload.ContainsKey("exp"))
+ {
+ long exp = long.Parse(payload["exp"].ToString());
+ webToken.Expiration = ConvertEpochToDateTime(exp);
+ }
+
+ if (payload.ContainsKey("iat"))
+ {
+ long iat = long.Parse(payload["iat"].ToString());
+ webToken.Issued = ConvertEpochToDateTime(iat);
+ }
+
+ if (payload.ContainsKey("refresh-token"))
+ {
+ webToken.RefreshToken = payload["refresh-token"].ToString();
+ }
+
+ return webToken;
+ }
+
+ protected static DateTime ConvertEpochToDateTime(long seconds)
+ {
+ var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ return epoch.AddSeconds(seconds);
+ }
+ }
+
+ public class WebToken<T> : WebToken where T : class
+ {
+ public T Object { get; protected set; }
+
+ private WebToken()
+ {
+
+ }
+
+ public static WebToken<T> CreateNew(String secret, T obj = null, DateTime? expiration = null)
+ {
+ DateTime issued = DateTime.UtcNow;
+
+ var builder = new JwtBuilder()
+ .WithAlgorithm(new HMACSHA256Algorithm())
+ .WithSecret(secret)
+ .IssuedAt(issued);
+
+ if (expiration != null)
+ {
+ builder = builder.ExpirationTime(expiration.Value);
+ }
+
+ String refreshToken = Guid.NewGuid().ToString();
+
+ builder = builder.AddClaim("object", obj);
+ builder = builder.AddClaim("refresh-token", refreshToken);
+
+ return new WebToken<T>()
+ {
+ AccessToken = builder.Build(),
+ RefreshToken = refreshToken,
+ Expiration = expiration,
+ Issued = issued,
+ Object = obj,
+ };
+ }
+
+ public static new WebToken<T> FromToken(String token)
+ {
+ WebToken<T> webToken = new WebToken<T>();
+
+ var payload = new JwtBuilder()
+ .WithValidator(null)
+ .Decode<IDictionary<string, object>>(token);
+
+ webToken.AccessToken = token;
+
+ if (payload.ContainsKey("exp"))
+ {
+ long exp = long.Parse(payload["exp"].ToString());
+ webToken.Expiration = ConvertEpochToDateTime(exp);
+ }
+
+ if (payload.ContainsKey("iat"))
+ {
+ long iat = long.Parse(payload["iat"].ToString());
+ webToken.Issued = ConvertEpochToDateTime(iat);
+ }
+
+ if (payload.ContainsKey("refresh-token"))
+ {
+ webToken.RefreshToken = payload["refresh-token"].ToString();
+ }
+
+ webToken.Object = JsonConvert.DeserializeObject<T>(payload["object"].ToString());
+
+ return webToken;
+ }
+
+ public new WebToken<T> Renew(String secret)
+ {
+ var newToken = WebToken<T>.CreateNew(secret, Object, DateTime.UtcNow.Add(Expiration.Value - Issued));
+ newToken.RefreshToken = RefreshToken;
+ return newToken;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Web/Tango.MachineService.Gateway/packages.config b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/packages.config
new file mode 100644
index 000000000..617c72547
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService.Gateway/packages.config
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Antlr" version="3.5.0.2" targetFramework="net461" />
+ <package id="bootstrap" version="3.3.7" targetFramework="net461" />
+ <package id="jQuery" version="3.3.1" targetFramework="net461" />
+ <package id="JWT" version="6.1.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" />
+ <package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.5.1" targetFramework="net461" />
+ <package id="Microsoft.ApplicationInsights.Web" version="2.5.1" targetFramework="net461" />
+ <package id="Microsoft.ApplicationInsights.WindowsServer" version="2.5.1" targetFramework="net461" />
+ <package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.5.1" targetFramework="net461" />
+ <package id="Microsoft.AspNet.Mvc" version="5.2.4" targetFramework="net461" />
+ <package id="Microsoft.AspNet.Razor" version="3.2.4" targetFramework="net461" />
+ <package id="Microsoft.AspNet.TelemetryCorrelation" version="1.0.0" targetFramework="net461" />
+ <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
+ <package id="Microsoft.AspNet.WebApi" version="5.2.4" targetFramework="net461" />
+ <package id="Microsoft.AspNet.WebApi.Client" version="5.2.4" targetFramework="net461" />
+ <package id="Microsoft.AspNet.WebApi.Core" version="5.2.4" targetFramework="net461" />
+ <package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.4" targetFramework="net461" />
+ <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.4" targetFramework="net461" />
+ <package id="Microsoft.AspNet.WebPages" version="3.2.4" targetFramework="net461" />
+ <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net461" />
+ <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
+ <package id="Modernizr" version="2.8.3" targetFramework="net461" />
+ <package id="Newtonsoft.Json" version="11.0.1" targetFramework="net461" />
+ <package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net461" />
+ <package id="WebGrease" version="1.6.0" targetFramework="net461" />
+</packages> \ No newline at end of file