예제 #1
0
        public static List <VIDEO_ATTACHMENT> SelectVideoAttachmentListByRecord(int recordType, decimal recordID, string sessionID)
        {
            // get all attachments related to a specific record (ie quality issue, ehs incident, etc...)
            List <VIDEO_ATTACHMENT> ret = new List <VIDEO_ATTACHMENT>();

            try
            {
                using (PSsqmEntities entities = new PSsqmEntities())
                {
                    if (recordID == 0)
                    {
                        ret = (from d in entities.VIDEO_ATTACHMENT
                               where (d.RECORD_TYPE == recordType && d.SESSION_ID == sessionID)
                               select d).ToList();
                    }
                    else
                    {
                        ret = (from d in entities.VIDEO_ATTACHMENT
                               where (d.RECORD_TYPE == recordType && d.VIDEO_ID == recordID)
                               select d).ToList();
                    }
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }

            return(ret);
        }
        public void PopulateInitialForm()
        {
            PSsqmEntities entities = new PSsqmEntities();

            IncidentId = (IsEditContext) ? IncidentId : NewIncidentId;

            if (IncidentId > 0)
            {
                try
                {
                    ActionIncident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).Single();
                    PLANT plant = SQMModelMgr.LookupPlant(entities, (decimal)ActionIncident.DETECT_PLANT_ID, "");
                    if (plant != null)
                    {
                        IncidentLocationTZ = plant.LOCAL_TIMEZONE;
                    }
                }
                catch { }

                XLATList = SQMBasePage.SelectXLATList(new string[1] {
                    "ACTION_CATEGORY"
                }, SessionManager.UserContext.Person.PREFERRED_LANG_ID.HasValue ? (int)SessionManager.UserContext.Person.PREFERRED_LANG_ID : 1);

                decimal typeId = (IsEditContext) ? EditIncidentTypeId : SelectedTypeId;

                // what the f**k does this do ?
                //formSteps = EHSIncidentMgr.GetStepsForincidentTypeId(typeId);
                //totalFormSteps = formSteps.Count();

                InitializeForm();
            }
        }
예제 #3
0
        public static List <SETTINGS> SelectSettingsGroup(string settingGroup, string settingFamily)
        {
            List <SETTINGS> settingsList = null;

            using (PSsqmEntities entities = new PSsqmEntities())
            {
                try
                {
                    if (string.IsNullOrEmpty(settingFamily))
                    {
                        settingsList = (from s in entities.SETTINGS
                                        where (s.SETTING_GROUP.ToUpper() == settingGroup.ToUpper())
                                        orderby s.SETTING_CD
                                        select s).ToList();
                    }
                    else
                    {
                        settingsList = (from s in entities.SETTINGS
                                        where (s.SETTING_FAMILY.ToUpper() == settingFamily.ToUpper())
                                        orderby s.SETTING_GROUP, s.SETTING_CD
                                        select s).ToList();
                    }
                }
                catch (Exception ex)
                {
                    //SQMLogger.LogException(ex);
                }
            }
            return(settingsList);
        }
        public void Initialize(string partText, bool enableProgram, bool enableLocation, bool enableStatus, string partNumberPerspective)
        {
            _entities                     = new PSsqmEntities();
            _searchMgr                    = new B2BPartner().Initialize();
            _searchMgr.CompanyID          = SessionManager.SessionContext.PrimaryCompany.COMPANY_ID;
            hfPartNumberPerspective.Value = partNumberPerspective;   // show customer part number or internal part number

            if (SessionManager.B2BLocation != null)
            {
                _searchMgr.BusorgID = SessionManager.B2BLocation.BusinessOrg.BUS_ORG_ID;
                if (SessionManager.B2BLocation.Plant != null)
                {
                    _searchMgr.PlantID = SessionManager.B2BLocation.Plant.PLANT_ID;
                }

                decimal customerID = SessionManager.SessionContext.PrimaryCompany.COMPANY_ID;
                if (SessionManager.B2BLocation.IsCustomerCompany(true))     // show part programs for user's customer location
                {
                    customerID = SessionManager.B2BLocation.Company.COMPANY_ID;
                }

                rddlProgram.DataSource     = SQMModelMgr.SelectPartProgramList(customerID, 0);
                rddlProgram.DataTextField  = "PROGRAM_NAME";
                rddlProgram.DataValueField = "PROGRAM_ID";
                rddlProgram.DataBind();
                rddlProgram.Items.Insert(0, new DropDownListItem("Any Program", "0"));

                // Bind location dropdown
                if (enableLocation)
                {
                    rddlLocation.DataSource     = SQMModelMgr.SelectPlantList(_entities, _searchMgr.CompanyID, _searchMgr.BusorgID);
                    rddlLocation.DataTextField  = "PLANT_NAME";
                    rddlLocation.DataValueField = "PLANT_ID";
                    rddlLocation.DataBind();
                    rddlLocation.Items.Insert(0, new DropDownListItem("Any Location", "0"));
                    rddlLocation.SelectedValue = _searchMgr.PlantID.ToString();
                }
                else
                {
                    rddlLocation.DataSource = new List <PLANT>()
                    {
                        SessionManager.B2BLocation.Plant
                    };
                    rddlLocation.DataTextField  = "PLANT_NAME";
                    rddlLocation.DataValueField = "PLANT_ID";
                    rddlLocation.DataBind();
                    rddlLocation.SelectedIndex = 0;
                }

                rddlProgram.Visible  = enableProgram;
                rddlLocation.Visible = enableLocation;
                rddlStatus.Visible   = enableStatus;
                if (!string.IsNullOrEmpty(partText))
                {
                    rsbPart.Text = partText;
                }

                SetupPage();
            }
        }
        public void GetUploadedFiles(int recordType, decimal recordId)
        {
            _recordType = recordType;
            _recordId   = recordId;

            var entities = new PSsqmEntities();

            var files = (from a in entities.VIDEO_ATTACHMENT
                         where a.RECORD_TYPE == recordType && a.VIDEO_ID == recordId
                         orderby a.FILE_NAME
                         select new
            {
                VideoAttachId = a.VIDEO_ATTACH_ID,
                VideoId = a.VIDEO_ID,
                FileName = a.FILE_NAME,
                Description = a.DESCRIPTION,
                Size = a.FILE_SIZE,
                DisplayType = a.DISPLAY_TYPE,
                Title = a.TITLE
            }).ToList();

            rgFiles.DataSource = files;
            rgFiles.DataBind();

            rgFiles.Visible = (files.Count > 0);
        }
