示例#1
0
        public static DOCUMENT FindCurrentDocument(string docScope, int displayType)
        {
            DOCUMENT ret = null;

            try
            {
                using (PSsqmEntities entities = new PSsqmEntities())
                {
                    decimal company_id;
                    if (SessionManager.EffLocation != null)
                    {
                        company_id = SessionManager.EffLocation.Company.COMPANY_ID;
                    }
                    else
                    {
                        company_id = SQMModelMgr.LookupPrimaryCompany(entities).COMPANY_ID;
                    }

                    ret = (from d in entities.DOCUMENT.Include("DOCUMENT_FILE")
                           select d).OrderByDescending(d => d.UPLOADED_DT).Where(l => l.COMPANY_ID == company_id && l.DISPLAY_TYPE == displayType).First();
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
                ret = null;
            }

            return(ret);
        }
示例#2
0
        public static DOCUMENT GetDocument(decimal doc_id)
        {
            DOCUMENT ret = null;

            try
            {
                using (PSsqmEntities entities = new PSsqmEntities())
                {
                    decimal company_id;
                    if (SessionManager.EffLocation != null)
                    {
                        company_id = SessionManager.EffLocation.Company.COMPANY_ID;
                    }
                    else
                    {
                        company_id = SQMModelMgr.LookupPrimaryCompany(entities).COMPANY_ID;
                    }

                    ret = (from d in entities.DOCUMENT.Include("DOCUMENT_FILE")
                           where (
                               (d.COMPANY_ID == company_id)                                          //filter by company id as well, for security
                               &&
                               (d.DOCUMENT_ID == doc_id)
                               )
                           select d).Single();
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
                ret = null;
            }

            return(ret);
        }
        public static SessionContext CreateSessionContext(UserContext userContext)
        {
            // create session if it doesn't currently exist
            if (SessionManager.SessionContext == null)
            {
                try
                {
                    SessionManager.SessionContext = new SessionContext();

                    SessionManager.SessionContext.SetPrimaryCompany(SQMModelMgr.LookupPrimaryCompany(new PSsqmEntities()));                       // get the primary company (QAI customer));
                }
                catch (Exception e)
                {
                    //SQMLogger.LogException(e);
                    return(null);
                }
            }

            return(SessionManager.SessionContext);
        }
        public static SessionContext CreateSessionContext(UserContext userContext)
        {
            // create session if it doesn't currently exist
            if (SessionManager.SessionContext == null)
            {
                try
                {
                    SessionManager.SessionContext = new SessionContext();

                    SessionManager.SessionContext.SetPrimaryCompany(SQMModelMgr.LookupPrimaryCompany(new PSsqmEntities()));   // get the primary company (QAI customer));

                    // load the user's preferred language definition
                    SessionManager.SessionContext.SetLanguage((int)userContext.Person.PREFERRED_LANG_ID);
                }
                catch (Exception e)
                {
                    //SQMLogger.LogException(e);
                    return(null);
                }
            }

            return(SessionManager.SessionContext);
        }
示例#5
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                uclSearchBar.PageTitle.Text = lblProbCaseTitle.Text;
                CaseCtl().isDirected        = false;

                Ucl_DocMgr ucl = (Ucl_DocMgr)this.Master.FindControl("uclDocSelect");
                if (ucl != null)
                {
                    ucl.BindDocumentSelect(CaseCtl().Context == "EHS" ? CaseCtl().Context : "SQM", 0, true);
                }

                if (ddlPlantSelect.Items.Count < 1)
                {
                    List <PLANT> plantList = SQMModelMgr.SelectPlantList(entities, SQMModelMgr.LookupPrimaryCompany(entities).COMPANY_ID, 0);
                    ddlPlantSelect.Items.Clear();
                    foreach (PLANT plant in plantList)
                    {
                        if (SessionManager.PlantAccess(plant.PLANT_ID))
                        {
                            RadComboBoxItem item = new RadComboBoxItem(plant.PLANT_NAME, plant.PLANT_ID.ToString());
                            item.CssClass = "prompt";
                            item.Checked  = true;
                            ddlPlantSelect.Items.Add(item);
                        }
                    }
                    ddlStatusSelect.SelectedValue = "A";
                }

                // create new case from quality issue
                if ((bool)SessionManager.ReturnStatus)
                {
                    if (SessionManager.ReturnObject is QI_OCCUR)
                    {
                        QI_OCCUR qiIssue = (QI_OCCUR)SessionManager.ReturnObject;
                        CaseCtl().CreateNew("QI", SessionManager.PrimaryCompany().COMPANY_ID, SessionManager.UserContext.Person);
                        CaseCtl().isAutoCreated = true;
                        CaseCtl().problemCase.ProbCase.DESC_LONG = qiIssue.INCIDENT.DESCRIPTION;
                        CaseCtl().problemCase.AddIncident(qiIssue.INCIDENT_ID);
                        uclCaseEdit.BindIncidentList(CaseCtl().problemCase.IncidentList);
                        uclCaseEdit.BindPartIssueItemList(CaseCtl().problemCase.PartIssueItemList);
                    }
                    else if (SessionManager.ReturnObject is TASK_STATUS)
                    {
                        // from inbox
                        CaseCtl().isDirected           = true;
                        uclSearchBar.ReturnButton.Text = lblReturnInbox.Text;
                        TASK_STATUS task = (TASK_STATUS)SessionManager.ReturnObject;
                        uclCaseList_Click(task.RECORD_ID);
                        if (CaseCtl().problemCase.CheckCaseNextStep() >= Convert.ToInt32(task.TASK_STEP))
                        {
                            PageTabClicked("lbTab" + task.TASK_STEP, task.TASK_STEP);
                        }
                        else
                        {
                            PageTabClicked("lbTab0", "0");
                        }
                    }
                    else if (SessionManager.ReturnObject is decimal)
                    {
                        // from console list
                        uclCaseList_Click((decimal)SessionManager.ReturnObject);
                        PageTabClicked("lbTab0", "0");
                    }
                    else if (SessionManager.ReturnObject is INCIDENT)
                    {
                        // Problem case from EHS Incident
                        INCIDENT incident   = (INCIDENT)SessionManager.ReturnObject;
                        decimal  locationId = EHSIncidentMgr.SelectIncidentLocationIdByIncidentId(incident.INCIDENT_ID);
                        CaseCtl().CreateNew("EHS", SessionManager.PrimaryCompany().COMPANY_ID, SessionManager.UserContext.Person);
                        CaseCtl().problemCase.ProbCase.DESC_SHORT    = incident.ISSUE_TYPE;
                        CaseCtl().problemCase.ProbCase.DESC_LONG     = incident.DESCRIPTION;
                        CaseCtl().problemCase.ProbCase.PROBCASE_TYPE = "EHS";
                        CaseCtl().problemCase.AddIncident(incident.INCIDENT_ID);
                        uclCaseEdit.BindIncidentList(CaseCtl().problemCase.IncidentList);
                        if (CaseCtl().problemCase.ProbCase.PROB_DEFINE == null)
                        {
                            CaseCtl().problemCase.CreateProblemDefinition();
                        }
                        CaseCtl().isAutoCreated = true;
                    }
                    else
                    {
                        uclSearchBar_OnSearchClick();
                    }
                }
                else
                {
                    uclSearchBar_OnSearchClick();
                }
            }
            else
            {
                /* add incidents from qi issue popup list */
                if ((bool)SessionManager.ReturnStatus)
                {
                    if (SessionManager.ReturnObject.GetType().ToString().ToUpper().Contains("INCIDENT"))
                    {
                        List <INCIDENT> incidentList = (List <INCIDENT>)SessionManager.ReturnObject;
                        foreach (INCIDENT incident in incidentList)
                        {
                            CaseCtl().problemCase.AddIncident(incident.INCIDENT_ID);
                        }
                        uclCaseEdit.BindIncidentList(CaseCtl().problemCase.IncidentList);
                        uclCaseEdit.BindPartIssueItemList(CaseCtl().problemCase.PartIssueItemList);
                        PageTabClicked("lbTab0", "0");
                    }

                    else if (SessionManager.ReturnObject == "DisplayCases")
                    {
                        uclSearchBar_OnSearchClick();
                        SessionManager.ClearReturns();
                    }
                }
            }
            SessionManager.ClearReturns();

            if (CaseCtl().isAutoCreated)
            {
                CaseCtl().Update();
                SetupPage();
                PageTabClicked("lbTab0", "0");
            }
        }