コード例 #1
0
        public int AddUpdateINCFORM_ALERT(decimal incidentId)
        {
            lblStatusMsg.Visible = false;
            int  status            = 0;
            bool allFieldsComplete = true;

            localCtx = new PSsqmEntities();

            INCFORM_ALERT incidentAlert = EHSIncidentMgr.LookupIncidentAlert(localCtx, IncidentId);

            if (incidentAlert == null)  // new alert
            {
                incidentAlert             = new INCFORM_ALERT();
                incidentAlert.INCIDENT_ID = LocalIncident.INCIDENT_ID;
                incidentAlert.ALERT_TYPE  = ((int)TaskRecordType.HealthSafetyIncident).ToString();
                incidentAlert.CREATE_DT   = DateTime.UtcNow;
                incidentAlert.CREATE_BY   = SessionManager.UserContext.UserName();
                localCtx.AddToINCFORM_ALERT(incidentAlert);
                lblAlertStatus.Text = XLATList.Where(l => l.XLAT_GROUP == "TASK_STATUS" && l.XLAT_CODE == "0").FirstOrDefault().DESCRIPTION;
            }
            SaveAttachments(incidentId);
            incidentAlert.LOCATION_LIST = "";
            foreach (RadComboBoxItem item in ddlLocations.Items.Where(i => i.Checked == true && i.Value.Contains("BU") == false).ToList())
            {
                incidentAlert.LOCATION_LIST += string.IsNullOrEmpty(incidentAlert.LOCATION_LIST) ? item.Value : (item.Value + ",");
            }

            incidentAlert.ALERT_GROUP = "";
            foreach (RadComboBoxItem item in ddlNotifyGroup.Items.Where(i => i.Checked == true).ToList())
            {
                incidentAlert.ALERT_GROUP += string.IsNullOrEmpty(incidentAlert.ALERT_GROUP) ? item.Value : (item.Value + ",");
            }

            incidentAlert.RESPONSIBLE_GROUP = ddlResponsibleGroup.SelectedValue;
            //  incidentAlert.ALERT_DESC = tbAlertDesc.Text;
            incidentAlert.COMMENTS = tbComments.Text;
            incidentAlert.DUE_DT   = rdpDueDate.SelectedDate;



            // Update CEO-Comments value.
            incidentAlert.CEO_COMMENTS = tbCeoComments.Text.Trim();

            // send general notifications
            if (incidentAlert.INCIDENT_ALERT_ID < 1)
            {
                EHSNotificationMgr.NotifyIncidentAlert(LocalIncident, ((int)SysPriv.notify).ToString(), "380",
                                                       ddlLocations.Items.Where(i => i.Checked == true && i.Value.Contains("BU") == false).Select(i => Convert.ToDecimal(i.Value)).ToList());
            }

            List <TASK_STATUS> alertTaskList = UpdateAlertTaskList(EHSIncidentMgr.GetAlertTaskList(localCtx, LocalIncident.INCIDENT_ID));

            status = localCtx.SaveChanges();

            // send specific task assignments
            EHSNotificationMgr.NotifyIncidentAlertTaskAssignment(LocalIncident, alertTaskList.Where(l => l.RESPONSIBLE_ID.HasValue).ToList());

            return(status);
        }
