Example #1
0
        private void SetupPage()
        {
            string[]        familyArray;
            string[]        groupArray;
            List <SETTINGS> settings = SQMSettings.SelectSettingsGroupExposed("", "");

            // select all of the Families
            familyArray = settings.Select(s => s.SETTING_FAMILY).Distinct().ToArray();
            // Select all of the groups for the default family
            if (familyArray.Count() > 0)
            {
                ddlSettingFamily.DataSource = familyArray;
                ddlSettingFamily.DataBind();

                groupArray = settings.Where(s => s.SETTING_FAMILY == familyArray[0]).Select(s => s.SETTING_GROUP).Distinct().ToArray();
                ddlSettingGroup.DataSource = groupArray;
                ddlSettingGroup.DataBind();

                if (groupArray.Count() > 0)
                {
                    // we need to populate the repeater
                    List <SETTINGS> set = SQMSettings.SelectSettingsGroupExposed(groupArray[0], familyArray[0]);
                    rptSettingList.DataSource = set;
                    rptSettingList.DataBind();
                }
            }
            ClearPage();
        }
Example #2
0
        //public static VIDEO_FILE SelectVideoFileById(decimal videoId)
        //{
        //	var entities = new PSsqmEntities();
        //	return (from i in entities.VIDEO_FILE where i.VIDEO_ID == videoId select i).FirstOrDefault();
        //}

        /// <summary>
        /// Delete all information for a specific video.
        /// </summary>
        /// <param name="videoId"></param>
        /// <param name="fileName"></param> Filename specified on the video record. Must be provided for file extension info.
        /// <returns></returns>
        public static int DeleteVideo(decimal videoId, string fileName)
        {
            int    status = 0;
            string delCmd = " IN (" + videoId + ") ";

            using (PSsqmEntities ctx = new PSsqmEntities())
            {
                try
                {
                    // delete all attachments
                    List <decimal> attachmentIds = (from a in ctx.VIDEO_ATTACHMENT
                                                    where a.VIDEO_ID == videoId
                                                    select a.VIDEO_ATTACH_ID).ToList();

                    if (attachmentIds != null && attachmentIds.Count > 0)
                    {
                        status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO_ATTACHMENT_FILE WHERE VIDEO_ATTACH_ID IN (" + String.Join(",", attachmentIds) + ")");
                        status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO_ATTACHMENT WHERE VIDEO_ATTACH_ID IN (" + String.Join(",", attachmentIds) + ")");
                    }

                    // delete the video from the Azure blob
                    // Retrieve storage account from connection string.
                    List <SETTINGS> sets               = SQMSettings.SelectSettingsGroup("MEDIA_UPLOAD", "");
                    string          storageContainer   = sets.Find(x => x.SETTING_CD == "STORAGE_CONTAINER").VALUE.ToString();
                    string          storageURL         = sets.Find(x => x.SETTING_CD == "STORAGE_URL").VALUE.ToString();
                    string          storageQueryString = sets.Find(x => x.SETTING_CD == "STORAGE_QUERY").VALUE.ToString();
                    string          fileType           = Path.GetExtension(fileName);
                    try
                    {
                        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                            CloudConfigurationManager.GetSetting("StorageConnectionString"));

                        // Create the blob client.
                        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

                        // Retrieve reference to a previously created container.
                        CloudBlobContainer container = blobClient.GetContainerReference(storageContainer);

                        // Retrieve reference to a blob named "myblob.txt".
                        CloudBlockBlob blockBlob = container.GetBlockBlobReference(videoId.ToString() + fileType);

                        // Delete the blob.
                        blockBlob.Delete();
                    }
                    catch (Exception videoEx)
                    {
                        // what to do if there is an exception? Just log the exception for now
                        SQMLogger.LogException(videoEx);
                    }
                    // delete the video header
                    status = ctx.ExecuteStoreCommand("DELETE FROM VIDEO WHERE VIDEO_ID" + delCmd);
                }
                catch (Exception ex)
                {
                    SQMLogger.LogException(ex);
                }
            }

            return(status);
        }
        public int BindUserList(List <PERSON> userList, decimal companyID)
        {
            int status = 0;

            if (companyID > 0)
            {
                SETTINGS sets = SQMSettings.GetSetting("COMPANY", "PLANTUSER");
                if (sets == null || sets.VALUE.ToUpper() != "N")
                {
                    SetPlantList(SQMModelMgr.SelectPlantList(new PSsqmEntities(), companyID, 0));
                }
            }
            else
            {
                SetPlantList(new List <PLANT>());
            }

            ToggleVisible(pnlUserList);
            rgUserList.DataSource = userList;
            rgUserList.DataBind();
            if (userList.Count == 0)
            {
                lblUserListEmpty.Visible = true;
            }

            return(status);
        }
        protected void btnVerify_Click(object sender, EventArgs e)
        {
            // retrieve the email from SQM_ACCESS
            lblForgotInvalidEmail.Visible = false;
            lblForgotNotSent.Visible      = false;
            lblForgotNotUpdated.Visible   = false;
            string strength            = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "COMPANY", "TASK", "PasswordComplexity").VALUE;
            string strEmailCompanyName = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailFromSystem").VALUE;
            int    msg = WebSiteCommon.RecoverPassword(tbEmail.Text.ToString(), "", strEmailCompanyName + " " + lblForgotPasswordEmailSubject.Text.ToString(), lblForgotPasswordEmailBody1a.Text.ToString() + strEmailCompanyName + lblForgotPasswordEmailBody1b.Text.ToString(), lblForgotPasswordEmailBody2.Text.ToString(), "<br><br>" + WebSiteCommon.GetXlatValueLong("passwordComplexity", strength) + "<br><br>" + lblForgotPasswordEmailBody3.Text.ToString());

            switch (msg)
            {
            case 10:
                tbEmail.Focus();
                lblForgotInvalidEmail.Visible = true;
                BindPwdForgot();
                break;

            case 20:
                tbEmail.Focus();
                lblForgotNotSent.Visible = true;
                BindPwdForgot();
                break;

            case 30:
                tbEmail.Focus();
                lblForgotNotUpdated.Visible = true;
                BindPwdForgot();
                break;

            default:
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "AlertPostback('" + hfForgotPasswordSent.Value + "','login');", true);
                break;
            }
        }
