public List<tasks> tasksGetAll() { List<tasks> lsttasks = new List<tasks>(); try { DataTable dt = SqlHelper.ExecuteDataset(SqlImplHelper.getConnectionString(), "tasksGetAll").Tables[0]; if (dt.Rows.Count > 0) { int colTaskId = dt.Columns["TaskId"].Ordinal; int colEventsDetectionId = dt.Columns["EventsDetectionId"].Ordinal; int colTaskStatudId = dt.Columns["TaskStatudId"].Ordinal; int colUserId = dt.Columns["UserId"].Ordinal; int colTaskTittle = dt.Columns["TaskTittle"].Ordinal; int colDateTime = dt.Columns["DateTime"].Ordinal; for (int i = 0; dt.Rows.Count > i; i++) { tasks NewEnt = new tasks(); NewEnt.TaskId = Int32.Parse(dt.Rows[i].ItemArray[colTaskId].ToString()); NewEnt.EventsDetectionId= Int32.Parse(dt.Rows[i].ItemArray[colEventsDetectionId].ToString()); NewEnt.TaskStatudId = Int32.Parse(dt.Rows[i].ItemArray[colTaskStatudId].ToString()); NewEnt.UserId = Int32.Parse(dt.Rows[i].ItemArray[colUserId].ToString()); NewEnt.TaskTittle = dt.Rows[i].ItemArray[colTaskTittle].ToString(); NewEnt.DateTime = DateTime.Parse(dt.Rows[i].ItemArray[colDateTime].ToString()); lsttasks.Add(NewEnt); } } return lsttasks; } catch(Exception ex) { throw ex; } }
public int tasksAdd( tasks tasks) { try { return (int)SqlHelper.ExecuteScalar(SqlImplHelper.getConnectionString(), "tasksAdd", tasks.EventsDetectionId, tasks.TaskStatudId, tasks.UserId, tasks.TaskTittle, tasks.DateTime); } catch(Exception ex) { throw ex; } }
public bool tasksUpdate(tasks tasks) { tasksImpl otasksImpl = new tasksImpl(); return otasksImpl.tasksUpdate( tasks); }
public int tasksAdd(tasks tasks) { tasksImpl otasksImpl = new tasksImpl(); return otasksImpl.tasksAdd(tasks); }
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..."; } } }
void tmrChecks_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd"; culture.DateTimeFormat.LongTimePattern = ""; Thread.CurrentThread.CurrentCulture = culture; DataTable dttResult = new DataTable(); libIDPSWatcherImpl libIDPS = new libIDPSWatcherImpl(); eventsdetectionBus oEventsDetection = new eventsdetectionBus(); tasksBus oTask = new tasksBus(); int newEventDetectionId; int counter; dttResult = libIDPS.getIDPSData(); if (dttResult.Rows.Count > 0) { counter = 0; foreach (DataRow row in dttResult.Rows) { DateTime dateTime = new DateTime(); if (String.IsNullOrEmpty(row[3].ToString())) dateTime = DateTime.Now; else dateTime = DateTime.Parse(row[3].ToString()); //DateTime.ParseExact(row[3].ToString(), "yyyy/MM/dd", CultureInfo.InvariantCulture); newEventDetectionId = 0; eventsdetection newEventDetection = new eventsdetection(); newEventDetection.IdsId = Convert.ToInt32(row[0].ToString()); newEventDetection.EventsAlarmId = Convert.ToInt32(row[1].ToString()); newEventDetection.IDPSEventId = Convert.ToInt32(row[2].ToString()); newEventDetection.DateTime = dateTime; newEventDetection.EventStatus = 1; newEventDetectionId = oEventsDetection.eventsdetectionAdd(newEventDetection); if (newEventDetectionId > 0) { tasks newTask = new tasks(); newTask.TaskStatudId = 1; newTask.DateTime = dateTime; newTask.UserId = 0; if (row[4].ToString().Length > 49) newTask.TaskTittle = row[4].ToString().Substring(0, 49); else newTask.TaskTittle = row[4].ToString(); newTask.EventsDetectionId = newEventDetectionId; if (oTask.tasksAdd(newTask) > 0) { counter++; lblCount.Text = counter.ToString(); } } } lblTimeStamp.Text = DateTime.Now.ToString(); } }
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(); } }
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..."; } } }
public tasks tasksGetByEventsDetectionId(int EventsDetectionId) { try { DataTable dt = SqlHelper.ExecuteDataset(SqlImplHelper.getConnectionString(), "tasksGetByIntrusionDetectionId", EventsDetectionId).Tables[0]; tasks NewEnt = new tasks(); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; NewEnt.TaskId = Int32.Parse(dr["TaskId"].ToString()); NewEnt.EventsDetectionId = Int32.Parse(dr["EventsDetectionId"].ToString()); NewEnt.TaskStatudId = Int32.Parse(dr["TaskStatudId"].ToString()); NewEnt.UserId = Int32.Parse(dr["UserId"].ToString()); NewEnt.TaskTittle = dr["TaskTittle"].ToString(); NewEnt.DateTime = DateTime.Parse(dr["DateTime"].ToString()); } return NewEnt; } catch (Exception ex) { throw ex; } }
public bool tasksUpdate( tasks tasks) { try { int update = (int)SqlHelper.ExecuteScalar(SqlImplHelper.getConnectionString(), "tasksUpdate", tasks.TaskId, tasks.EventsDetectionId, tasks.TaskStatudId, tasks.UserId, tasks.TaskTittle, tasks.DateTime); if (update > 0) { return true; } else { return false; } } catch(Exception ex) { throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone(); culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd"; culture.DateTimeFormat.LongTimePattern = ""; Thread.CurrentThread.CurrentCulture = culture; taskdetails auxNewTaskDetail = new taskdetails(); taskdetailsBus oTaskDetail = new taskdetailsBus(); tasks auxTasks = new tasks(); tasksBus oTasks = new tasksBus(); users auxUser = new users(); usersBus oUser = new usersBus(); eventsdetectionBus oEventsDetection = new eventsdetectionBus(); bool needRequiredFields = false; int saveType = 0; if (btnNew.Enabled) saveType = 2; if (!btnNew.Enabled) saveType = 1; if (String.IsNullOrEmpty(txtDateTime.Text)) needRequiredFields = true; if (String.IsNullOrEmpty(txtEffortHours.Text)) needRequiredFields = true; if (String.IsNullOrEmpty(txtDetail.Text)) needRequiredFields = true; if (String.IsNullOrEmpty(txtTaskId.Text)) needRequiredFields = true; if (!needRequiredFields) { auxUser = oUser.usersGetByUserName(HttpContext.Current.User.Identity.Name); DateTime dateTime = DateTime.ParseExact(txtDateTime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); auxNewTaskDetail.DateTime = dateTime; auxNewTaskDetail.EffortHours = Convert.ToDecimal(txtEffortHours.Text); auxNewTaskDetail.Details = txtDetail.Text; auxNewTaskDetail.TaskId = Convert.ToInt32(txtTaskId.Text); auxNewTaskDetail.UserId = Convert.ToInt32(ddlUsers.SelectedValue); int auxTaskStatus = Convert.ToInt32(ddlTaskStatus.SelectedValue); int auxUserAssigned = Convert.ToInt32(ddlUsers.SelectedValue); switch (saveType) { case 1: //save if (oTaskDetail.taskdetailsAdd(auxNewTaskDetail) > 0) { if (!oTasks.tasksUpdateStatus(Convert.ToInt32(txtTaskId.Text), auxTaskStatus )) { lblMessage.Text = "Imposible actualizar nuevo Estado de Tarea...\n"; } auxTasks = oTasks.tasksGetById(Convert.ToInt32(txtTaskId.Text)); if (!oEventsDetection.eventsdetectionUpdateStatus(auxTasks.EventsDetectionId, auxTaskStatus)) { lblMessage.Text = "Imposible actualizar nuevo Estado del Evento de Intrusión...\n"; } if (!oTasks.tasksUpdateUser(Convert.ToInt32(txtTaskId.Text), auxUserAssigned)) { lblMessage.Text = "Imposible actualizar nuevo Usuario asignado a la Tarea...\n"; } clearFields(); activateFields(false, true); btnNew.Enabled = true; getTaskDetailsData(TaskId); lblMessage.Text = "Datos guardados correctamente!"; } else lblMessage.Text = "Error al guardar los datos!"; break; case 2: //update if (Convert.ToInt32(hfTaskStatusOrigin.Value) != auxTaskStatus) { if (!oTasks.tasksUpdateStatus(Convert.ToInt32(txtTaskId.Text), auxTaskStatus )) { lblMessage.Text = "Imposible actualizar nuevo Estado de Tarea...\n"; } if (!oEventsDetection.eventsdetectionUpdateStatus(auxTasks.EventsDetectionId, auxTaskStatus)) { lblMessage.Text = "Imposible actualizar nuevo Estado del Evento de Intrusión...\n"; } } if (Convert.ToInt32(hfUserOrigin.Value) != auxUserAssigned) { if (!oTasks.tasksUpdateUser(Convert.ToInt32(txtTaskId.Text), auxUserAssigned)) { lblMessage.Text = "Imposible actualizar nuevo Usuario asignado a la Tarea...\n"; } } auxNewTaskDetail.TaskDetailsId = Convert.ToInt32(txtTaskDetailId.Text); if (oTaskDetail.taskdetailsUpdate(auxNewTaskDetail)) { lblMessage.Text = "Datos actualizados correctamente!"; clearFields(); activateFields(false, true); btnSave.Enabled = false; getTaskDetailsData(TaskId); lblMessage.Text = "Datos actualizados correctamente!"; } else lblMessage.Text = "Error al guardar los datos!"; break; } } else { lblMessage.Text = "Datos requeridos no cargados..."; } }
protected void gvTaskDetails_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = gvTaskDetails.SelectedRow; tasks auxTask = new tasks(); tasksBus oTask = new tasksBus(); if ((Label)row.FindControl("taskDetailsId") != null) { txtTaskDetailId.Text = ((Label)row.FindControl("taskDetailsId")).Text; } else { txtTaskDetailId.Text = ""; } if ((Label)row.FindControl("datetime") != null) { txtDateTime.Text = ((Label)row.FindControl("datetime")).Text; } else { txtDateTime.Text = ""; } if ((Label)row.FindControl("effortHours") != null) { txtEffortHours.Text = ((Label)row.FindControl("effortHours")).Text; } else { txtEffortHours.Text = ""; } if ((Label)row.FindControl("taskDetails") != null) { txtDetail.Text = ((Label)row.FindControl("taskDetails")).Text; } else { txtDetail.Text = ""; } if ((Label)row.FindControl("taskId") != null) { txtTaskId.Text = ((Label)row.FindControl("taskId")).Text; } else { txtTaskId.Text = ""; } try { auxTask = oTask.tasksGetById(Convert.ToInt32(txtTaskId.Text)); ddlTaskStatus.SelectedValue = auxTask.TaskStatudId.ToString(); ddlUsers.SelectedValue = auxTask.UserId.ToString(); hfTaskStatusOrigin.Value = auxTask.TaskStatudId.ToString(); hfUserOrigin.Value = auxTask.UserId.ToString(); } catch { } activateFields(true, false); btnSave.Enabled = true; }
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(); } }