public int UpdateCausation(decimal incidentID) { int status = 0; using (PSsqmEntities ctx = new PSsqmEntities()) { status = ctx.ExecuteStoreCommand("DELETE FROM INCFORM_CAUSATION WHERE INCIDENT_ID = " + incidentID.ToString()); if (!string.IsNullOrEmpty(ddlCausation.SelectedValue)) { INCFORM_CAUSATION causation = new INCFORM_CAUSATION(); causation.INCIDENT_ID = incidentID; causation.CAUSEATION_CD = ddlCausation.SelectedValue; causation.TEAM_LIST = tbTeam.Text.Trim(); causation.LAST_UPD_BY = SessionManager.UserContext.UserName(); causation.LAST_UPD_DT = WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ); ctx.AddToINCFORM_CAUSATION(causation); status = ctx.SaveChanges(); EHSIncidentMgr.UpdateIncidentStatus(incidentID, IncidentStepStatus.rootcauseComplete, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); } else { } } return(status); }
private int SaveLostTime(decimal incidentId, List <INCFORM_LOSTTIME_HIST> itemList) { int status = 0; PSsqmEntities entities = new PSsqmEntities(); using (var ctx = new PSsqmEntities()) { ctx.ExecuteStoreCommand("DELETE FROM INCFORM_LOSTTIME_HIST WHERE INCIDENT_ID = {0}", incidentId); } int seq = 0; foreach (INCFORM_LOSTTIME_HIST item in itemList) { var newItem = new INCFORM_LOSTTIME_HIST(); if (!String.IsNullOrEmpty(item.WORK_STATUS) && item.WORK_STATUS != "") { newItem.INCIDENT_ID = incidentId; newItem.ITEM_DESCRIPTION = item.ITEM_DESCRIPTION; newItem.WORK_STATUS = item.WORK_STATUS; newItem.BEGIN_DT = item.BEGIN_DT; newItem.RETURN_TOWORK_DT = item.RETURN_TOWORK_DT; newItem.NEXT_MEDAPPT_DT = item.NEXT_MEDAPPT_DT; newItem.RETURN_EXPECTED_DT = item.RETURN_EXPECTED_DT; newItem.LAST_UPD_BY = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME; newItem.LAST_UPD_DT = WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ); entities.AddToINCFORM_LOSTTIME_HIST(newItem); status = entities.SaveChanges(); } } if (seq > 0) { EHSIncidentMgr.UpdateIncidentStatus(incidentId, IncidentStepStatus.workstatus, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); } /* * if (status > -1) * { * EHSNotificationMgr.NotifyIncidentStatus(WorkStatusIncident, ((int)SysPriv.update).ToString(), "Work status updated"); * } */ return(status); }
private int SaveContainment(decimal incidentId, List <INCFORM_CONTAIN> itemList) { PSsqmEntities entities = new PSsqmEntities(); int status = 0; using (var ctx = new PSsqmEntities()) { ctx.ExecuteStoreCommand("DELETE FROM INCFORM_CONTAIN WHERE INCIDENT_ID = {0}", incidentId); } int seq = 0; foreach (INCFORM_CONTAIN item in itemList) { var newItem = new INCFORM_CONTAIN(); if (!string.IsNullOrEmpty(item.ITEM_DESCRIPTION)) { seq = seq + 1; newItem.INCIDENT_ID = incidentId; newItem.ITEM_SEQ = seq; newItem.ITEM_DESCRIPTION = item.ITEM_DESCRIPTION; newItem.ASSIGNED_PERSON_ID = item.ASSIGNED_PERSON_ID; newItem.START_DATE = item.START_DATE; newItem.COMMENTS = item.COMMENTS; newItem.LAST_UPD_BY = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME; newItem.LAST_UPD_DT = WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ); entities.AddToINCFORM_CONTAIN(newItem); status = entities.SaveChanges(); } } if (seq > 0) { EHSIncidentMgr.UpdateIncidentStatus(incidentId, IncidentStepStatus.containment, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); } return(status); }
protected int SaveRootCauses(decimal incidentId, List <INCFORM_ROOT5Y> itemList) { PSsqmEntities entities = new PSsqmEntities(); int status = 0; using (var ctx = new PSsqmEntities()) { ctx.ExecuteStoreCommand("DELETE FROM INCFORM_ROOT5Y WHERE INCIDENT_ID = {0}", incidentId); } int seq = 0; foreach (INCFORM_ROOT5Y item in itemList) { var newItem = new INCFORM_ROOT5Y(); if (!string.IsNullOrEmpty(item.ITEM_DESCRIPTION)) { seq = seq + 1; newItem.INCIDENT_ID = incidentId; newItem.ITEM_SEQ = seq; newItem.ITEM_TYPE = item.ITEM_TYPE; newItem.PROBLEM_SERIES = item.PROBLEM_SERIES; newItem.ITEM_DESCRIPTION = item.ITEM_DESCRIPTION; newItem.IS_ROOTCAUSE = item.IS_ROOTCAUSE; newItem.LAST_UPD_BY = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME; newItem.LAST_UPD_DT = WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ); entities.AddToINCFORM_ROOT5Y(newItem); status = entities.SaveChanges(); } } if (seq > 0) { EHSIncidentMgr.UpdateIncidentStatus(incidentId, IncidentStepStatus.rootcause, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); } return(status); }
private int SaveActions(decimal incidentId, List <TASK_STATUS> actionList) { PSsqmEntities entities = new PSsqmEntities(); int status = 0; foreach (TASK_STATUS action in actionList) { if (!string.IsNullOrEmpty(action.DESCRIPTION) && action.DUE_DT.HasValue && action.RESPONSIBLE_ID.HasValue) { EHSIncidentMgr.CreateOrUpdateTask(ActionIncident, action, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); } } if (status > -1) { EHSNotificationMgr.NotifyIncidentStatus(ActionIncident, ((int)SysPriv.update).ToString(), "Corrective action specified"); } EHSIncidentMgr.UpdateIncidentStatus(incidentId, IncidentStepStatus.correctiveaction, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); return(status); }
public int AddUpdateINCFORM_APPROVAL(decimal incidentId, string option) { //To get approvertype from usercontext. -NIHARIKA SAXENA var approveerType = (SessionManager.UserContext.PrivList.Where(p => p.PRIV <= 100).FirstOrDefault()).PRIV_GROUP.ToString(); //Check status of severityLevel of Global Safety Group bool severityLevel = false; var itemList = new List <INCFORM_APPROVAL>(); int status = 0; int numRequired = 0; int requiredCount = 0; int approvalCount = 0; bool isRequired; bool isChanged = false; List <INCFORM_APPROVAL> approvalList = new List <INCFORM_APPROVAL>(); using (PSsqmEntities ctx = new PSsqmEntities()) { foreach (RepeaterItem item in rptApprovals.Items) { isRequired = false; HiddenField hfreq = (HiddenField)item.FindControl("hfReqdComplete"); if (hfreq.Value.ToLower() == "true") { ++numRequired; isRequired = true; } INCFORM_APPROVAL approval = new INCFORM_APPROVAL(); approval.INCIDENT_ID = incidentId; approval.APPROVAL_LEVEL = 0; approval.STEP = ApprovalStep.STEP; Label lba = (Label)item.FindControl("lbApprover"); Label lb = (Label)item.FindControl("lbItemSeq"); CheckBox cba = (CheckBox)item.FindControl("cbIsAccepted"); RadDatePicker rda = (RadDatePicker)item.FindControl("rdpAcceptDate"); HiddenField hfrole = (HiddenField)item.FindControl("hfRoleDesc"); HiddenField hf = (HiddenField)item.FindControl("hfItemSeq"); HiddenField hfINCFORM_APPROVER_LIST_ID = (HiddenField)item.FindControl("hfINCFORM_APPROVER_LIST_ID"); approval.ITEM_SEQ = Convert.ToInt32(hf.Value); approval.APPROVER_TITLE = hfrole.Value; if (IncidentId > MaxIncidentForNewFeature && ApprovalStep.STEP < 6) { approval.INCFORM_APPROVER_LIST_ID = Convert.ToDecimal(hfINCFORM_APPROVER_LIST_ID.Value); } //Update SEVERITY_LEVEL value. - if (chkSeverityLevel00.Checked && chkSeverityLevel00.Visible == true) { severityLevel = chkSeverityLevel00.Checked; approval.SEVERITY_LEVEL = SysPriv.first_add.ToString(); } else if (chkSeverityLevel01.Checked && chkSeverityLevel01.Visible == true) { severityLevel = chkSeverityLevel01.Checked; approval.SEVERITY_LEVEL = SysPriv.l1.ToString(); } else if (chkSeverityLevel02.Checked && chkSeverityLevel02.Visible == true) { severityLevel = chkSeverityLevel02.Checked; approval.SEVERITY_LEVEL = SysPriv.l2.ToString(); } else if (chkSeverityLevel03.Checked && chkSeverityLevel03.Visible == true) { severityLevel = chkSeverityLevel03.Checked; approval.SEVERITY_LEVEL = SysPriv.l3.ToString(); } else if (chkSeverityLevel04.Checked && chkSeverityLevel04.Visible == true) { severityLevel = chkSeverityLevel04.Checked; approval.SEVERITY_LEVEL = SysPriv.l4.ToString(); } approvalList.Add(approval); if (cba.Checked == true) // is approved { ++approvalCount; if (isRequired) { ++requiredCount; } hf = (HiddenField)item.FindControl("hfApprovalID"); if (string.IsNullOrEmpty(hf.Value) || hf.Value == "0") { // save new approval to db isChanged = true; approval.APPROVAL_DATE = rda.SelectedDate; approval.IsAccepted = true; hf = (HiddenField)item.FindControl("hfPersonID"); if (string.IsNullOrEmpty(hf.Value) || hf.Value == "0") { approval.APPROVER_PERSON_ID = SessionManager.UserContext.Person.PERSON_ID; approval.APPROVER_PERSON = SessionManager.UserContext.UserName(); } else { approval.APPROVER_PERSON_ID = Convert.ToDecimal(hf.Value); approval.APPROVER_PERSON = lba.Text; } ctx.AddToINCFORM_APPROVAL(approval); } } } if (approveerType == "Global Safety Group") { if (severityLevel) { lblResponseMsg.Text = ""; chkSeverityLevel00.Enabled = false; chkSeverityLevel01.Enabled = false; chkSeverityLevel02.Enabled = false; chkSeverityLevel03.Enabled = false; chkSeverityLevel04.Enabled = false; //status = ctx.ExecuteStoreCommand("DELETE FROM INCFORM_APPROVAL WHERE INCIDENT_ID = " + incidentId.ToString() + " AND STEP = " + ApprovalStep.ToString()); status = ctx.SaveChanges(); } else { status = -1; } } else { status = ctx.SaveChanges(); } bool notifyStepComplete = false; string incidentStep = ""; // determine step status if (approvalCount > 0) { if (ApprovalStep.STEP == 10.0m) { incidentStep = "Approvals"; IncidentStepStatus stat; if ((numRequired > 0 && requiredCount == numRequired) || approvalCount == rptApprovals.Items.Count) { stat = (IncidentStepStatus)Math.Min(rptApprovals.Items.Count + 150, 155); EHSIncidentMgr.UpdateIncidentStatus(incidentId, stat, true, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); notifyStepComplete = true; } else { incidentStep = ApprovalStep.STEP == 5.5m ? "CorrectiveActionApproval" : "InitialActionApproval"; stat = (IncidentStepStatus)Math.Min(approvalCount + 150, 154); EHSIncidentMgr.UpdateIncidentStatus(incidentId, stat, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ)); } } else { if ((numRequired > 0 && requiredCount == numRequired) || approvalCount == rptApprovals.Items.Count) { EHSIncidentMgr.UpdateIncidentApprovalStatus(incidentId, ApprovalStep.STEP); notifyStepComplete = true; } } } // only send notifications when approvals are added if (isChanged) { NotifyCycle notifyCycle; try { notifyCycle = ApprovalStep.NOTIFY_CYCLE.HasValue ? (NotifyCycle)ApprovalStep.NOTIFY_CYCLE : NotifyCycle.None; } catch { notifyCycle = NotifyCycle.None; } if (notifyStepComplete && ApprovalStep.STEP == 10.0m) { EHSNotificationMgr.NotifyIncidentStatus(LocalIncident, ((int)SysPriv.approve).ToString(), ""); } if (notifyCycle == NotifyCycle.notifyNext) { INCFORM_APPROVAL priorApproval = new INCFORM_APPROVAL(); foreach (INCFORM_APPROVAL approval in approvalList) { // notify missing approvers when prior roles approved or the step was completed by 380 or 390 priv if (!approval.APPROVAL_DATE.HasValue && (priorApproval.APPROVAL_DATE.HasValue || notifyStepComplete)) { List <string> infoList = new List <string>(); infoList.Add(approval.APPROVER_TITLE); infoList.Add(priorApproval.APPROVER_TITLE); EHSNotificationMgr.NotifyIncidentSignoffRequired(LocalIncident, approval, ApprovalStep.STEP_HEADING_TEXT, approval.ITEM_SEQ >= 390 ? "SIGNOFF" : "APPROVAL", infoList); } priorApproval = approval; } } } } if (IncidentId > MaxIncidentForNewFeature && ApprovalStep.STEP < 6) { bool isNotify = false; if (isChanged) { using (PSsqmEntities ctx = new PSsqmEntities()) { //foreach (RepeaterItem item in rptApprovals.Items) //{ // CheckBox cba = (CheckBox)item.FindControl("cbIsAccepted"); // HiddenField hfINCFORM_APPROVER_LIST_ID = (HiddenField)item.FindControl("hfINCFORM_APPROVER_LIST_ID"); // HiddenField hfAPPROVERType = (HiddenField)item.FindControl("hfAPPROVERType"); // if (cba.Checked && (hfAPPROVERType.Value == "A" || hfAPPROVERType.Value == "N")) // { // isNotify = true; // } // else if (!cba.Checked && (hfAPPROVERType.Value == "A" || hfAPPROVERType.Value == "N")) // { // isNotify = false; // break; // } //} //if (isNotify) //{ foreach (RepeaterItem item in rptApprovals.Items) { HiddenField hfrole = (HiddenField)item.FindControl("hfRoleDesc"); CheckBox cba = (CheckBox)item.FindControl("cbIsAccepted"); HiddenField hfINCFORM_APPROVER_LIST_ID = (HiddenField)item.FindControl("hfINCFORM_APPROVER_LIST_ID"); List <string> infoList = new List <string>(); infoList.Add(hfrole.Value); decimal?applistid = Convert.ToDecimal(hfINCFORM_APPROVER_LIST_ID.Value); INCFORM_APPROVER_LIST appList = (from i in ctx.INCFORM_APPROVER_LIST where i.INCFORM_APPROVER_LIST_ID == applistid select i).FirstOrDefault(); PERSON person = (from i in ctx.PERSON where i.PERSON_ID == appList.PERSON_ID select i).FirstOrDefault(); if (!cba.Checked) { if (person != null) { EHSNotificationMgr.NotifyApprover(LocalIncident, person.PERSON_ID, ApprovalStep.STEP_HEADING_TEXT, appList.PRIV >= 390 ? "SIGNOFF" : "APPROVAL", infoList); } } } //CheckBox cba = (CheckBox)item.FindControl("cbIsAccepted"); //HiddenField hfINCFORM_APPROVER_LIST_ID = (HiddenField)item.FindControl("hfINCFORM_APPROVER_LIST_ID"); //HiddenField hfAPPROVERType = (HiddenField)item.FindControl("hfAPPROVERType"); //if (!cba.Checked && (hfAPPROVERType.Value == "R")) //{ // decimal? applistid = Convert.ToDecimal(hfINCFORM_APPROVER_LIST_ID.Value); // INCFORM_APPROVER_LIST appList = (from i in ctx.INCFORM_APPROVER_LIST where i.INCFORM_APPROVER_LIST_ID == applistid select i).FirstOrDefault(); // if (appList.PERSON_ID != null) // { // PERSON person = (from i in ctx.PERSON where i.PERSON_ID == appList.PERSON_ID select i).FirstOrDefault(); // EHSNotificationMgr.NotifyRegionalApprover(person.PERSON_ID, "Notify Regional Approver"); // } //} //} } } } return(status); }