From 43a05def8e8b8c3499eb20ae1b08077cbdc77a3d Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 19 Oct 2018 17:58:19 +0200 Subject: [PATCH] =?UTF-8?q?Up=C3=A8date=20LAND=20x=20gestione=20import=20w?= =?UTF-8?q?eb.config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MP-LAND/Controllers/HomeController.cs | 50 ++++++++++++++++----------- MP-LAND/MP-LAND.csproj | 3 ++ MP-LAND/Models/AnagraficaOperatori.cs | 1 + MP-LAND/Models/ConfigTmp.cs | 22 ++++++++++++ MP-LAND/Models/MPModel.Context.cs | 1 + MP-LAND/Models/MPModel.Designer.cs | 2 +- MP-LAND/Models/MPModel.edmx | 35 +++++++++++++++++++ MP-LAND/Models/MPModel.edmx.diagram | 1 + MP-LAND/Views/Home/ConfigMan.cshtml | 34 +++++++++++------- 9 files changed, 116 insertions(+), 33 deletions(-) create mode 100644 MP-LAND/Models/ConfigTmp.cs diff --git a/MP-LAND/Controllers/HomeController.cs b/MP-LAND/Controllers/HomeController.cs index 3f37728e..2c247dc1 100644 --- a/MP-LAND/Controllers/HomeController.cs +++ b/MP-LAND/Controllers/HomeController.cs @@ -154,7 +154,7 @@ namespace MP.Controllers /// /// /// - public ActionResult ConfigMan() + public ActionResult ConfigMan(string sorgente) { ViewBag.Title = "Steamware's MAPO Suite - Configurations"; @@ -165,37 +165,47 @@ namespace MP.Controllers { ViewBag.Message = "File web.config presente"; // leggo il file di conf caricato... - System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/FileUpload/web.config"); + System.Configuration.Configuration rootWebConfig = WebConfigurationManager.OpenWebConfiguration("~/FileUpload/web.config"); - // imposto sorgente !!!FARE!!! - string sorgente = "MAPO"; - // resetto tab import - memLayer.ML.taConfigTmp.reset(sorgente); - // carico dati! - var settings = rootWebConfig.AppSettings.Settings; - foreach (var item in settings.AllKeys) + if (sorgente != "" && sorgente != null) { - memLayer.ML.taConfigTmp.insertQuery(sorgente, item, settings[item].Value, string.Format("{0}-{1}", sorgente, item)); - } - // salvo in viewbag gli elenchi 0/1/2 (tutte, nuove, modificate) + // resetto tab import + memLayer.ML.taConfigTmp.reset(sorgente); + // carico dati! + var settings = rootWebConfig.AppSettings.Settings; + foreach (var item in settings.AllKeys) + { + memLayer.ML.taConfigTmp.insertQuery(sorgente, item, settings[item].Value, string.Format("{0}-{1}", sorgente, item)); + } + // salvo in viewbag gli elenchi 0/1/2 (tutte, nuove, modificate) - ViewBag.keyList = "CARICATO!"; + using (var ctx = new MoonProEntities()) + { + try + { + // esegue stored procedure come function, recuperando chiave desiderata... + var elConfig = ctx.ConfigTmp.ToList(); + ViewBag.elConfig = elConfig; + } + catch + { } + } + + ViewBag.keyList = "CARICATO!"; + } } else { ViewBag.Message = "Attenzione: nessun file presente!"; } - // se c'è il file carico le info da importare... - - // VIEW! - return View(); + return View((object)ViewBag.elConfig); } [HttpPost] - public ActionResult UploadFile(HttpPostedFileBase file) + public ActionResult UploadFile(HttpPostedFileBase file, string sorgente) { - if (file != null && file.ContentLength > 0) + if (file != null && file.ContentLength > 0 && sorgente != "") { try { @@ -212,7 +222,7 @@ namespace MP.Controllers { ViewBag.Message = "Non è stato selezionato alcun file."; } - return RedirectToAction("ConfigMan", "Home"); + return RedirectToAction("ConfigMan", "Home", new { sorgente }); } diff --git a/MP-LAND/MP-LAND.csproj b/MP-LAND/MP-LAND.csproj index 54ebbd7e..3dad0258 100644 --- a/MP-LAND/MP-LAND.csproj +++ b/MP-LAND/MP-LAND.csproj @@ -136,6 +136,9 @@ MPModel.tt + + MPModel.tt + True True diff --git a/MP-LAND/Models/AnagraficaOperatori.cs b/MP-LAND/Models/AnagraficaOperatori.cs index dc5bf00d..50c4f336 100644 --- a/MP-LAND/Models/AnagraficaOperatori.cs +++ b/MP-LAND/Models/AnagraficaOperatori.cs @@ -19,5 +19,6 @@ namespace MP.Models public string Nome { get; set; } public Nullable isAdmin { get; set; } public string authKey { get; set; } + public string CodOprExt { get; set; } } } diff --git a/MP-LAND/Models/ConfigTmp.cs b/MP-LAND/Models/ConfigTmp.cs new file mode 100644 index 00000000..e9f0fad8 --- /dev/null +++ b/MP-LAND/Models/ConfigTmp.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// Codice generato da un modello. +// +// Le modifiche manuali a questo file potrebbero causare un comportamento imprevisto dell'applicazione. +// Se il codice viene rigenerato, le modifiche manuali al file verranno sovrascritte. +// +//------------------------------------------------------------------------------ + +namespace MP.Models +{ + using System; + using System.Collections.Generic; + + public partial class ConfigTmp + { + public string sorgente { get; set; } + public string chiave { get; set; } + public string valore { get; set; } + public string note { get; set; } + } +} diff --git a/MP-LAND/Models/MPModel.Context.cs b/MP-LAND/Models/MPModel.Context.cs index 1dec6e64..49c4b2c8 100644 --- a/MP-LAND/Models/MPModel.Context.cs +++ b/MP-LAND/Models/MPModel.Context.cs @@ -29,6 +29,7 @@ namespace MP.Models public virtual DbSet AnagKeyValue { get; set; } public virtual DbSet AnagraficaOperatori { get; set; } + public virtual DbSet ConfigTmp { get; set; } public virtual ObjectResult stp_AKV_getByKey(string nomeVar) { diff --git a/MP-LAND/Models/MPModel.Designer.cs b/MP-LAND/Models/MPModel.Designer.cs index 4d3d7778..b74228ed 100644 --- a/MP-LAND/Models/MPModel.Designer.cs +++ b/MP-LAND/Models/MPModel.Designer.cs @@ -1,4 +1,4 @@ -// Generazione del codice predefinita abilitata per il modello 'C:\Users\samuele\Documents\VisualStudioProjects\MoonPro_dotnet\MP\Models\MPModel.edmx'. +// Generazione del codice predefinita abilitata per il modello 'C:\Users\samuele.steamw\Documents\VisualStudioProject\MoonPro_dotnet\MP-LAND\Models\MPModel.edmx'. // Per abilitare la generazione del codice legacy, modificare il valore della proprietà della finestra di progettazione 'Strategia di generazione del codice // su 'Legacy ObjectContext'. Questa proprietà è disponibile nella finestra Proprietà quando il modello è // aperto nella finestra di progettazione. diff --git a/MP-LAND/Models/MPModel.edmx b/MP-LAND/Models/MPModel.edmx index da2c3725..e650c374 100644 --- a/MP-LAND/Models/MPModel.edmx +++ b/MP-LAND/Models/MPModel.edmx @@ -24,6 +24,17 @@ + + + + + + + + + + + @@ -31,6 +42,7 @@ + @@ -52,6 +64,7 @@ + @@ -69,6 +82,17 @@ + + + + + + + + + + + @@ -92,6 +116,7 @@ + @@ -100,6 +125,16 @@ + + + + + + + + + + diff --git a/MP-LAND/Models/MPModel.edmx.diagram b/MP-LAND/Models/MPModel.edmx.diagram index 8c2b1239..8f02a6b8 100644 --- a/MP-LAND/Models/MPModel.edmx.diagram +++ b/MP-LAND/Models/MPModel.edmx.diagram @@ -7,6 +7,7 @@ + diff --git a/MP-LAND/Views/Home/ConfigMan.cshtml b/MP-LAND/Views/Home/ConfigMan.cshtml index 9d7bedab..09478503 100644 --- a/MP-LAND/Views/Home/ConfigMan.cshtml +++ b/MP-LAND/Views/Home/ConfigMan.cshtml @@ -1,4 +1,6 @@ -
+@model IEnumerable + +
@@ -39,6 +41,9 @@

Step 1 - File Upload

@using (Html.BeginForm("UploadFile", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })) { + + +


@@ -49,17 +54,22 @@

Step 2 - File IMPORT

@ViewBag.keyList - @*@using (Html.BeginForm("ProcessFile", - "Home", - FormMethod.Post, - new { enctype = "multipart/form-data" })) - { - -

- -

-
@ViewBag.Message
- }*@ +
+
+ @if (Model != null) + { + foreach (var item in Model) + { +
+ @item.chiave +
+
+ @item.valore +
+ } + } +
+