Пример #1
0
    /// <summary>
    /// Validates control.
    /// </summary>
    public override bool IsValid()
    {
        // Check for maximum length
        if (MaxLength > 0)
        {
            return(textbox.Text.Length <= MaxLength);
        }

        var stringValue = (string)Value;

        if ((stringValue != InfoHelper.CODENAME_AUTOMATIC) && !String.IsNullOrEmpty(stringValue))
        {
            if (!RequireIdentifier && !ValidationHelper.IsCodeName(stringValue))
            {
                ValidationError = ResHelper.GetStringFormat("general.codenamenotvalid", HTMLHelper.HTMLEncode(stringValue));
                return(false);
            }

            if (RequireIdentifier && !ValidationHelper.IsIdentifier(stringValue))
            {
                ValidationError = ResHelper.GetStringFormat("general.erroridentifierformat", HTMLHelper.HTMLEncode(stringValue));
                return(false);
            }
        }

        return(base.IsValid());
    }
    /// <summary>
    /// Handles OnAfterValidate event of the UI form.
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event argument</param>
    protected void Control_OnAfterValidate(object sender, EventArgs e)
    {
        if (siteInfo != null)
        {
            // Check for domain name collision
            if (siteInfo.Status == SiteStatusEnum.Running)
            {
                string   domainName  = ValidationHelper.GetString(Control.GetFieldValue("SiteDomainAliasName"), String.Empty);
                SiteInfo runningSite = SiteInfoProvider.GetRunningSiteInfo(domainName, null);
                if ((runningSite != null) && (siteInfo.SiteID != runningSite.SiteID))
                {
                    Control.StopProcessing = true;

                    // Hide error message because user gets informed via confirmation
                    Control.MessagesPlaceHolder.Visible = false;

                    string postBackRef = ControlsHelper.GetPostBackEventReference(Control.ObjectManager.HeaderActions, "StopSite;");
                    string script      = "if (confirm('" + ScriptHelper.GetString(ResHelper.GetStringFormat("sitedomain.proceedwithcollision", runningSite.DisplayName), false) + "')) { " + postBackRef + "; }";
                    ScriptHelper.RegisterStartupScript(Control.Page, typeof(string), "DomainCollisionMessage", ScriptHelper.GetScript(script));
                }
            }

            // Remember the state of the site
            runAfterSave = (siteInfo.Status == SiteStatusEnum.Running);
        }
    }
        public async Task <ActionResult> ResetPassword(PageViewModel <ResetPasswordViewModel> uploadModel)
        {
            var metadata = new Models.PageMetadata
            {
                Title = Localize("Identity.Account.ResetPassword.Title")
            };

            var message     = ConcatenateContactAdmin("General.Error");
            var messageType = MessageType.Error;

            if (ModelState.IsValid)
            {
                var accountResult = await _accountManager.ResetPasswordAsync(uploadModel.Data);

                if (accountResult.Success)
                {
                    message     = Localize("Identity.Account.ResetPassword.Success.Message");
                    messageType = MessageType.Info;

                    if (HttpContext.User.Identity?.IsAuthenticated == false)
                    {
                        var signInAppendix = ResHelper.GetStringFormat("Identity.Account.ResetPassword.Success.SignInAppendix", Url.Action(nameof(SignIn)));
                        message = message.Insert(message.Length, $" {signInAppendix}");
                    }
                }
            }

            return(View("UserMessage", GetPageViewModel(metadata, uploadModel.Data, message, false, true, messageType)));
        }
Пример #4
0
        // GET: /Account/ConfirmUser
        public async Task <ActionResult> ConfirmUser(int?userId, string token)
        {
            var title        = ErrorTitle;
            var message      = ConcatenateContactAdmin("General.Error");
            var displayAsRaw = false;
            var messageType  = MessageType.Error;

            if (userId.HasValue)
            {
                var accountResult = await _accountManager.ConfirmUserAsync(userId.Value, token, Request);

                switch (accountResult.ResultState)
                {
                case ConfirmUserResultState.EmailNotConfirmed:
                    message = Localize("Identity.Account.ConfirmUser.ConfirmationFailure.Message");
                    break;

                case ConfirmUserResultState.AvatarNotCreated:
                    message     = Localize("Identity.Account.ConfirmUser.AvatarFailure.Message");
                    messageType = MessageType.Warning;
                    break;

                case ConfirmUserResultState.UserConfirmed:
                    title        = Localize("Identity.Account.ConfirmUser.Success.Title");
                    message      = ResHelper.GetStringFormat("Identity.Account.ConfirmUser.Success.Message", Url.Action("SignIn"));
                    displayAsRaw = true;
                    messageType  = MessageType.Info;
                    break;
                }
            }

            return(View("UserMessage", GetPageViewModel(title, message, false, displayAsRaw, messageType)));
        }
