public void Reset() { EventThread.Enqueue("Reset", () => { #if VERSION0 Task.Delay(TimeSpan.FromMilliseconds(500)).Wait(); StopService(); Task.Delay(TimeSpan.FromMilliseconds(1000)).Wait(); StartService(); #else PS.ClearMessages(); MainTaskConfigured = false; #endif }); }
public SactaProxy(bool WebEnabled = true) { InitializeComponent(); if (WebEnabled) { SactaProxyWebApp = new SactaProxyWebApp(() => History); SactaProxyWebApp.UserActivityEvent += (sender, args) => { EventThread?.Enqueue("OnUserActivityEvent", () => { var idh = args.InOut ? HistoryItems.UserLogin : args.Cause == "" ? HistoryItems.UserLogout : HistoryItems.UserErrorAccess; History?.Add(idh, args.User, "", "", "", args.Cause); }); }; } else { SactaProxyWebApp = null; } }
protected void MainProcessing() { Logger.Info <SactaProxy>("Arrancando Servicio."); MainTaskSync = new System.Threading.ManualResetEvent(false); EventThread.Start(); MainTaskConfigured = ConfigureService(); StartWebServer(); History.Add(HistoryItems.ServiceStarted); do { EventThread.Enqueue("MainProcessing", () => { try { if (MainTaskConfigured == false) { StopManagers(true); StopWebServer(); MainTaskConfigured = ConfigureService(); StartWebServer(); } GlobalStateManager.MainStandbyCheck((isDual, isMain) => { if (isDual) { if (isMain && !PS.IsStarted) { //Logger.Info<SactaProxy>("Entrando en Modo DUAL-MAIN"); History.Add(HistoryItems.ServiceInMode, "", "", "Master"); StartManagers(); } else if (!isMain && PS.IsStarted) { //Logger.Info<SactaProxy>("Entrando en Modo DUAL-STANDBY"); History.Add(HistoryItems.ServiceInMode, "", "", "Standby"); StopManagers(); } } else { if (!PS.IsStarted) { //Logger.Info<SactaProxy>("Entrando en Modo SINGLE"); History.Add(HistoryItems.ServiceInMode, "", "", "Simple"); StartManagers(); } } }); } catch { } }); }while (MainTaskSync.WaitOne(TimeSpan.FromSeconds(2)) == false); StopManagers(true); StopWebServer(); History.Add(HistoryItems.ServiceEnded); EventThread.ControlledStop(); Logger.Info <SactaProxy>("Servicio Detenido."); }