diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-16 14:35:19 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-11-16 14:35:19 +0200 |
| commit | 0ee81ef847af3702b3b37f94cc62e835f9294e55 (patch) | |
| tree | e3cc6daea355c8cc7a5dbf48f5e0c594230d90fb /Software/Visual_Studio/DataStore/Tango.DataStore.CLI | |
| parent | 76b22e4d05cbd8d771f678e4b5adc2dc5159afa8 (diff) | |
| download | Tango-0ee81ef847af3702b3b37f94cc62e835f9294e55.tar.gz Tango-0ee81ef847af3702b3b37f94cc62e835f9294e55.zip | |
Working on DataStore WebAPI & CLI.
Diffstat (limited to 'Software/Visual_Studio/DataStore/Tango.DataStore.CLI')
6 files changed, 255 insertions, 0 deletions
diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/App.config b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/App.config new file mode 100644 index 000000000..a46da65da --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/App.config @@ -0,0 +1,28 @@ +<?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> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> + </startup> + <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="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="Z.EntityFramework.Extensions" publicKeyToken="59b66d028979105b" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.50.0" newVersion="4.0.50.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Options.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Options.cs new file mode 100644 index 000000000..80b3caf7e --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Options.cs @@ -0,0 +1,51 @@ +using CommandLine; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Web; + +namespace Tango.DataStore.CLI +{ + public class OptionsBase + { + [Option(longName: "email", HelpText = "Email address", Required = true)] + public String Email { get; set; } + + [Option(longName: "password", HelpText = "Password")] + public String Password { get; set; } + + [Option(longName: "env", HelpText = "Environment")] + public DeploymentSlot Environment { get; set; } + } + + [Verb("get", HelpText = "Get a data store item.")] + public class GetOptions : OptionsBase + { + [Option(longName: "sn", HelpText = "Machine serial number")] + public String MachineSerialNumber { get; set; } + + [Option(longName: "collection", HelpText = "Collection name")] + public String Collection { get; set; } + + [Option(longName: "key", HelpText = "Item key")] + public String Key { get; set; } + } + + [Verb("put", HelpText = "Get a data store item.")] + public class PutOptions : OptionsBase + { + [Option(longName: "sn", HelpText = "Machine serial number")] + public String MachineSerialNumber { get; set; } + + [Option(longName: "collection", HelpText = "Collection name")] + public String Collection { get; set; } + + [Option(longName: "key", HelpText = "Item key")] + public String Key { get; set; } + + [Option(longName: "value", HelpText = "Item value")] + public String Value { get; set; } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs new file mode 100644 index 000000000..e27f76c79 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Program.cs @@ -0,0 +1,49 @@ +using CommandLine; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; + +namespace Tango.DataStore.CLI +{ + class Program + { + static void Main(string[] args) + { + var result = Parser.Default.ParseArguments<GetOptions, PutOptions>(args) + .WithParsed<GetOptions>((options) => + { + Console.WriteLine($"{options.Email}, {options.Password}"); + }) + .WithParsed<PutOptions>((options) => + { + Console.WriteLine($"{options.Email}, {options.Password}"); + }) + .WithNotParsed((errors) => + { + + }); + + Console.ReadLine(); + } + + private static int DisplayHelp<T>(ParserResult<T> result, IEnumerable<Error> errs) + { + var helpText = CommandLine.Text.HelpText.AutoBuild(result, h => + { + h.AdditionalNewLineAfterOption = false; + h.AddNewLineBetweenHelpSections = true; + h.AddEnumValuesToHelpText = true; + h.AutoVersion = false; + h.Heading = CommandLine.Text.HeadingInfo.Empty; + h.MaximumDisplayWidth = 110; + // h.AddVerbs(typeof(SyncOptions), typeof(QueryOptions), typeof(TokenOptions)); + return h; // only h + }); + Console.WriteLine(helpText); + return 1; + } + } +} diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..366b8e28e --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.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.DataStore.CLI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.DataStore.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("6189b8c3-7af9-43dd-8a61-a8a05f526f62")] + +// 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/DataStore/Tango.DataStore.CLI/Tango.DataStore.CLI.csproj b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Tango.DataStore.CLI.csproj new file mode 100644 index 000000000..05e4022c4 --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/Tango.DataStore.CLI.csproj @@ -0,0 +1,86 @@ +<?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>{6189B8C3-7AF9-43DD-8A61-A8A05F526F62}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>Tango.DataStore.CLI</RootNamespace> + <AssemblyName>Tango.DataStore.CLI</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>bin\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>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="CommandLine, Version=2.8.0.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL"> + <HintPath>..\..\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll</HintPath> + </Reference> + <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.2.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.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <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="Options.cs" /> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj"> + <Project>{F441FEEE-322A-4943-B566-110E12FD3B72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Web\Tango.Web.csproj"> + <Project>{5001990f-977b-48ff-b217-0236a5022ad8}</Project> + <Name>Tango.Web</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.DataStore.EF\Tango.DataStore.EF.csproj"> + <Project>{88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4}</Project> + <Name>Tango.DataStore.EF</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <Folder Include="Options\" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/packages.config b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/packages.config new file mode 100644 index 000000000..71553e4ac --- /dev/null +++ b/Software/Visual_Studio/DataStore/Tango.DataStore.CLI/packages.config @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="CommandLineParser" version="2.8.0" targetFramework="net461" /> + <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> +</packages>
\ No newline at end of file |