Пример #5
0
    /// <summary>
    /// Handles after validation event of UIForm.
    /// </summary>
    protected void OnAfterValidate(object sender, EventArgs e)
    {
        // Perform additional validation if web farm server is enabled
        if (ValidationHelper.GetBoolean(Control.GetFieldValue("ServerEnabled"), false))
        {
            // Get the web farm server object
            var serverId = QueryHelper.GetInteger("objectid", 0);
            var webFarm  = WebFarmServerInfoProvider.GetWebFarmServerInfo(serverId) ?? new WebFarmServerInfo();

            // Get current license
            var currentLicense = LicenseContext.CurrentLicenseInfo;
            if (currentLicense == null)
            {
                return;
            }

            // Enabling or new server as action insert
            var action = ((webFarm.ServerID > 0) && webFarm.ServerEnabled) ? ObjectActionEnum.Edit : ObjectActionEnum.Insert;
            if (!currentLicense.CheckServerCount(WebSyncHelper.ServerCount, action))
            {
                // Set validation message
                Control.ValidationErrorMessage = ResHelper.GetStringFormat("licenselimitation.infopagemessage", FeatureEnum.Webfarm.ToStringRepresentation());
                Control.StopProcessing         = true;

                // Log "servers exceeded" event
                var message = ResHelper.GetString("licenselimitation.serversexceeded");
                EventLogProvider.LogEvent(EventType.WARNING, "WebFarms", LicenseHelper.LICENSE_LIMITATION_EVENTCODE, message, RequestContext.CurrentURL);
            }
        }
    }
Пример #6
0
    /// <summary>
    /// Reload control's data.
    /// </summary>
    public override void ReloadData()
    {
        base.ReloadData();
        if (!string.IsNullOrEmpty(RESTServiceQueryURL))
        {
            try
            {
                HttpWebRequest  request  = CreateWebRequest();
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                // If everything went ok, parse the xml recieved to dataset and bind it to the grid
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    DataSet ds = new DataSet();
                    ds.ReadXml(response.GetResponseStream());

                    basicDataGrid.DataSource = ds;
                    basicDataGrid.DataBind();
                    basicDataGrid.ItemDataBound += new DataGridItemEventHandler(basicDataGrid_ItemDataBound);
                }
            }
            catch (Exception ex)
            {
                // Handle the error
                EventLogProvider.LogException("GridForRESTService", "GETDATA", ex);

                lblError.Text    = ResHelper.GetStringFormat("RESTService.RequestFailed", ex.Message);
                lblError.Visible = true;
            }
        }
    }