Example #5
0
        protected void btnSettingSearch_Click(object sender, EventArgs e)
        {
            // we need to populate the repeater
            List <SETTINGS> set = SQMSettings.SelectSettingsGroupExposed(ddlSettingGroup.SelectedValue.ToString(), ddlSettingFamily.SelectedValue.ToString());

            rptSettingList.DataSource = set;
            rptSettingList.DataBind();
        }
        public static void NotifyOnCreate(decimal incidentId, decimal plantId)
        {
            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>();

            INCIDENT incident         = EHSIncidentMgr.SelectIncidentById(entities, incidentId);
            string   incidentLocation = EHSIncidentMgr.SelectIncidentLocationNameByIncidentId(incidentId);
            string   incidentType     = EHSIncidentMgr.SelectIncidentTypeByIncidentId(incidentId);

            List <ATTACHMENT> attachList = SQM.Website.Classes.SQMDocumentMgr.SelectAttachmentListByRecord(40, incidentId, "", "");

            List <NOTIFY> notifications = SQMModelMgr.SelectNotifyHierarchy(companyId, busOrgId, plantId, 0, TaskRecordType.HealthSafetyIncident);

            foreach (NOTIFY n in notifications)
            {
                if (n.NOTIFY_PERSON1 != null)
                {
                    emailIds.Add((decimal)n.NOTIFY_PERSON1);
                }
                if (n.NOTIFY_PERSON2 != null)
                {
                    emailIds.Add((decimal)n.NOTIFY_PERSON2);
                }
            }

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

                string emailSubject = "Incident Created: " + incidentType + " (" + incidentLocation + ")";
                string emailBody    = "A new incident has been created:<br/>" +
                                      "<br/>" +
                                      incidentLocation + "<br/>" +
                                      incidentType + "<br/>" +
                                      "<br/>" +
                                      incident.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      "Please log in to " + appUrl + " to view the incident.";

                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", attachList));
                    thread.IsBackground = true;
                    thread.Start();

                    //WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "");
                }
            }
        }
        protected bool ShouldSendNotification()
        {
            bool shouldSend = false;

            var      entities = new PSsqmEntities();
            TimeSpan timeBetweenNotifications = new TimeSpan(24, 0, 0);
            DateTime lastSentDate;

            SETTINGS stHours = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "HoursBetweenNotifications");

            if (stHours != null)
            {
                if (!string.IsNullOrEmpty(stHours.VALUE))
                {
                    int hours;
                    if (Int32.TryParse(stHours.VALUE, out hours))
                    {
                        timeBetweenNotifications = new TimeSpan(hours, 0, 0);
                    }
                }

                SETTINGS stLastSent = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "NotificationLastSent");

                if (stLastSent != null)
                {
                    if (DateTime.TryParse(stLastSent.VALUE, out lastSentDate))
                    {
                        WriteLine("Last sent date: " + lastSentDate);
                        shouldSend = (DateTime.Now.Subtract(timeBetweenNotifications) > lastSentDate);

                        if (shouldSend == true)
                        {
                            // Set last sent date to now
                            stLastSent.VALUE = DateTime.Now.ToString();
                            SQMSettings.UpdateSettings(entities, stLastSent, "Automated Emailer");
                        }
                    }
                    else
                    {
                        shouldSend = false;
                    }
                }
                else
                {
                    WriteLine("Missing value in SETTINGS table: NotificationLastSent");
                    shouldSend = false;
                }
            }
            else
            {
                WriteLine("Missing value in SETTINGS table: HoursBetweenNotifications");
                shouldSend = false;
            }

            WriteLine("Should send: " + shouldSend);

            return(shouldSend);
        }
