169 lines
3.9 KiB
C#
169 lines
3.9 KiB
C#
using AppData;
|
|
using SteamWare;
|
|
using System;
|
|
|
|
namespace NKC_WF.WebUserControls
|
|
{
|
|
public partial class cmp_kitImpCheck : BaseUserControl
|
|
{
|
|
/// <summary>
|
|
/// Folder x SQL import
|
|
/// </summary>
|
|
protected string _SqlImportDir = memLayer.ML.CRS("_SqlImportDir");
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// Nome file caricato
|
|
/// </summary>
|
|
public string fileName
|
|
{
|
|
get
|
|
{
|
|
return hfFileName.Value;
|
|
}
|
|
set
|
|
{
|
|
hfFileName.Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Nome file caricato
|
|
/// </summary>
|
|
public string batchName
|
|
{
|
|
get
|
|
{
|
|
return hfBatchName.Value;
|
|
}
|
|
set
|
|
{
|
|
hfBatchName.Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// NUM TASK eseguito
|
|
/// </summary>
|
|
public string numTask
|
|
{
|
|
get
|
|
{
|
|
return hfNumTask.Value;
|
|
}
|
|
set
|
|
{
|
|
hfNumTask.Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Esito OK a check import
|
|
/// </summary>
|
|
public string checkOk
|
|
{
|
|
get
|
|
{
|
|
return hfCheckOk.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCheckOk.Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// File effettivamente caricato
|
|
/// </summary>
|
|
public string imported
|
|
{
|
|
get
|
|
{
|
|
return hfImported.Value;
|
|
}
|
|
set
|
|
{
|
|
hfImported.Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Verifico il file e aggiorno visualizazione di conseguenza
|
|
/// </summary>
|
|
private void processValidation()
|
|
{
|
|
// controllo ed aggiorno...
|
|
bool fileOk = !string.IsNullOrEmpty(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);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Effettua un test di importazione o l'importazione effettiva
|
|
/// </summary>
|
|
/// <param name="testOnly">true= solo test, false= vero import (SE non ci sono errori)</param>
|
|
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();
|
|
}
|
|
}
|
|
} |