Пример #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var feature = QueryHelper.GetString("feature", "");

        titleElem.TitleText = GetString("LicenseLimitation.InfoPageTitle");
        lblMessage.Text     = ResHelper.GetStringFormat("LicenseLimitation.InfoPageMessage", HTMLHelper.HTMLEncode(feature));
    }
    /// <summary>
    /// Handles OnAfterValidate event of the UI form.
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event argument</param>
    protected void Control_OnAfterValidate(object sender, EventArgs e)
    {
        // Check for domain name collision
        if (siteInfo.Status == SiteStatusEnum.Running)
        {
            string  domainName = ValidationHelper.GetString(Control.GetFieldValue("SiteDomainName"), String.Empty);
            DataSet ds         = SiteInfoProvider.CheckDomainNameForCollision(domainName, siteInfo.SiteID);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                int      collisionSiteID = ValidationHelper.GetInteger(ds.Tables[0].Rows[0]["SiteID"], 0);
                SiteInfo collisionSite   = SiteInfoProvider.GetSiteInfo(collisionSiteID);

                if (collisionSite != null)
                {
                    Control.StopProcessing = true;

                    // Hide error message because user gets informed via confirmation
                    Control.MessagesPlaceHolder.Visible = false;

                    string postBackRef = ControlsHelper.GetPostBackEventReference(Control.ObjectManager.HeaderActions, "StopSite;");
                    string script      = "if (confirm('" + ScriptHelper.GetString(ResHelper.GetStringFormat("sitedomain.proceedwithcollision", collisionSite.DisplayName), false) + "')) { " + postBackRef + "; } ";
                    ScriptHelper.RegisterStartupScript(Control.Page, typeof(string), "DomainCollisionMessage", ScriptHelper.GetScript(script));
                }
            }
        }

        // Remember the state of the site
        runSite = (siteInfo.Status == SiteStatusEnum.Running);
    }
    /// <summary>
    /// Handle btnOK's OnClick event.
    /// </summary>
    protected void ObjectManager_OnSaveData(object sender, SimpleObjectManagerEventArgs e)
    {
        string errorMessage = "";

        // Get PageTemplateInfo.
        pti = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
        if (pti != null)
        {
            // Update WebParts configuration in PageTemplate.
            try
            {
                pti.WebParts = txtWebParts.Text;
                PageTemplateInfoProvider.SetPageTemplateInfo(pti);
                ShowChangesSaved();

                // Update textbox value
                txtWebParts.Text = HTMLHelper.ReformatHTML(pti.WebParts, "  ");
            }
            catch (UnauthorizedAccessException ex)
            {
                errorMessage = ResHelper.GetStringFormat("general.sourcecontrolerror", ex.Message);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            // Show error message
            if (!String.IsNullOrEmpty(errorMessage))
            {
                ShowError(errorMessage);
            }
        }
    }
    /// <summary>
    /// Shows info message to prompt the user to select the winning A/B variant after the A/B test has finished.
    /// </summary>
    private void ShowPromoteWinnerInfoMessage()
    {
        if (TestStatus != ABTestStatusEnum.Finished || !UserHasPermissions)
        {
            return;
        }

        string message;

        if (DocumentManager.AllowSave || IsDialog)
        {
            message = GetString("abtesting.finishedtest.promotewinnerpromptmessage");
        }
        else
        {
            string siteName     = SiteInfoProvider.GetSiteName(ABTest.ABTestSiteID);
            int    nodeId       = TreePathUtils.GetNodeIdByAliasPath(siteName, ABTest.ABTestOriginalPage);
            string editPageLink = ApplicationUrlHelper.GetPageEditLink(nodeId, ABTest.ABTestCulture);
            var    link         = URLHelper.GetAbsoluteUrl(editPageLink);

            message = ResHelper.GetStringFormat("abtesting.finishedtest.promotewinnerpromptmessage.warning", link);
        }

        ShowInformation(message);
    }
Пример #11
0
 private object CreateSuccessList(IEnumerable <MailingAddressDto> addresses)
 {
     return(new
     {
         Header = ResHelper.GetStringFormat("Kadena.MailingList.GoodAddressesFound", addresses.Count()),
         Btns = new
         {
             Use = new
             {
                 Text = ResHelper.GetString("Kadena.MailingList.UseOnlyCorrect"),
                 Url = "/klist/useonlycorrect"
             }
         },
         Items = addresses.Any() ? addresses.Select(a => new UpdateAddressDto
         {
             Id = a.Id,
             FullName = a.FirstName,
             FirstAddressLine = a.Address1,
             SecondAddressLine = a.Address2,
             City = a.City,
             State = a.State,
             PostalCode = a.Zip,
         })
                 .Take(NumberOfItems)
         : null
     });
 }
Пример #12
0
 private object CreateErrorList(IEnumerable <MailingAddressDto> addresses)
 {
     return(new
     {
         Header = ResHelper.GetStringFormat("Kadena.MailingList.BadAddressesFound", addresses.Count()),
         Tip = ResHelper.GetString("Kadena.MailingList.ToCorrectErrorsGoTo"),
         Btns = new
         {
             Reupload = new
             {
                 Text = ResHelper.GetString("Kadena.MailingList.ReuploadList"),
                 Url = URLHelper.AddParameterToUrl(ReuploadListPageUrl, "containerId", _containerId.ToString())
             },
             Correct = ResHelper.GetString("Kadena.MailingList.CorrectErrors")
         },
         Items = addresses.Any() ? addresses.Select(a => new UpdateAddressDto
         {
             Id = a.Id,
             FullName = a.FirstName,
             FirstAddressLine = a.Address1,
             SecondAddressLine = a.Address2,
             City = a.City,
             State = a.State,
             PostalCode = a.Zip,
             ErrorMessage = a.ErrorMessage
         })
         : null
     });
 }
Пример #13
0
    private void ShowStartProcessConfirmation(What what)
    {
        var confirmationMessage       = String.Empty;
        var workflowId                = ValidationHelper.GetInteger(hdnIdentifier.Value, 0);
        var selectedAutomationProcess = WorkflowInfo.Provider.Get(workflowId);

        if (selectedAutomationProcess == null || !selectedAutomationProcess.IsAutomation)
        {
            ShowError(ResHelper.GetString("ma.action.initiateprocess.noprocess"));
            return;
        }

        switch (what)
        {
        case What.All:
        {
            confirmationMessage = ResHelper.GetStringFormat("om.contactgroupmember.confirmstartselectedprocessforall", selectedAutomationProcess.WorkflowDisplayName);
            break;
        }

        case What.Selected:
        {
            confirmationMessage = ResHelper.GetStringFormat("om.contactgroupmember.confirmstartselectedprocess", selectedAutomationProcess.WorkflowDisplayName);
            break;
        }
        }

        var script = $@"if(confirm({ScriptHelper.GetString(confirmationMessage)})){{
{ControlsHelper.GetPostBackEventReference(btnOk, START_PROCESS_CONFIRMED)};
}} else {{
Refresh();
}}";

        ScriptHelper.RegisterStartupScript(btnOk, typeof(string), $"StartProcessConfirmation{Guid.NewGuid()}", script, true);
    }
