diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-21 20:21:57 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-02-21 20:21:57 +0200 |
| commit | 956f9ea033553136ebf199fff30f288dc26fbeb0 (patch) | |
| tree | 3780e906d8d4f12c5be3836e1704d93d8d4966bd /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService | |
| parent | 808ce20dbd74862a75499ee0d4e87247ee4479b4 (diff) | |
| download | Tango-956f9ea033553136ebf199fff30f288dc26fbeb0.tar.gz Tango-956f9ea033553136ebf199fff30f288dc26fbeb0.zip | |
Working on machine studio update center..
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService')
8 files changed, 361 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc new file mode 100644 index 000000000..bad3e4fcd --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc @@ -0,0 +1 @@ +<%@ ServiceHost Language="C#" Debug="true" Service="Tango.MachineStudio.UpdateService.MachineStudioUpdateService" CodeBehind="MachineStudioUpdateService.svc.cs" %>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs new file mode 100644 index 000000000..4cfea1b8a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.ServiceModel.Web; +using System.Text; +using Tango.Integration.Observables; +using Tango.Logging; +using Tango.MachineStudio.Common.Update; + +namespace Tango.MachineStudio.UpdateService +{ + public class MachineStudioUpdateService : IMachineStudioUpdateService + { + public CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request) + { + LogManager.Log("Request received..."); + + try + { + CheckForUpdatesResponse response = new CheckForUpdatesResponse(); + + using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + { + db.Configuration.LazyLoadingEnabled = false; + + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password); + + if (user != null) + { + var latestVersion = db.MachineStudioVersions.FirstOrDefault(); + Version currentVersionNumber = Version.Parse(request.Version); + + if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersionNumber) + { + response.IsUpdateAvailable = true; + + response.FtpHost = ConfigurationManager.AppSettings["FtpHost"].ToString(); + response.UserName = ConfigurationManager.AppSettings["UserName"].ToString(); + response.Password = ConfigurationManager.AppSettings["Password"].ToString(); + response.FilePath = latestVersion.FtpFilePath; + response.Version = latestVersion.Version; + } + } + else + { + throw new FaultException("Invalid user credentials."); + } + } + + return response; + } + catch (Exception ex) + { + LogManager.Log(ex); + throw new FaultException(ex.ToString()); + } + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..6b9387721 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +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.MachineStudio.UpdateService")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.MachineStudio.UpdateService")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[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("cc6d62e9-c300-42f3-b452-79966e902b10")] + +// 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.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj new file mode 100644 index 000000000..c9400b2d1 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Tango.MachineStudio.UpdateService.csproj @@ -0,0 +1,142 @@ +<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <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>{CC6D62E9-C300-42F3-B452-79966E902B10}</ProjectGuid> + <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Tango.MachineStudio.UpdateService</RootNamespace> + <AssemblyName>Tango.MachineStudio.UpdateService</AssemblyName> + <TargetFrameworkVersion>v4.6</TargetFrameworkVersion> + <WcfConfigValidationEnabled>True</WcfConfigValidationEnabled> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <UseIISExpress>true</UseIISExpress> + <IISExpressSSLPort /> + <IISExpressAnonymousAuthentication /> + <IISExpressWindowsAuthentication /> + <IISExpressUseClassicPipelineMode /> + <UseGlobalApplicationHostFile /> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\Build\Debug\Web\Machine Studio Update Service\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll</HintPath> + </Reference> + <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <Reference Include="System.Web.DynamicData" /> + <Reference Include="System.Web.Entity" /> + <Reference Include="System.Web.ApplicationServices" /> + <Reference Include="System" /> + <Reference Include="System.Configuration" /> + <Reference Include="System.Core" /> + <Reference Include="System.Data" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.EnterpriseServices" /> + <Reference Include="System.Runtime.Serialization" /> + <Reference Include="System.ServiceModel" /> + <Reference Include="System.ServiceModel.Web" /> + <Reference Include="System.Web" /> + <Reference Include="System.Web.Extensions" /> + <Reference Include="System.Web.Services" /> + <Reference Include="System.Xml" /> + <Reference Include="System.Xml.Linq" /> + </ItemGroup> + <ItemGroup> + <Content Include="MachineStudioUpdateService.svc" /> + <Content Include="Web.config" /> + </ItemGroup> + <ItemGroup> + <Compile Include="MachineStudioUpdateService.svc.cs"> + <DependentUpon>MachineStudioUpdateService.svc</DependentUpon> + </Compile> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <Folder Include="App_Data\" /> + </ItemGroup> + <ItemGroup> + <Content Include="packages.config" /> + <None Include="Properties\PublishProfiles\FolderProfile.pubxml" /> + <None Include="Web.Debug.config"> + <DependentUpon>Web.config</DependentUpon> + </None> + <None Include="Web.Release.config"> + <DependentUpon>Web.config</DependentUpon> + </None> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Integration\Tango.Integration.csproj"> + <Project>{4206ac58-3b57-4699-8835-90bf6db01a61}</Project> + <Name>Tango.Integration</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.MachineStudio.Common\Tango.MachineStudio.Common.csproj"> + <Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project> + <Name>Tango.MachineStudio.Common</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" /> + <ProjectExtensions> + <VisualStudio> + <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> + <WebProjectProperties> + <UseIIS>True</UseIIS> + <AutoAssignPort>True</AutoAssignPort> + <DevelopmentServerPort>65206</DevelopmentServerPort> + <DevelopmentServerVPath>/</DevelopmentServerVPath> + <IISUrl>http://localhost:53044/</IISUrl> + <NTLMAuthentication>False</NTLMAuthentication> + <UseCustomServer>False</UseCustomServer> + <CustomServerUrl> + </CustomServerUrl> + <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> + </WebProjectProperties> + </FlavorProperties> + </VisualStudio> + </ProjectExtensions> + <!-- 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/MachineStudio/Tango.MachineStudio.UpdateService/Web.Debug.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Debug.config new file mode 100644 index 000000000..fae9cfefa --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Debug.config @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 --> + +<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>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config new file mode 100644 index 000000000..da6e960b8 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.Release.config @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 --> + +<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>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config new file mode 100644 index 000000000..b0d2452f0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/Web.config @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="utf-8"?> +<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" /> + </configSections> + <appSettings> + <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> + <add key="FtpHost" value="localhost" /> + <add key="UserName" value="Tango" /> + <add key="Password" value="Aa123456" /> + </appSettings> + <system.web> + <compilation debug="true" targetFramework="4.6" /> + <httpRuntime targetFramework="4.6" /> + </system.web> + <system.serviceModel> + <behaviors> + <serviceBehaviors> + <behavior> + <!-- To avoid disclosing metadata information, set the values below to false before deployment --> + <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> + <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> + <serviceDebug includeExceptionDetailInFaults="false" /> + </behavior> + </serviceBehaviors> + </behaviors> + <protocolMapping> + <add binding="basicHttpsBinding" scheme="https" /> + </protocolMapping> + <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> + </system.serviceModel> + <system.webServer> + <modules runAllManagedModulesForAllRequests="false" /> + <!-- + To browse web app root directory during debugging, set the value below to true. + Set to false before deployment to avoid disclosing web app folder information. + --> + <directoryBrowse enabled="true" /> + </system.webServer> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> + </providers> + </entityFramework> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <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> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/packages.config b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/packages.config new file mode 100644 index 000000000..9256e1591 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.0.0" targetFramework="net46" /> +</packages>
\ No newline at end of file |