Example #8
0
        private void SetupPage()
        {
            if (ddlPlantSelect.Items.Count < 1)
            {
                List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true);
                SQMBasePage.SetLocationList(ddlPlantSelect, UserContext.FilterPlantAccessList(locationList), 0);

                rcbStatusSelect.SelectedValue = "A";
            }
            divAuditList.Visible = true;

            dmFromDate.ShowPopupOnFocus = dmToDate.ShowPopupOnFocus = true;
            // ABW 1/5/16 - use user's default plant local time for search default
            DateTime localTime = SessionManager.UserContext.LocalTime;

            dmFromDate.SelectedDate = localTime.AddMonths(-1);
            dmToDate.SelectedDate   = localTime.AddMonths(1);

            if (Mode == AuditMode.Audit)
            {
                lblViewEHSRezTitle.Text  = GetLocalResourceObject("lblViewEHSRezTitleResource1.Text").ToString();
                lblPageInstructions.Text = GetLocalResourceObject("lblPageInstructionsResource1.Text").ToString();
                //lblStatus.Text = "Assessment Status:";
                rbNew.Text           = GetLocalResourceObject("rbNewResource1.Text").ToString();
                lblAuditDate.Visible = true;
                phAudit.Visible      = true;

                SETTINGS sets = SQMSettings.GetSetting("EHS", "AUDITSEARCHFROM");
                if (sets != null)
                {
                    try
                    {
                        string[] args = sets.VALUE.Split('-');
                        if (args.Length > 1)
                        {
                            dmFromDate.SelectedDate = new DateTime(Convert.ToInt32(args[0]), Convert.ToInt32(args[1]), Convert.ToInt32(args[2]));
                        }
                        else
                        {
                            dmFromDate.SelectedDate = SessionManager.UserContext.LocalTime.AddMonths(Convert.ToInt32(args[0]) * -1);
                        }
                    }
                    catch { }
                }

                if (rcbAuditType.Items.Count < 1)
                {
                    foreach (AUDIT_TYPE ip in EHSAuditMgr.SelectAuditTypeList(SessionManager.PrimaryCompany().COMPANY_ID, false))
                    {
                        RadComboBoxItem item = new RadComboBoxItem(ip.TITLE, ip.AUDIT_TYPE_ID.ToString());
                        item.Checked = true;
                        rcbAuditType.Items.Add(item);
                    }
                }
            }
        }
        public void BindPwdEdit(bool bShowButtons)
        {
            string strength = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "COMPANY", "TASK", "PasswordComplexity").VALUE;

            lblPasswordPolicy.Text = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "PASSWORDCOMPLEXITY", "TASK", strength).VALUE;

            string script = "function f(){OpenPasswordEditWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
        }
        private void MessageDisplay(EHSProfileStatus status)
        {
            lblInputError.Visible = lblPeriodLimit.Visible = lblProfileNotExist.Visible = lblNoMetrics.Visible = lblNoInputs.Visible = lblRangeWarning.Visible = lblIncompleteInputs.Visible = false;
            uclExport.Visible     = phApproval.Visible = true;

            // suppress local approval input when auto-rollup settings are active
            SETTINGS sets = SQMSettings.GetSetting("EHS", "INPUTFINALIZE");

            if (sets != null && !string.IsNullOrEmpty(sets.VALUE))
            {
                phApproval.Visible = false;
            }

            if (LocalProfile() != null)
            {
                LocalProfile().CurrentStatus = status;
                BindSharedCalendars();
            }
            switch (status)
            {
            case EHSProfileStatus.NonExist:
                lblProfileNotExist.Visible = true;
                uclExport.Visible          = phApproval.Visible = false;
                break;

            case EHSProfileStatus.PeriodLimit:
                lblPeriodLimit.Visible = true;
                break;

            case EHSProfileStatus.InputError:
                lblInputError.Visible = true;
                break;

            case EHSProfileStatus.NoMeasures:
                lblNoMetrics.Visible = true;
                uclExport.Visible    = phApproval.Visible = false;
                break;

            case EHSProfileStatus.NoInputs:
                lblNoInputs.Visible = true;
                break;

            case EHSProfileStatus.OutOFRange:
                lblRangeWarning.Visible = true;
                break;

            case EHSProfileStatus.Incomplete:
                lblIncompleteInputs.Visible = true;
                break;

            default:
                break;
            }
        }
        public void GetUploadedFiles()
        {
            List <SETTINGS> sets = SQMSettings.SelectSettingsGroup("MEDIA_UPLOAD", "");

            storageContainer   = sets.Find(x => x.SETTING_CD == "STORAGE_CONTAINER").VALUE.ToString();
            storageURL         = sets.Find(x => x.SETTING_CD == "STORAGE_URL").VALUE.ToString();
            storageQueryString = sets.Find(x => x.SETTING_CD == "STORAGE_QUERY").VALUE.ToString();

            var entities = new PSsqmEntities();

            var files = (from a in entities.VIDEO
                         where a.SOURCE_TYPE == _recordType && a.SOURCE_ID == _recordId
                         orderby a.FILE_NAME
                         select new
            {
                VideoId = a.VIDEO_ID,
                RecordStep = a.SOURCE_STEP,
                FileName = a.FILE_NAME,
                Description = a.DESCRIPTION,
                Title = a.TITLE,
                Size = a.FILE_SIZE
            }).ToList();

            if (!string.IsNullOrEmpty(_recordStep))
            {
                if (_recordType == 40 && _recordStep == "2")                 // Special case to cover second page incident attachments originally entered with no recordstep
                {
                    rgFiles.DataSource = files.Where(f => (f.RecordStep == "2" || f.RecordStep == ""));
                }
                else
                {
                    rgFiles.DataSource = files.Where(f => f.RecordStep == _recordStep);
                }
            }
            else
            {
                rgFiles.DataSource = files;
            }
            rgFiles.DataBind();

            if (files.Count > 0 && (_recordType == (int)TaskRecordType.Audit || _recordType == (int)TaskRecordType.HealthSafetyIncident))
            {
                pnlListVideo.Visible      = true;
                rgFiles.Visible           = true;
                pnlNoVideosClosed.Visible = false;
            }
            else
            {
                pnlListVideo.Visible = false;
                rgFiles.Visible      = false;
            }
            //rgFiles.Visible = (files.Count > 0);
        }
        protected void PreviewFile(object sender, EventArgs e)
        {
            byte[] fileContent;
            if (ddlDataType.SelectedValue.Equals(""))
            {
                SetStatusMessage("You must select a file type from the drop down list");
            }
            else if (ddlPlantSelect.SelectedIndex == 0 && ddlDataType.SelectedValue.Equals("RECEIPT"))
            {
                SetStatusMessage("You must select a Receiving Location to upload a receipt record");
            }
            else
            {
                // validate the date in the select control
                periodYear  = 0;
                periodMonth = 0;

                List <SETTINGS> sets = SQMSettings.SelectSettingsGroup("FILE_UPLOAD", ""); // ABW 20140805

                string        fileName       = ddlDataType.SelectedValue.ToString() + ".TXT";
                int           primaryCompany = Convert.ToInt32(sets.Find(x => x.SETTING_CD == "CompanyID").VALUE);
                PSsqmEntities Entities       = new PSsqmEntities();
                BUSINESS_ORG  busOrg         = SQMModelMgr.LookupBusOrg(Entities, primaryCompany, "", true, false);
                selectedFile = tbFileSelected.Text = flUpload.FileName;
                int fileLen = flUpload.PostedFile.ContentLength;

                fileContent = new byte[Convert.ToInt32(fileLen)];
                int nBytes = flUpload.PostedFile.InputStream.Read(fileContent, 0, Convert.ToInt32(fileLen));
                fileDelimiter       = sets.Find(x => x.SETTING_CD == "FileDelimiter1").VALUE.ToCharArray();
                plantDataMultiplier = 1;

                //fileReader = new SQMFileReader().InitializeCSV(1, flUpload.PostedFile.FileName, fileContent, fileDelimiter, plantDataMultiplier);
                fileReader = new SQMFileReader().InitializeCSV(primaryCompany, fileName, fileContent, fileDelimiter, plantDataMultiplier, periodYear, periodMonth, busOrg.PREFERRED_CURRENCY_CODE);
                using (StreamReader sr = new StreamReader(fileReader.FileStream))
                {
                    string line;
                    int    lineNo = 0;

                    while ((line = sr.ReadLine()) != null)
                    {
                        fileReader.PreviewList.Add(line);
                    }
                    gvPreview.DataSource = fileReader.PreviewList;
                    gvPreview.DataBind();
                    gvPreview.Visible      = true;
                    gvExcelPreview.Visible = false;
                }
            }
            if (ddlDataType.SelectedValue.Equals("RECEIPT"))
            {
                dvPlantSelect.Style.Add("display", "inline");
            }
        }