Пример #14
0
    private void ShowParameterWarning()
    {
        var names = Enumerable.Empty <string>();

        if (!RequestHelper.IsPostBack() && WorkflowStep?.ValidateParameters(out names) == false)
        {
            var error = ResHelper.GetStringFormat("ma.step.emptyrequiredparameters", String.Join(", ", names.Select(i => $"<b>{HTMLHelper.HTMLEncode(i)}</b>")));
            ShowWarning(error);
        }
    }
        private void SendWaitForApprovalEmail(string email)
        {
            var message = new IdentityMessage()
            {
                Destination = email,
                Subject     = ResHelper.GetString("membership.registrationapprovalnoticesubject"),
                Body        = ResHelper.GetStringFormat("membership.registrationapprovalnoticebody", SiteContext.CurrentSite.DisplayName)
            };

            UserManager.EmailService.SendAsync(message);
        }
    /// <summary>
    /// Saves resource string and its translations. Returns true if the string is successfully saved.
    /// </summary>
    public bool Save()
    {
        if (!EnableTranslations)
        {
            return(false);
        }

        string resKey = ResourceStringKey;

        if (!ValidationHelper.IsCodeName(resKey))
        {
            ShowError(GetString("culture.invalidresstringkey"));
            return(false);
        }

        // Check if key is free for use (must be free or id must be same)
        if (!KeyIsFreeToUse(mResourceStringInfo.StringID, resKey))
        {
            base.ShowError(ResHelper.GetStringFormat("localizable.keyexists", resKey));
            return(false);
        }

        // Check if default translation is set if required
        if (DefaultTranslationRequired)
        {
            string defaultTranslation = mTranslations[CultureHelper.DefaultUICultureCode.ToLowerInvariant()].Text.Trim();
            string defaultCultureName = CultureInfoProvider.GetCultureInfo(CultureHelper.DefaultUICultureCode).CultureName;
            if (String.IsNullOrEmpty(defaultTranslation))
            {
                base.ShowError(ResHelper.GetStringFormat("localizable.deletedefault", defaultCultureName));
                return(false);
            }
        }

        // Log staging tasks synchronously
        using (new CMSActionContext {
            AllowAsyncActions = false
        })
        {
            SaveResourceStringInfo(resKey);
            EditedResourceStringKey = resKey;
            SaveTranslations();
        }

        ShowChangesSaved();

        if (!String.IsNullOrEmpty(RedirectUrlAfterSave))
        {
            RedirectToUrlAfterSave();
        }

        return(true);
    }
