using SteamWare; using System.Text.RegularExpressions; namespace AppData { /// /// macchina di gestione degli stati /// public class stateMachine { protected DS_AppTableAdapters.AnagEventiTableAdapter taEv; protected DS_AppTableAdapters.TraEv2StatiTableAdapter taEv2St; //protected DS_applicazioneTableAdapters.IstObjTableAdapter taIstObj; protected stateMachine() { avvioTA(); setupConnectionStringBase(); } /// /// avvia table adapters /// private void avvioTA() { taEv = new DS_AppTableAdapters.AnagEventiTableAdapter(); taEv2St = new DS_AppTableAdapters.TraEv2StatiTableAdapter(); //taIstObj = new DS_applicazioneTableAdapters.IstObjTableAdapter(); } /// /// effettua setup dei connection strings da web.config della singola applicazione /// protected virtual void setupConnectionStringBase() { string connString = memLayer.ML.confReadString("CTrackConnectionString"); // connections strings del db taEv.Connection.ConnectionString = connString; taEv2St.Connection.ConnectionString = connString; //taIstObj.Connection.ConnectionString = connString; } public static stateMachine st = new stateMachine(); /// /// restituisce il tipo di comando associato... /// /// /// public tipoAzione azioneComando(inputComando comando) { Match testNumTask = Regex.Match(comando.valore, mUtils.reNumTask); Match testOper = Regex.Match(comando.valore, mUtils.reCodOper); Match testPost = Regex.Match(comando.valore, mUtils.reCodPost); tipoAzione _azione = tipoAzione.noAct; // se è un SET OPR o POST è un azione IMPLICITA... if (testOper.Success || testPost.Success) { _azione = tipoAzione.esegui; } else if (testNumTask.Success) { _azione = tipoAzione.esegui; } else if (dataLayer.man.taAF.getByKey(comando.currCmdIn).Rows.Count > 0) { _azione = tipoAzione.esegui; } else { // altrimenti controllo azione string toDo = ""; try { toDo = taEv.getByKey(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; } } return _azione; } } public enum tipoAzione { annulla, conferma, esegui, noAct, setup } public enum tipoEsito { error, ok, undef } }