diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-17 05:26:44 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-17 05:26:44 +0200 |
| commit | f32a4fdbaaa4ef966d27c7d2727d81bf65aabb61 (patch) | |
| tree | 07f4d18cb3033e3bef1309af3f447a2bab63195c /Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI | |
| parent | a309970822fdc61357db07c32fd67b15d1c497f0 (diff) | |
| download | Tango-f32a4fdbaaa4ef966d27c7d2727d81bf65aabb61.tar.gz Tango-f32a4fdbaaa4ef966d27c7d2727d81bf65aabb61.zip | |
StubsUtils
Diffstat (limited to 'Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI')
4 files changed, 180 insertions, 0 deletions
diff --git a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/App.config b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/App.config new file mode 100644 index 000000000..731f6de6c --- /dev/null +++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/App.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> + </startup> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/Program.cs b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/Program.cs new file mode 100644 index 000000000..b72e15236 --- /dev/null +++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/Program.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.IO.Pipes; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.StubsUtils.Shared; + +namespace Tango.StubsUtils.SessionClient.CLI +{ + class Program + { + private const string PIPE_NAME = "Tango_Stubs_Server"; + + static void Main(string[] args) + { + String line = String.Empty; + + Console.WriteLine("Tango Stub Session Client v1.0"); + + while (true) + { + Console.Write("> "); + line = Console.ReadLine(); + + if (line.ToLower() == "exit") + { + Environment.Exit(0); + } + + args = line.Split(' '); + + StubPackageResponseDTO response = null; + + try + { + var _client = new NamedPipeClientStream(PIPE_NAME); + _client.Connect(5000); + + var writer = new StreamWriter(_client); + + var jsonRequest = String.Join(" ", args); + + writer.WriteLine(jsonRequest); + writer.Flush(); + + var reader = new StreamReader(_client); + String responseString = reader.ReadToEnd(); + response = new StubPackageResponseDTO(); + response.Status = responseString.StartsWith("Status: OK") ? StubPackageResponseStatus.OK : StubPackageResponseStatus.Error; + response.Message = responseString; + } + catch (Exception ex) + { + OnError($"Error communicating with the stubs service. {ex.Message}"); + } + + if (response.Status == StubPackageResponseStatus.OK) + { + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine(response.Message); + } + else + { + OnError(response.Message); + } + } + } + + private static void OnError(String error) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"{error}"); + Console.ForegroundColor = ConsoleColor.Gray; + } + } +} diff --git a/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..14f843bcf --- /dev/null +++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/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.StubsUtils.SessionClient.CLI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.StubsUtils.SessionClient.CLI")] +[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("f1b727f5-adf5-4a81-a740-7e64e48b29d4")] + +// 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 Build and Revision 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/StubsUtils/Tango.StubsUtils.SessionClient.CLI/Tango.StubsUtils.SessionClient.CLI.csproj b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/Tango.StubsUtils.SessionClient.CLI.csproj new file mode 100644 index 000000000..6ccf31b7b --- /dev/null +++ b/Software/Visual_Studio/StubsUtils/Tango.StubsUtils.SessionClient.CLI/Tango.StubsUtils.SessionClient.CLI.csproj @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" 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> + <ProjectGuid>{F1B727F5-ADF5-4A81-A740-7E64E48B29D4}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>Tango.StubsUtils.SessionClient.CLI</RootNamespace> + <AssemblyName>tangostub_s</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\Build\StubsUtils\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>..\..\Build\StubsUtils\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Tango.StubsUtils.Shared\Tango.StubsUtils.Shared.csproj"> + <Project>{dae96f06-72cd-411d-90a3-9456ae79f699}</Project> + <Name>Tango.StubsUtils.Shared</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file |
