object IExpressionBuilderProvider.Evaluate(NameValueCollection arguments, Type controlType, string propertyName, string expressionPrefix)
            {
                if (string.IsNullOrEmpty(NameValueCollectionExtensions.GetValueByIndexOrName(arguments, 0, "Name")))
                {
                    CrmExpressionBuilder <SnippetExpressionBuilder.Provider> .ThrowArgumentException(propertyName, expressionPrefix, "Name={snippet name} [, Key={ResourceManager key}] [, Format={format string}] [, Portal={portal name}]");
                }

                string valueByIndexOrName1 = NameValueCollectionExtensions.GetValueByIndexOrName(arguments, 0, "Name");
                string key = NameValueCollectionExtensions.GetValueByIndexOrName(arguments, 1, "Key") ?? string.Empty;
                string valueByIndexOrName2 = NameValueCollectionExtensions.GetValueByIndexOrName(arguments, 2, "Format");
                Type   returnType          = CrmExpressionBuilder <SnippetExpressionBuilder.Provider> .GetReturnType(controlType, propertyName);

                var adapter = new SnippetDataAdapter(new PortalConfigurationDataAdapterDependencies());
                var snippet = adapter.Select(valueByIndexOrName1);

                var snippetByName = snippet == null ? null : snippet.Entity;

                if (Microsoft.Xrm.Client.TypeExtensions.IsA(returnType, typeof(Entity)))
                {
                    return((object)snippetByName);
                }

                if (snippetByName == null)
                {
                    string value = ResourceManager.GetString(key);
                    if (value == null)
                    {
                        return((object)key);
                    }

                    return((object)value);
                }

                return(CrmExpressionBuilder <SnippetExpressionBuilder.Provider> .GetEvalData((object)snippetByName, "adx_value", (string)null, valueByIndexOrName2, returnType));
            }
Esempio n. 2
0
        protected void Page_Init(object sender, EventArgs e)
        {
#if TELERIKWEBUI
            const bool captchaEnabled = true;
#else
            const bool captchaEnabled = false;
#endif
            var snippetDataAdapter =
                new SnippetDataAdapter(new PortalContextDataAdapterDependencies(
                                           PortalCrmConfigurationManager.CreatePortalContext(), requestContext: Context.Request.RequestContext));
            var submitButtonTextSnippet = snippetDataAdapter.Select("ContactUs/Submit");
            var submitButtonText        = submitButtonTextSnippet == null || submitButtonTextSnippet.Value == null ||
                                          string.IsNullOrWhiteSpace(submitButtonTextSnippet.Value.Value as string)
                                ? DefaultSubmitButtonText
                                : (string)submitButtonTextSnippet.Value.Value;
            var submitButtonBusyTextSnippet = snippetDataAdapter.Select("ContactUs/Submit");
            var submitButtonBusyText        = submitButtonBusyTextSnippet == null || submitButtonBusyTextSnippet.Value == null ||
                                              string.IsNullOrWhiteSpace(submitButtonBusyTextSnippet.Value.Value as string)
                                ? DefaultSubmitButtonBusyText
                                : (string)submitButtonBusyTextSnippet.Value.Value;


            FormView.InsertItemTemplate = new ItemTemplate(FormView.ValidationGroup, captchaEnabled, addSubmitButton: true,
                                                           submitButtonCommmandName: "Insert", submitButtonCauseValidation: true, submitButtonText: submitButtonText,
                                                           submitButtonBusyText: submitButtonBusyText, submitButtonCssClass: "btn btn-primary");
        }
Esempio n. 3
0
        public async Task <ActionResult> ChangePassword()
        {
            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            if (user == null)
            {
                throw new ApplicationException("Account error.");
            }

            var snippets = new SnippetDataAdapter(new PortalConfigurationDataAdapterDependencies());

            var breadcrumbSnippetName = snippets.Select("Profile/SecurityNav/ChangePassword");

            ViewBag.PageTitle = breadcrumbSnippetName != null ? breadcrumbSnippetName.Value.Value : ResourceManager.GetString("Change_Password_DefaultText");

            return(View(new ChangePasswordViewModel {
                Username = user.UserName, Email = user.Email
            }));
        }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType     = "application/atom+xml";
            context.Response.ContentEncoding = Encoding.UTF8;

            var snippets = new SnippetDataAdapter(new PortalConfigurationDataAdapterDependencies());

            var titleSnippet       = snippets.Select("Careers/Feed/Title");
            var descriptionSnippet = snippets.Select("Careers/Feed/Description");

            var feed = new SyndicationFeed(GetSyndicationItems())
            {
                Title       = SyndicationContent.CreatePlaintextContent(titleSnippet == null ? ResourceManager.GetString("Job_Postings_Text") : titleSnippet.Value.ToString()),
                Description = SyndicationContent.CreatePlaintextContent(descriptionSnippet == null ? ResourceManager.GetString("Job_Postings_Text") : descriptionSnippet.Value.ToString())
            };

            using (var writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8))
            {
                feed.SaveAsAtom10(writer);
            }
        }
Esempio n. 5
0
        public async Task <ActionResult> ChangeLogin(CancellationToken cancellationToken)
        {
            if (Adxstudio.Xrm.Configuration.PortalSettings.Instance.Ess.IsEss)
            {
                return(HttpNotFound());
            }

            var userId = User.Identity.GetUserId();
            var user   = await UserManager.FindByIdAsync(userId);

            if (user == null)
            {
                throw new ApplicationException("Account error.");
            }

            var id         = 0;
            var userLogins = await UserManager.GetLoginsAsync(userId);

            var tasks = AuthenticationManager.GetExternalAuthenticationTypes().Select(p => ToExternalAuthenticationTypes(id++, userLogins, p, cancellationToken));
            var externalAuthenticationTypes = await Task.WhenAll(tasks);

            var logins = externalAuthenticationTypes
                         .OrderBy(pair => pair.Provider.Caption)
                         .ToList();

            ViewBag.ShowRemoveButton = user.PasswordHash != null || userLogins.Count() > 1;

            var snippets = new SnippetDataAdapter(new PortalConfigurationDataAdapterDependencies());

            var breadcrumbSnippetName = snippets.Select("Profile/SecurityNav/ChangeLogin");

            ViewBag.PageTitle = breadcrumbSnippetName != null ? breadcrumbSnippetName.Value.Value : ResourceManager.GetString("Manage_External_Authentication");

            return(View(new ChangeLoginViewModel {
                Logins = logins
            }));
        }
Esempio n. 6
0
        public async Task <ActionResult> ChangeEmail()
        {
            if (Adxstudio.Xrm.Configuration.PortalSettings.Instance.Ess.IsEss)
            {
                return(HttpNotFound());
            }

            var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            if (user == null)
            {
                throw new ApplicationException("Account error.");
            }

            var snippets = new SnippetDataAdapter(new PortalConfigurationDataAdapterDependencies());

            var breadcrumbSnippetName = snippets.Select("Profile/SecurityNav/ChangeEmail");

            ViewBag.PageTitle = breadcrumbSnippetName != null ? breadcrumbSnippetName.Value.Value : ResourceManager.GetString("Change_Email_Defaulttext");

            return(View(new ChangeEmailViewModel {
                Email = user.Email
            }));
        }