diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-13 19:50:34 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-13 19:50:34 +0300 |
| commit | 9493a730360fbcf5afb612bcd7b3bcbe0a2174f9 (patch) | |
| tree | ed60abf7a8402521f929abf65cb943ed6d6ef3b6 /Software/Visual_Studio/Utilities | |
| parent | b4643d9c4a6a1d43572eebc628fb0cd311b26923 (diff) | |
| download | Tango-9493a730360fbcf5afb612bcd7b3bcbe0a2174f9.tar.gz Tango-9493a730360fbcf5afb612bcd7b3bcbe0a2174f9.zip | |
Implemented EventTypes excel generator.
Added and delete new hardware events according to Events.xlsx document.
Diffstat (limited to 'Software/Visual_Studio/Utilities')
6 files changed, 195 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/App.config b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/App.config new file mode 100644 index 000000000..92aa00bf9 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/App.config @@ -0,0 +1,16 @@ +<?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" /> + </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> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Program.cs new file mode 100644 index 000000000..e4fc911ec --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Program.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Core.Helpers; +using Tango.Documents; + +namespace Tango.EventsTypesGenerator +{ + class Program + { + private class ExcelEventType + { + public String Code { get; set; } + public String Name { get; set; } + public String Description { get; set; } + public String Category { get; set; } + public String Group { get; set; } + public String UserInterventionRequired { get; set; } + public String Resolvable { get; set; } + + public override string ToString() + { + return String.Format("{0}, {1}, {2}, {3}, {4}, {5}, {6}", Code, Name, Description, Category, Group, UserInterventionRequired, Resolvable); + } + } + + static void Main(string[] args) + { + Console.WriteLine("Generating hardware event types..."); + + ExcelReader reader = new ExcelReader(PathHelper.GetStartupPath() + "\\Events.xlsx"); + var results = reader.GetDataByIndex<ExcelEventType>("Events", 2); + + Console.WriteLine("Clearing all previous hardware events..."); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var eventTypes = db.EventTypes.ToList(); + + foreach (var evType in eventTypes) + { + EventTypesGroups group = (EventTypesGroups)evType.EventTypesGroup.Code; + + if (group != EventTypesGroups.Application && group != EventTypesGroups.Transport) + { + db.EventTypes.Remove(evType); + } + } + + Console.WriteLine("Inserting new events..."); + + foreach (var evType in results) + { + Console.WriteLine("Inserting " + evType.ToString()); + + EventType newEvent = new EventType(); + newEvent.Code = int.Parse(evType.Code); + newEvent.Name = evType.Name; + newEvent.Description = evType.Description; + newEvent.EventTypesCategory = db.EventTypesCategories.SingleOrDefault(x => x.Name == evType.Category); + newEvent.EventTypesGroup = db.EventTypesGroups.SingleOrDefault(x => x.Name == evType.Group); + newEvent.RequiresUserIntervention = evType.UserInterventionRequired == "Yes" ? true : false; + newEvent.Resolvable = evType.Resolvable == "Yes" ? true : false; + db.EventTypes.Add(newEvent); + } + + + Console.WriteLine("Saving changed..."); + db.SaveChanges(); + } + + Console.WriteLine("Done!"); + Console.ReadLine(); + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..64514b030 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +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 Event Types Generator")] +[assembly: AssemblyVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Tango.EventsTypesGenerator.csproj b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Tango.EventsTypesGenerator.csproj new file mode 100644 index 000000000..6ab5723a7 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/Tango.EventsTypesGenerator.csproj @@ -0,0 +1,81 @@ +<?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>{0BDA9B52-9879-4C5E-84E3-81D00B75DACC}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>Tango.EventsTypesGenerator</RootNamespace> + <AssemblyName>Tango.EventsTypesGenerator</AssemblyName> + <TargetFrameworkVersion>v4.6</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>..\..\Build\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\Debug\</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="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="..\..\Versioning\GlobalVersionInfo.cs"> + <Link>GlobalVersionInfo.cs</Link> + </Compile> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <Content Include="..\..\Resources\Events.xlsx"> + <Link>Events.xlsx</Link> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </Content> + <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.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Documents\Tango.Documents.csproj"> + <Project>{ca87a608-7b17-4c98-88f2-42abee10f4c1}</Project> + <Name>Tango.Documents</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/packages.config b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/packages.config new file mode 100644 index 000000000..9256e1591 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.EventsTypesGenerator/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 diff --git a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs index e3e225bbb..96f0ed441 100644 --- a/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs +++ b/Software/Visual_Studio/Utilities/Tango.PMRGenerator.CLI/Program.cs @@ -52,7 +52,7 @@ namespace Tango.PMRGenerator.CLI GenerateColorLabLiquidTypes(db, pmrFolder); GenerateDiagnosticsValueComponents(db, pmrFolder); GenerateDiagnosticsMonitors(db, pmrFolder); - GenerateDiagnosticsEventTypes(db, pmrFolder); + GenerateEventTypes(db, pmrFolder); } Console.WriteLine("Done"); @@ -573,15 +573,15 @@ namespace Tango.PMRGenerator.CLI File.WriteAllText(Path.Combine(pmrFolder, "Diagnostics", messageFile.Name + ".proto"), messageString); } - private static void GenerateDiagnosticsEventTypes(ObservablesContext db, String pmrFolder) + private static void GenerateEventTypes(ObservablesContext db, String pmrFolder) { - Console.WriteLine("Generating Diagnostics Event Types..."); + Console.WriteLine("Generating Event Types..."); ProtoEnumFile enumFile = new ProtoEnumFile(); enumFile.Name = "EventType"; enumFile.Package = "Tango.PMR.Diagnostics"; - foreach (var field in db.EventTypes.ToList().OrderBy(x => x.Code)) + foreach (var field in db.EventTypes.ToList().Where(x => x.Code < 1000).OrderBy(x => x.Code)) { enumFile.Fields.Add(new EnumerationField() { |
