public List<severity> severityGetAll() { List<severity> lstseverity = new List<severity>(); try { DataTable dt = SqlHelper.ExecuteDataset(SqlImplHelper.getConnectionString(), "severityGetAll").Tables[0]; if (dt.Rows.Count > 0) { int colSeverityId = dt.Columns["SeverityId"].Ordinal; int colSeverityDescription = dt.Columns["SeverityDescription"].Ordinal; int colSLATimeToResponse = dt.Columns["SLATimeToResponse"].Ordinal; for (int i = 0; dt.Rows.Count > i; i++) { severity NewEnt = new severity(); NewEnt.SeverityId = Int32.Parse(dt.Rows[i].ItemArray[colSeverityId].ToString()); NewEnt.SeverityDescription = dt.Rows[i].ItemArray[colSeverityDescription].ToString(); NewEnt.SLATimeToResponse = Int32.Parse(dt.Rows[i].ItemArray[colSLATimeToResponse].ToString()); lstseverity.Add(NewEnt); } } return lstseverity; } catch(Exception ex) { throw ex; } }
public int severityAdd( severity severity) { try { return (int)SqlHelper.ExecuteScalar(SqlImplHelper.getConnectionString(), "severityAdd", severity.SeverityDescription, severity.SLATimeToResponse); } catch(Exception ex) { throw ex; } }
public severity severityGetById(int SeverityId) { try { DataTable dt = SqlHelper.ExecuteDataset(SqlImplHelper.getConnectionString(), "severityGetById", SeverityId).Tables[0]; severity NewEnt = new severity(); if(dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; NewEnt.SeverityId = Int32.Parse(dr["SeverityId"].ToString()); NewEnt.SeverityDescription = dr["SeverityDescription"].ToString(); NewEnt.SLATimeToResponse = Int32.Parse(dr["SLATimeToResponse"].ToString()); } return NewEnt; } catch(Exception ex) { throw ex; } }
public bool severityUpdate(severity severity) { try { int update = SqlHelper.ExecuteNonQuery(SqlImplHelper.getConnectionString(), "severityUpdate", severity.SeverityId, severity.SeverityDescription, severity.SLATimeToResponse); if (update > 0) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
public static LogLevel GetNLoggerLogLevel(severity s) { switch (s) { case severity.debug: return(LogLevel.Debug); case severity.info: return(LogLevel.Info); case severity.error: return(LogLevel.Error); case severity.warning: return(LogLevel.Warn); case severity.success: return(LogLevel.Info); default: //why required? return(LogLevel.Info); } }
private static void log(string context, string fileName, severity level, string member, int lineNumber, string toLog, string primaryState = null, string secondaryState = null) { if (Globals.WorldClosed) { return; } if (Static.numLines >= Static.maxNumLines) { return; } if (level <= severity.WARNING) { DebugNotify("Logger: " + level, 2000, level); } Static.m_logItems.AddTail(new LogItem() { context = context, fileName = fileName, time = DateTime.Now, level = level, member = member, lineNumber = lineNumber, toLog = toLog, primaryState = primaryState, secondaryState = secondaryState, thread = ThreadTracker.GetNameOrNumber() }); if (MyAPIGateway.Parallel != null) { MyAPIGateway.Parallel.StartBackground(logLoop); } }
public void debugNotify(string message, int disappearTimeMs = 2000, severity level = severity.TRACE) { notify(message, disappearTimeMs, level); }
/// <summary> /// For logging WARNING and higher severity. /// </summary> /// <param name="toLog">message to log</param> /// <param name="methodName">calling method</param> /// <param name="level">severity level</param> /// <param name="primaryState">class specific, appears before secondary state in log</param> /// <param name="secondaryState">class specific, appears before message in log</param> public void log(string toLog, string methodName, severity level = severity.TRACE, string primaryState = null, string secondaryState = null) { log(level, methodName, toLog, primaryState, secondaryState); }
/// <summary> /// For a safe way to display a message as a notification, not conditional. /// </summary> /// <param name="message">the notification message</param> /// <param name="disappearTimeMs">time on screen, in milliseconds</param> /// <param name="level">severity level</param> /// <returns>true iff the message was displayed</returns> public static void notify(string message, int disappearTimeMs = 2000, severity level = severity.TRACE) { if (worldClosed) return; MyFontEnum font = fontForSeverity(level); if (MyAPIGateway.Utilities != null) MyAPIGateway.Utilities.TryInvokeOnGameThread(() => MyAPIGateway.Utilities.ShowNotification(message, disappearTimeMs, font)); //else // log(severity.WARNING, "ShowNotificationDebug()", "MyAPIGateway.Utilities == null"); }
/// <summary> /// Do not call from outside Logger class, use debugLog or alwaysLog. /// </summary> /// <param name="level">severity level</param> /// <param name="methodName">calling method</param> /// <param name="toLog">message to log</param> /// <param name="primaryState">class specific, appears before secondary state in log</param> /// <param name="secondaryState">class specific, appears before message in log</param> private void log(severity level, string methodName, string toLog, string primaryState = null, string secondaryState = null) { if (loggingClosed) return; if (numLines >= maxNumLines) return; if (level <= severity.WARNING) debugNotify("Logger: " + level, 2000, level); else if (level > MinimumLevel) return; if (toLog.Contains("\n") || toLog.Contains("\r")) { string[] split = toLog.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in split) log(level, methodName, line, primaryState, secondaryState); return; } lock_log.AcquireExclusive(); try { if (logWriter == null) if (MyAPIGateway.Utilities == null || !createLog()) return; // cannot log string context; if (f_context != null) try { context = f_context.Invoke(); } catch { context = string.Empty; } else context = string.Empty; if (primaryState == null) { if (f_state_primary != null) try { primaryState = f_state_primary.Invoke(); } catch { primaryState = string.Empty; } } if (secondaryState == null) { if (f_state_secondary != null) try { secondaryState = f_state_secondary.Invoke(); } catch { secondaryState = string.Empty; } } numLines++; appendWithBrackets(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff")); appendWithBrackets(level.ToString()); try { appendWithBrackets(ThreadTracker.GetNameOrNumber()); } catch { appendWithBrackets("N/A"); } appendWithBrackets(context); appendWithBrackets(m_classname); appendWithBrackets(methodName); appendWithBrackets(primaryState); appendWithBrackets(secondaryState); stringCache.Append(toLog); logWriter.WriteLine(stringCache); logWriter.Flush(); stringCache.Clear(); } catch (Exception ex) { debugNotify("Exception while logging", 2000, severity.ERROR); MyAPIGateway.Utilities.ShowMissionScreen(ex.GetType().Name, screenDescription: ex.ToString()); } finally { lock_log.ReleaseExclusive(); } }
protected void getEventsDetectionData() { DataTable dttEventsDetection = new DataTable(); dttEventsDetection.Columns.Add(new DataColumn("eventsDetectionId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("datetime", System.Type.GetType("System.DateTime"))); dttEventsDetection.Columns.Add(new DataColumn("eventStauts", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("eventStatusDescription", System.Type.GetType("System.String"))); dttEventsDetection.Columns.Add(new DataColumn("IDSId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("IDPS", System.Type.GetType("System.String"))); dttEventsDetection.Columns.Add(new DataColumn("idsName", System.Type.GetType("System.String"))); dttEventsDetection.Columns.Add(new DataColumn("eventsAlarmId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("severityId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("severityDescription", System.Type.GetType("System.String"))); dttEventsDetection.Columns.Add(new DataColumn("SLATimeToResponse", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("TaskId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("IDPSEventId", System.Type.GetType("System.Int32"))); List <eventsdetection> lstEvetnsDetection = new List <eventsdetection>(); eventsdetectionBus oEventsDetection = new eventsdetectionBus(); idsBus oIDPS = new idsBus(); eventsalarmBus oEventsAlarm = new eventsalarmBus(); severityBus oSeverity = new severityBus(); tasksBus oTask = new tasksBus(); taskstatusBus oTaskStatus = new taskstatusBus(); lstEvetnsDetection = oEventsDetection.eventsdetectionGetAll(); if (lstEvetnsDetection.Count > 0) { foreach (eventsdetection row in lstEvetnsDetection) { if (row.EventStatus == 2 || row.EventStatus == 5) //Closed, Rejected { continue; } ids auxIDPS = new ids(); eventsalarm auxEventAlarm = new eventsalarm(); severity auxSeverity = new severity(); tasks auxTask = new tasks(); taskstatus auxTaskStatus = new taskstatus(); auxIDPS = oIDPS.idsGetById(row.IdsId); auxEventAlarm = oEventsAlarm.eventsalarmGetById(row.EventsAlarmId); auxSeverity = oSeverity.severityGetById(auxEventAlarm.Severity); auxTask = oTask.tasksGetByEventsDetectionId(row.EventsDetectionId); auxTaskStatus = oTaskStatus.taskstatusGetById(row.EventStatus); dttEventsDetection.Rows.Add(row.EventsDetectionId, row.DateTime, row.EventStatus, auxTaskStatus.TaskStatusDescription, row.IdsId, auxIDPS.IdsIP, auxIDPS.idsName, row.EventsAlarmId, auxSeverity.SeverityId, auxSeverity.SeverityDescription, auxSeverity.SLATimeToResponse, auxTask.TaskId, row.IDPSEventId); } gvEventsDetection.DataSource = dttEventsDetection; gvEventsDetection.DataBind(); } }
/// <summary> /// For logging WARNING and higher severity. /// </summary> /// <param name="level">severity level</param> /// <param name="methodName">calling method</param> /// <param name="toLog">message to log</param> /// <param name="primaryState">class specific, appears before secondary state in log</param> /// <param name="secondaryState">class specific, appears before message in log</param> public void log(severity level, string methodName, string toLog, string primaryState = null, string secondaryState = null) { if (closed || level > maxLevelToLog) return; lock_log.AcquireExclusive(); try { if (logWriter == null) if (MyAPIGateway.Utilities == null || !createLog()) return; // cannot log if (f_gridName != null) gridName = f_gridName.Invoke(); if (primaryState == null) { if (f_state_primary != null) default_primary = f_state_primary.Invoke(); primaryState = default_primary; } if (secondaryState == null) { if (f_state_secondary != null) default_secondary = f_state_secondary.Invoke(); secondaryState = default_secondary; } if (toLog == null) toLog = "no message"; if (numLines >= maxNumLines) return; numLines++; appendWithBrackets(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff")); appendWithBrackets(level.ToString()); appendWithBrackets(gridName); appendWithBrackets(className); appendWithBrackets(methodName); appendWithBrackets(primaryState); appendWithBrackets(secondaryState); stringCache.Append(toLog); logWriter.WriteLine(stringCache); logWriter.Flush(); stringCache.Clear(); } catch { } finally { lock_log.ReleaseExclusive(); } }
public static void Execute( severity s, object o, string instanceId = null, bool removeNewlinesFromMessage = true ) { try { //dont check forever var methodInfo = new StackFrame(1).GetMethod(); if (methodInfo.DeclaringType.Name == typeof(LogIt).Name) { methodInfo = new StackFrame(2).GetMethod(); } if (methodInfo.DeclaringType.Name == typeof(LogIt).Name) { methodInfo = new StackFrame(3).GetMethod(); } //for format consistency //https://social.msdn.microsoft.com/Forums/vstudio/en-US/bb926074-d593-4e0b-8754-7026acc607ec/datetime-tostring-colon-replaced-with-period?forum=csharpgeneral var dt = DateTime.UtcNow; var dts = dt.ToString("yyyy-MM-dd HH") + ":" + dt.ToString("mm") + ":" + dt.ToString("ss") + "." + dt.ToString("fff"); var ss = "[" + s.ToString().ToUpper() + "]"; var @class = (methodInfo.DeclaringType == null) ? "" : methodInfo.DeclaringType.Name ; var method = (methodInfo.DeclaringType == null) ? "" : methodInfo.Name ; o = o ?? ""; var msg = o.ToString(); //json convert instead? msg = !removeNewlinesFromMessage ? msg : msg.Replace("\r\n", " ").Replace("\n", " ") ; //currently just a string //var whereIAm = WhereAmI.Execute(stepUp: 3); //this is for cloud watch logs which requires space after timestamp: http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/send_logs_to_cwl.html var space = " "; var instance = string.IsNullOrWhiteSpace(instanceId) ? "" : $"|{instanceId}"; var log = $"{dts}{space}|{ss}|{@class}|{method}{instance}|{msg}"; if (s == severity.error) { Console.ForegroundColor = ConsoleColor.Red; } else if (s == severity.success) { Console.ForegroundColor = ConsoleColor.Green; } else if (s == severity.warning) { Console.ForegroundColor = ConsoleColor.Yellow; } else { Console.ForegroundColor = ConsoleColor.White; } //TODO: check exists if (!doNotlogToLambda) { LambdaLogger.Log(log); } //if (_log != null) { // _log.Log(logLevel: GetLogLevel(s), log); //} nlogger.Log(level: GetNLoggerLogLevel(s), message: log); } catch (Exception ex) { E("error in LogIt|" + ex.Message); } }
/// <summary> /// For logging messages in any build. /// </summary> public static void AlwaysLog(string toLog, severity level = severity.TRACE, string context = null, string primaryState = null, string secondaryState = null, [CallerFilePath] string filePath = null, [CallerMemberName] string member = null, [CallerLineNumber] int lineNumber = 0) { log(context, Path.GetFileName(filePath), level, member, lineNumber, toLog, primaryState, secondaryState); }
protected void btnSave_Click(object sender, EventArgs e) { severity auxNewSeverity = new severity(); severityBus oSeverity = new severityBus(); bool needRequiredFields = false; int saveType = 0; if (btnNew.Enabled) { saveType = 2; } if (!btnNew.Enabled) { saveType = 1; } if (String.IsNullOrEmpty(txtSeverityDescription.Text)) { needRequiredFields = true; } if (String.IsNullOrEmpty(txtSLATTR.Text)) { needRequiredFields = true; } if (!needRequiredFields) { auxNewSeverity.SeverityDescription = txtSeverityDescription.Text; auxNewSeverity.SLATimeToResponse = Convert.ToInt32(txtSLATTR.Text); switch (saveType) { case 1: //save if (oSeverity.severityAdd(auxNewSeverity) > 0) { lblMessage.Text = "Datos guardados correctamente!"; clearFields(); activateFields(false, true); btnNew.Enabled = true; gvGetData(); } else { lblMessage.Text = "Error al guardar los datos!"; } break; case 2: //update auxNewSeverity.SeverityId = Convert.ToInt32(txtSeverityId.Text); if (oSeverity.severityUpdate(auxNewSeverity)) { lblMessage.Text = "Datos actualizados correctamente!"; clearFields(); activateFields(false, true); btnSave.Enabled = false; btnNew.Enabled = true; gvGetData(); } else { lblMessage.Text = "Error al guardar los datos!"; } break; } } else { lblMessage.Text = "Error, existen campos sin completar!"; } }
public bool severityUpdate(severity severity) { severityImpl oseverityImpl = new severityImpl(); return(oseverityImpl.severityUpdate(severity)); }
private void getTasksData() { DataTable dttTasks = new DataTable(); dttTasks.Columns.Add(new DataColumn("taskId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("datetime", System.Type.GetType("System.DateTime"))); dttTasks.Columns.Add(new DataColumn("taskTittle", System.Type.GetType("System.String"))); dttTasks.Columns.Add(new DataColumn("eventsDetectionId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("taskStatusId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("statusDescription", System.Type.GetType("System.String"))); dttTasks.Columns.Add(new DataColumn("userId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("userName", System.Type.GetType("System.String"))); dttTasks.Columns.Add(new DataColumn("serverityId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("sererityDescription", System.Type.GetType("System.String"))); dttTasks.Columns.Add(new DataColumn("SLAStatus", System.Type.GetType("System.String"))); List <tasks> lstTasks = new List <tasks>(); tasksBus oTasks = new tasksBus(); eventsdetectionBus oEventsDetection = new eventsdetectionBus(); idsBus oIDPS = new idsBus(); eventsalarmBus oEventsAlarm = new eventsalarmBus(); severityBus oSeverity = new severityBus(); taskstatusBus oTaskStatus = new taskstatusBus(); usersBus oUsers = new usersBus(); lstTasks = oTasks.tasksGetAll(); if (lstTasks.Count > 0) { foreach (tasks row in lstTasks) { if (row.TaskStatudId == 2 || row.TaskStatudId == 5) //Closed, Rejected { continue; } taskstatus auxStatus = new taskstatus(); users auxUser = new users(); eventsdetection auxEventDetection = new eventsdetection(); eventsalarm auxEventAlarm = new eventsalarm(); severity auxSeverity = new severity(); string SLASatus = ""; auxStatus = oTaskStatus.taskstatusGetById(row.TaskStatudId); auxUser = oUsers.usersGetById(row.UserId); auxEventDetection = oEventsDetection.eventsdetectionGetById(row.EventsDetectionId); auxEventAlarm = oEventsAlarm.eventsalarmGetById(auxEventDetection.EventsAlarmId); auxSeverity = oSeverity.severityGetById(auxEventAlarm.Severity); DateTime deadTime = row.DateTime; deadTime.AddMinutes(auxSeverity.SLATimeToResponse); if (DateTime.Now > deadTime) { SLASatus = "Vencido"; } if (DateTime.Now < deadTime) { SLASatus = "En término"; } dttTasks.Rows.Add(row.TaskId, row.DateTime, row.TaskTittle, row.EventsDetectionId, row.TaskStatudId, auxStatus.TaskStatusDescription, row.UserId, auxUser.UserName, auxEventAlarm.Severity, auxSeverity.SeverityDescription, SLASatus); } gvTasks.DataSource = dttTasks; gvTasks.DataBind(); } }
/// <summary> /// For a safe way to display a message as a notification, not conditional. Logs a warning iff message cannot be displayed. /// </summary> /// <param name="message">the notification message</param> /// <param name="disappearTimeMs">time on screen, in milliseconds</param> /// <param name="level">severity level</param> /// <returns>true iff the message was displayed</returns> public void notify(string message, int disappearTimeMs = 2000, severity level = severity.TRACE) { MyFontEnum font = fontForSeverity(level); if (MyAPIGateway.Utilities != null) MyAPIGateway.Utilities.ShowNotification(message, disappearTimeMs, font); else log(severity.WARNING, "ShowNotificationDebug()", "MyAPIGateway.Utilities == null"); }
/// <summary> /// For logging WARNING and higher severity. /// </summary> /// <param name="toLog">message to log</param> /// <param name="methodName">calling method</param> /// <param name="level">severity level</param> /// <param name="primaryState">class specific, appears before secondary state in log</param> /// <param name="secondaryState">class specific, appears before message in log</param> public void alwaysLog(string toLog, string methodName, severity level = severity.TRACE, string primaryState = null, string secondaryState = null) { log(level, methodName, toLog, primaryState, secondaryState); }
public int severityAdd(severity severity) { severityImpl oseverityImpl = new severityImpl(); return oseverityImpl.severityAdd( severity); }
public static void debugNotify(string message, int disappearTimeMs = 2000, severity level = severity.TRACE) { notify(message, disappearTimeMs, level); }
public bool severityUpdate(severity severity) { severityImpl oseverityImpl = new severityImpl(); return oseverityImpl.severityUpdate( severity); }
private static MyFontEnum fontForSeverity(severity level = severity.TRACE) { switch (level) { case severity.INFO: return MyFontEnum.Green; case severity.TRACE: return MyFontEnum.White; case severity.DEBUG: return MyFontEnum.Debug; case severity.WARNING: return MyFontEnum.Red; case severity.ERROR: return MyFontEnum.Red; case severity.FATAL: return MyFontEnum.Red; default: return MyFontEnum.White; } }
/// <summary> /// See <see cref="ILogger.WriteLine"/> /// </summary> public void WriteLine(severity severity, string message, params object[] args) { Console.WriteLine("{0}: {1}", severity.ToString(), string.Format(message, args)); }
/// <summary> /// For logging WARNING and higher severity. /// </summary> /// <param name="level">severity level</param> /// <param name="methodName">calling method</param> /// <param name="toLog">message to log</param> /// <param name="primaryState">class specific, appears before secondary state in log</param> /// <param name="secondaryState">class specific, appears before message in log</param> public void log(severity level, string methodName, string toLog, string primaryState = null, string secondaryState = null) { if (closed) { return; } lock_log.AcquireExclusive(); try { if (logWriter == null) { if (MyAPIGateway.Utilities == null || !createLog()) { return; // cannot log } } if (f_gridName != null) { gridName = f_gridName.Invoke(); } if (primaryState == null) { if (f_state_primary != null) { default_primary = f_state_primary.Invoke(); } primaryState = default_primary; } if (secondaryState == null) { if (f_state_secondary != null) { default_secondary = f_state_secondary.Invoke(); } secondaryState = default_secondary; } if (toLog == null) { toLog = "no message"; } if (numLines >= maxNumLines) { return; } numLines++; appendWithBrackets(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff")); appendWithBrackets(level.ToString()); appendWithBrackets(gridName); appendWithBrackets(className); appendWithBrackets(methodName); appendWithBrackets(primaryState); appendWithBrackets(secondaryState); stringCache.Append(toLog); logWriter.WriteLine(stringCache); logWriter.Flush(); stringCache.Clear(); } catch { } finally { lock_log.ReleaseExclusive(); } }
public static void alwaysLog(string className, string toLog, severity level = severity.TRACE, string context = null, string primaryState = null, string secondaryState = null, [CallerMemberName] string member = null, [CallerLineNumber] int lineNumber = 0) { log(context, className, level, member, lineNumber, toLog, primaryState, secondaryState); }
public bool severityUpdate( severity severity) { try { int update = SqlHelper.ExecuteNonQuery(SqlImplHelper.getConnectionString(), "severityUpdate", severity.SeverityId, severity.SeverityDescription, severity.SLATimeToResponse); if (update > 0) { return true; } else { return false; } } catch(Exception ex) { throw ex; } }
public void debugLog(string toLog, severity level = severity.TRACE, string primaryState = null, string secondaryState = null, [CallerMemberName] string member = null, [CallerLineNumber] int lineNumber = 0) { log(level, member, lineNumber, toLog, primaryState, secondaryState); }
public void debugLog(bool condition, Func<string> toLog, severity level = severity.TRACE, string primaryState = null, string secondaryState = null, [CallerMemberName] string member = null, [CallerLineNumber] int lineNumber = 0) { if (condition) log(level, member, lineNumber, toLog.Invoke(), primaryState, secondaryState); }
private static void log(string context, string className, severity level, string member, int lineNumber, string toLog, string primaryState = null, string secondaryState = null) { if (Static == null) return; if (Static.numLines >= Static.maxNumLines) return; if (level <= severity.WARNING) debugNotify("Logger: " + level, 2000, level); Static.m_logItems.Enqueue(new LogItem() { context = context, className = className, time = DateTime.Now, level = level, member = member, lineNumber = lineNumber, toLog = toLog, primaryState = primaryState, secondaryState = secondaryState, thread = ThreadTracker.GetNameOrNumber() }); if (MyAPIGateway.Parallel != null) MyAPIGateway.Parallel.StartBackground(logLoop); }
public int severityAdd(severity severity) { severityImpl oseverityImpl = new severityImpl(); return(oseverityImpl.severityAdd(severity)); }
/// <summary> /// Do not call from outside Logger class, use debugLog or alwaysLog. /// </summary> /// <param name="level">severity level</param> /// <param name="methodName">calling method</param> /// <param name="toLog">message to log</param> /// <param name="primaryState">class specific, appears before secondary state in log</param> /// <param name="secondaryState">class specific, appears before message in log</param> private void log(severity level, string member, int lineNumber, string toLog, string primaryState = null, string secondaryState = null) { if (Static == null) return; if (Static.numLines >= Static.maxNumLines) return; if (level <= severity.WARNING) debugNotify("Logger: " + level, 2000, level); else if (level > MinimumLevel) return; Static.m_logItems.Enqueue(new LogItem() { context = f_context.InvokeIfExists(), className = m_classname, time = DateTime.Now, level = level, member = member, lineNumber = lineNumber, toLog = toLog, primaryState = primaryState ?? f_state_primary.InvokeIfExists(), secondaryState = secondaryState ?? f_state_secondary.InvokeIfExists(), thread = ThreadTracker.GetNameOrNumber() }); if (MyAPIGateway.Parallel != null) MyAPIGateway.Parallel.StartBackground(logLoop); }
protected void btnSearch_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtSearch.Text)) { DataTable dttTasks = new DataTable(); dttTasks.Columns.Add(new DataColumn("taskId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("datetime", System.Type.GetType("System.DateTime"))); dttTasks.Columns.Add(new DataColumn("taskTittle", System.Type.GetType("System.String"))); dttTasks.Columns.Add(new DataColumn("eventsDetectionId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("taskStatusId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("statusDescription", System.Type.GetType("System.String"))); dttTasks.Columns.Add(new DataColumn("userId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("userName", System.Type.GetType("System.String"))); dttTasks.Columns.Add(new DataColumn("serverityId", System.Type.GetType("System.Int32"))); dttTasks.Columns.Add(new DataColumn("sererityDescription", System.Type.GetType("System.String"))); dttTasks.Columns.Add(new DataColumn("SLAStatus", System.Type.GetType("System.String"))); tasks auxtTasks = new tasks(); tasksBus oTasks = new tasksBus(); eventsdetectionBus oEventsDetection = new eventsdetectionBus(); idsBus oIDPS = new idsBus(); eventsalarmBus oEventsAlarm = new eventsalarmBus(); severityBus oSeverity = new severityBus(); taskstatusBus oTaskStatus = new taskstatusBus(); usersBus oUsers = new usersBus(); auxtTasks = oTasks.tasksGetById(Convert.ToInt32(txtSearch.Text)); if (auxtTasks != null) { taskstatus auxStatus = new taskstatus(); users auxUser = new users(); eventsdetection auxEventDetection = new eventsdetection(); eventsalarm auxEventAlarm = new eventsalarm(); severity auxSeverity = new severity(); auxStatus = oTaskStatus.taskstatusGetById(auxtTasks.TaskStatudId); auxUser = oUsers.usersGetById(auxtTasks.UserId); auxEventDetection = oEventsDetection.eventsdetectionGetById(auxtTasks.EventsDetectionId); auxEventAlarm = oEventsAlarm.eventsalarmGetById(auxEventDetection.EventsAlarmId); auxSeverity = oSeverity.severityGetById(auxEventAlarm.Severity); //resolver SLAStatus dttTasks.Rows.Add(auxtTasks.TaskId, auxtTasks.DateTime, auxtTasks.TaskTittle, auxtTasks.EventsDetectionId, auxtTasks.TaskStatudId, auxStatus.TaskStatusDescription, auxtTasks.UserId, auxUser.UserName, auxEventAlarm.Severity, auxSeverity.SeverityDescription, ""); gvTasks.DataSource = dttTasks; gvTasks.DataBind(); } else { lblMessage.Text = "Busqueda sin resultados..."; } } }
public void debugLog(bool condition, Func<string> toLog, string methodName, severity level = severity.TRACE, string primaryState = null, string secondaryState = null) { if (condition) log(level, methodName, toLog.Invoke(), primaryState, secondaryState); }
protected void getTaskData(int taskId) { DataTable dttTask = new DataTable(); dttTask.Columns.Add(new DataColumn("taskId", System.Type.GetType("System.Int32"))); dttTask.Columns.Add(new DataColumn("datetime", System.Type.GetType("System.DateTime"))); dttTask.Columns.Add(new DataColumn("taskTittle", System.Type.GetType("System.String"))); dttTask.Columns.Add(new DataColumn("eventsDetectionId", System.Type.GetType("System.Int32"))); dttTask.Columns.Add(new DataColumn("taskStatusId", System.Type.GetType("System.Int32"))); dttTask.Columns.Add(new DataColumn("statusDescription", System.Type.GetType("System.String"))); dttTask.Columns.Add(new DataColumn("userId", System.Type.GetType("System.Int32"))); dttTask.Columns.Add(new DataColumn("userName", System.Type.GetType("System.String"))); dttTask.Columns.Add(new DataColumn("serverityId", System.Type.GetType("System.Int32"))); dttTask.Columns.Add(new DataColumn("sererityDescription", System.Type.GetType("System.String"))); dttTask.Columns.Add(new DataColumn("SLAStatus", System.Type.GetType("System.String"))); tasks auxtTasks = new tasks(); tasksBus oTasks = new tasksBus(); eventsdetectionBus oEventsDetection = new eventsdetectionBus(); idsBus oIDPS = new idsBus(); eventsalarmBus oEventsAlarm = new eventsalarmBus(); severityBus oSeverity = new severityBus(); taskstatusBus oTaskStatus = new taskstatusBus(); usersBus oUsers = new usersBus(); auxtTasks = oTasks.tasksGetById(taskId); if (auxtTasks != null) { taskstatus auxStatus = new taskstatus(); users auxUser = new users(); eventsdetection auxEventDetection = new eventsdetection(); eventsalarm auxEventAlarm = new eventsalarm(); severity auxSeverity = new severity(); string SLASatus = ""; auxStatus = oTaskStatus.taskstatusGetById(auxtTasks.TaskStatudId); auxUser = oUsers.usersGetById(auxtTasks.UserId); auxEventDetection = oEventsDetection.eventsdetectionGetById(auxtTasks.EventsDetectionId); auxEventAlarm = oEventsAlarm.eventsalarmGetById(auxEventDetection.EventsAlarmId); auxSeverity = oSeverity.severityGetById(auxEventAlarm.Severity); DateTime deadTime = auxtTasks.DateTime; deadTime.AddMinutes(auxSeverity.SLATimeToResponse); if (DateTime.Now > deadTime) { SLASatus = "Vencido"; } if (DateTime.Now < deadTime) { SLASatus = "En término"; } dttTask.Rows.Add(auxtTasks.TaskId, auxtTasks.DateTime, auxtTasks.TaskTittle, auxtTasks.EventsDetectionId, auxtTasks.TaskStatudId, auxStatus.TaskStatusDescription, auxtTasks.UserId, auxUser.UserName, auxEventAlarm.Severity, auxSeverity.SeverityDescription, SLASatus); gvTask.DataSource = dttTask; gvTask.DataBind(); } }
protected void btnSearch_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtSearch.Text)) { DataTable dttEventsDetection = new DataTable(); dttEventsDetection.Columns.Add(new DataColumn("eventsDetectionId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("datetime", System.Type.GetType("System.DateTime"))); dttEventsDetection.Columns.Add(new DataColumn("eventStauts", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("eventStatusDescription", System.Type.GetType("System.String"))); dttEventsDetection.Columns.Add(new DataColumn("IDSId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("IDPS", System.Type.GetType("System.String"))); dttEventsDetection.Columns.Add(new DataColumn("idsName", System.Type.GetType("System.String"))); dttEventsDetection.Columns.Add(new DataColumn("eventsAlarmId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("severityId", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("severityDescription", System.Type.GetType("System.String"))); dttEventsDetection.Columns.Add(new DataColumn("SLATimeToResponse", System.Type.GetType("System.Int32"))); dttEventsDetection.Columns.Add(new DataColumn("TaskId", System.Type.GetType("System.Int32"))); eventsdetection auxEvetnsDetection = new eventsdetection(); eventsdetectionBus oEventsDetection = new eventsdetectionBus(); idsBus oIDPS = new idsBus(); eventsalarmBus oEventsAlarm = new eventsalarmBus(); severityBus oSeverity = new severityBus(); tasksBus oTask = new tasksBus(); auxEvetnsDetection = oEventsDetection.eventsdetectionGetById(Convert.ToInt32(txtSearch.Text)); if (auxEvetnsDetection != null) { string strStatus = ""; ids auxIDPS = new ids(); eventsalarm auxEventAlarm = new eventsalarm(); severity auxSeverity = new severity(); tasks auxTask = new tasks(); switch (auxEvetnsDetection.EventStatus) { case 1: strStatus = "Pendiente"; break; case 2: strStatus = "En tratamiento"; break; case 3: strStatus = "Cerrado"; break; } auxIDPS = oIDPS.idsGetById(auxEvetnsDetection.IdsId); auxEventAlarm = oEventsAlarm.eventsalarmGetById(auxEvetnsDetection.EventsAlarmId); auxSeverity = oSeverity.severityGetById(auxEventAlarm.Severity); auxTask = oTask.tasksGetByEventsDetectionId(auxEvetnsDetection.EventsDetectionId); dttEventsDetection.Rows.Add(auxEvetnsDetection.EventsDetectionId, auxEvetnsDetection.DateTime, auxEvetnsDetection.EventStatus, strStatus, auxEvetnsDetection.IdsId, auxIDPS.IdsIP, auxIDPS.idsName, auxEvetnsDetection.EventsAlarmId, auxSeverity.SeverityId, auxSeverity.SeverityDescription, auxSeverity.SLATimeToResponse, auxTask.TaskId); gvEventsDetection.DataSource = dttEventsDetection; gvEventsDetection.DataBind(); } else { lblMessage.Text = "Busqueda sin resultados..."; } } }