protected void getUsersData() { List <users> lstUsers = new List <users>(); usersBus oUsers = new usersBus(); lstUsers = oUsers.usersGetAll(); if (lstUsers.Count > 0) { ddlUsers.DataSource = lstUsers; ddlUsers.DataValueField = "userId"; ddlUsers.DataTextField = "userName"; ddlUsers.DataBind(); } }
protected void _Login_Authenticate(object sender, AuthenticateEventArgs e) { users auxUser = new users(); usersBus oUser = new usersBus(); auxUser = oUser.usersGetByUserName(_Login.UserName); string hashPwd = Services.Utility.ResumeSHA1(_Login.Password); if (auxUser != null) { if (String.Compare(hashPwd, auxUser.UserPassword) == 0) { FormsAuthentication.RedirectFromLoginPage(_Login.UserName, _Login.RememberMeSet); } } }
protected void getUsersData() { DataTable dttUsers = new DataTable(); dttUsers.Columns.Add(new DataColumn("userId", System.Type.GetType("System.Int32"))); dttUsers.Columns.Add(new DataColumn("userName", System.Type.GetType("System.String"))); dttUsers.Columns.Add(new DataColumn("userLastName", System.Type.GetType("System.String"))); dttUsers.Columns.Add(new DataColumn("userFirstName", System.Type.GetType("System.String"))); dttUsers.Columns.Add(new DataColumn("userGroupId", System.Type.GetType("System.Int32"))); dttUsers.Columns.Add(new DataColumn("userGroupDescription", System.Type.GetType("System.String"))); dttUsers.Columns.Add(new DataColumn("userActive", System.Type.GetType("System.Boolean"))); List <users> lstUsers = new List <users>(); usersBus oUsers = new usersBus(); usergroup auxGroup = new usergroup(); usergroupBus oGroup = new usergroupBus(); lstUsers = oUsers.usersGetAll(); if (lstUsers.Count > 0) { foreach (users row in lstUsers) { auxGroup = oGroup.usergroupGetById(row.UserGroupId); dttUsers.Rows.Add(row.UserId, row.UserName, row.UserLastName, row.UserFirstName, row.UserGroupId, auxGroup.UserGroupDescription, row.UserActive); } gvUsers.DataSource = dttUsers; gvUsers.DataBind(); } }
protected void getTaskDetailsData(int taskId) { DataTable dttTaskDetails = new DataTable(); dttTaskDetails.Columns.Add(new DataColumn("taskDetailsId", System.Type.GetType("System.Int32"))); dttTaskDetails.Columns.Add(new DataColumn("taskId", System.Type.GetType("System.Int32"))); dttTaskDetails.Columns.Add(new DataColumn("taskDetails", System.Type.GetType("System.String"))); dttTaskDetails.Columns.Add(new DataColumn("datetime", System.Type.GetType("System.DateTime"))); dttTaskDetails.Columns.Add(new DataColumn("effortHours", System.Type.GetType("System.Decimal"))); dttTaskDetails.Columns.Add(new DataColumn("userId", System.Type.GetType("System.Int32"))); dttTaskDetails.Columns.Add(new DataColumn("userName", System.Type.GetType("System.String"))); List <taskdetails> lstTaskDetails = new List <taskdetails>(); taskdetailsBus oTaskDetails = new taskdetailsBus(); usersBus oUsers = new usersBus(); lstTaskDetails = oTaskDetails.taskdetailsGetByTaskId(taskId); if (lstTaskDetails.Count > 0) { foreach (taskdetails row in lstTaskDetails) { users auxUser = new users(); auxUser = oUsers.usersGetById(row.UserId); dttTaskDetails.Rows.Add(row.TaskDetailsId, row.TaskId, row.Details, row.DateTime, row.EffortHours, row.UserId, auxUser.UserName); } gvTaskDetails.DataSource = dttTaskDetails; gvTaskDetails.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 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..."; } }
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(); } }
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..."; } } }
protected void btnSave_Click(object sender, EventArgs e) { users auxNewUser = new users(); usersBus oUsers = new usersBus(); bool needRequiredFields = false; int saveType = 0; if (btnNew.Enabled) { saveType = 2; } if (!btnNew.Enabled) { saveType = 1; } if (String.IsNullOrEmpty(txtUserName.Text)) { needRequiredFields = true; } if (String.IsNullOrEmpty(txtUserLastName.Text)) { needRequiredFields = true; } if (String.IsNullOrEmpty(txtUserFirstName.Text)) { needRequiredFields = true; } if (String.IsNullOrEmpty(txtPassword.Text)) { needRequiredFields = true; } if (String.IsNullOrEmpty(txtMail.Text)) { needRequiredFields = true; } if (!needRequiredFields) { auxNewUser.UserName = txtUserName.Text; auxNewUser.UserFirstName = txtUserFirstName.Text; auxNewUser.UserLastName = txtUserLastName.Text; auxNewUser.UserMail = txtMail.Text; auxNewUser.UserPassword = txtPassword.Text; auxNewUser.UserActive = Convert.ToSByte(chkActive.Checked); auxNewUser.UserSMSNumber = txtSMS.Text; auxNewUser.UserGroupId = Convert.ToInt32(ddlUserGroup.SelectedValue); switch (saveType) { case 1: //save if (oUsers.usersAdd(auxNewUser) > 0) { lblMessage.Text = "Datos guardados correctamente!"; clearFields(); activateFields(false, true); btnNew.Enabled = true; getUsersData(); } else { lblMessage.Text = "Error al guardar los datos!"; } break; case 2: //update auxNewUser.UserId = Convert.ToInt32(userId.Value); if (oUsers.usersUpdate(auxNewUser)) { lblMessage.Text = "Datos actualizados correctamente!"; clearFields(); activateFields(false, true); btnSave.Enabled = false; getUsersData(); } else { lblMessage.Text = "Error al guardar los datos!"; } break; } } else { lblMessage.Text = "Error, existen campos sin completar!"; } }
protected void gvUsers_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = gvUsers.SelectedRow; users auxUser = new users(); usersBus oUser = new usersBus(); List <userrolesmapping> lstGroupRolesMapping = new List <userrolesmapping>(); userrolesmappingBus oRolesMapping = new userrolesmappingBus(); userroles auxRol = new userroles(); userrolesBus oRoles = new userrolesBus(); try { ddlUserGroup.SelectedValue = ((Label)row.FindControl("userGroupId")).Text; } catch { } if ((Label)row.FindControl("userId") != null) { userId.Value = ((Label)row.FindControl("userId")).Text; } else { userId.Value = ""; } if ((Label)row.FindControl("userName") != null) { txtUserName.Text = ((Label)row.FindControl("userName")).Text; } else { txtUserName.Text = ""; } if ((Label)row.FindControl("userLastName") != null) { txtUserLastName.Text = ((Label)row.FindControl("userLastName")).Text; } else { txtUserLastName.Text = ""; } if ((Label)row.FindControl("userFirstName") != null) { txtUserFirstName.Text = ((Label)row.FindControl("userFirstName")).Text; } else { txtUserFirstName.Text = ""; } if ((CheckBox)row.FindControl("userActive") != null) { chkActive.Checked = ((CheckBox)row.FindControl("userActive")).Checked; } else { chkActive.Checked = false; } auxUser = oUser.usersGetById(Convert.ToInt32(userId.Value)); txtMail.Text = auxUser.UserMail; txtPassword.Text = auxUser.UserPassword; txtSMS.Text = auxUser.UserSMSNumber; cblRolesRoles.Items.Clear(); lstGroupRolesMapping = oRolesMapping.userrolesmappingGetByUserGroupId(Convert.ToInt32(ddlUserGroup.SelectedValue)); if (lstGroupRolesMapping.Count > 0) { int index = 0; foreach (userrolesmapping rowRolMapping in lstGroupRolesMapping) { auxRol = oRoles.userrolesGetById(rowRolMapping.UserRoleId); cblRolesRoles.Items.Add(auxRol.UserRoleDescription); cblRolesRoles.Items[index].Selected = true; index++; } } activateFields(true, false); btnSave.Enabled = true; }
protected void generateBarChartUsers() { DataTable dttTaskByUser = new DataTable(); dttTaskByUser.Columns.Add(new DataColumn("userId", System.Type.GetType("System.Int32"))); dttTaskByUser.Columns.Add(new DataColumn("userName", System.Type.GetType("System.String"))); dttTaskByUser.Columns.Add(new DataColumn("Quantity", System.Type.GetType("System.Int32"))); List <users> lstUsers = new List <users>(); usersBus oUsers = new usersBus(); List <tasks> lstTasks = new List <tasks>(); tasksBus oTask = new tasksBus(); lstUsers = oUsers.usersGetAll(); if (lstUsers.Count > 0) { foreach (users rowUser in lstUsers) { int qtyTask = 0; if (Convert.ToBoolean(rowUser.UserActive)) { lstTasks = oTask.tasksGetAll(); foreach (tasks rowTask in lstTasks) { if (rowTask.UserId == rowUser.UserId) { if (rowTask.TaskStatudId != 2) //Closed { if (rowTask.TaskStatudId != 5) //Rejected { qtyTask++; } } } } dttTaskByUser.Rows.Add(rowUser.UserId, rowUser.UserName, qtyTask); } } } //Task without User int qtyWithoutUser = 0; lstTasks = oTask.tasksGetAll(); if (lstTasks.Count > 0) { foreach (tasks row in lstTasks) { if (row.UserId < 1) { qtyWithoutUser++; } } if (qtyWithoutUser > 0) { dttTaskByUser.Rows.Add(0, "No asignado", qtyWithoutUser); } } barChartUsers.Series[0].XValueMember = "userName"; barChartUsers.Series[0].YValueMembers = "Quantity"; barChartUsers.DataSource = dttTaskByUser; barChartUsers.DataBind(); }