Пример #17
0
    protected void EditForm_OnItemValidation(object sender, ref string errorMessage)
    {
        var ctrl = sender as FormEngineUserControl;

        if ((ctrl == null))
        {
            return;
        }

        switch (ctrl.FieldInfo.Name)
        {
        case "CurrencyCode":
            var currencies = CurrencyInfoProvider.GetCurrenciesByCode(SiteID);
            var code       = ctrl.Value.ToString();

            // Currency with same code already exists
            if (currencies.ContainsKey(code))
            {
                // And it is not currently edited one
                if ((mEditedCurrency == null) || (currencies[code].CurrencyID != mEditedCurrency.CurrencyID))
                {
                    errorMessage = ResHelper.GetStringFormat("com.currencycodenotunique", code);
                }
            }
            break;

        case "CurrencyEnabled":
        {
            var main = CurrencyInfoProvider.GetMainCurrency(ConfiguredSiteID);
            if ((main != null) && (mEditedCurrency != null) && (main.CurrencyID == mEditedCurrency.CurrencyID) &&
                !ValidationHelper.GetBoolean(ctrl.Value, true))
            {
                errorMessage = ResHelper.GetStringFormat("ecommerce.disablemaincurrencyerror", main.CurrencyDisplayName);
            }
        }
        break;

        case "CurrencyFormatString":
            try
            {
                // Test for double exception
                string.Format(ctrl.Value.ToString().Trim(), 1.234);
                string.Format(ctrl.Value.ToString().Trim(), "12.12");
            }
            catch
            {
                errorMessage = GetString("Currency_Edit.ErrorCurrencyFormatString");
            }
            break;
        }
    }
Пример #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            IEnumerable <ProjectDto> projects = null;

            try
            {
                var workGroupName = SettingsKeyInfoProvider.GetValue($"{SiteContext.CurrentSiteName}.KDA_WorkgroupName");
                var client        = DIContainer.Resolve <IBidClient>();
                var reqResult     = client.GetProjects(workGroupName).Result;
                if (reqResult.Success)
                {
                    projects = reqResult.Payload;
                }
                else
                {
                    throw new InvalidOperationException(reqResult.ErrorMessages);
                }
            }
            catch (Exception exc)
            {
                pnlOpenProject.Visible       = false;
                pnlCompletedProjects.Visible = false;

                inpError.Value = ResHelper.GetString("Kadena.Error.MicroserviceFailed");
                EventLogProvider.LogException("BidsList Load", "EXCEPTION", exc, CurrentSite.SiteID);
                return;
            }

            int openCount = 0, completedCount = 0;

            if (projects != null)
            {
                var openProjects      = projects.Where(p => p.Active).OrderByDescending(p => p.UpdateDate).ToArray();
                var completedProjects = projects.Where(p => !p.Active).OrderByDescending(p => p.UpdateDate).ToArray();

                openCount      = openProjects.Count();
                completedCount = completedProjects.Count();

                FillTable(tblOpenProjects, phOpenPagination, openProjects, RecordsPerPage);
                FillTable(tblCompletedProjects, phCompletedPagination, completedProjects, RecordsPerPage);
            }

            lblOpenProject.InnerText       = ResHelper.GetStringFormat("Kadena.KSource.OpenProjectsCaption", openCount);
            lblCompletedProjects.InnerText = ResHelper.GetStringFormat("Kadena.KSource.CompletedProjectsCaption", completedCount);

            pnlOpenProject.Visible       = true;
            pnlCompletedProjects.Visible = true;
        }
