protected void btnStatusSave_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn == null || string.IsNullOrEmpty(btn.CommandArgument))
            {
                return;
            }

            string[] cmd = btn.CommandArgument.Split('~');             // recordType, recordID, recordSubID, taskStep, taskType

            EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(Convert.ToInt32(cmd[0]), Convert.ToDecimal(cmd[1]));

            if (auditQuestion != null)
            {
                auditQuestion.Status            = ddlAnswerStatus.SelectedValue.ToString();
                auditQuestion.ResolutionComment = tbResolutionComment.Text.ToString();
                if (auditQuestion.Status.Equals("03"))
                {
                    // update the complete date with the local date/time of the plant
                    AUDIT    audit     = EHSAuditMgr.SelectAuditById(entities, auditQuestion.AuditId);
                    PLANT    plant     = SQMModelMgr.LookupPlant((decimal)audit.DETECT_PLANT_ID);
                    DateTime localTime = WebSiteCommon.LocalTime(DateTime.UtcNow, plant.LOCAL_TIMEZONE);
                    auditQuestion.CompleteDate = localTime;
                }
                EHSAuditMgr.UpdateAnswer(auditQuestion);
            }
            UpdateTaskList("update");
        }
        private decimal GetTaskLocation(TASK_STATUS task)
        {
            decimal plantID = SessionManager.UserContext.HRLocation.Plant.PLANT_ID;

            switch ((TaskRecordType)task.RECORD_TYPE)
            {
            case TaskRecordType.HealthSafetyIncident:
            case TaskRecordType.PreventativeAction:
                INCIDENT incident = EHSIncidentMgr.SelectIncidentById(new PSsqmEntities(), task.RECORD_ID);
                if (incident != null && incident.DETECT_PLANT_ID.HasValue)
                {
                    plantID = (decimal)incident.DETECT_PLANT_ID;
                }
                break;

            case TaskRecordType.Audit:
                AUDIT audit = EHSAuditMgr.SelectAuditById(new PSsqmEntities(), task.RECORD_ID);
                if (audit != null && audit.DETECT_PLANT_ID.HasValue)
                {
                    plantID = (decimal)audit.DETECT_PLANT_ID;
                }
                break;
            }

            return(plantID);
        }
        protected void AddAttach(decimal auditId, decimal questionId)
        {
            EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(auditId, questionId);
            AUDIT            audit         = EHSAuditMgr.SelectAuditById(new PSsqmEntities(), auditId);
            int recordType = (int)TaskRecordType.Audit;

            // before we call the radWindow, we need to update the page?
            uclAttachWin.OpenManageAttachmentsWindow(recordType, audit.AUDIT_ID, auditQuestion.QuestionId.ToString(), Resources.LocalizedText.AttachmentsUpload.ToString(), Resources.LocalizedText.AttachmentsForAssessment.ToString());
        }
        private void AddTask(decimal auditID, decimal questionID)
        {
            int              recordType    = (int)TaskRecordType.Audit;
            AUDIT            audit         = EHSAuditMgr.SelectAuditById(new PSsqmEntities(), auditID);
            EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(auditID, questionID);

            //List<TASK_STATUS> tasks = TaskMgr.AuditTaskListByRecord(recordType, auditID, questionID);
            uclTask.BindTaskAdd(recordType, auditQuestion.AuditId, auditQuestion.QuestionId, "350", "T", auditQuestion.QuestionText, (decimal)audit.DETECT_PLANT_ID, "");
            string script = "function f(){OpenUpdateTaskWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
        }
Exemplo n.º 5
0
        public static void NotifyOnAuditCreate(decimal auditId, decimal personId)
        {
            var entities = new PSsqmEntities();

            decimal companyId = SessionManager.UserContext.HRLocation.Company.COMPANY_ID;
            decimal busOrgId  = SessionManager.UserContext.HRLocation.BusinessOrg.BUS_ORG_ID;
            var     emailIds  = new HashSet <decimal>();

            AUDIT  audit     = EHSAuditMgr.SelectAuditById(entities, auditId);
            string auditType = EHSAuditMgr.SelectAuditTypeByAuditId(auditId);

            emailIds.Add((decimal)audit.AUDIT_PERSON);

            if (emailIds.Count > 0)
            {
                string appUrl = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "MailURL").VALUE;
                if (string.IsNullOrEmpty(appUrl))
                {
                    appUrl = "the website";
                }

                string emailSubject = "Audit Created: " + auditType;
                string emailBody    = "A new audit has been created:<br/>" +
                                      "<br/>" +
                                      auditType + "<br/>" +
                                      "<br/>" +
                                      "Please log in to " + appUrl + auditPath + " to view the audit.";

                foreach (decimal eid in emailIds)
                {
                    string emailAddress = (from p in entities.PERSON where p.PERSON_ID == eid select p.EMAIL).FirstOrDefault();

                    Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "", "web"));
                    thread.IsBackground = true;
                    thread.Start();

                    //WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "");
                }
            }
        }