From bbb32747564cc76a799bff2e24acc1621c6c74ee Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Thu, 19 Nov 2020 04:32:11 +0200 Subject: Roles and Permission EDrawMax + csv generator + pdf. --- .../FSE/Tango.FSE.DPGraphGenerator/App.config | 24 ++++++ .../FSE/Tango.FSE.DPGraphGenerator/Program.cs | 88 ++++++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 +++++++++ .../Tango.FSE.DPGraphGenerator.csproj | 75 ++++++++++++++++++ .../FSE/Tango.FSE.DPGraphGenerator/packages.config | 4 + 5 files changed, 227 insertions(+) create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/App.config create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Program.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Tango.FSE.DPGraphGenerator.csproj create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/packages.config (limited to 'Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator') diff --git a/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/App.config b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/App.config new file mode 100644 index 000000000..4ef5218a0 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/App.config @@ -0,0 +1,24 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Program.cs b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Program.cs new file mode 100644 index 000000000..9eb0fb7b6 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Program.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.CSV; + +namespace Tango.FSE.DPGraphGenerator +{ + class Program + { + private class RolePermission + { + public String Name { get; set; } + + public override string ToString() + { + return Name; + } + } + + private class RoleModel + { + public String Name { get; set; } + public List Permissions { get; set; } + + public RoleModel() + { + Permissions = new List(); + } + } + + static void Main(string[] args) + { + String outputFolder = Path.GetFullPath(@"..\..\..\Roles & Permissions"); + + Console.WriteLine($"Generating roles and permissions csv files to '{outputFolder}'..."); + + List models = new List(); + + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var roles = db.Roles.ToList(); + var roles_permissions = db.RolesPermissions.ToList(); + var permissions = db.Permissions.ToList(); + + foreach (var role in roles.Where(x => x.Name.Contains("FSE")).ToList()) + { + RoleModel model = new RoleModel(); + model.Name = role.Description; + + List role_permissions = role.RolesPermissions.Select(x => x.Permission).ToList(); + + foreach (var permission in role_permissions.OrderBy(x => x.Code)) + { + model.Permissions.Add(new RolePermission() { Name = permission.Name.Replace("FSE_", "") }); + } + + models.Add(model); + } + } + + Directory.CreateDirectory(outputFolder); + + foreach (var model in models) + { + Console.WriteLine($"Generating role '{model.Name}'..."); + + using (DynamicCsvFile csvFile = new DynamicCsvFile(Path.Combine(outputFolder, $"{model.Name}.csv"))) + { + csvFile.Columns.Add(new DynamicCsvFileColumn() { Name = model.Name }); + + foreach (var permission in model.Permissions) + { + csvFile.Append(permission); + } + } + } + + Console.WriteLine(); + Console.WriteLine("Done!, press return to exit..."); + Console.ReadLine(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Properties/AssemblyInfo.cs b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..4cec0e5fd --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/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.FSE.DPGraphGenerator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.FSE.DPGraphGenerator")] +[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("c57d9d68-336c-4665-9ef4-ec1bdbb84885")] + +// 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/FSE/Tango.FSE.DPGraphGenerator/Tango.FSE.DPGraphGenerator.csproj b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Tango.FSE.DPGraphGenerator.csproj new file mode 100644 index 000000000..ae2b84d7c --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/Tango.FSE.DPGraphGenerator.csproj @@ -0,0 +1,75 @@ + + + + + Debug + AnyCPU + {C57D9D68-336C-4665-9EF4-EC1BDBB84885} + Exe + Tango.FSE.DPGraphGenerator + Tango.FSE.DPGraphGenerator + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} + Tango.Core + + + {58e8825f-0c96-449c-b320-1e82b0aa876b} + Tango.CSV + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/packages.config b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.DPGraphGenerator/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.3.1