protected override void OnInit(EventArgs e)
        {
            //var context = CrmConfigurationManager.CreateContext(ContextName, true);

            var portal = PortalCrmConfigurationManager.CreatePortalContext();

            var context = portal.ServiceContext;

            var entity = portal.Entity;

            var commentAdapterFactory = new CommentDataAdapterFactory(entity.ToEntityReference());

            var dataAdapter = commentAdapterFactory.GetAdapter();

            if (dataAdapter == null)
            {
                Visible = false;

                return;
            }

            var logicalName = dataAdapter.GetCommentLogicalName();

            EntityName = logicalName;

            EntityMetadata = context.RetrieveEntity(EntityName, EntityFilters.Attributes);
        }
Exemplo n.º 2
0
        protected void NewComment_OnItemInserting(object sender, CrmEntityFormViewInsertingEventArgs e)
        {
            var commentAdapterFactory = new CommentDataAdapterFactory(Entity.ToEntityReference());

            var dataAdapter = commentAdapterFactory.GetAdapter(Portal, Request.RequestContext);

            if (dataAdapter == null)
            {
                Visible = false;

                return;
            }

            var content          = e.Values[dataAdapter.GetCommentContentAttributeName()];
            var sanitizedContent = new WhiteListHtmlSanitizer(true).Sanitize(content == null ? string.Empty : content.ToString());

            var attributes = dataAdapter.GetCommentAttributes(sanitizedContent, CommentAuthorName.Text, CommentAuthorEmail.Text, CommentAuthorUrl.Text, Context);

            foreach (var attribute in attributes)
            {
                e.Values[attribute.Key] = attribute.Value;
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                CommentsView.DataBind();
            }

            var commentAdapterFactory = new CommentDataAdapterFactory(Entity.ToEntityReference());

            var dataAdapter = commentAdapterFactory.GetAdapter(Portal, Request.RequestContext);

            if (dataAdapter == null)
            {
                Visible = false;

                return;
            }

            var commentPolicyReader = dataAdapter.GetCommentPolicyReader();

            CommentsView.Visible = (!commentPolicyReader.IsCommentPolicyNone);

            NewCommentPanel.Visible = CommentsOpenToCurrentUser(commentPolicyReader);
        }
Exemplo n.º 4
0
        protected void CreateCommentDataAdapter(object sender, ObjectDataSourceEventArgs e)
        {
            var commentAdapterFactory = new CommentDataAdapterFactory(Entity.ToEntityReference());

            e.ObjectInstance = commentAdapterFactory.GetAdapter(Portal, Request.RequestContext);
        }