예제 #6
0
        public static List <PERSPECTIVE_TARGET_CALC> SelectTargetCalcList(PSsqmEntities ctx, decimal plantID, int year, int month)
        {
            List <PERSPECTIVE_TARGET_CALC> tcList = new List <PERSPECTIVE_TARGET_CALC>();

            try
            {
                if (plantID > 0)
                {
                    tcList = (from c in ctx.PERSPECTIVE_TARGET_CALC
                              where (c.PERIOD_YEAR == year && c.PERIOD_MONTH == month && (c.PLANT_ID == plantID || c.PLANT_ID == null))
                              select c).ToList();
                }
                else
                {
                    tcList = (from c in ctx.PERSPECTIVE_TARGET_CALC
                              where (c.PERIOD_YEAR == year && c.PERIOD_MONTH == month)
                              select c).OrderBy(l => l.PLANT_ID).ToList();
                }
            }
            catch (Exception e)
            {
                //     SQMLogger.LogException(e);
            }

            return(tcList);
        }
예제 #7
0
        public static PERSPECTIVE_VIEW LookupView(PSsqmEntities ctx, string perspective, string viewName, decimal viewID)
        {
            PERSPECTIVE_VIEW view = null;

            try
            {
                if (viewID > 0)
                {
                    view = (from v in ctx.PERSPECTIVE_VIEW.Include("PERSPECTIVE_VIEW_ITEM")
                            where (v.VIEW_ID == viewID)
                            select v).Single();
                }
                else
                {
                    view = (from v in ctx.PERSPECTIVE_VIEW.Include("PERSPECTIVE_VIEW_ITEM")
                            where (v.PERSPECTIVE == perspective && v.VIEW_NAME == viewName)
                            select v).Single();
                }
            }
            catch (Exception ex)
            {
                //SQMLogger.LogException(ex);
            }

            return(view);
        }