Example #13
0
        protected void lnkEditCode_Click(object sender, EventArgs e)
        {
            LinkButton lnk = (LinkButton)sender;

            string[] args = lnk.CommandArgument.ToString().Split('~');
            selectedCode = SQMSettings.SelectSettingByCode(entities, ddlSettingGroup.SelectedValue.ToString(), ddlSettingFamily.SelectedValue.ToString(), args[0]);
            uclSearchBar.SetButtonsEnabled(false, false, false, true, false, false);
            uclSearchBar.SetButtonsVisible(false, false, false, true, false, false);
            uclSearchBar.SetButtonsNotClicked();
            uclSearchBar.TitleItem.Text = selectedCode.SETTING_CD;
            tbValue.Enabled             = true;
            DisplaySetting(args[1]);
        }
Example #14
0
        private void SetupPage()
        {
            if (ddlPlantSelect.Items.Count < 1)
            {
                List <BusinessLocation> locationList = SQMModelMgr.SelectBusinessLocationList(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, 0, true);
                SQMBasePage.SetLocationList(ddlPlantSelect, UserContext.FilterPlantAccessList(locationList), 0);

                rcbStatusSelect.SelectedValue = "A";
            }
            divAuditList.Visible = true;

            dmFromDate.ShowPopupOnFocus = dmToDate.ShowPopupOnFocus = true;
            dmFromDate.SelectedDate     = DateTime.Now.AddMonths(-1);
            dmToDate.SelectedDate       = DateTime.Now.AddMonths(1);

            if (Mode == AuditMode.Audit)
            {
                lblViewEHSRezTitle.Text  = "Manage Environmental Health &amp; Safety Audits";
                lblPageInstructions.Text = "Add or update EH&amp;S Audits below.";
                //lblStatus.Text = "Audit Status:";
                rbNew.Text           = "New Audit";
                lblAuditDate.Visible = true;
                phAudit.Visible      = true;

                SETTINGS sets = SQMSettings.GetSetting("EHS", "AUDITSEARCHFROM");
                if (sets != null)
                {
                    try
                    {
                        string[] args = sets.VALUE.Split('-');
                        if (args.Length > 1)
                        {
                            dmFromDate.SelectedDate = new DateTime(Convert.ToInt32(args[0]), Convert.ToInt32(args[1]), Convert.ToInt32(args[2]));
                        }
                        else
                        {
                            dmFromDate.SelectedDate = DateTime.Now.AddMonths(Convert.ToInt32(args[0]) * -1);
                        }
                    }
                    catch { }
                }

                foreach (AUDIT_TYPE ip in EHSAuditMgr.SelectAuditTypeList(SessionManager.PrimaryCompany().COMPANY_ID, false))
                {
                    RadComboBoxItem item = new RadComboBoxItem(ip.TITLE, ip.AUDIT_TYPE_ID.ToString());
                    item.Checked = true;
                    rcbAuditType.Items.Add(item);
                }
            }
        }
        protected void rgPrivList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                if (defaultPrivs == null)
                {
                    defaultPrivs = SQMSettings.SelectSettingsGroup("DEFAULT_PRIVS", "");
                }

                GridDataItem item = (GridDataItem)e.Item;
                Label        lbl;
                LinkButton   lnk;

                PRIVLIST data = (PRIVLIST)item.DataItem;

                if (data.PRIV_GROUP != null)
                {
                    lbl      = (Label)item.FindControl("lblPrivDesc");
                    lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "PRIV_PRIV" && x.XLAT_CODE == data.PRIV.ToString()).FirstOrDefault().DESCRIPTION_SHORT;

                    lbl      = (Label)item.FindControl("lblScope");
                    lbl.Text = XLATList.Where(x => x.XLAT_GROUP == "PRIV_SCOPE" && x.XLAT_CODE == data.SCOPE.ToString()).FirstOrDefault().DESCRIPTION_SHORT;

                    lnk = (LinkButton)item.FindControl("lnkDeletePriv");
                    lnk.CommandArgument = data.PRIV_GROUP.ToString() + "~" + data.PRIV.ToString() + "~" + data.SCOPE.ToString();
                    // hide the link for the default privs that can't be removed
                    if (defaultPrivs.Count > 0)
                    {
                        foreach (SETTINGS setting in defaultPrivs)
                        {
                            try
                            {
                                priv   = Convert.ToInt16(setting.SETTING_CD.ToString());
                                scopes = setting.VALUE.ToString().Split(',');
                                for (int i = 0; i < scopes.Count(); i++)
                                {
                                    if (data.PRIV == Convert.ToInt16(setting.SETTING_CD.Trim()) && data.SCOPE == scopes[i].Trim())
                                    {
                                        lnk.Visible = false;
                                    }
                                }
                            }
                            catch { }
                        }
                    }
                }
            }
        }
