using AppData; using SteamWare; using System; namespace NKC_WF.WebUserControls { public partial class cmp_kitImpCheck : BaseUserControl { /// /// Folder x SQL import /// protected string _SqlImportDir = memLayer.ML.CRS("_SqlImportDir"); protected void Page_Load(object sender, EventArgs e) { } /// /// Nome file caricato /// public string fileName { get { return hfFileName.Value; } set { hfFileName.Value = value; } } /// /// Nome file caricato /// public string batchName { get { return hfBatchName.Value; } set { hfBatchName.Value = value; } } /// /// NUM TASK eseguito /// public string numTask { get { return hfNumTask.Value; } set { hfNumTask.Value = value; } } /// /// Esito OK a check import /// public string checkOk { get { return hfCheckOk.Value; } set { hfCheckOk.Value = value; } } /// /// File effettivamente caricato /// public string imported { get { return hfImported.Value; } set { hfImported.Value = value; } } /// /// Verifico il file e aggiorno visualizazione di conseguenza /// private void processValidation() { // controllo ed aggiorno... bool fileOk = fileName != ""; bool testOk = checkOk == "YES"; bool importOk = imported == "TRUE"; string newClass1 = fileOk ? "alert alert-success" : "alert alert-secondary"; string newClass2 = testOk ? "alert alert-success" : "alert alert-secondary"; string newClass3 = importOk ? "alert alert-success" : "alert alert-secondary"; updateClass(divStep1, newClass1); updateClass(divStep2, newClass2); updateClass(divStep3, newClass3); } private static void updateClass(System.Web.UI.HtmlControls.HtmlGenericControl currControl, string newClass) { currControl.Attributes.Remove("class"); currControl.Attributes.Add("class", newClass); } /// /// Effettua un test di importazione o l'importazione effettiva /// /// true= solo test, false= vero import (SE non ci sono errori) public void tryImport(bool testOnly) { DateTime adesso = DateTime.Now; string dirImport = $"{_SqlImportDir}{adesso.ToString("yyyy-MM")}\\"; try { // chiamo procedura SQL x import BATCH... come test o reale secondo del parametro int numTicket = 0; var tabCount = DataLayer.man.taCount.getNextNum("NumTicket"); if (tabCount.Count == 1) { numTicket = tabCount[0].LastNum; } DataLayer.man.taImpLog.importCsvKit($"{dirImport}", fileName, batchName, ";", "\n", "2", numTicket, 0, 0, testOnly); // ora effettua validazione e mostra eventuale esito... processValidation(); } catch (Exception exc) { logger.lg.scriviLog($"KitCsvMan: Eccezione in IMPORT file:{Environment.NewLine}{exc}"); } } protected void lbtDoAction_Click(object sender, EventArgs e) { // in base a cosa ho in memoria procedo con successivo step, qui FAKE... if (fileName == "") { numTask = DateTime.Now.Second.ToString(); fileName = "TEST"; } else { if (checkOk != "OK") { checkOk = "OK"; } else { if (imported == "YES") { } else { imported = "YES"; } } } processValidation(); } } }