protected void btnSave_Click(object sender, EventArgs e) { intrusionevents auxNewIntrusionEvents = new intrusionevents(); intrusioneventsBus oIntrusionEvents = new intrusioneventsBus(); bool needRequiredFields = false; int saveType = 0; if (btnNew.Enabled) saveType = 2; if (!btnNew.Enabled) saveType = 1; if (String.IsNullOrEmpty(txtIntrusionDetail.Text)) needRequiredFields = true; if ((String.IsNullOrEmpty(txtCVEId.Text)) && (String.IsNullOrEmpty(txtCWEId.Text)) && (String.IsNullOrEmpty(txtCAPECId.Text)) && (String.IsNullOrEmpty(txtOWASPId.Text))) needRequiredFields = true; if (!needRequiredFields) { if (txtIntrusionDetail.Text.Length > 49) auxNewIntrusionEvents.IntrusionEventDetail = txtIntrusionDetail.Text.Substring(0, 49); else auxNewIntrusionEvents.IntrusionEventDetail = txtIntrusionDetail.Text; auxNewIntrusionEvents.CVEId = txtCVEId.Text; auxNewIntrusionEvents.CWEId = txtCWEId.Text; auxNewIntrusionEvents.CAPECId = txtCAPECId.Text; auxNewIntrusionEvents.OWASPId = txtOWASPId.Text; switch (saveType) { case 1: //save if (oIntrusionEvents.intrusioneventsAdd(auxNewIntrusionEvents) > 0) { lblMessage.Text = "Datos guardados correctamente!"; clearFields(); activateFields(false, true); btnNew.Enabled = true; getIntrusionEventsData(); } else lblMessage.Text = "Error al guardar los datos!"; break; case 2: //update auxNewIntrusionEvents.IntrusionEventsId = Convert.ToInt32(txtIntrusionEventId.Text); if (oIntrusionEvents.intrusioneventsUpdate(auxNewIntrusionEvents)) { lblMessage.Text = "Datos actualizados correctamente!"; clearFields(); activateFields(false, true); btnSave.Enabled = false; getIntrusionEventsData(); } else lblMessage.Text = "Error al guardar los datos!"; break; } } }
protected void gvAlarms_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = gvAlarms.SelectedRow; eventsalarm auxEventsAlarm = new eventsalarm(); eventsalarmBus oEventsAlarm = new eventsalarmBus(); intrusionevents auxIntrusionEvent = new intrusionevents(); List<intrusionevents> lstIntrusionEventsAssigned = new List<intrusionevents>(); intrusioneventsBus oIntrusionEvents = new intrusioneventsBus(); List<eventsalarm_intrusionevents_mapping> lstEventsMapping = new List<eventsalarm_intrusionevents_mapping>(); eventsalarm_intrusionevents_mappingBus oEventsMapping = new eventsalarm_intrusionevents_mappingBus(); try { ddlSeverity.SelectedValue = ((Label)row.FindControl("severity")).Text; } catch { } if ((Label)row.FindControl("eventsAlarmId") != null) { txtEventAlarmId.Text = ((Label)row.FindControl("eventsAlarmId")).Text; } else { txtEventAlarmId.Text = ""; } if ((Label)row.FindControl("eventsAlarmTittle") != null) { txtEventsAlarmTittle.Text = ((Label)row.FindControl("eventsAlarmTittle")).Text; } else { txtEventsAlarmTittle.Text = ""; } if ((Label)row.FindControl("checkFrecuency") != null) { txtCheckFrequency.Text = ((Label)row.FindControl("checkFrecuency")).Text; } else { txtCheckFrequency.Text = ""; } if ((CheckBox)row.FindControl("active") != null) { chkActive.Checked = ((CheckBox)row.FindControl("active")).Checked; } else { chkActive.Checked = false; } auxEventsAlarm = oEventsAlarm.eventsalarmGetById(Convert.ToInt32(txtEventAlarmId.Text)); lstEventsMapping = oEventsMapping.eventsalarm_intrusionevents_mappingGetByEventsAlarmId(Convert.ToInt32(txtEventAlarmId.Text)); if (lstEventsMapping.Count > 0) { foreach (eventsalarm_intrusionevents_mapping rowMapping in lstEventsMapping) { auxIntrusionEvent = oIntrusionEvents.intrusioneventsGetById(rowMapping.IntrusionEventId); lstIntrusionEventsAssigned.Add(auxIntrusionEvent); } gvIntrusionEventsAssigned.DataSource = lstIntrusionEventsAssigned; gvIntrusionEventsAssigned.DataBind(); } ddlIDPS.SelectedValue = auxEventsAlarm.IdsId.ToString(); chkBIA.Items[0].Selected = Convert.ToBoolean(auxEventsAlarm.AffectConfidence); chkBIA.Items[1].Selected = Convert.ToBoolean(auxEventsAlarm.AffectIntegrity); chkBIA.Items[2].Selected = Convert.ToBoolean(auxEventsAlarm.AffectAvailability); getSignatureData(auxEventsAlarm.IdsId); ddlIDPSSignatures.SelectedValue = auxEventsAlarm.IdsSignatureCategoryId.ToString(); activateFields(true, false); btnSave.Enabled = true; }
protected void getIntrusionEventsData() { List<intrusionevents> lstIntrusionEvent = new List<intrusionevents>(); intrusioneventsBus oIntrusionEvents = new intrusioneventsBus(); ListItem intrusionItems = new ListItem(); lstIntrusionEvent = oIntrusionEvents.intrusioneventsGetAll(); if (lstIntrusionEvent.Count > 0) { gvIntrusionEvents.DataSource = lstIntrusionEvent; gvIntrusionEvents.DataBind(); } }
protected void getEventsAlarmData() { DataTable dttEventsAlarm = new DataTable(); dttEventsAlarm.Columns.Add(new DataColumn("eventsAlarmId", System.Type.GetType("System.Int32"))); dttEventsAlarm.Columns.Add(new DataColumn("eventsAlarmTittle", System.Type.GetType("System.String"))); dttEventsAlarm.Columns.Add(new DataColumn("checkFrecuency", System.Type.GetType("System.Int32"))); dttEventsAlarm.Columns.Add(new DataColumn("serverity", System.Type.GetType("System.Int32"))); dttEventsAlarm.Columns.Add(new DataColumn("severityDescription", System.Type.GetType("System.String"))); dttEventsAlarm.Columns.Add(new DataColumn("SLATimeToResponse", System.Type.GetType("System.Int32"))); dttEventsAlarm.Columns.Add(new DataColumn("active", System.Type.GetType("System.Boolean"))); List<eventsalarm> lstEventsAlarm = new List<eventsalarm>(); eventsalarmBus oEventsAlarm = new eventsalarmBus(); intrusioneventsBus oIntrusionEvents = new intrusioneventsBus(); severityBus oSeverity = new severityBus(); lstEventsAlarm = oEventsAlarm.eventsalarmGetAll(); if (lstEventsAlarm.Count > 0) { foreach (eventsalarm row in lstEventsAlarm) { intrusionevents auxIntrusionEvent = new intrusionevents(); severity auxSeverity = new severity(); auxSeverity = oSeverity.severityGetById(row.Severity); dttEventsAlarm.Rows.Add(row.EventsAlarmId, row.EventsAlarmTittle, row.CheckFrecuency, row.Severity, auxSeverity.SeverityDescription, auxSeverity.SLATimeToResponse, row.Active); } gvAlarms.DataSource = dttEventsAlarm; gvAlarms.DataBind(); } }
protected void gvEvents_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = gvEvents.SelectedRow; intrusionevents auxIntrusionEvents = new intrusionevents(); intrusioneventsBus oIntrusionEvent = new intrusioneventsBus(); if ((Label)row.FindControl("intrusionEventId") != null) { txtIntrusionEventId.Text = ((Label)row.FindControl("intrusionEventId")).Text; } else { txtIntrusionEventId.Text = ""; } if ((Label)row.FindControl("intrusionEventDetail") != null) { txtIntrusionDetail.Text = ((Label)row.FindControl("intrusionEventDetail")).Text; } else { txtIntrusionDetail.Text = ""; } if ((Label)row.FindControl("CVEId") != null) { txtCVEId.Text = ((Label)row.FindControl("CVEId")).Text; } else { txtCVEId.Text = ""; } if ((Label)row.FindControl("CWEId") != null) { txtCWEId.Text = ((Label)row.FindControl("CWEId")).Text; } else { txtCWEId.Text = ""; } if ((Label)row.FindControl("CAPECId") != null) { txtCAPECId.Text = ((Label)row.FindControl("CAPECId")).Text; } else { txtCAPECId.Text = ""; } if ((Label)row.FindControl("OWASPId") != null) { txtOWASPId.Text = ((Label)row.FindControl("OWASPId")).Text; } else { txtOWASPId.Text = ""; } activateFields(true, false); btnSave.Enabled = true; }
protected void getIntrusionEventsData() { DataTable dttIntrusionEvents = new DataTable(); dttIntrusionEvents.Columns.Add(new DataColumn("intrusionEventId", System.Type.GetType("System.Int32"))); dttIntrusionEvents.Columns.Add(new DataColumn("intrusionEventDetail", System.Type.GetType("System.String"))); dttIntrusionEvents.Columns.Add(new DataColumn("CVEId", System.Type.GetType("System.String"))); dttIntrusionEvents.Columns.Add(new DataColumn("CWEId", System.Type.GetType("System.String"))); dttIntrusionEvents.Columns.Add(new DataColumn("CAPECId", System.Type.GetType("System.String"))); dttIntrusionEvents.Columns.Add(new DataColumn("OWASPId", System.Type.GetType("System.String"))); List<intrusionevents> lstInstrusionEvents = new List<intrusionevents>(); intrusioneventsBus oIntrusionEvents = new intrusioneventsBus(); lstInstrusionEvents = oIntrusionEvents.intrusioneventsGetAll(); if (lstInstrusionEvents.Count > 0) { foreach (intrusionevents row in lstInstrusionEvents) { dttIntrusionEvents.Rows.Add(row.IntrusionEventsId, row.IntrusionEventDetail, row.CVEId, row.CWEId, row.CAPECId, row.OWASPId); } gvEvents.DataSource = dttIntrusionEvents; gvEvents.DataBind(); } }