Example #16
0
        protected bool SaveSettings(bool updateSetting)
        {
            PSsqmEntities Entities = new PSsqmEntities();
            string        strCode  = selectedCode.SETTING_CD;
            SETTINGS      settings = SQMSettings.SelectSettingByCode(Entities, ddlSettingGroup.SelectedValue.ToString(), ddlSettingFamily.SelectedValue.ToString(), strCode);

            bool success;

            // AW20131106 - need to verify that the SSO_ID and email address are unique in the system
            bool bErrors = false;

            settings.VALUE = tbValue.Text.ToString();
            // update the code
            selectedCode = SQMSettings.UpdateSettings(Entities, settings, SessionManager.UserContext.UserName());
            return(true);
        }
        public void BindPrivGroups(List <PRIVGROUP> privGroupList, BusinessLocation businessLocation, string context)
        {
            hfPrivGroupContext.Value = context;

            if (ddlPrivGroupStatus.Items.Count == 0)
            {
                XLATList = SQMBasePage.SelectXLATList(new string[3] {
                    "ACTIVE_STATUS", "PRIV_PRIV", "PRIV_SCOPE"
                });

                ddlPrivGroupStatus.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "ACTIVE_STATUS").ToList();
                ddlPrivGroupStatus.DataValueField = "XLAT_CODE";
                ddlPrivGroupStatus.DataTextField  = "DESCRIPTION";
                ddlPrivGroupStatus.DataBind();
            }

            if (ddlScope.Items.Count == 0)
            {
                ddlScope.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "PRIV_SCOPE").ToList();
                ddlScope.DataValueField = "XLAT_CODE";
                ddlScope.DataTextField  = "DESCRIPTION";
                ddlScope.DataBind();
            }

            if (ddlPriviledge.Items.Count == 0)
            {
                ddlPriviledge.DataSource     = XLATList.Where(x => x.XLAT_GROUP == "PRIV_PRIV").ToList();
                ddlPriviledge.DataValueField = "XLAT_CODE";
                ddlPriviledge.DataTextField  = "DESCRIPTION";
                ddlPriviledge.DataBind();
                RadComboBoxItem item = new RadComboBoxItem("", "select a priviledge level");
                ddlPriviledge.Items.Insert(0, item);
                try
                {
                    item         = ddlPriviledge.FindItemByValue("100");
                    item.Enabled = false;
                }
                catch { }
            }

            defaultPrivs = SQMSettings.SelectSettingsGroup("DEFAULT_PRIVS", "");

            pnlPrivGroups.Visible = true;

            rgPrivGroup.DataSource = privGroupList;
            rgPrivGroup.DataBind();
        }
