///<summary>Sets IsProcessed to true on all eService signals of the passed in severity.</summary> public static void ProcessSignalsForSeverity(eServiceSignalSeverity severity) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), severity); return; } string command = "UPDATE eservicesignal SET IsProcessed=1 WHERE Severity=" + POut.Int((int)severity); Db.NonQ(command); if (severity == eServiceSignalSeverity.Error) //Delete corresponding alert. { AlertItems.DeleteFor(AlertType.EConnectorError); } }
///<summary>Inserts a healthy heartbeat.</summary> public static void InsertHeartbeatForService(eServiceCode serviceCode) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), serviceCode); return; } AlertItems.DeleteFor(AlertType.EConnectorDown); string command = "SELECT * FROM eservicesignal WHERE ServiceCode=" + POut.Int((int)serviceCode) + " AND Severity IN (" + POut.Int((int)eServiceSignalSeverity.NotEnabled) + "," + POut.Int((int)eServiceSignalSeverity.Working) + "," + POut.Int((int)eServiceSignalSeverity.Critical) + ") ORDER BY SigDateTime DESC " + DbHelper.LimitWhere(1);//only select not enabled, working, and critical statuses. EServiceSignal eServiceSignalLast = Crud.EServiceSignalCrud.SelectOne(command); DateTime dtNow = MiscData.GetNowDateTime(); //If initializing or changing state to working from not working, insert two signals; An anchor and a rolling timestamp. if (eServiceSignalLast == null || eServiceSignalLast.Severity != eServiceSignalSeverity.Working) //First ever heartbeat or critical which was not previously critical. { if (eServiceSignalLast != null && eServiceSignalLast.Severity == eServiceSignalSeverity.Critical //Do not create a signal if the eConnector was stopped because of an update && (eServiceSignalLast.SigDateTime > UpdateHistories.GetLastUpdateHistory().DateTimeUpdated || UpdateHistories.GetLastUpdateHistory().DateTimeUpdated.AddMinutes(10) < dtNow)) { //Changing from critical to working so alert user that this change took place and tell them how long we were in critical state. //Insert() will also insert Alert. Insert(new EServiceSignal() { ServiceCode = (int)serviceCode, Severity = eServiceSignalSeverity.Error, SigDateTime = dtNow, IsProcessed = false, Description = "Listener was critical for " + DateTime.Now.Subtract(eServiceSignalLast.SigDateTime).ToStringHmm() }); } Insert(new EServiceSignal() { ServiceCode = (int)serviceCode, Severity = eServiceSignalSeverity.Working, SigDateTime = dtNow, IsProcessed = true, Description = "Heartbeat Anchor" }); //anchor heartbeat Insert(new EServiceSignal() { ServiceCode = (int)serviceCode, Severity = eServiceSignalSeverity.Working, SigDateTime = dtNow.AddSeconds(1), IsProcessed = true, Description = "Heartbeat" }); //rolling heartbeat return; } eServiceSignalLast.SigDateTime = dtNow; Update(eServiceSignalLast); }