Пример #1
0
    public string[] UpdateSettings_UserSettingsPage(string caller, string settingsState, string personnelLoadState, string personnelCountState, string PersonnelID, string PersonnelSearchTerms, string SettingsTerms)
    {
        this.InitializeCulture();

        string[]            retMessage    = new string[4];
        Caller              settingCaller = (Caller)Enum.Parse(typeof(Caller), this.StringBuilder.CreateString(caller));
        SettingsState       SS            = (SettingsState)Enum.Parse(typeof(SettingsState), this.StringBuilder.CreateString(settingsState));
        LoadState           PLS           = (LoadState)Enum.Parse(typeof(LoadState), this.StringBuilder.CreateString(personnelLoadState));
        PersonnelCountState PCS           = (PersonnelCountState)Enum.Parse(typeof(PersonnelCountState), this.StringBuilder.CreateString(personnelCountState));
        decimal             personnelID   = decimal.Parse(this.StringBuilder.CreateString(PersonnelID), CultureInfo.InvariantCulture);

        PersonnelSearchTerms = this.StringBuilder.CreateString(PersonnelSearchTerms);
        SettingsTerms        = this.StringBuilder.CreateString(SettingsTerms);


        try
        {
            AttackDefender.CSRFDefender(this.Page);
            switch (SS)
            {
            case SettingsState.EmailSMS:
                EmailSMSSettingsObj emailSMSSettingsObj = this.JsSerializer.Deserialize <EmailSMSSettingsObj>(SettingsTerms);
                bool IsSendEmail = bool.Parse(emailSMSSettingsObj.IsSendEmail);
                bool IsSendSMS   = bool.Parse(emailSMSSettingsObj.IsSendSMS);
                EmailSMSTransferState SendEmailState = (EmailSMSTransferState)Enum.Parse(typeof(EmailSMSTransferState), emailSMSSettingsObj.SendEmailState);
                EmailSMSTransferState SendSMSState   = (EmailSMSTransferState)Enum.Parse(typeof(EmailSMSTransferState), emailSMSSettingsObj.SendSMSState);
                int    EmailDay        = int.Parse(emailSMSSettingsObj.DailyEmailDay, CultureInfo.InvariantCulture);
                string DailyEmailTime  = emailSMSSettingsObj.DailyEmailHour + ":" + emailSMSSettingsObj.DailyEmailMinute;
                string HourlyEmailTime = emailSMSSettingsObj.HourlyEmailHour + ":" + emailSMSSettingsObj.HourlyEmailMinute;
                int    SMSDay          = int.Parse(emailSMSSettingsObj.DailySMSDay, CultureInfo.InvariantCulture);
                string DailySMSTime    = emailSMSSettingsObj.DailySMSHour + ":" + emailSMSSettingsObj.DailySMSMinute;
                string HourlySMSTime   = emailSMSSettingsObj.HourlySMSHour + ":" + emailSMSSettingsObj.HourlySMSMinute;

                EmailSettings emailSettings = new EmailSettings();
                emailSettings.Active = IsSendEmail;
                switch (SendEmailState)
                {
                case EmailSMSTransferState.Daily:
                    emailSettings.SendByDay = true;
                    break;

                case EmailSMSTransferState.Hourly:
                    emailSettings.SendByDay = false;
                    break;
                }
                emailSettings.DayCount   = EmailDay;
                emailSettings.TheDayHour = DailyEmailTime;
                emailSettings.TheHour    = HourlyEmailTime;

                SMSSettings smsSettings = new SMSSettings();
                smsSettings.Active = IsSendSMS;
                switch (SendSMSState)
                {
                case EmailSMSTransferState.Daily:
                    smsSettings.SendByDay = true;
                    break;

                case EmailSMSTransferState.Hourly:
                    smsSettings.SendByDay = false;
                    break;
                }
                smsSettings.DayCount   = SMSDay;
                smsSettings.TheDayHour = DailySMSTime;
                smsSettings.TheHour    = HourlySMSTime;


                switch (PCS)
                {
                case PersonnelCountState.Single:
                    switch (settingCaller)
                    {
                    case Caller.Personal:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings);
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings);
                        break;

                    case Caller.Management:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings, personnelID);
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings, personnelID);
                        break;

                    default:
                        break;
                    }
                    break;

                case PersonnelCountState.Group:
                    switch (PLS)
                    {
                    case LoadState.Normal:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings, personnelID);
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings, personnelID);
                        break;

                    case LoadState.Search:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings, PersonnelSearchTerms);
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings, PersonnelSearchTerms);
                        break;

                    case LoadState.AdvancedSearch:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings, this.APSProv.CreateAdvancedPersonnelSearchProxy(PersonnelSearchTerms));
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings, this.APSProv.CreateAdvancedPersonnelSearchProxy(PersonnelSearchTerms));
                        break;
                    }
                    break;
                }
                break;

            case SettingsState.Dashboard:
                DashboardSettingsObj dashboardSettingsObj = this.JsSerializer.Deserialize <DashboardSettingsObj>(SettingsTerms);
                IList <Dashboards>   dashboardList        = DashboardBusiness.GetAll();

                decimal dashboardID1 = dashboardSettingsObj.DashboardID1 == "" ? 0 : Convert.ToDecimal(dashboardSettingsObj.DashboardID1, CultureInfo.InvariantCulture);
                decimal dashboardID2 = dashboardSettingsObj.DashboardID2 == "" ? 0 : Convert.ToDecimal(dashboardSettingsObj.DashboardID2, CultureInfo.InvariantCulture);
                decimal dashboardID3 = dashboardSettingsObj.DashboardID3 == "" ? 0 : Convert.ToDecimal(dashboardSettingsObj.DashboardID3, CultureInfo.InvariantCulture);
                decimal dashboardID4 = dashboardSettingsObj.DashboardID4 == "" ? 0 : Convert.ToDecimal(dashboardSettingsObj.DashboardID4, CultureInfo.InvariantCulture);

                DashboardSettings dashboardObj = new DashboardSettings();
                dashboardObj.Dashboard1 = dashboardList.SingleOrDefault(d => d.ID == dashboardID1);
                dashboardObj.Dashboard2 = dashboardList.SingleOrDefault(d => d.ID == dashboardID2);
                dashboardObj.Dashboard3 = dashboardList.SingleOrDefault(d => d.ID == dashboardID3);
                dashboardObj.Dashboard4 = dashboardList.SingleOrDefault(d => d.ID == dashboardID4);

                switch (PCS)
                {
                case PersonnelCountState.Single:
                    switch (settingCaller)
                    {
                    case Caller.Personal:
                        this.UserSettingsBusiness.SaveDashboardSetting(dashboardObj);

                        break;

                    case Caller.Management:
                        this.UserSettingsBusiness.SaveDashboardSetting(dashboardObj, personnelID);

                        break;

                    default:
                        break;
                    }
                    break;

                case PersonnelCountState.Group:
                    switch (PLS)
                    {
                    case LoadState.Normal:
                        this.UserSettingsBusiness.SaveDashboardSetting(dashboardObj, personnelID);

                        break;

                    case LoadState.Search:
                        this.UserSettingsBusiness.SaveDashboardSetting(dashboardObj, PersonnelSearchTerms);

                        break;

                    case LoadState.AdvancedSearch:
                        this.UserSettingsBusiness.SaveDashboardSetting(dashboardObj, this.APSProv.CreateAdvancedPersonnelSearchProxy(PersonnelSearchTerms));

                        break;
                    }
                    break;
                }
                break;

            case SettingsState.CollectiveRequestRegistType:
                OperatorCollectiveRequestRegistType operatorCollectiveRequestTypeObj = this.JsSerializer.Deserialize <OperatorCollectiveRequestRegistType>(SettingsTerms);
                CollectiveRequestRegistType         collectiveRequestRegistTypeObj   = (CollectiveRequestRegistType)Enum.Parse(typeof(CollectiveRequestRegistType), operatorCollectiveRequestTypeObj.CollectiveRequestRegistType);

                switch (PCS)
                {
                case PersonnelCountState.Single:
                    switch (settingCaller)
                    {
                    case Caller.Personal:
                        this.UserSettingsBusiness.SaveOperatorCollectiveRequestRegistType(collectiveRequestRegistTypeObj);

                        break;

                    case Caller.Management:
                        this.UserSettingsBusiness.SaveOperatorCollectiveRequestRegistType(collectiveRequestRegistTypeObj, personnelID);

                        break;

                    default:
                        break;
                    }
                    break;

                case PersonnelCountState.Group:
                    switch (PLS)
                    {
                    case LoadState.Normal:
                        this.UserSettingsBusiness.SaveOperatorCollectiveRequestRegistType(collectiveRequestRegistTypeObj, personnelID);

                        break;

                    case LoadState.Search:
                        this.UserSettingsBusiness.SaveOperatorCollectiveRequestRegistType(collectiveRequestRegistTypeObj, PersonnelSearchTerms);

                        break;

                    case LoadState.AdvancedSearch:
                        this.UserSettingsBusiness.SaveOperatorCollectiveRequestRegistType(collectiveRequestRegistTypeObj, this.APSProv.CreateAdvancedPersonnelSearchProxy(PersonnelSearchTerms));

                        break;
                    }
                    break;
                }
                break;
            }
            retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
            retMessage[1] = GetLocalResourceObject("OperationCompleted").ToString();
            retMessage[2] = "success";
            retMessage[3] = SS.ToString();
            return(retMessage);
        }
        catch (UIValidationExceptions ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
            return(retMessage);
        }
        catch (UIBaseException ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
            return(retMessage);
        }
        catch (Exception ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
            return(retMessage);
        }
    }
