diff --git a/README.md b/README.md index 4442b1d..5c1f806 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,18 @@ # DeployUtils -Progetto per utility in fase di deploy \ No newline at end of file +Progetto per utility in fase di deploy + +## WebConfigSetter + +Console app dedicata alla gestione install delle web applications. +Viene impiegata per leggere conf da file *.xml (dotNet Framework) + *.json (dotNet core) x uniformare e gestire conf clienti su stringhe connessione, aprametri programmi + +## ConfMan.IOB + +Applicazione per la gestione, conversione dei file conf x IOB, e per la converzione del formato. + +Da completare insieme ad update dell'app IOB-WIN-NEXT. + +## MapoDataFiller + +Gestione fillup dati MAPO (alternativa ai simulatori) - LEGACY? \ No newline at end of file diff --git a/README.pdf b/README.pdf new file mode 100644 index 0000000..483fa00 Binary files /dev/null and b/README.pdf differ diff --git a/WebConfigSetter/CONF/ConfigDB.json b/WebConfigSetter/CONF/ConfigDB.json new file mode 100644 index 0000000..1b4be5e --- /dev/null +++ b/WebConfigSetter/CONF/ConfigDB.json @@ -0,0 +1,53 @@ +{ + "appSettRules": { + "DbConfConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MoonProConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MoonProConnectionStringIS": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro_IS;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MoonProConnectionStringES3": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro_ES3;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "PermessiConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "UtenteCdcConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_Anagrafica;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "VocabolarioConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "CTrackConnectionString": "Data Source=localhost\\SQLEXPRESS;Initial Catalog=Jetco_C_TRACK;Persist Security Info=True;User id=steamware;Password=viadante16;", + "DevicesAuthConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_Anagrafica;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "DevicesConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_Anagrafica;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MoonProConnectionStringArca": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro_IS;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MagDataConnectionString": "Data Source=localhost\\SQLEXPRESS;Initial Catalog=Jetco_MoonPro_MAG;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MoonProConnectionStringMAG": "Data Source=localhost\\SQLEXPRESS;Initial Catalog=Jetco_MoonPro_MAG;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "mdbConnString": "mongodb://localhost:27017" + }, + "connStrRules": { + "MoonProConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MapoDb.Properties.Settings.MoonProConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MapoDb.Properties.Settings.MoonPro_IS_ConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro_IS;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MapoDb.Properties.Settings.C_TRACKConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_C_TRACK;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MapoDb.Properties.Settings.MoonPro_ES3ConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro_ES3;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "ErrorLog": "Data Source=localhost\\sqlexpress;Initial Catalog=Elmah;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "AppData.Properties.Settings.C_TRACKConnectionString": "Data Source=localhost\\SQLEXPRESS;Initial Catalog=Jetco_C_TRACK;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MoonProEntities": "metadata=res://*/Models.MPModel.csdl|res://*/Models.MPModel.ssdl|res://*/Models.MPModel.msl;provider=System.Data.SqlClient;provider connection string=\"data source=localhost\\SQLEXPRESS;initial catalog=Jetco_MoonPro;persist security info=True;user id=steamware;password=viadante16;multipleactiveresultsets=True;application name=EntityFramework\"", + "MagData.Properties.Settings.MoonPro_MAGConnectionString": "Data Source=localhost\\SQLEXPRESS;Initial Catalog=Jetco_MoonPro_MAG;Persist Security Info=True;User ID=steamware;Password=viadante16;", + "MapoMonEntities": "metadata=res://*/Models.MapoModel.csdl|res://*/Models.MapoModel.ssdl|res://*/Models.MapoModel.msl;provider=System.Data.SqlClient;provider connection string=\"data source=localhost\\SQLEXPRESS;initial catalog=Jetco_MoonPro;persist security info=True;user id=steamware;password=viadante16;multipleactiveresultsets=True;application name=EntityFramework\"", + "SteamWare.Properties.Settings.DbConfConnectionString": "Data Source=localhost\\sqlexpress;Initial Catalog=Jetco_MoonPro;Persist Security Info=True;User ID=steamware;Password=viadante16;" + }, + "jsonConnStrRules": { + "DefaultConnection": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro;Trusted_Connection=True;MultipleActiveResultSets=true", + "MP.Stats": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro_STATS;User ID=steamware;Password=viadante16;integrated security=False;MultipleActiveResultSets=True;App=MP.STATS;", + "MP.Prog": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro_PROG;User ID=steamware;Password=viadante16;integrated security=False;MultipleActiveResultSets=True;App=MP.Prog;", + "MP.Land": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro;User ID=steamware;Password=viadante16;integrated security=False;MultipleActiveResultSets=True;App=MP.Land;", + "MP.Mon": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro;User ID=steamware;Password=viadante16;integrated security=False;MultipleActiveResultSets=True;App=MP.Mon;", + "MP.Tab": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.TAB3;", + "MP.Data": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.Spec;", + "MP.Inve": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro_MAG; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;", + "MP.IS": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro_IS; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;", + "MP.All": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro; User ID=steamware; Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.All;", + "MP.Mag": "Server=localhost\\SQLEXPRESS;Database=Jetco_MoonPro_MAG; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.Mag;", + "BaseUrl": "https://maposrv.egalware.com/", + "downloadPath": "C:\\Steamware\\installers\\MP", + "Redis": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", + "RedisAdmin": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true", + "maxAge": "2000", + "cacheCheckArtUsato": 2, + "redisLongTimeCache": 15, + "MpIoBaseUrl": "http://localhost/MP/IO/", + "BaseUrlJumper": "http://maposrv.egalware.com/mp/inve/Jumper?" + } +} \ No newline at end of file diff --git a/WebConfigSetter/Objects.cs b/WebConfigSetter/Objects.cs index b6f74a5..c0b649d 100644 --- a/WebConfigSetter/Objects.cs +++ b/WebConfigSetter/Objects.cs @@ -5,7 +5,8 @@ namespace WebConfigSetter public enum operationMode { readConf = 0, - writeConf + writeConf, + reorgConf } public class jsonAppConfig diff --git a/WebConfigSetter/Program.cs b/WebConfigSetter/Program.cs index dad6970..164a55d 100644 --- a/WebConfigSetter/Program.cs +++ b/WebConfigSetter/Program.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json.Linq; using System; using System.IO; +using System.Linq; using System.Reflection; using System.Xml; @@ -22,9 +23,10 @@ namespace WebConfigSetter #region Protected Properties - protected static string baseDir { get; set; } = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);//@"c:\Steamware\WebConfigSetter"; + //@"c:\Steamware\WebConfigSetter"; + protected static string baseDir { get; set; } = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); #if DEBUG - protected static string baseWebAppDir { get; set; } = @"\\iis02\c$\inetpub\wwwroot\MP\"; + protected static string baseWebAppDir { get; set; } = @"\\iis01\c$\inetpub\wwwroot\MP\"; #else protected static string baseWebAppDir { get; set; } = @"c:\inetpub\wwwroot\MP\"; @@ -34,7 +36,7 @@ namespace WebConfigSetter protected static string currentSetFile { get; set; } = $@"{confDir}\default.json"; /// - /// modalità scrittura (altrimenti legge e carica conf parsando i files) + /// Modalità operativa: lettura/scrittura/riorg file conf /// protected static operationMode opMode { get; set; } = operationMode.readConf; @@ -56,7 +58,7 @@ namespace WebConfigSetter Console.WriteLine(separatore); Console.WriteLine(""); Console.WriteLine("Sintassi: WebConfigSetter.exe $1 $2 $3"); - Console.WriteLine("$1: Modalità operativa (0=read, 1=write)"); + Console.WriteLine("$1: Modalità operativa (0=read [default], 1=write, 2=riorganizzazione)"); Console.WriteLine("$2: WebApp directory di base"); Console.WriteLine("$3: SetName da applicare"); Console.WriteLine(separatore); @@ -67,16 +69,13 @@ namespace WebConfigSetter // carico parametri opzionali if (args.Length > 0) { - opMode = args[0] == "1" ? operationMode.writeConf : operationMode.readConf; + setOpMode(args[0]); } else { - Console.WriteLine($"Modalità operativa 0=read, 1=write [{opMode}]"); + Console.WriteLine($"Modalità operativa 0=read [default], 1=write, 2=riorganizzazione [{opMode}]"); userInput = Console.ReadLine(); - if (!string.IsNullOrEmpty(userInput)) - { - opMode = userInput == "1" ? operationMode.writeConf : operationMode.readConf; - } + setOpMode(userInput); } if (args.Length > 1) { @@ -119,20 +118,48 @@ namespace WebConfigSetter Console.WriteLine(separatore); } + /// + /// impostazione modalità operativa da parametro + /// + /// + private static void setOpMode(string currOpt) + { + switch (currOpt) + { + case "0": + opMode = operationMode.readConf; + break; + case "1": + opMode = operationMode.writeConf; + break; + case "2": + opMode = operationMode.reorgConf; + break; + default: + opMode = operationMode.readConf; + break; + } + } + /// /// Esecuzione richiesta principale /// private static void processRequest() { - // caso 1: acquisisco conf - if (opMode == operationMode.readConf) + switch (opMode) { - readConfToFiles(); - } - // caso 2: effettuo sostituzioni - else - { - writeConfToFiles(); + case operationMode.readConf: + readConfToFiles(); + break; + case operationMode.writeConf: + writeConfToFiles(); + break; + case operationMode.reorgConf: + reorgConfFile(); + break; + default: + readConfToFiles(); + break; } } @@ -234,6 +261,11 @@ namespace WebConfigSetter } } + // STEP 3: riordino blocchi configurazione + currConfig.appSettRules = currConfig.appSettRules.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); + currConfig.connStrRules = currConfig.connStrRules.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); + currConfig.jsonConnStrRules = currConfig.jsonConnStrRules.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); + // serializzo! string rawData = JsonConvert.SerializeObject(currConfig, Newtonsoft.Json.Formatting.Indented); @@ -365,6 +397,41 @@ namespace WebConfigSetter } } + private static void reorgConfFile() + { + // check file exists... + if (File.Exists(currentSetFile)) + { + // leggo il file delle configurazioni da applicare... + string rawData = File.ReadAllText(currentSetFile); + if (!string.IsNullOrEmpty(rawData)) + { + // leggo conf + currConfig = JsonConvert.DeserializeObject(rawData); + + // riordino blocchi configurazione + currConfig.appSettRules = currConfig.appSettRules.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); + currConfig.connStrRules = currConfig.connStrRules.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); + currConfig.jsonConnStrRules = currConfig.jsonConnStrRules.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); + + // salvo: serializzo! + rawData = JsonConvert.SerializeObject(currConfig, Newtonsoft.Json.Formatting.Indented); + + // salvo il file di conf! + File.WriteAllText(currentSetFile, rawData); + + } + else + { + Console.WriteLine($"Errore: file conf vuoto: {currentSetFile}"); + } + } + else + { + Console.WriteLine($"Errore: file conf non trovato: {currentSetFile}"); + } + } + #endregion Private Methods } } \ No newline at end of file diff --git a/WebConfigSetter/WebConfigSetter.csproj b/WebConfigSetter/WebConfigSetter.csproj index a447574..02d8c77 100644 --- a/WebConfigSetter/WebConfigSetter.csproj +++ b/WebConfigSetter/WebConfigSetter.csproj @@ -24,6 +24,9 @@ Always + + Always + Always