コード例 #1
0
        protected object GetDescription(SiteMapNode node)
        {
            if (node == null)
            {
                return(null);
            }

            var entityNode = node as CrmSiteMapNode;

            if (entityNode == null || entityNode.Entity == null)
            {
                return(node.Description);
            }

            var entity = XrmContext.MergeClone(entityNode.Entity);

            switch (entityNode.Entity.LogicalName)
            {
            case "adx_communityforum":
                return(Html.TextAttribute(XrmContext, entity, "adx_description"));

            case "adx_shortcut":
                return(Html.HtmlAttribute(XrmContext, entity, "adx_description"));

            case "adx_blog":
            case "adx_event":
            case "adx_webfile":
            case "adx_webpage":
                return(Html.HtmlAttribute(XrmContext, entity, "adx_summary"));

            default:
                return(node.Description);
            }
        }
コード例 #2
0
        protected void SendKBArticle_Click(object sender, EventArgs e)
        {
            var from = ServiceContext.GetSiteSettingValueByName(Website, "smtp/from");

            var mail = new MailMessage
            {
                From       = new MailAddress(from),
                Subject    = Article.Title,
                Body       = ArticleContent.Replace("style=\"", "style=\"line-height: normal;").Replace("style='", "style='line-height: normal;"),
                IsBodyHtml = true
            };

            mail.To.Add(toEmailAddresses.Text);

            var smtpServer   = ServiceContext.GetSiteSettingValueByName(Website, "smtp/server");
            var smtpUserName = ServiceContext.GetSiteSettingValueByName(Website, "smtp/userName");
            var smtpPassword = ServiceContext.GetSiteSettingValueByName(Website, "smtp/password");

            var smtp = new SmtpClient(smtpServer)
            {
                Credentials = new NetworkCredential(smtpUserName, smtpPassword)
            };

            smtp.Send(mail);

            var noteSubject = "Note created on " + DateTime.Now + " by " + Contact.FullName;

            var contact = XrmContext.MergeClone(Contact);

            XrmContext.AddNoteAndSave(contact, noteSubject, "Knowledge Base Article titled: " + Article.Title + ", was emailed to " + toEmailAddresses.Text + " on " + DateTime.Now);

            toEmailAddresses.Text = "";

            EmailSentMessage.Text = "Your email has been sent.";
        }
        protected void OnItemInserting(object sender, CrmEntityFormViewInsertingEventArgs e)
        {
            var currentContact = XrmContext.MergeClone(Contact);

            if (currentContact == null)
            {
                return;
            }

            var contactParentCustomerAccount = currentContact.GetRelatedEntity(XrmContext, new Relationship("contact_customer_accounts"));

            if (contactParentCustomerAccount != null)
            {
                e.Values["msa_partnerid"] = contactParentCustomerAccount.ToEntityReference();
            }

            e.Values["msa_partneroppid"] = currentContact.ToEntityReference();

            e.Values["adx_createdbyusername"] = Contact.GetAttributeValue <string>("fullname");

            // e.Values["adx_createdbyipaddress"] = Request.UserHostAddress ?? "";

            e.Values["adx_partnercreated"] = true;

            // If no estimated revenue was submitted, leave as system-calculated.

            e.Values["isrevenuesystemcalculated"] = (!e.Values.ContainsKey("estimatedvalue")) || (e.Values["estimatedvalue"] == null);

            Guid accountId;

            if ((Account_dropdown.SelectedItem == null || Account_dropdown.SelectedIndex == 0) || !Guid.TryParse(Account_dropdown.SelectedItem.Value, out accountId))
            {
                return;
            }

            var account = XrmContext.CreateQuery("account").FirstOrDefault(a => a.GetAttributeValue <Guid>("accountid") == accountId);

            if (account != null)
            {
                e.Values["customerid"] = account.ToEntityReference();
            }
        }
コード例 #4
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            MissingFieldsMessage.Visible = false;

            var contact = XrmContext.MergeClone(Contact);

            ManageLists(XrmContext, contact);

            ProfileFormView.UpdateItem();

            var returnUrl = Request["returnurl"];

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                Context.RedirectAndEndResponse(returnUrl);
            }
        }
コード例 #5
0
ファイル: Profile.aspx.cs プロジェクト: bhushanawhad/OpenLan
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            if (!Request.IsAuthenticated)
            {
                return;
            }

            if (AccountInformation.Visible)
            {
                var contactAccount = Contact.contact_customer_accounts;

                SaveAccountDetails(XrmContext.AccountSet.FirstOrDefault(a => a.AccountId == contactAccount.AccountId));
            }

            if (SelfInformation.Visible)
            {
                var contact = XrmContext.MergeClone(Contact);

                SetContactDetails(contact);

                XrmContext.UpdateObject(contact);

                ManageLists(XrmContext, contact);

                XrmContext.SaveChanges();
            }

            var snippet = RegistrationPanel.FindControl("ProfileUpdatedMsg");

            if (snippet != null)
            {
                snippet.Visible = true;
            }
        }
コード例 #6
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            MissingFieldsMessage.Visible = false;

            var contact = XrmContext.MergeClone(Contact);

            ManageLists(XrmContext, contact);

            ProfileFormView.UpdateItem();

            var returnUrl = Request["returnurl"];

            var languageContext = this.Context.GetContextLanguageInfo();

            if (languageContext.IsCrmMultiLanguageEnabled && _forceRedirect)
            {
                // When forcing redirect for language change, make the confirmation message visible after redirect
                // It is only needed when redirecting back to Profile page
                if (string.IsNullOrWhiteSpace(returnUrl))
                {
                    Session[ConfirmationOneTimeMessageSessionKey] = true;
                }

                // respect returnUrl if it was provided during the form submit
                // otherwise, redirect back to current page
                var redirectUri = string.IsNullOrWhiteSpace(returnUrl) ? Request.Url : returnUrl.AsAbsoluteUri(Request.Url);
                returnUrl = languageContext.FormatUrlWithLanguage(overrideUri: redirectUri);
            }

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                Context.RedirectAndEndResponse(returnUrl);
            }
        }