Пример #2
0
    public string[] UpdateSettings_UserSettingsPage(string caller, string settingsState, string personnelLoadState, string personnelCountState, string PersonnelID, string PersonnelSearchTerms, string SettingsTerms)
    {
        this.InitializeCulture();

        string[]            retMessage    = new string[4];
        Caller              settingCaller = (Caller)Enum.Parse(typeof(Caller), this.StringBuilder.CreateString(caller));
        SettingsState       SS            = (SettingsState)Enum.Parse(typeof(SettingsState), this.StringBuilder.CreateString(settingsState));
        LoadState           PLS           = (LoadState)Enum.Parse(typeof(LoadState), this.StringBuilder.CreateString(personnelLoadState));
        PersonnelCountState PCS           = (PersonnelCountState)Enum.Parse(typeof(PersonnelCountState), this.StringBuilder.CreateString(personnelCountState));
        decimal             personnelID   = decimal.Parse(this.StringBuilder.CreateString(PersonnelID));

        PersonnelSearchTerms = this.StringBuilder.CreateString(PersonnelSearchTerms);
        SettingsTerms        = this.StringBuilder.CreateString(SettingsTerms);
        EmailSMSSettingsObj emailSMSSettingsObj = this.JsSerializer.Deserialize <EmailSMSSettingsObj>(SettingsTerms);

        try
        {
            switch (SS)
            {
            case SettingsState.EmailSMS:
                bool IsSendEmail = bool.Parse(emailSMSSettingsObj.IsSendEmail);
                bool IsSendSMS   = bool.Parse(emailSMSSettingsObj.IsSendSMS);
                EmailSMSTransferState SendEmailState = (EmailSMSTransferState)Enum.Parse(typeof(EmailSMSTransferState), emailSMSSettingsObj.SendEmailState);
                EmailSMSTransferState SendSMSState   = (EmailSMSTransferState)Enum.Parse(typeof(EmailSMSTransferState), emailSMSSettingsObj.SendSMSState);
                int    EmailDay        = int.Parse(emailSMSSettingsObj.DailyEmailDay);
                string DailyEmailTime  = emailSMSSettingsObj.DailyEmailHour + ":" + emailSMSSettingsObj.DailyEmailMinute;
                string HourlyEmailTime = emailSMSSettingsObj.HourlyEmailHour + ":" + emailSMSSettingsObj.HourlyEmailMinute;
                int    SMSDay          = int.Parse(emailSMSSettingsObj.DailySMSDay);
                string DailySMSTime    = emailSMSSettingsObj.DailySMSHour + ":" + emailSMSSettingsObj.DailySMSMinute;
                string HourlySMSTime   = emailSMSSettingsObj.HourlySMSHour + ":" + emailSMSSettingsObj.HourlySMSMinute;

                EmailSettings emailSettings = new EmailSettings();
                emailSettings.Active = IsSendEmail;
                switch (SendEmailState)
                {
                case EmailSMSTransferState.Daily:
                    emailSettings.SendByDay = true;
                    break;

                case EmailSMSTransferState.Hourly:
                    emailSettings.SendByDay = false;
                    break;
                }
                emailSettings.DayCount   = EmailDay;
                emailSettings.TheDayHour = DailyEmailTime;
                emailSettings.TheHour    = HourlyEmailTime;

                SMSSettings smsSettings = new SMSSettings();
                smsSettings.Active = IsSendSMS;
                switch (SendSMSState)
                {
                case EmailSMSTransferState.Daily:
                    smsSettings.SendByDay = true;
                    break;

                case EmailSMSTransferState.Hourly:
                    smsSettings.SendByDay = false;
                    break;
                }
                smsSettings.DayCount   = SMSDay;
                smsSettings.TheDayHour = DailySMSTime;
                smsSettings.TheHour    = HourlySMSTime;


                switch (PCS)
                {
                case PersonnelCountState.Single:
                    switch (settingCaller)
                    {
                    case Caller.Personal:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings);
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings);
                        break;

                    case Caller.Management:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings, personnelID);
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings, personnelID);
                        break;

                    default:
                        break;
                    }
                    break;

                case PersonnelCountState.Group:
                    switch (PLS)
                    {
                    case LoadState.Normal:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings, personnelID);
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings, personnelID);
                        break;

                    case LoadState.Search:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings, PersonnelSearchTerms);
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings, PersonnelSearchTerms);
                        break;

                    case LoadState.AdvancedSearch:
                        this.UserSettingsBusiness.SaveEmailSetting(emailSettings, this.APSProv.CreateAdvancedPersonnelSearchProxy(PersonnelSearchTerms));
                        this.UserSettingsBusiness.SaveSMSSetting(smsSettings, this.APSProv.CreateAdvancedPersonnelSearchProxy(PersonnelSearchTerms));
                        break;
                    }
                    break;
                }
                break;
            }
            retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
            retMessage[1] = GetLocalResourceObject("OperationCompleted").ToString();
            retMessage[2] = "success";
            return(retMessage);
        }
        catch (UIValidationExceptions ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
            return(retMessage);
        }
        catch (UIBaseException ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
            return(retMessage);
        }
        catch (Exception ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
            return(retMessage);
        }
    }