Пример #19
0
    private void CheckSubscriptionLicences()
    {
        // Hide message if requested by user
        if (!CheckWarningMessage(SESSION_KEY_SUBSCRIPTION_LICENCES))
        {
            pnlSubscriptionLicencesWarning.Visible = false;
            CacheHelper.Add(SUBSCRIPTION_LICENSES_WARNING_ALREADY_CLOSED_TODAY, true, CacheHelper.GetCacheDependency($"{LicenseKeyInfo.OBJECT_TYPE}|all"),
                            DateTime.Now.AddDays(1), CacheConstants.NoSlidingExpiration);
            SessionHelper.Remove(SESSION_KEY_SUBSCRIPTION_LICENCES);
            return;
        }

        if (!AreSubscriptionLicensesValid(out int numberOfInvalidLicenses, out bool onlyWarning, out int daysToExpiration))
        {
            if (onlyWarning)
            {
                // Warning was already closed by someone and will be displayed after 24h again
                if (!CacheHelper.TryGetItem(SUBSCRIPTION_LICENSES_WARNING_ALREADY_CLOSED_TODAY, out bool _))
                {
                    pnlSubscriptionLicencesWarning.Visible = true;
                    ltlSubscriptionLicenceWarning.Text     = numberOfInvalidLicenses > 1 ?
                                                             ResHelper.GetStringFormat("subscriptionlicenses.warning.multiple", UrlResolver.ResolveUrl(ApplicationUrlHelper.GetApplicationUrl("Licenses", "Licenses")), numberOfInvalidLicenses) :
                                                             ResHelper.GetStringFormat("subscriptionlicenses.warning.single", daysToExpiration);
                }
            }
            else
            {
                pnlSubscriptionLicencesError.Visible = true;
                ltlSubscriptionLicenceError.Text     = numberOfInvalidLicenses > 1 ?
                                                       GetMultipleSubscriptionLicensesErrorMessage() :
                                                       GetSingleSubscriptionLicenseErrorMessage();
            }
        }

        string GetMultipleSubscriptionLicensesErrorMessage()
        {
            return(daysToExpiration > 0
                ? ResHelper.GetStringFormat("subscriptionlicenses.error.multiple", UrlResolver.ResolveUrl(ApplicationUrlHelper.GetApplicationUrl("Licenses", "Licenses")), numberOfInvalidLicenses, daysToExpiration)
                : ResHelper.GetString("subscriptionlicenses.error.graceperiodexpired"));
        }

        string GetSingleSubscriptionLicenseErrorMessage()
        {
            return(daysToExpiration > 0
                ? ResHelper.GetStringFormat("subscriptionlicenses.error.single", daysToExpiration)
                : ResHelper.GetString("subscriptionlicenses.error.graceperiodexpired"));
        }
    }
Пример #20
0
    private string CreateNewsletterIssueUsedInAutomationErrorMessage(IEnumerable <string> automationProcessesNames)
    {
        const int MAX_NAMES_COUNT = 5;

        var sbProcessesNames = new StringBuilder();

        foreach (var processName in automationProcessesNames.Take(MAX_NAMES_COUNT))
        {
            sbProcessesNames.Append($"<strong>{TextHelper.LimitLength(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(processName)), 39)}</strong><br />");
        }

        if (automationProcessesNames.Count() > MAX_NAMES_COUNT)
        {
            sbProcessesNames.Append($"{ResHelper.GetStringFormat("general.andxmore", automationProcessesNames.Count() - MAX_NAMES_COUNT)}<br />");
        }

        return(String.Format(GetString("emailbuilder.error.emailusedinmarketingautomation"), sbProcessesNames.ToString()));
    }