Example #18
0
        protected void ddlSettingFamily_SelectedIndexChanged(object sender, EventArgs e)
        {
            string[]        groupArray;
            List <SETTINGS> settings = SQMSettings.SelectSettingsGroupExposed("", ddlSettingFamily.SelectedValue.ToString());

            groupArray = settings.Select(s => s.SETTING_GROUP).Distinct().ToArray();
            ddlSettingGroup.DataSource = groupArray;
            ddlSettingGroup.DataBind();

            //if (groupArray.Count() > 0)
            //{
            //	// we need to populate the repeater
            //	List<SETTINGS> set = SQMSettings.SelectSettingsGroup(groupArray[0], "");
            //	rptSettingList.DataSource = set;
            //	rptSettingList.DataBind();
            //}
        }
        protected void OnPlantProfileSelect(decimal plantID)
        {
            ClearInput();

            if (directedPlantID > 0)  // override plant select ddl when directed from inbox, etc...
            {
                SetLocalProfile(new EHSProfile().Load(directedPlantID, false, true));
            }
            else
            {
                SetLocalProfile(new EHSProfile().Load(plantID, false, true));
            }

            MessageDisplay(LocalProfile().Status);
            if (LocalProfile().Status != EHSProfileStatus.Normal)
            {
                return;
            }

            AccessMode accessMode = UserContext.CheckAccess("EHS", "311");

            if (accessMode > AccessMode.Update)
            {
                LocalProfile().FilterByResponsibleID = 0;
                LocalProfile().MinPeriodDate         = new DateTime(2001, 1, 1);
                uclInputHdr.LoadProfileInputHdr(false, LocalProfile().MinPeriodDate, DateTime.Now, SessionManager.UserContext.HRLocation.Plant.PLANT_ID, true, true);
            }
            else
            {
                LocalProfile().FilterByResponsibleID = SessionManager.UserContext.Person.PERSON_ID;
                SETTINGS sets = SQMSettings.GetSetting("EHS", "INPUTLIMIT");
                LocalProfile().MinPeriodDate = DateTime.Now.AddMonths(sets != null ? Convert.ToInt32(sets.VALUE) * -1 : -5);
                uclInputHdr.LoadProfileInputHdr(false, LocalProfile().MinPeriodDate, DateTime.Now, SessionManager.UserContext.HRLocation.Plant.PLANT_ID, true, true);
            }

            if (directedPlantID > 0)  // override plant select ddl when directed from inbox, etc...
            {
                uclInputHdr.SelectLocation(LocalProfile().Plant);
            }

            if (LocalProfile() != null && LocalProfile().Status == EHSProfileStatus.Normal)
            {
                OnInputPeriodSelect(uclInputHdr.SelectedPeriodDate);
            }
        }
        //protected void btnReceiptsSearchClick(object sender, EventArgs e)
        //{
        //	if (OnSearchReceiptsClick != null)
        //	{
        //		Button btn = (Button)sender;
        //		OnSearchReceiptsClick(btn.CommandArgument);
        //	}
        //}

        #endregion


        #region ehsaudit

        public void BindAuditListRepeater(object theList, string appContext)
        {
            pnlAuditListRepeater.Visible = true;
            staticAppContext             = appContext;

            // first check settings to see if the company allows ReAudits
            List <SETTINGS> sets = SQMSettings.SelectSettingsGroup("AUDIT", "");            // ABW 20140805

            allowReAudits = "";
            try
            {
                allowReAudits = sets.Find(x => x.SETTING_CD == "AllowReAudit").VALUE;
            }
            catch { }


            rgAuditList.DataSource = theList;
            rgAuditList.DataBind();
        }
Example #21
0
        protected void OnPlantProfileSelect(decimal plantID)
        {
            ClearInput();

            if (directedPlantID > 0)  // override plant select ddl when directed from inbox, etc..
            {
                SetLocalProfile(new EHSProfile().Load(directedPlantID, false, true));
            }
            else
            {
                SetLocalProfile(new EHSProfile().Load(plantID, false, true));
            }

            MessageDisplay(LocalProfile().Status);
            if (LocalProfile().Status != EHSProfileStatus.Normal)
            {
                return;
            }

            if (UserContext.GetMaxScopePrivilege(SysScope.envdata) < SysPriv.originate)              // allow approvers and admins to see all metrics
            {
                LocalProfile().FilterByResponsibleID = 0;
                LocalProfile().MinPeriodDate         = new DateTime(2001, 1, 1);
                uclInputHdr.LoadProfileInputHdr(false, LocalProfile().MinPeriodDate, DateTime.Now, SessionManager.UserContext.HRLocation.Plant.PLANT_ID, true, true);
            }
            else
            {
                LocalProfile().FilterByResponsibleID = SessionManager.UserContext.Person.PERSON_ID;
                SETTINGS sets = SQMSettings.GetSetting("EHS", "INPUTLIMIT");
                LocalProfile().MinPeriodDate = DateTime.Now.AddMonths(sets != null ? Convert.ToInt32(sets.VALUE) * -1 : -5);
                uclInputHdr.LoadProfileInputHdr(false, LocalProfile().MinPeriodDate, DateTime.Now, SessionManager.UserContext.HRLocation.Plant.PLANT_ID, true, true);
            }

            if (directedPlantID > 0)  // override plant select ddl when directed from inbox, etc...
            {
                uclInputHdr.SelectLocation(LocalProfile().Plant);
            }

            if (LocalProfile() != null && LocalProfile().Status == EHSProfileStatus.Normal)
            {
                OnInputPeriodSelect(uclInputHdr.SelectedPeriodDate);
            }
        }
 public void BindOrgListRepeater(List <BUSINESS_ORG> theList)
 {
     if (theList.Count > 0)
     {
         SETTINGS sets = SQMSettings.GetSetting("COMPANY", "PLANTUSER");
         if (sets == null || sets.VALUE.ToUpper() != "N")
         {
             SetUserList(SQMModelMgr.SelectPersonList(theList[0].COMPANY_ID, 0, true, false));
         }
     }
     else
     {
         SetUserList(new List <PERSON>());
     }
     ToggleVisible(pnlOrgListRepeater);
     totalRowCount            = 0;
     rptBusOrgList.DataSource = theList;
     rptBusOrgList.DataBind();
     SetRepeaterDisplay(rptBusOrgList, lblBusOrgListEmptyRepeater, divGVScrollOrgListRepeater, 8, (TotalRowCount += rptBusOrgList.Items.Count), "scrollAreaLarge");
 }