예제 #8
0
        /// <summary>
        /// Select a list of open EHS audits by company
        /// </summary>
        public static List <AUDIT> SelectOpenAudits(decimal companyId, List <decimal> plantIdList)
        {
            var audits = new List <AUDIT>();

            try
            {
                var date1900 = DateTime.Parse("01/01/1900 00:00:00");
                var entities = new PSsqmEntities();
                if (plantIdList == null)
                {
                    audits = (from i in entities.AUDIT
                              where i.AUDIT_TYPE.ToUpper() == "EHS" && (i.CLOSE_DATE == date1900 || i.CLOSE_DATE == null)
                              orderby i.AUDIT_ID descending
                              select i).ToList();
                }
                else
                {
                    audits = (from i in entities.AUDIT
                              where i.AUDIT_TYPE.ToUpper() == "EHS" && (i.CLOSE_DATE == date1900 || i.CLOSE_DATE == null) &&
                              plantIdList.Contains((decimal)i.DETECT_PLANT_ID)
                              orderby i.AUDIT_ID descending
                              select i).ToList();
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }

            return(audits);
        }
예제 #9
0
        public static List <PERSON> SelectAuditPersonList(decimal auditId)
        {
            var personSelectList = new List <PERSON>();
            var entities         = new PSsqmEntities();

            AUDIT   audit     = SelectAuditById(entities, auditId);
            decimal companyId = 0;

            if (audit.DETECT_COMPANY_ID != null)
            {
                companyId = audit.DETECT_COMPANY_ID;
            }

            // start with all data originators for the company
            List <PERSON> personList = SQMModelMgr.SelectPersonList(companyId, 0, true, false).Where(l => l.ROLE <= 300).OrderBy(p => p.LAST_NAME).ToList();

            personList = SQMModelMgr.FilterPersonListByAppContext(personList, "EHS");
            // limit the list to those people having access to the plant where the audit (if defined) occurred
            if (audit != null)
            {
                foreach (PERSON person in personList)
                {
                    if (SQMModelMgr.PersonPlantAccess(person, (decimal)audit.DETECT_PLANT_ID))
                    {
                        personSelectList.Add(person);
                    }
                }
            }

            personSelectList = personSelectList.OrderBy(p => p.FIRST_NAME).ToList();
            personSelectList = personSelectList.OrderBy(p => p.LAST_NAME).ToList();

            return(personSelectList);
        }
예제 #10
0
        public static List <AUDIT_TYPE> SelectAuditTypeList(decimal companyId, bool activeOnly)
        {
            var auditTypeList = new List <AUDIT_TYPE>();

            try
            {
                var entities = new PSsqmEntities();

                if (activeOnly)
                {
                    auditTypeList = (from itc in entities.AUDIT_TYPE
                                     where !itc.INACTIVE
                                     orderby itc.TITLE
                                     select itc).ToList();
                }
                else
                {
                    auditTypeList = (from itc in entities.AUDIT_TYPE
                                     orderby itc.TITLE
                                     select itc).ToList();
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }

            return(auditTypeList);
        }
예제 #11
0
        /// <summary>
        /// Select a list of all EHS audits by company
        /// </summary>
        public static List <AUDIT> SelectAudits(decimal companyId, List <decimal> plantIdList)
        {
            var audits = new List <AUDIT>();

            try
            {
                var entities = new PSsqmEntities();
                if (plantIdList == null)
                {
                    audits = (from i in entities.AUDIT
                              where i.AUDIT_TYPE.ToUpper() == "EHS"
                              orderby i.AUDIT_ID descending
                              select i).ToList();
                }
                else
                {
                    audits = (from i in entities.AUDIT
                              where i.AUDIT_TYPE.ToUpper() == "EHS" &&
                              plantIdList.Contains((decimal)i.DETECT_PLANT_ID)
                              orderby i.AUDIT_ID descending
                              select i).ToList();
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }

            return(audits);
        }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (this.entities = new PSsqmEntities())
            {
                var measures = (from m in this.entities.EHS_MEASURE
                                where m.MEASURE_CATEGORY == "SAFE" && m.MEASURE_SUBCATEGORY == "SAFE1"
                                select new { m.MEASURE_ID, m.MEASURE_CD }).ToDictionary(m => m.MEASURE_CD, m => m.MEASURE_ID);

                foreach (var history in this.entities.PLANT_ACCOUNTING)
                {
                    var date = new DateTime(history.PERIOD_YEAR, history.PERIOD_MONTH, 1);

                    this.AddToData(history.PLANT_ID, measures["S60002"], date, history.TIME_WORKED);
                    this.AddToData(history.PLANT_ID, measures["S60001"], date, history.TIME_LOST);
                    this.AddToData(history.PLANT_ID, measures["S20005"], date, history.TIME_LOST_CASES);
                    this.AddToData(history.PLANT_ID, measures["S60003"], date, history.TOTAL_DAYS_RESTRICTED);
                    this.AddToData(history.PLANT_ID, measures["S20004"], date, history.RECORDED_CASES);
                    this.AddToData(history.PLANT_ID, measures["S20003"], date, history.FIRST_AID_CASES);
                    this.AddToData(history.PLANT_ID, measures["S30003"], date, history.LEADERSHIP_WALKS);
                    this.AddToData(history.PLANT_ID, measures["S40003"], date, history.JOB_SILL_ANALYSIS);
                    this.AddToData(history.PLANT_ID, measures["S50001"], date, history.SAFETY_TRAIN_SESSIONS);
                }

                this.entities.SaveChanges();
            }
        }
        public void PopulateInitialForm()
        {
            PSsqmEntities entities = new PSsqmEntities();
            decimal       typeId   = (IsEditContext) ? EditIncidentTypeId : SelectedTypeId;

            if (IncidentId > 0)
            {
                try
                {
                    LocalIncident = (from i in entities.INCIDENT where i.INCIDENT_ID == IncidentId select i).SingleOrDefault();
                    PLANT plant = SQMModelMgr.LookupPlant(entities, (decimal)LocalIncident.DETECT_PLANT_ID, "");
                    if (plant != null)
                    {
                        IncidentLocationTZ = plant.LOCAL_TIMEZONE;
                    }


                    if (PageMode == PageUseMode.ViewOnly)
                    {
                        divTitle.Visible  = true;
                        lblFormTitle.Text = Resources.LocalizedText.RootCause;
                    }

                    pnlRoot5Y.Enabled = PageMode == PageUseMode.ViewOnly ? false : EHSIncidentMgr.CanUpdateIncident(LocalIncident, IsEditContext, SysPriv.originate, LocalIncident.INCFORM_LAST_STEP_COMPLETED);
                }
                catch { }
            }

            InitializeForm();
        }
예제 #14
0
        public static VIDEO_ATTACHMENT DeleteVideoAttachment(decimal videoAttachID)
        {
            VIDEO_ATTACHMENT this_at = null;

            try
            {
                using (PSsqmEntities entities = new PSsqmEntities())
                {
                    VIDEO_ATTACHMENT_FILE this_atfile = (from d in entities.VIDEO_ATTACHMENT_FILE
                                                         where (d.VIDEO_ATTACH_ID == videoAttachID)
                                                         select d).Single();
                    if (this_atfile != null)
                    {
                        entities.DeleteObject(this_atfile);
                        entities.SaveChanges();
                    }

                    this_at = (from d in entities.VIDEO_ATTACHMENT
                               where (d.VIDEO_ATTACH_ID == videoAttachID)
                               select d).Single();
                    if (this_at != null)
                    {
                        entities.DeleteObject(this_at);
                        entities.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }

            return(this_at);
        }
예제 #15
0
        public static List <PERSPECTIVE_VIEW> SelectViewList(string perspective, decimal companyID)
        {
            List <PERSPECTIVE_VIEW> viewList = new List <PERSPECTIVE_VIEW>();

            if (perspective != "0")
            {
                using (PSsqmEntities ctx = new PSsqmEntities())
                {
                    if (string.IsNullOrEmpty(perspective))
                    {
                        viewList = (from v in ctx.PERSPECTIVE_VIEW.Include("PERSPECTIVE_VIEW_ITEM")
                                    where (v.COMPANY_ID == companyID)
                                    select v).ToList();
                    }
                    else
                    {
                        viewList = (from v in ctx.PERSPECTIVE_VIEW.Include("PERSPECTIVE_VIEW_ITEM")
                                    where (v.PERSPECTIVE == perspective && v.COMPANY_ID == companyID)
                                    select v).ToList();
                    }
                }
            }

            return(viewList);
        }
예제 #16
0
        public static bool ShouldAuditReportClose(AUDIT audit)
        {
            var entities         = new PSsqmEntities();
            int auditClosedScore = 0;

            var questionList = SelectAuditQuestionList((decimal)audit.AUDIT_TYPE_ID, 0, audit.AUDIT_ID);

            foreach (var q in questionList)
            {
                string answer = (from a in entities.AUDIT_ANSWER
                                 where a.AUDIT_ID == audit.AUDIT_ID && a.AUDIT_QUESTION_ID == q.QuestionId
                                 select a.ANSWER_VALUE).FirstOrDefault();

                if (q.QuestionId == (decimal)EHSQuestionId.CompletionDate && !string.IsNullOrEmpty(answer))
                {
                    auditClosedScore++;
                }

                if (q.QuestionId == (decimal)EHSQuestionId.CompletedBy && !string.IsNullOrEmpty(answer))
                {
                    auditClosedScore++;
                }
            }

            return(auditClosedScore >= 2);
        }
예제 #17
0
        public static List <PERSPECTIVE_TARGET> SelectTargets(PSsqmEntities ctx, decimal companyID, int effectiveYear)
        {
            List <PERSPECTIVE_TARGET> targetList = new List <PERSPECTIVE_TARGET>();

            try
            {
                if (effectiveYear == 0)
                {
                    targetList = (from v in ctx.PERSPECTIVE_TARGET
                                  where (v.COMPANY_ID == companyID)
                                  select v).OrderBy(l => l.EFF_YEAR).ToList();
                }
                else
                {
                    targetList = (from v in ctx.PERSPECTIVE_TARGET
                                  where (v.COMPANY_ID == companyID && v.EFF_YEAR == effectiveYear)
                                  select v).ToList();
                    // try to select prior year if current does not exist
                    if (targetList == null || targetList.Count == 0)
                    {
                        targetList = (from v in ctx.PERSPECTIVE_TARGET
                                      where (v.COMPANY_ID == companyID && v.EFF_YEAR == (effectiveYear - 1))
                                      select v).ToList();
                    }
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }

            return(targetList);
        }
예제 #18
0
        /// <summary>
        /// Select a list of all EHS audits by company
        /// </summary>
        public static List <AUDIT_SCHEDULER> SelectActiveAuditSchedulers(decimal companyId, List <decimal> plantIdList)
        {
            var auditschedules = new List <AUDIT_SCHEDULER>();

            try
            {
                var entities = new PSsqmEntities();
                if (plantIdList == null)
                {
                    auditschedules = (from i in entities.AUDIT_SCHEDULER
                                      where i.INACTIVE == false
                                      orderby i.AUDIT_SCHEDULER_ID descending
                                      select i).ToList();
                }
                else
                {
                    auditschedules = (from i in entities.AUDIT_SCHEDULER
                                      where i.INACTIVE == false &&
                                      plantIdList.Contains((decimal)i.PLANT_ID)
                                      orderby i.AUDIT_SCHEDULER_ID descending
                                      select i).ToList();
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }

            return(auditschedules);
        }
예제 #19
0
        public static int UpdateTargetCalcList(PSsqmEntities ctx, List <PERSPECTIVE_TARGET_CALC> tcList, string updateBy)
        {
            int status = 0;

            try
            {
                for (int n = 0; n < tcList.Count; n++)
                {
                    PERSPECTIVE_TARGET_CALC tc = tcList[n];
                    if (tc.EntityState != EntityState.Unchanged)
                    {
                        tc = (PERSPECTIVE_TARGET_CALC)SQMModelMgr.SetObjectTimestamp(tc, updateBy, tc.EntityState);
                        if (tc.EntityState == EntityState.Detached)
                        {
                            ctx.AddToPERSPECTIVE_TARGET_CALC(tc);
                        }
                    }
                }
                status = ctx.SaveChanges();
            }
            catch (Exception e)
            {
                // SQMLogger.LogException(e);
            }

            return(status);
        }
예제 #20
0
        public static void CreateOrUpdateTask(decimal auditId, decimal responsiblePersonId, int recordTypeId, DateTime dueDate, string status)
        {
            var entities = new PSsqmEntities();

            AUDIT      audit   = SelectAuditById(entities, auditId);
            AUDIT_TYPE type    = SelectAuditTypeById(entities, audit.AUDIT_TYPE_ID);
            var        taskMgr = new TaskStatusMgr();

            taskMgr.Initialize(recordTypeId, auditId);
            taskMgr.LoadTaskList(recordTypeId, auditId);
            TASK_STATUS task = taskMgr.FindTask("0", "T", responsiblePersonId);

            if (task == null)
            {
                task        = taskMgr.CreateTask("0", "T", 0, type.TITLE.ToString(), dueDate, responsiblePersonId);
                task.STATUS = ((int)TaskMgr.CalculateTaskStatus(task)).ToString();
            }
            else
            {
                switch (status)
                {
                case "C":
                    task.STATUS = ((int)TaskStatus.Complete).ToString();
                    taskMgr.SetTaskComplete(task, responsiblePersonId);
                    break;
                }
                //task = taskMgr.UpdateTask(task, dueDate, responsiblePersonId, audit.AUDIT_TYPE_ID.ToString());
            }

            taskMgr.UpdateTaskList(auditId);
        }
예제 #21
0
        static void Main(string[] args)
        {
            output   = new StringBuilder();
            entities = new PSsqmEntities();
            DateTime currentTime = DateTime.UtcNow;

            WriteLine("Started: " + currentTime.ToString("hh:mm MM/dd/yyyy"));

            //OverdueTaskNotifications(currentTime);
            //return;

            // arguments:
            // no arguments supplied == exec all tasks
            // audit == schedule audits only
            // notify == send notifications only
            if (args.Length == 0 || args.Contains("audit"))
            {
                // Close & Schedule Audits from the Scheduler, based on local plant date & time
                AuditScheduler();
            }

            if (args.Length == 0 || args.Contains("notify"))
            {
                OverdueTaskNotifications(currentTime);
            }

            // After all Hourly processes are complete, wrap up the output log
            WriteLine("");
            WriteLine("Completed: " + DateTime.UtcNow.ToString("hh:mm MM/dd/yyyy"));

            WriteLogFile();
        }
예제 #22
0
        public static void DeleteAuditTask(decimal auditId, int recordTypeId)
        {
            var entities = new PSsqmEntities();
            var taskMgr  = new TaskStatusMgr();

            taskMgr.DeleteTask(recordTypeId, auditId);
        }
예제 #23
0
 static void UpdateOrdinalData(PSsqmEntities entities, EHS_DATA ehs_data, dynamic types, Dictionary <string, int> type_data)
 {
     if (type_data != null)              // might be null if ordinal data type not activated in the FIRSTAID-ORDINALS or RECORDABLE-ORDINALS SETTINGS table
     {
         foreach (var t in types)
         {
             string group = t.XLAT_GROUP;
             string code  = t.XLAT_CODE;
             var    data  = entities.EHS_DATA_ORD.FirstOrDefault(d => d.DATA_ID == ehs_data.DATA_ID && d.XLAT_GROUP == group && d.XLAT_CODE == code);
             if (type_data.ContainsKey(code))
             {
                 if (data == null)
                 {
                     entities.EHS_DATA_ORD.AddObject(new EHS_DATA_ORD()
                     {
                         EHS_DATA   = ehs_data,
                         XLAT_GROUP = t.XLAT_GROUP,
                         XLAT_CODE  = t.XLAT_CODE,
                         VALUE      = type_data[code]
                     });
                 }
                 else
                 {
                     data.VALUE = type_data[code];
                 }
             }
             else if (data != null)
             {
                 entities.DeleteObject(data);
             }
         }
     }
 }
        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_DESCRIPTION = item.ITEM_DESCRIPTION;
                    newItem.LAST_UPD_BY      = SessionManager.UserContext.Person.FIRST_NAME + " " + SessionManager.UserContext.Person.LAST_NAME;
                    newItem.LAST_UPD_DT      = DateTime.Now;

                    entities.AddToINCFORM_ROOT5Y(newItem);
                    status = entities.SaveChanges();
                }
            }
            return(status);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PSsqmEntities entities = new PSsqmEntities();

            companyId = SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID;

            if (IsPostBack)
            {
                // Since IsPostBack is always TRUE for every invocation of this user control we need some way
                // to determine whether or not to refresh its page controls, or just data bind instead.
                // Here we are using the "__EVENTTARGET" form event property to see if this user control is loading
                // because of certain page control events that are supposed to be fired off as actual postbacks.

                IsFullPagePostback = false;
                var targetID = Request.Form["__EVENTTARGET"];
                if (!string.IsNullOrEmpty(targetID))
                {
                    var targetControl = this.Page.FindControl(targetID);

                    if (targetControl != null)
                    {
                        if ((this.Page.FindControl(targetID).ID == "btnSave") ||
                            (this.Page.FindControl(targetID).ID == "btnNext") ||
                            (this.Page.FindControl(targetID).ID == "btnAddFinal"))
                        {
                            IsFullPagePostback = true;
                        }
                    }
                }
            }
        }
예제 #26
0
        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);
        }
예제 #27
0
        public static void CheckForUpdates(string baseCurrencyCode)
        {
            entities = new PSsqmEntities();

            //var currencyCodes = (from c in entities.CURRENCY where c.CURRENCY_CODE != baseCurrencyCode select c.CURRENCY_CODE).ToList();
            var currencyCodes = (from c in entities.CURRENCY select c.CURRENCY_CODE).ToList();

            DateTime lastMonth = DateTime.Now.AddMonths(-1);

            foreach (string quoteCurrencyCode in currencyCodes)
            {
                DateTime latestDate = new DateTime(2000, 1, 1);

                CURRENCY_XREF latestEntry = (from cx in entities.CURRENCY_XREF
                                             where cx.CURRENCY_CODE == quoteCurrencyCode
                                             orderby cx.EFF_YEAR descending, cx.EFF_MONTH descending
                                             select cx).FirstOrDefault();

                if (latestEntry != null)
                {
                    latestDate = new DateTime(latestEntry.EFF_YEAR, latestEntry.EFF_MONTH, 1);
                }

                if (latestDate < lastMonth)
                {
                    UpdateCurrency(baseCurrencyCode, quoteCurrencyCode, latestDate);
                }
            }
            entities.SaveChanges();
        }
예제 #28
0
        public static CURRENCY_XREF InsertRate(string currencyCode, int year, int month, double rate)
        {
            CURRENCY_XREF xref;

            using (PSsqmEntities entities = new PSsqmEntities())
            {
                try
                {
                    xref = (from x in entities.CURRENCY_XREF
                            where (x.EFF_YEAR == year && x.EFF_MONTH == month && x.CURRENCY_CODE == currencyCode)
                            select x).Single();
                }
                catch
                {
                    xref           = new CURRENCY_XREF();
                    xref.EFF_YEAR  = year;
                    xref.EFF_MONTH = month;
                    entities.AddToCURRENCY_XREF(xref);
                }

                xref.CURRENCY_CODE      = currencyCode;
                xref.BASE_CURRENCY_RATE = (decimal)rate;

                entities.SaveChanges();
            }

            return(xref);
        }
예제 #29
0
        public static List <PROB_CASE> SelectUserCaseList(List <PROB_CASE> problemCaseList)
        {
            var userCaseList = new List <PROB_CASE>();

            using (PSsqmEntities entities = new PSsqmEntities())
            {
                try
                {
                    foreach (PROB_CASE probCase in problemCaseList)
                    {
                        List <INCIDENT> incidentList = ProblemCase.LookupProbIncidentList(entities, probCase);
                        foreach (INCIDENT incident in incidentList)
                        {
                            if (SessionManager.PlantAccess((decimal)incident.DETECT_PLANT_ID) || (incident.RESP_PLANT_ID.HasValue && SessionManager.PlantAccess((decimal)incident.RESP_PLANT_ID)))
                            {
                                userCaseList.Add(probCase);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //  SQMLogger.LogException(ex);
                }
            }

            return(userCaseList);
        }
예제 #30
0
        public static List <VIDEO> SelectVideoListByRecord(int recordType, decimal recordID, string recordStep, string sessionID)
        {
            // get all attachments related to a specific record (ie quality issue, ehs incident, etc...)
            List <VIDEO> ret = new List <VIDEO>();

            try
            {
                using (PSsqmEntities entities = new PSsqmEntities())
                {
                    if (!string.IsNullOrEmpty(recordStep))
                    {
                        ret = (from d in entities.VIDEO
                               where (d.SOURCE_TYPE == recordType && d.SOURCE_ID == recordID && d.SOURCE_STEP == recordStep)
                               select d).ToList();
                    }
                    else
                    {
                        ret = (from d in entities.VIDEO
                               where (d.SOURCE_TYPE == recordType && d.SOURCE_ID == recordID)
                               select d).ToList();
                    }
                }
            }
            catch (Exception e)
            {
                //SQMLogger.LogException(e);
            }

            return(ret);
        }