Пример #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptHelper.RegisterDialogScript(Page);

        if (SelectedSite == null)
        {
            lnkGenerate.Enabled = lnkInvalidate.Enabled = false;
            return;
        }

        lnkGenerate.OnClientClick   = "modalDialog('" + UrlResolver.ResolveUrl("~/CMSModules/REST/FormControls/GenerateHash.aspx") + "' , 'GenerateAuthHash', 800, 410); return false;";
        lnkInvalidate.OnClientClick = $"return confirm('{ResHelper.GetStringFormat("rest.invalidatehash.confirmation", HTMLHelper.EncodeForHtmlAttribute(SelectedSite.DisplayName))}');";

        lnkInvalidate.Click += (s, args) =>
        {
            SettingsKeyInfoProvider.SetValue("CMSRESTUrlHashSalt", SelectedSite.SiteName, Guid.NewGuid());
            lblInvalidate.Visible = true;
        };

        lblInvalidate.Text = ResHelper.GetStringFormat("rest.invalidatehash.message", HTMLHelper.HTMLEncode(SelectedSite.DisplayName));
    }
    /// <summary>
    /// Handles after validation event of UIForm.
    /// </summary>
    protected void OnAfterValidate(object sender, EventArgs e)
    {
        // Perform additional validation if web farm server is enabled
        if (ValidationHelper.GetBoolean(Control.GetFieldValue("ServerEnabled"), false))
        {
            // Get the web farm server object
            var serverId      = QueryHelper.GetInteger("objectid", 0);
            var webFarmServer = WebFarmServerInfoProvider.GetWebFarmServerInfo(serverId) ?? new WebFarmServerInfo();

            if (!webFarmServer.ServerEnabled && !WebFarmLicenseHelper.CanAddServer)
            {
                // Set validation message
                Control.ValidationErrorMessage = ResHelper.GetStringFormat("licenselimitation.infopagemessage", FeatureEnum.Webfarm.ToStringRepresentation());
                Control.StopProcessing         = true;

                // Log "servers exceeded" event
                var message = ResHelper.GetString("licenselimitation.serversexceeded");
                EventLogProvider.LogEvent(EventType.WARNING, "WebFarms", LicenseHelper.LICENSE_LIMITATION_EVENTCODE, message, RequestContext.CurrentURL);
            }
        }
    }
    /// <summary>
    /// OnPreRender event handler
    /// </summary>
    /// <param name="e"></param>
    protected override void OnPreRender(EventArgs e)
    {
        if (SearchTaskInfo != null)
        {
            GeneralizedInfo relatedObjectInfo = ProviderHelper.GetInfoById(SearchTaskInfo.SearchTaskRelatedObjectType, SearchTaskInfo.SearchTaskRelatedObjectID);
            string          relatedObjectStr  = String.Empty;

            if (relatedObjectInfo == null)
            {
                relatedObjectStr = ResHelper.GetStringFormat(
                    "smartsearch.searchtaskrelatedobjectnotexist",
                    TypeHelper.GetNiceObjectTypeName(SearchTaskInfo.SearchTaskRelatedObjectType),
                    SearchTaskInfo.SearchTaskRelatedObjectID
                    );
            }
            else
            {
                relatedObjectStr = relatedObjectInfo.GetFullObjectName(false, true, false);
            }

            StringBuilder report = new StringBuilder();
            report.Append("<div class='form-horizontal'>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.tasktype"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(GetString("smartsearch.tasktype." + SearchTaskInfo.SearchTaskType.ToStringRepresentation())), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskobjecttype"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(TypeHelper.GetNiceObjectTypeName(SearchTaskInfo.SearchTaskObjectType)), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskfield"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskField), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskvalue"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskValue), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskrelatedobject"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(relatedObjectStr), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskservername"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskServerName), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskcreated"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskCreated.ToString()), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskstatus"), ":</span></div><div class='editing-form-value-cell'><span class='form-control-text'>", UniGridFunctions.ColoredSpanMsg(HTMLHelper.HTMLEncode(GetString("smartsearch.searchtaskstatusenum." + SearchTaskInfo.SearchTaskStatus.ToStringRepresentation())), SearchTaskInfo.SearchTaskStatus != SearchTaskStatusEnum.Error), "</span></div></div>");
            report.Append("<div class='form-group'><div class='editing-form-label-cell'><span class='control-label'>", GetString("smartsearch.task.taskerrormessage"), ":</strong></div><div class='editing-form-value-cell'><span class='form-control-text'>", HTMLHelper.HTMLEncode(SearchTaskInfo.SearchTaskErrorMessage), "</span></div></div>");
            report.Append("</div>");

            lblReport.Text = report.ToString();
        }
        else
        {
            lblReport.Text = GetString("srch.task.tasknotexist");
        }
    }