Example #23
0
        public static int NotifyIncidentTaskAssigment(INCIDENT incident, TASK_STATUS theTask, string scopeAction)
        {
            int    status = 0;
            PLANT  plant  = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID);
            PERSON person = SQMModelMgr.LookupPerson((decimal)theTask.RESPONSIBLE_ID, "");

            if (person != null && !string.IsNullOrEmpty(person.EMAIL))
            {
                List <XLAT> XLATList = SQMBasePage.SelectXLATList(new string[3] {
                    "NOTIFY_SCOPE", "NOTIFY_SCOPE_TASK", "NOTIFY_TASK_STATUS"
                });
                string appUrl = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailURL").VALUE;
                if (string.IsNullOrEmpty(appUrl))
                {
                    appUrl = "the website";
                }

                string emailTo      = person.EMAIL;
                string actionText   = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == scopeAction).FirstOrDefault().DESCRIPTION;
                string emailSubject = "Health/Safety Incident " + actionText + ": " + incident.ISSUE_TYPE + " (" + plant.PLANT_NAME + ")";
                string emailBody    = "You have been assigned to one or more tasks regarding the following Incident: <br/>" +
                                      "<br/>" +
                                      "Incident ID: " + WebSiteCommon.FormatID(incident.INCIDENT_ID, 6) + "<br/>" +
                                      plant.PLANT_NAME + "<br/>" +
                                      incident.ISSUE_TYPE + "<br/>" +
                                      "<br/>" +
                                      incident.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      theTask.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      "Due : " + theTask.DUE_DT.ToString() + "<br/>" +
                                      "<br/>" +
                                      "Please log in to " + (appUrl + incidentPath) + " to view this incident.";

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

            return(status);
        }
        public void BindAuditListRepeater(object theList, string appContext)
        {
            pnlAuditListRepeater.Visible = true;
            staticAppContext             = appContext;

            List <SETTINGS> sets = SQMSettings.SelectSettingsGroup("AUDIT", "");

            string expandDetails = sets.Find(x => x.SETTING_CD == "AuditExceptionExpanded").VALUE.ToString();

            if (expandDetails != null && expandDetails.ToUpper().Equals("Y"))
            {
                rgAuditList.MasterTableView.GroupsDefaultExpanded = true;
            }
            else
            {
                rgAuditList.MasterTableView.GroupsDefaultExpanded = false;
            }

            rgAuditList.DataSource = theList;
            rgAuditList.DataBind();
        }
Example #25
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, "");
                }
            }
        }
        public void gvPlantList_OnRowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
        {
            if ((!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Header.ToString())) & (!e.Row.RowType.ToString().Trim().Equals(System.Web.UI.WebControls.ListItemType.Footer.ToString())))
            {
                System.Web.UI.WebControls.Label       lbl     = new Label();
                System.Web.UI.WebControls.HiddenField hfField = new HiddenField();

                try
                {
                    lbl      = (Label)e.Row.Cells[0].FindControl("lblLocationType_out");
                    hfField  = (HiddenField)e.Row.Cells[0].FindControl("hfLocationType");
                    lbl.Text = WebSiteCommon.GetXlatValue("locationType", hfField.Value);

                    lbl      = (Label)e.Row.Cells[0].FindControl("lblStatus_out");
                    hfField  = (HiddenField)e.Row.Cells[0].FindControl("hfStatus_out");
                    lbl.Text = WebSiteCommon.GetStatusString(hfField.Value);

                    SETTINGS sets = SQMSettings.GetSetting("COMPANY", "PLANTUSER");
                    if (sets == null || sets.VALUE.ToUpper() != "N")
                    {
                        LinkButton  lnk     = (LinkButton)e.Row.Cells[0].FindControl("lnkView_out");
                        decimal     plantID = Convert.ToDecimal(lnk.CommandArgument);
                        HiddenField hf      = (HiddenField)e.Row.Cells[0].FindControl("hfPlantCompanyID");
                        lnk.ToolTip = "";
                        foreach (PERSON person in UserList())
                        {
                            if (person.ROLE > 1 && SQMModelMgr.PersonPlantAccess(person, plantID))
                            {
                                lnk.ToolTip += (" " + person.FIRST_NAME + " " + person.LAST_NAME + ",");
                            }
                        }
                        lnk.ToolTip = lnk.ToolTip.TrimEnd(',');
                    }
                }
                catch
                {
                }
            }
        }
