142 lines
4.1 KiB
C#
142 lines
4.1 KiB
C#
using SteamWare;
|
|
|
|
namespace BusinessLogic
|
|
{
|
|
/// <summary>
|
|
/// macchina di gestione degli stati
|
|
/// </summary>
|
|
public class stateMachine
|
|
{
|
|
#if false
|
|
protected DS_applicazioneTableAdapters.EventiTableAdapter taEv;
|
|
private DS_applicazioneTableAdapters.TraEv2StatiTableAdapter taEv2St;
|
|
private DS_applicazioneTableAdapters.IstObjTableAdapter taIstObj;
|
|
#endif
|
|
protected stateMachine()
|
|
{
|
|
avvioTA();
|
|
setupConnectionStringBase();
|
|
}
|
|
/// <summary>
|
|
/// avvia table adapters
|
|
/// </summary>
|
|
private void avvioTA()
|
|
{
|
|
#if false
|
|
taEv = new DS_applicazioneTableAdapters.EventiTableAdapter();
|
|
taEv2St = new DS_applicazioneTableAdapters.TraEv2StatiTableAdapter();
|
|
taIstObj = new DS_applicazioneTableAdapters.IstObjTableAdapter();
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// effettua setup dei connection strings da web.config delal singola applicazione
|
|
/// </summary>
|
|
protected virtual void setupConnectionStringBase()
|
|
{
|
|
#if false
|
|
string connString = memLayer.ML.confReadString("XPSConnectionString");
|
|
// connections strings del db
|
|
taEv.Connection.ConnectionString = connString;
|
|
taEv2St.Connection.ConnectionString = connString;
|
|
taIstObj.Connection.ConnectionString = connString;
|
|
#endif
|
|
}
|
|
public static stateMachine st = new stateMachine();
|
|
/// <summary>
|
|
/// restituisce il tipo di comando associato...
|
|
/// </summary>
|
|
/// <param name="comando"></param>
|
|
/// <returns></returns>
|
|
public tipoAzione azioneComando(inputComando comando)
|
|
{
|
|
tipoAzione _azione = tipoAzione.noAct;
|
|
string toDo = "";
|
|
#if false
|
|
try
|
|
{
|
|
toDo = taEv.getByCodEvento(comando.currCmdIn)[0].Action;
|
|
}
|
|
catch
|
|
{ }
|
|
switch (toDo)
|
|
{
|
|
case "ok":
|
|
_azione = tipoAzione.conferma;
|
|
break;
|
|
case "ko":
|
|
_azione = tipoAzione.annulla;
|
|
break;
|
|
case "act":
|
|
_azione = tipoAzione.esegui;
|
|
break;
|
|
default:
|
|
_azione = tipoAzione.noAct;
|
|
break;
|
|
}
|
|
#endif
|
|
return _azione;
|
|
}
|
|
/// <summary>
|
|
/// verifica se sia possibile, dagli input segnalati, eseguire un comando secondo la tab transizione stati e restituisce adeguato output su esecuzione/errore e eventuali messaggi
|
|
/// </summary>
|
|
/// <param name="codMappa">mappa di riferimento</param>
|
|
/// <param name="codTipoObj">oggetto di riferimento</param>
|
|
/// <param name="codStato">stato corrente</param>
|
|
/// <param name="codEvento">evento</param>
|
|
/// <returns>oggetto di risposta x esito ok/ko</returns>
|
|
public tipoEsito doAction(string codMappa, string idxObj, string codStato, string codEvento)
|
|
{
|
|
tipoEsito answ = tipoEsito.undef;
|
|
string codTipoObj = ""; // di default pongo a vuoto...
|
|
#if false
|
|
try
|
|
{
|
|
codTipoObj = taIstObj.getByIdxObj(idxObj)[0].CodObj;
|
|
}
|
|
catch
|
|
{ }
|
|
// controllo su tab se ci sia riga con transizione
|
|
DS_applicazione.TraEv2StatiDataTable tabEv2St = taEv2St.getByKey(codMappa, codTipoObj, codStato, codEvento);
|
|
if (tabEv2St.Rows.Count > 0)
|
|
{
|
|
switch (codTipoObj)
|
|
{
|
|
case "U":
|
|
// aggiorno singolo obj
|
|
XPS.obj.taObj.updateStato(tabEv2St[0].NextCodStato, user_std.UtSn.utente, DateTime.Now, idxObj);
|
|
// chiamo update stato obj ancestors:
|
|
XPS.obj.taSP.sp_updateAncestorState(string.Format("{0}%", idxObj.Substring(0, 8)));
|
|
break;
|
|
case "D":
|
|
// sto scannando il DDT aggiorno tutto il tree...
|
|
string codObjCommon = idxObj.Replace("D", "%");
|
|
XPS.obj.taObj.updateStatoTree(tabEv2St[0].NextCodStato, user_std.UtSn.utente, DateTime.Now, codObjCommon);
|
|
break;
|
|
}
|
|
// salvo esito
|
|
answ = tipoEsito.ok;
|
|
}
|
|
else
|
|
{
|
|
// non c'è, segnalo errore...
|
|
answ = tipoEsito.error;
|
|
}
|
|
#endif
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
public enum tipoAzione
|
|
{
|
|
annulla,
|
|
conferma,
|
|
esegui,
|
|
noAct
|
|
}
|
|
public enum tipoEsito
|
|
{
|
|
error,
|
|
ok,
|
|
undef
|
|
}
|
|
} |