Пример #24
0
    protected void ObjectManager_OnSaveData(object sender, SimpleObjectManagerEventArgs e)
    {
        if (PageTemplate != null)
        {
            PageTemplate.PageTemplateHeader              = txtTemplateHeader.Text.Trim();
            PageTemplate.PageTemplateAllowInheritHeader  = chkAllowInherit.Checked;
            PageTemplate.PageTemplateInheritParentHeader = chkInheritParent.Checked;

            try
            {
                // Save changes
                PageTemplateInfoProvider.SetPageTemplateInfo(PageTemplate);
                ShowChangesSaved();
            }
            catch (UnauthorizedAccessException ex)
            {
                ShowError(ResHelper.GetStringFormat("general.sourcecontrolerror", ex.Message));
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
    }
Пример #25
0
 private void LoadMarketableRecipientsCount()
 {
     var newsletterMarketableRecipientsCount = NewsletterHelper.GetNewsletterMarketableRecipientsCount(mNewsletter);
     ltlTotalRecipientsCount.Text = ResHelper.GetStringFormat("emailmarketing.ui.recipientsheader", newsletterMarketableRecipientsCount);
 }
    private void SaveContainer()
    {
        try
        {
            // Validate user input
            string errorMessage = new Validator()
                                  .NotEmpty(txtContainerDisplayName.Text, rfvDisplayName.ErrorMessage)
                                  .NotEmpty(txtContainerName.Text, rfvCodeName.ErrorMessage)
                                  .IsCodeName(txtContainerName.Text, GetString("General.InvalidCodeName"))
                                  .Result;

            if (!string.IsNullOrEmpty(errorMessage))
            {
                ShowError(errorMessage);
                return;
            }

            // Parse the container text
            string text  = txtContainerText.Text;
            string after = "";

            int wpIndex = text.IndexOf(WebPartContainerInfoProvider.WP_CHAR);
            if (wpIndex >= 0)
            {
                after = text.Substring(wpIndex + 1).Replace(WebPartContainerInfoProvider.WP_CHAR, "");
                text  = text.Substring(0, wpIndex);
            }

            WebPartContainerInfo webPartContainerObj = new WebPartContainerInfo()
            {
                ContainerTextBefore  = text,
                ContainerTextAfter   = after,
                ContainerCSS         = txtContainerCSS.Text,
                ContainerName        = txtContainerName.Text.Trim(),
                ContainerDisplayName = txtContainerDisplayName.Text.Trim()
            };

            // Check for duplicity
            if (WebPartContainerInfoProvider.GetWebPartContainerInfo(webPartContainerObj.ContainerName) != null)
            {
                ShowError(GetString("Container_Edit.UniqueError"));
                return;
            }

            WebPartContainerInfoProvider.SetWebPartContainerInfo(webPartContainerObj);
            UIContext.EditedObject = webPartContainerObj;
            CMSObjectManager.CheckOutNewObject(Page);

            if (mDialogMode)
            {
                ProcessDialog(webPartContainerObj, true);
            }
            else
            {
                ProcessPage(webPartContainerObj);
            }
        }
        catch (SecurityException ex)
        {
            ShowError(!SystemContext.IsFullTrustLevel ? ResHelper.GetStringFormat("general.fulltrustrequired", ex.Message) : ex.Message);
        }
        catch (Exception ex)
        {
            ShowError(ex.Message);
        }
    }
 public static string LocalizeFormat(string resourceKey, params object[] args) =>
 ResHelper.GetStringFormat(resourceKey, args);
Пример #28
0
 /// <summary>
 /// Initializes the account status area with the number of points.
 /// </summary>
 /// <param name="points">A number of points on Data.com user or partner account.</param>
 private void InitializeAccountPoints(long points)
 {
     AccountPointsLiteral.Text = ResHelper.GetStringFormat("datacom.buycontact.accountpoints", points);
 }
        private static ModelClientValidationRule LocalizeValidationRule(ModelClientValidationRule rule, object[] arguments)
        {
            rule.ErrorMessage = ResHelper.GetStringFormat(rule.ErrorMessage, arguments);

            return(rule);
        }
        private static ModelValidationResult LocalizeValidationResult(ModelValidationResult result, object[] arguments)
        {
            result.Message = ResHelper.GetStringFormat(result.Message, arguments);

            return(result);
        }