Example #27
0
        protected void SetupPage()
        {
            hdCurrentActiveMenu.Value = SessionManager.CurrentMenuItem;

            lbBusinessCard1_out.Text = SessionManager.UserContext.UserName(); // +": " + SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME;
            lblActiveLocation.Text   = SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME;
            if (SessionManager.StatOfTheDay != null)
            {
                lblActiveLocation.Text   = SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME + ": ";
                lblStatOfTheDay_out.Text = SQMBasePage.FormatValue(SessionManager.StatOfTheDay.Value, 0);
                lblStatOfTheDay.Visible  = lblStatOfTheDay_out.Visible = true;
            }
            else
            {
                lblStatOfTheDay_out.Text = "n/a";
            }
            pnlStatOfTheDay.Visible = true;

            if (ddlUserLang.Items.Count == 0)
            {
                foreach (LOCAL_LANGUAGE lang in SQMModelMgr.SelectLanguageList(new PSsqmEntities(), true))
                {
                    ddlUserLang.Items.Add(new RadComboBoxItem(lang.LANGUAGE_NAME, lang.LANGUAGE_ID.ToString()));
                }
            }
            tbUserPhone.Text = SessionManager.UserContext.Person.PHONE;
            if (ddlUserLang.FindItemByValue(SessionManager.UserContext.Person.PREFERRED_LANG_ID.ToString()) != null)
            {
                ddlUserLang.SelectedValue = SessionManager.UserContext.Person.PREFERRED_LANG_ID.ToString();
            }

            // ABW 20160118 - show password reset based on parameter
            SETTINGS setsPwdReset = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "COMPANY", "TASK", "PasswordResetEnable");

            if (setsPwdReset != null && setsPwdReset.VALUE.ToUpper() == "Y")
            {
                trChangePwd.Visible = true;
            }
        }
        protected void rgAuditAnswers_ItemCommand(object sender, GridCommandEventArgs e)
        {
            // add this back to the grid to hit this code... OnItemCommand="rgAuditAnswers_ItemCommand"
            // only close if the company setting AuditExceptionExpanded = "N"
            List <SETTINGS> sets = SQMSettings.SelectSettingsGroup("AUDIT", "");

            string expandDetails = sets.Find(x => x.SETTING_CD == "AuditExceptionExpanded").VALUE.ToString();

            if (expandDetails == null || !expandDetails.ToUpper().Equals("Y"))
            {
                if (e.CommandName == RadGrid.ExpandCollapseCommandName)
                {
                    foreach (GridItem item in e.Item.OwnerTableView.Items)
                    {
                        if (item.Expanded && item != e.Item && item.Parent.ID != e.Item.Parent.ID)
                        {
                            item.Expanded = false;
                        }
                    }
                }
            }
        }
Example #29
0
        private void uclSearchBar_OnSaveClick()
        {
            lblErrorUpdating.Visible    = false;
            lblConfirmMustMatch.Visible = false;
            if (hdnEncrypt.Value.ToString().Equals("True") && !tbValue.Text.ToString().Equals(tbValueConfirm.Text.ToString()))
            {
                lblConfirmMustMatch.Visible = true;
                return;
            }
            bool success = SaveSettings(true);

            if (success)
            {
                ClearPage();
                List <SETTINGS> set = SQMSettings.SelectSettingsGroupExposed(ddlSettingGroup.SelectedValue.ToString(), ddlSettingFamily.SelectedValue.ToString());
                rptSettingList.DataSource = set;
                rptSettingList.DataBind();
            }
            else
            {
                lblErrorUpdating.Visible = true;
            }
        }
        protected void rgUserList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                try
                {
                    GridDataItem item = (GridDataItem)e.Item;
                    PERSON       user = (PERSON)e.Item.DataItem;

                    if (user.STATUS == "I")
                    {
                        Image img = (Image)e.Item.FindControl("imgStatus");
                        img.ImageUrl = "/images/defaulticon/16x16/no.png";
                        img.Visible  = true;
                    }

                    SETTINGS sets = SQMSettings.GetSetting("COMPANY", "PLANTUSER");
                    if (sets == null || sets.VALUE.ToUpper() != "N")
                    {
                        Label lbl = (Label)e.Item.FindControl("lblUserStatus");
                        lbl.Text = WebSiteCommon.GetXlatValue("statusCodeDelete", lbl.Text);

                        lbl = (Label)e.Item.FindControl("lblUserRole");
                        if (user.JOBCODE != null)
                        {
                            lbl.Text = (user.JOBCODE_CD + " / " + user.JOBCODE.JOB_DESC);
                        }
                        //lbl.Text = WebSiteCommon.GetXlatValue("userRole", user.ROLE.ToString());

                        LinkButton lnk = (LinkButton)e.Item.FindControl("lnkHRLocation");
                        lnk.ToolTip = "";
                        PLANT plant = null;

                        if ((plant = PlantList().Where(l => l.PLANT_ID == user.PLANT_ID).FirstOrDefault()) != null)
                        {
                            lnk.Text = plant.PLANT_NAME;
                        }

                        if (user.ROLE == 1 || user.ROLE == 100)
                        {
                            if ((plant = PlantList().Where(l => l.PLANT_ID == user.PLANT_ID).FirstOrDefault()) != null)
                            {
                                lnk.ToolTip = plant.PLANT_NAME + " ...";
                            }
                        }
                        else
                        {
                            string[] args = (user.PLANT_ID.ToString() + "," + user.NEW_LOCATION_CD).Split(',');
                            foreach (string loc in args.Distinct().ToArray())
                            {
                                if ((plant = PlantList().Where(l => l.PLANT_ID.ToString() == loc).FirstOrDefault()) != null)
                                {
                                    lnk.ToolTip += (" " + plant.PLANT_NAME + ",");
                                }
                            }
                        }
                        lnk.ToolTip = lnk.ToolTip.TrimEnd(',');
                    }
                }
                catch
                {
                    ;
                }
            }
        }