コード例 #2
0
        void InitializeForm(PSsqmEntities ctx)
        {
            lblStatusMsg.Visible = false;
            pnlAlert.Visible     = true;
            //pnlBaseForm2.Visible = true;
            localCtx      = ctx;
            LocalIncident = EHSIncidentMgr.SelectIncidentById(localCtx, IncidentId);
            //populate form when LocalIncident is not null
            //if (LocalIncident == null)
            //{
            //    return;
            //}
            if (LocalIncident != null)
            {
                GetAttachments(IncidentId);

                //To get Privilege information and if Privilege is CEO-Group then CEO-Comments section is editable.
                string PrivInfo = SessionManager.UserContext.Person.PRIV_GROUP.ToString();
                if (PrivInfo == "CEO-GROUP")
                {
                    tbCeoComments.ReadOnly = false;
                }

                INCFORM_ALERT incidentAlert = EHSIncidentMgr.LookupIncidentAlert(localCtx, IncidentId);

                SQMBasePage.SetLocationList(ddlLocations, SQMModelMgr.SelectBusinessLocationList(1m, 0, true), 0);

                ddlNotifyGroup.DataSource     = SQMModelMgr.SelectPrivGroupList("A", true);
                ddlNotifyGroup.DataValueField = "PRIV_GROUP";
                ddlNotifyGroup.DataTextField  = "DESCRIPTION";
                ddlNotifyGroup.DataBind();

                ddlResponsibleGroup.DataSource     = SQMModelMgr.SelectPrivGroupList("A", true);
                ddlResponsibleGroup.DataValueField = "PRIV_GROUP";
                ddlResponsibleGroup.DataTextField  = "DESCRIPTION";
                ddlResponsibleGroup.DataBind();

                rdpDueDate = SQMBasePage.SetRadDateCulture(rdpDueDate, "");
                rdpDueDate.SelectedDate = DateTime.UtcNow.AddDays(1);

                List <NOTIFYACTION> notifyList = SQMModelMgr.SelectNotifyActionList(localCtx, null, null);
                NOTIFYACTION        dfltNotify = notifyList.Where(l => l.NOTIFY_SCOPE == "IN-0" && l.SCOPE_TASK == "400").FirstOrDefault(); // get default alert notification groups

                btnSave.Enabled = false;

                pnlAlert.Enabled = btnSave.Visible = EHSIncidentMgr.CanUpdateIncident(LocalIncident, true, SysPriv.admin, LocalIncident.INCFORM_LAST_STEP_COMPLETED);

                if (incidentAlert == null)
                {
                    if (dfltNotify != null)
                    {
                        ddlNotifyGroup.Items.Where(i => dfltNotify.NOTIFY_DIST.Split(',').Contains(i.Value)).ToList().ForEach(i => i.Checked = true);
                    }
                    lblAlertStatus.Text = "";
                }
                else
                {
                    ddlLocations.Items.Where(i => incidentAlert.LOCATION_LIST.Split(',').Contains(i.Value)).ToList().ForEach(i => i.Checked = true);
                    //  tbAlertDesc.Text = incidentAlert.ALERT_DESC;

                    tbComments.Text = incidentAlert.COMMENTS;

                    // Get CEO-comments value from database and display it.
                    tbCeoComments.Text = incidentAlert.CEO_COMMENTS;

                    ddlNotifyGroup.Items.Where(i => incidentAlert.ALERT_GROUP.Split(',').Contains(i.Value)).ToList().ForEach(i => i.Checked = true);
                    if ((ddlResponsibleGroup.FindItemByValue(incidentAlert.RESPONSIBLE_GROUP)) != null)
                    {
                        ddlResponsibleGroup.SelectedValue = incidentAlert.RESPONSIBLE_GROUP;
                    }
                    rdpDueDate.SelectedDate = incidentAlert.DUE_DT;
                    lblAlertStatus.Text     = XLATList.Where(l => l.XLAT_GROUP == "TASK_STATUS" && l.XLAT_CODE == "0").FirstOrDefault().DESCRIPTION;
                }

                lblNotifyGroup.Text = "";
                //Apply condotional code to desplay data in grid of Process Description
                if (LocalIncident.INCFORM_INJURYILLNESS != null)
                {
                    if (string.IsNullOrEmpty(LocalIncident.INCFORM_INJURYILLNESS.BUSINESS_TYPE))
                    {
                        BusinessType.Style.Add("display", "none");
                    }
                    else
                    {
                        lblBusinessTypeVal.Text = XLATList.Where(p => p.XLAT_CODE == LocalIncident.INCFORM_INJURYILLNESS.BUSINESS_TYPE).Select(p => p.DESCRIPTION_SHORT).FirstOrDefault();
                        //  display: block;
                        //    BusinessType.Style.Add("display", "block");
                    }
                }
                else
                {
                    BusinessType.Style.Add("display", "none");
                }


                if (LocalIncident.INCFORM_INJURYILLNESS != null)
                {
                    if (string.IsNullOrEmpty(LocalIncident.INCFORM_INJURYILLNESS.MACRO_PROCESS_TYPE))
                    {
                        MacroProcessType.Style.Add("display", "none");
                    }
                    else
                    {
                        lblMacroProcessTypeVal.Text = XLATList.Where(p => p.XLAT_CODE == LocalIncident.INCFORM_INJURYILLNESS.MACRO_PROCESS_TYPE).Select(p => p.DESCRIPTION_SHORT).FirstOrDefault();
                        //  MacroProcessType.Style.Add("display", "block");
                    }
                }
                else
                {
                    MacroProcessType.Style.Add("display", "none");
                }

                if (LocalIncident.INCFORM_INJURYILLNESS != null)
                {
                    if (string.IsNullOrEmpty(LocalIncident.INCFORM_INJURYILLNESS.SPECIFIC_PROCESS_TYPE))
                    {
                        SpecificProcessType.Style.Add("display", "none");
                    }
                    else
                    {
                        lblSpecificProcessTypeVal.Text = XLATList.Where(p => p.XLAT_CODE == LocalIncident.INCFORM_INJURYILLNESS.SPECIFIC_PROCESS_TYPE).Select(p => p.DESCRIPTION_SHORT).FirstOrDefault();
                        //SpecificProcessType.Style.Add("display", "block");
                    }
                }
                else
                {
                    SpecificProcessType.Style.Add("display", "none");
                }

                if (LocalIncident.INCFORM_INJURYILLNESS != null)
                {
                    if (string.IsNullOrEmpty(LocalIncident.INCFORM_INJURYILLNESS.EQUIPMENT_MANUFACTURER_NAME))
                    {
                        EquipmentManufacturerName.Style.Add("display", "none");
                    }
                    else
                    {
                        lblEquipmentManufacturerNameVal.Text = LocalIncident.INCFORM_INJURYILLNESS.EQUIPMENT_MANUFACTURER_NAME;
                        // EquipmentManufacturerName.Style.Add("display", "block");
                    }
                }
                else
                {
                    EquipmentManufacturerName.Style.Add("display", "none");
                }


                foreach (RadComboBoxItem item in ddlNotifyGroup.Items.Where(i => i.Checked == true).ToList())
                {
                    lblNotifyGroup.Text += string.IsNullOrEmpty(lblNotifyGroup.Text) ? item.Text : (", " + item.Text);
                }

                if (BindTAlertaskList(EHSIncidentMgr.GetAlertTaskList(localCtx, LocalIncident.INCIDENT_ID)) > 0)
                {
                    btnSave.Enabled = true;
                }
            }
            else
            {
                btnSave.Visible  = false;
                pnlAlert.Visible = false;
            }
        }