protected void btnSave_Click(object sender, EventArgs e)
        {
            ids auxNewIDPS = new ids();
            idsBus oIDS = new idsBus();
            bool needRequiredFields = false;
            int saveType = 0;

            if (btnNew.Enabled)  saveType = 2;
            if (!btnNew.Enabled) saveType = 1;

            if (String.IsNullOrEmpty(txtIDPSName.Text)) needRequiredFields = true;
            if (String.IsNullOrEmpty(txtIP.Text)) needRequiredFields = true;

            if (!needRequiredFields)
            {
                auxNewIDPS.idsName = txtIDPSName.Text;
                auxNewIDPS.IdsTypeId = Convert.ToInt32(ddlIDPSType.SelectedValue);
                auxNewIDPS.DatabaseTypeId = Convert.ToInt32(ddlDatabaseType.SelectedValue);
                auxNewIDPS.IdsIP = txtIP.Text;
                auxNewIDPS.DatabaseUser = txtUserDataBase.Text;
                auxNewIDPS.DatabasePass = txtPassDataBase.Text;
                auxNewIDPS.DatabaseName = txtSourceDataBase.Text;
                auxNewIDPS.DatabaseHost = txtHostDatabase.Text;
                auxNewIDPS.IdsVersion = txtIDPSVersion.Text;
                auxNewIDPS.Active = Convert.ToSByte(chkActive.Checked);

                switch (saveType)
                {
                    case 1: //save
                        if (oIDS.idsAdd(auxNewIDPS) > 0)
                        {
                            lblMessage.Text = "Datos guardados correctamente!";
                            clearFields();
                            activateFields(false, true);
                            btnNew.Enabled = true;
                            getIDPSData();
                        }
                        else
                            lblMessage.Text = "Error al guardar los datos!";
                    break;
                    case 2: //update
                        auxNewIDPS.IdsId = Convert.ToInt32(txtIDPSId.Text);
                        if (oIDS.idsUpdate(auxNewIDPS))
                        {
                            lblMessage.Text = "Datos actualizados correctamente!";
                            clearFields();
                            activateFields(false, true);
                            btnSave.Enabled = false;
                            getIDPSData();
                        }
                        else
                            lblMessage.Text = "Error al guardar los datos!";
                    break;
                }
            }
            else
            {
                lblMessage.Text = "Error, existen campos sin completar!";
            }
        }
        protected void getIDPSData()
        {
            List<ids> lstIDPS = new List<ids>();
            idsBus oIDPS = new idsBus();

            lstIDPS = oIDPS.idsGetAll();

            if (lstIDPS.Count > 0)
            {
                ddlIDPS.DataSource = lstIDPS;
                ddlIDPS.DataValueField = "idsId";
                ddlIDPS.DataTextField = "idsName";
                ddlIDPS.DataBind();
            }
        }
        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...";
                }
            }
        }
        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();
            }
        }
        public DataTable getIDPSData()
        {
            DataSet dtsResult   = new DataSet();
            DataTable dttResult = new DataTable();

            dttResult.Columns.Add(new DataColumn("IDPSId", System.Type.GetType("System.Int32")));
            dttResult.Columns.Add(new DataColumn("EventsAlarmId", System.Type.GetType("System.Int32")));
            dttResult.Columns.Add(new DataColumn("IDPSEventId", System.Type.GetType("System.Int32")));
            dttResult.Columns.Add(new DataColumn("datetime   ", System.Type.GetType("System.String")));
            dttResult.Columns.Add(new DataColumn("description", System.Type.GetType("System.String")));
            dttResult.Columns.Add(new DataColumn("source     ", System.Type.GetType("System.String")));

            List<eventsalarm> lstEventsAlarm = new List<eventsalarm>();
            eventsalarmBus oEventsAlarm = new eventsalarmBus();

            ids auxIDPS = new ids();
            idsBus oIDPSBus = new idsBus();

            lstEventsAlarm = oEventsAlarm.eventsalarmGetAll();

            if (lstEventsAlarm.Count > 0)
            {
                foreach (eventsalarm row in lstEventsAlarm)
                {
                    switch (row.IdsId)
                    {
                        case 1: //ossec
                            auxIDPS  = oIDPSBus.idsGetById(row.IdsId);
                            dtsResult= requestOSSECEvents( auxIDPS.DatabaseHost,
                                                           auxIDPS.DatabaseName,
                                                           auxIDPS.DatabaseUser,
                                                           auxIDPS.DatabasePass,
                                                           row.IdsSignatureCategoryId);

                            if (dtsResult.Tables[0].Rows.Count > 0)
                            {
                                foreach(DataRow rowResult in dtsResult.Tables[0].Rows)
                                {
                                    dttResult.Rows.Add(row.IdsId,
                                                       row.EventsAlarmId,
                                                       Convert.ToInt32(rowResult[0].ToString()),
                                                       rowResult[1].ToString(),
                                                       rowResult[2].ToString(),
                                                       rowResult[3].ToString());
                                }
                            }

                        break;
                        case 2: //snort
                        case 3: //suricata
                            auxIDPS  = oIDPSBus.idsGetById(row.IdsId);
                            dtsResult= requestbarnyard2Events(auxIDPS.DatabaseHost,
                                                              auxIDPS.DatabaseName,
                                                              auxIDPS.DatabaseUser,
                                                              auxIDPS.DatabasePass,
                                                              row.IdsSignatureCategoryId);

                            if (dtsResult.Tables[0].Rows.Count > 0)
                            {
                                foreach (DataRow rowResult in dtsResult.Tables[0].Rows)
                                {
                                    dttResult.Rows.Add(row.IdsId,
                                                       row.EventsAlarmId,
                                                       Convert.ToInt32(rowResult[0].ToString()),
                                                       rowResult[1].ToString(),
                                                       rowResult[2].ToString(),
                                                       rowResult[3].ToString());
                                }
                            }
                        break;

                        case 4: //bro
                            auxIDPS = oIDPSBus.idsGetById(row.IdsId);
                            dtsResult = requestBroEvents(auxIDPS.DatabaseHost,
                                                         auxIDPS.DatabaseName,
                                                         auxIDPS.DatabaseUser,
                                                         auxIDPS.DatabasePass,
                                                         row.IdsSignatureCategoryId);

                            if (dtsResult.Tables[0].Rows.Count > 0)
                            {
                                foreach (DataRow rowResult in dtsResult.Tables[0].Rows)
                                {
                                    dttResult.Rows.Add(row.IdsId,
                                                       row.EventsAlarmId,
                                                       Convert.ToInt32(rowResult[0].ToString()),
                                                       rowResult[1].ToString(),
                                                       rowResult[2].ToString(),
                                                       rowResult[3].ToString());
                                }
                            }
                        break;
                    }
                }
            }
            return dttResult;
        }
        public DataSet getIDPSSignaturesCategory(int idpsId)
        {
            ids auxIDPS = new ids();
            idsBus oIDPSBus = new idsBus();
            DataSet dtsResult = new DataSet();
            string sqlQuery;

            auxIDPS = oIDPSBus.idsGetById(idpsId);

            if (auxIDPS != null)
            {
                switch (auxIDPS.IdsId)
                {
                    case 1: //ossec
                        sqlQuery= "SELECT   cat_id as SignatureCategoryId,    "
                                  + "       cat_name as SignatureCategoryName "
                                  + " FROM  Category                          "
                                  + " ORDER by cat_id;                        ";

                        dtsResult= ExecQueryMySQL(auxIDPS.DatabaseHost,
                                                             auxIDPS.DatabaseName,
                                                             auxIDPS.DatabaseUser,
                                                             auxIDPS.DatabasePass,
                                                             sqlQuery);
                    break;
                    case 2: //snort
                    case 3: //suricata
                        sqlQuery= "SELECT   sig_class_id   as SignatureCategoryId,    "
                                  + "       sig_class_name as SignatureCategoryName   "
                                  + " FROM  sig_class                                 "
                                  + " ORDER by sig_class_id;                          ";

                        dtsResult= ExecQueryMySQL(auxIDPS.DatabaseHost,
                                                             auxIDPS.DatabaseName,
                                                             auxIDPS.DatabaseUser,
                                                             auxIDPS.DatabasePass,
                                                             sqlQuery);
                    break;
                    case 4: //bro
                        //TODO
                    break;
                }
            }

            return dtsResult;
        }
        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...";
                }
            }
        }
        protected void generateFunnelChart()
        {
            DataTable dttIntrusionByIDPS = new DataTable();
            dttIntrusionByIDPS.Columns.Add(new DataColumn("idpsId", System.Type.GetType("System.Int32")));
            dttIntrusionByIDPS.Columns.Add(new DataColumn("idpsName", System.Type.GetType("System.String")));
            dttIntrusionByIDPS.Columns.Add(new DataColumn("Quantity", System.Type.GetType("System.Int32")));

            List<eventsdetection> lstEventsDetection = new List<eventsdetection>();
            eventsdetectionBus oEventsDetection = new eventsdetectionBus();

            List<ids> lstIDPS = new List<ids>();
            idsBus oIDPS = new idsBus();

            lstIDPS = oIDPS.idsGetAll();

            if (lstIDPS.Count > 0)
            {
                foreach (ids rowIDPS in lstIDPS)
                {
                    int qtyIntrusion = 0;
                    if (Convert.ToBoolean(rowIDPS.Active))
                    {
                        lstEventsDetection = oEventsDetection.eventsdetectionGetAll();
                        foreach (eventsdetection rowEvent in lstEventsDetection)
                        {
                            if (rowEvent.IdsId == rowIDPS.IdsId)
                                qtyIntrusion++;
                        }

                        dttIntrusionByIDPS.Rows.Add(rowIDPS.IdsId, rowIDPS.idsName, qtyIntrusion);
                    }
                }
            }

            funnelChart.Legends.Add(new Legend("Leyenda"));
            funnelChart.Legends["Leyenda"].DockedToChartArea = "ChartArea1";
            funnelChart.Legends["Leyenda"].IsDockedInsideChartArea = false;
            funnelChart.Series["Series1"].Legend = "Leyenda";
            funnelChart.Series["Series1"].IsVisibleInLegend = true;

            funnelChart.Series[0].XValueMember = "idpsName";
            funnelChart.Series[0].YValueMembers = "Quantity";
            funnelChart.DataSource = dttIntrusionByIDPS;
            funnelChart.DataBind();
        }
        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 gvIDPS_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = gvIDPS.SelectedRow;

            ids auxIDPS = new ids();
            idsBus oIDPS = new idsBus();

            try
            {
                ddlIDPSType.SelectedValue= ((Label)row.FindControl("idsTypeId")).Text;
                ddlDatabaseType.SelectedValue = ((Label)row.FindControl("databaseTypeId")).Text;
            }
            catch
            {

            }

            if ((Label)row.FindControl("idsId") != null) { txtIDPSId.Text = ((Label)row.FindControl("idsId")).Text; } else { txtIDPSId.Text = ""; }
            if ((Label)row.FindControl("idsName") != null) { txtIDPSName.Text = ((Label)row.FindControl("idsName")).Text; } else { txtIDPSName.Text = ""; }
            if ((Label)row.FindControl("idsVersion") != null) { txtIDPSVersion.Text = ((Label)row.FindControl("idsVersion")).Text; } else { txtIDPSVersion.Text = ""; }
            if ((Label)row.FindControl("idsIP") != null) { txtIP.Text = ((Label)row.FindControl("idsIP")).Text; } else { txtIP.Text = ""; }
            if ((CheckBox)row.FindControl("active") != null) { chkActive.Checked = ((CheckBox)row.FindControl("active")).Checked; } else { chkActive.Checked = false; }

            auxIDPS = oIDPS.idsGetById(Convert.ToInt32(txtIDPSId.Text));
            txtUserDataBase.Text = auxIDPS.DatabaseUser;
            txtPassDataBase.Text = auxIDPS.DatabasePass;
            txtSourceDataBase.Text = auxIDPS.DatabaseName;
            txtHostDatabase.Text = auxIDPS.DatabaseHost;
            activateFields(true, false);
            btnSave.Enabled = true;
        }
        protected void getIDPSData()
        {
            DataTable dttIDPS = new DataTable();
            dttIDPS.Columns.Add(new DataColumn("idsId"           , System.Type.GetType("System.Int32")));
            dttIDPS.Columns.Add(new DataColumn("idsName"         , System.Type.GetType("System.String")));
            dttIDPS.Columns.Add(new DataColumn("idsversion"      , System.Type.GetType("System.String")));
            dttIDPS.Columns.Add(new DataColumn("idsTypeId"       , System.Type.GetType("System.Int32")));
            dttIDPS.Columns.Add(new DataColumn("idsTypeDesc"     , System.Type.GetType("System.String")));
            dttIDPS.Columns.Add(new DataColumn("databaseTypeId"  , System.Type.GetType("System.Int32")));
            dttIDPS.Columns.Add(new DataColumn("databaseTypeDesc", System.Type.GetType("System.String")));
            dttIDPS.Columns.Add(new DataColumn("idsIP"           , System.Type.GetType("System.String")));
            dttIDPS.Columns.Add(new DataColumn("active"          , System.Type.GetType("System.Boolean")));

            List<ids> lstIDPS = new List<ids>();
            idsBus oIDPS = new idsBus();

            idstype auxIDPSType = new idstype();
            idstypeBus oIDPSType = new idstypeBus();

            databasestype auxDatabaseType = new databasestype();
            databasestypeBus oDatabaseType = new databasestypeBus();

            lstIDPS = oIDPS.idsGetAll();

            if (lstIDPS.Count > 0)
            {
                foreach (ids row in lstIDPS)
                {
                    auxIDPSType = oIDPSType.idstypeGetById(row.IdsTypeId);
                    auxDatabaseType = oDatabaseType.databasestypeGetById(row.DatabaseTypeId);

                    dttIDPS.Rows.Add( row.IdsId,
                                      row.idsName,
                                      row.IdsVersion,
                                      row.IdsTypeId,
                                      auxIDPSType.IdsTypeName,
                                      row.DatabaseTypeId,
                                      auxDatabaseType.DatabaseName,
                                      row.IdsIP,
                                      row.Active);
                }

                gvIDPS.DataSource = dttIDPS;
                gvIDPS.DataBind();
            }
        }