aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-08-30 19:38:41 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-08-30 19:38:41 +0300
commitdd6bc91bb43b70fcae954834cd03c6028f3eefa5 (patch)
tree08710978223e7bc2eedae6c7515a241e6b1c64a8 /Software/Visual_Studio/Web/Tango.MachineService
parent5c9bca9cb0bbbb1c448228ef5ac5f898f17e9827 (diff)
parenta4a0d4973c8eff2bbfe2c8e753f30626c9e9076d (diff)
downloadTango-dd6bc91bb43b70fcae954834cd03c6028f3eefa5.tar.gz
Tango-dd6bc91bb43b70fcae954834cd03c6028f3eefa5.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs96
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Publish Machine Service via FTP.pubxml21
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj7
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Web.config97
4 files changed, 170 insertions, 51 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
index 8054aae8c..e4e01e7d1 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/SynchronizationController.cs
@@ -125,6 +125,102 @@ namespace Tango.MachineService.Controllers
return response;
}
+ [HttpPost]
+ public DownloadUpdateResponse MachineUpdate(DownloadUpdateRequest request)
+ {
+ DownloadUpdateResponse response = new DownloadUpdateResponse();
+
+ try
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault(GetLocalServerAddress()))
+ {
+ db.Configuration.LazyLoadingEnabled = false;
+ String serial_number = request.SerialNumber;
+
+ var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == serial_number);
+
+ if (machine == null)
+ {
+ OnError(HttpStatusCode.NotFound, "The specified serial number could not be found.");
+ }
+
+ var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid);
+
+ var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault();
+
+ response.Version = latest_machine_version.Version;
+
+ response.FtpAddress = GetFtpAddress();
+ response.FtpFilePath = latest_machine_version.FtpFilePath;
+ response.FtpUserName = GetFtpUserName();
+ response.FtpPassword = GetFtpPassword();
+
+ DbCredentials credentials = new DbCredentials();
+
+ using (DbManager manager = DbManager.FromAddressAndName(GetDbAddress(), "Tango"))
+ {
+ credentials = manager.CreateRandomLoginAndUser("Tango");
+
+ Task.Delay(TimeSpan.FromMinutes(10)).ContinueWith((x) =>
+ {
+ using (DbManager m = DbManager.FromAddressAndName(GetDbAddress(), "Tango"))
+ {
+ m.DeleteLoginAndUser(credentials.UserName, "Tango");
+ }
+ });
+ }
+
+ response.DbAddress = GetDbAddress();
+ response.DbUserName = credentials.UserName;
+ response.DbPassword = credentials.Password;
+ }
+ }
+ catch (Exception ex)
+ {
+ OnError(HttpStatusCode.InternalServerError, ex.Message);
+ }
+
+ return response;
+ }
+
+ [HttpPost]
+ public CheckForUpdateResponse CheckForUpdate(CheckForUpdateRequest request)
+ {
+ CheckForUpdateResponse response = new CheckForUpdateResponse();
+
+ try
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault(GetLocalServerAddress()))
+ {
+ db.Configuration.LazyLoadingEnabled = false;
+
+ var machine = db.Machines.SingleOrDefault(x => x.SerialNumber == request.SerialNumber);
+
+ if (machine == null)
+ {
+ OnError(HttpStatusCode.NotFound, "The specified serial number could not be found.");
+ }
+
+ var machine_version = db.MachineVersions.SingleOrDefault(x => x.Guid == machine.MachineVersionGuid);
+
+ var latest_machine_version = db.TangoVersions.Where(x => x.MachineVersionGuid == machine_version.Guid).ToList().OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault();
+
+ if (Version.Parse(latest_machine_version.Version) > Version.Parse(request.Version))
+ {
+ response.IsUpdateAvailable = true;
+ }
+
+ response.Version = latest_machine_version.Version;
+ }
+ }
+ catch (Exception ex)
+ {
+ OnError(HttpStatusCode.InternalServerError, ex.Message);
+ }
+
+ return response;
+ }
+
#region Helpers
private void OnError(HttpStatusCode code, String message)
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Publish Machine Service via FTP.pubxml b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Publish Machine Service via FTP.pubxml
new file mode 100644
index 000000000..bd9a693e0
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Properties/PublishProfiles/Publish Machine Service via FTP.pubxml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+This file is used by the publish/package process of your Web project. You can customize the behavior of this process
+by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
+-->
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <WebPublishMethod>FTP</WebPublishMethod>
+ <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
+ <LastUsedPlatform>Any CPU</LastUsedPlatform>
+ <SiteUrlToLaunchAfterPublish />
+ <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
+ <ExcludeApp_Data>False</ExcludeApp_Data>
+ <publishUrl>twine01</publishUrl>
+ <DeleteExistingFiles>True</DeleteExistingFiles>
+ <FtpPassiveMode>True</FtpPassiveMode>
+ <FtpSitePath>MachineService</FtpSitePath>
+ <UserName>PublishFTP|Roy</UserName>
+ <_SavePWD>False</_SavePWD>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
index bc05f04bc..3f54c8568 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Tango.MachineService.csproj
@@ -83,9 +83,9 @@
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
- <Reference Include="System.Web.Extensions" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Abstractions" />
+ <Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
@@ -222,6 +222,9 @@
<ItemGroup>
<Folder Include="App_Data\" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="Properties\PublishProfiles\Publish Machine Service via FTP.pubxml" />
+ </ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
@@ -248,7 +251,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config
index d116dc437..281fdadeb 100644
--- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=301879
@@ -6,21 +6,18 @@
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+ <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<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" />
-
- <add key="LocalServerAddress" value="twine01\SQLTWINE_TEST" />
-
- <add key="FtpAddress" value="Twine01" />
- <add key="FtpUserName" value="Tango|FTPReader" />
- <add key="FtpPassword" value="Aa123456" />
-
- <add key="DbAddress" value="twine01\SQLTWINE_TEST" />
+ <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"/>
+ <add key="LocalServerAddress" value="twine01\SQLTWINE_TEST"/>
+ <add key="FtpAddress" value="Twine01"/>
+ <add key="FtpUserName" value="Tango|FTPReader"/>
+ <add key="FtpPassword" value="Aa123456"/>
+ <add key="DbAddress" value="twine01\SQLTWINE_TEST"/>
</appSettings>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
@@ -31,74 +28,76 @@
</system.Web>
-->
<system.web>
- <compilation debug="true" targetFramework="4.6" />
- <httpRuntime targetFramework="4.5" />
+ <compilation debug="true" targetFramework="4.7.2"/>
+ <httpRuntime targetFramework="4.5"/>
<httpModules>
- <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
+ <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" />
+ <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>
- <validation validateIntegratedModeConfiguration="false" />
+ <validation validateIntegratedModeConfiguration="false"/>
<modules>
- <remove name="ApplicationInsightsWebTracking" />
- <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
+ <remove name="ApplicationInsightsWebTracking"/>
+ <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler"/>
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
- <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
- <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
+ <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
+ <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.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" />
+ <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.5.2.14234" newVersion="1.5.2.14234" />
+ <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
+ <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
- <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
+ <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" />
+ <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.3.0" newVersion="5.2.3.0" />
+ <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
+ <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
<dependentAssembly>
- <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
+ <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.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=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
- <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
+ <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
+ <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
<entityFramework>
- <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+ <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
- <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
- <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
+ <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
+ <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
</providers>
</entityFramework>
-
-<system.data>
+ <system.data>
<DbProviderFactories>
- <remove invariant="System.Data.SQLite.EF6" />
- <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
- <remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
- </system.data></configuration> \ No newline at end of file
+ <remove invariant="System.Data.SQLite.EF6"/>
+ <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6"/>
+ <remove invariant="System.Data.SQLite"/>
+ <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite"/>
+ </DbProviderFactories>
+ </system.data>
+</configuration> \ No newline at end of file