Пример #1
0
        public void CreateDiscussionThread()
        {
            ManagedAccount        a = new ManagedAccount(Session);
            ManagedDiscussion     d = new ManagedDiscussion(Session);
            ManagedDiscussionPost p = new ManagedDiscussionPost(Session);

            try
            {
                a.Create("Test User", "testpassword", "*****@*****.**", DateTime.UtcNow, AdminSecurityContext);
                a.VerifyAllEmails();
                a.AddDefaultPicture();

                TransitDiscussion t_d = new TransitDiscussion();
                t_d.Description = GetNewString();
                t_d.Name        = GetNewString();
                t_d.Personal    = false;
                d.CreateOrUpdate(t_d, a.GetSecurityContext());

                TransitDiscussionPost t_p = new TransitDiscussionPost();
                t_p.Subject      = GetNewString();
                t_p.Body         = GetNewString();
                t_p.DiscussionId = d.Id;
                p.CreateOrUpdate(t_p, a.GetSecurityContext());

                Session.Flush();
            }
            finally
            {
                p.Delete(a.GetSecurityContext());
                d.Delete(a.GetSecurityContext());
                a.Delete(a.GetSecurityContext());
            }
        }
 public void post_Click(object sender, EventArgs e)
 {
     TransitDiscussionPost tw = new TransitDiscussionPost();
     tw.Subject = "Untitled";
     tw.Body = inputPost.Text;
     tw.DiscussionId = DiscussionId;
     tw.DiscussionThreadId = DiscussionThreadId;
     SessionManager.CreateOrUpdate<TransitDiscussionPost>(
         tw, SessionManager.DiscussionService.CreateOrUpdateDiscussionPost);
     SessionManager.InvalidateCache<TransitDiscussion>();
     SessionManager.InvalidateCache<TransitDiscussionThread>();
     Redirect(Request.Url.PathAndQuery);
 }
Пример #3
0
    public void post_Click(object sender, EventArgs e)
    {
        TransitDiscussionPost tw = new TransitDiscussionPost();

        tw.Subject            = "Untitled";
        tw.Body               = inputPost.Text;
        tw.DiscussionId       = DiscussionId;
        tw.DiscussionThreadId = DiscussionThreadId;
        SessionManager.CreateOrUpdate <TransitDiscussionPost>(
            tw, SessionManager.DiscussionService.CreateOrUpdateDiscussionPost);
        SessionManager.InvalidateCache <TransitDiscussion>();
        SessionManager.InvalidateCache <TransitDiscussionThread>();
        Redirect(Request.Url.PathAndQuery);
    }
Пример #4
0
        public void CreateDiscussionThreadInvalidChild()
        {
            ManagedAccount        a  = new ManagedAccount(Session);
            ManagedDiscussion     d1 = new ManagedDiscussion(Session);
            ManagedDiscussion     d2 = new ManagedDiscussion(Session);
            ManagedDiscussionPost p  = new ManagedDiscussionPost(Session);

            try
            {
                a.Create("Test User", "testpassword", "*****@*****.**", DateTime.UtcNow, AdminSecurityContext);
                a.VerifyAllEmails();
                a.AddDefaultPicture();

                TransitDiscussion t_d = new TransitDiscussion();
                t_d.Description = GetNewString();
                t_d.Name        = GetNewString();
                t_d.Personal    = false;
                d1.CreateOrUpdate(t_d, a.GetSecurityContext());

                t_d.Name = GetNewString();
                d2.CreateOrUpdate(t_d, a.GetSecurityContext());

                TransitDiscussionPost t_p = new TransitDiscussionPost();
                t_p.Subject      = GetNewString();
                t_p.Body         = GetNewString();
                t_p.DiscussionId = d1.Id;

                int id1 = p.CreateOrUpdate(t_p, a.GetSecurityContext());
                Assert.AreNotEqual(0, id1);

                t_p.DiscussionId = d2.Id;
                int id2 = p.CreateOrUpdate(t_p, a.GetSecurityContext());
                Assert.AreNotEqual(0, id2);

                // can't create child of other discussion
                t_p.DiscussionId           = d1.Id;
                t_p.DiscussionPostParentId = id2;
                int id3 = p.CreateOrUpdate(t_p, a.GetSecurityContext());

                Session.Flush();
            }
            finally
            {
                d1.Delete(AdminSecurityContext);
                d2.Delete(AdminSecurityContext);
                a.Delete(AdminSecurityContext);
            }
        }
Пример #5
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TransitDiscussionPost t_post = SessionManager.DiscussionService.GetDiscussionPostById(
                SessionManager.Ticket, RequestId);

            TransitDiscussion t_discussion = SessionManager.DiscussionService.GetDiscussionById(
                SessionManager.Ticket, t_post.DiscussionId);

            // discussions

            if (t_discussion.ObjectId != 0 && !string.IsNullOrEmpty(t_discussion.ParentObjectType))
            {
                listDiscussions.DataSource = SessionManager.DiscussionService.GetDiscussionsByObjectId(
                    SessionManager.Ticket, t_discussion.ParentObjectType, t_discussion.ObjectId, null);
            }
            else
            {
                listDiscussions.DataSource = SessionManager.DiscussionService.GetDiscussions(
                    SessionManager.Ticket, null);
            }

            listDiscussions.DataBind();

            // blogs

            List <TransitAccountBlog> t_blogs = SessionManager.BlogService.GetAccountBlogs(
                SessionManager.Ticket, SessionManager.AccountId, null);
            t_blogs.AddRange(SessionManager.BlogService.GetAuthoredAccountBlogs(
                                 SessionManager.Ticket, SessionManager.AccountId, null));
            listBlogs.DataSource = t_blogs;
            listBlogs.DataBind();

            // ----

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Discussions", Request, "DiscussionsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(t_discussion.Name, Request, string.Format("DiscussionView.aspx?id={0}", t_discussion.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode(t_post.Subject, Request, string.Format("DiscussionThreadView.aspx?id={0}&did={1}", t_post.DiscussionThreadId, t_discussion.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode("Move", Request.Url));
            StackSiteMap(sitemapdata);

            ReportWarning("Warning! This will move the post out of its thread, including all its replies. " +
                          "This cannot be undone.");
        }
    }
Пример #6
0
    public void moveToDiscussion_Click(object sender, EventArgs args)
    {
        int id = SessionManager.DiscussionService.MoveAccountBlogPost(
            SessionManager.Ticket,
            RequestId,
            int.Parse(listDiscussions.SelectedValue));

        TransitDiscussionPost t_post = SessionManager.DiscussionService.GetDiscussionPostById(
            SessionManager.Ticket, id);

        SessionManager.InvalidateCache <TransitDiscussion>();
        SessionManager.InvalidateCache <TransitDiscussionPost>();
        SessionManager.InvalidateCache <TransitAccountBlog>();
        SessionManager.InvalidateCache <TransitAccountBlogPost>();

        Redirect(string.Format("DiscussionThreadView.aspx?id={0}&did={1}",
                               t_post.DiscussionThreadId, t_post.DiscussionId));
    }
Пример #7
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TransitDiscussionThread tt = SessionManager.DiscussionService.GetDiscussionThreadById(
                SessionManager.Ticket, RequestId);

            TransitDiscussion td = SessionManager.DiscussionService.GetDiscussionById(
                SessionManager.Ticket, tt.DiscussionId);

            TransitDiscussionPost tp = SessionManager.DiscussionService.GetDiscussionThreadPost(
                SessionManager.Ticket, tt.Id);

            this.Title = Renderer.Render(td.Name);

            if (td.ObjectId != 0 && !string.IsNullOrEmpty(td.ParentObjectType))
            {
                listDiscussions.DataSource = SessionManager.DiscussionService.GetDiscussionsByObjectId(
                    SessionManager.Ticket, td.ParentObjectType, td.ObjectId, null);
            }
            else
            {
                listDiscussions.DataSource = SessionManager.DiscussionService.GetDiscussions(
                    SessionManager.Ticket, null);
            }

            listDiscussions.DataBind();

            ListItemManager.TrySelect(listDiscussions, tt.DiscussionId);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Discussions", Request, "DiscussionsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(td.Name, Request, string.Format("DiscussionView.aspx?id={0}", td.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode(tp.Subject, Request, string.Format("DiscussionThreadView.aspx?id={0}&did={1}", tp.DiscussionThreadId, td.Id)));
            sitemapdata.Add(new SiteMapDataAttributeNode("Move", Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Пример #8
0
    public void post_Click(object sender, EventArgs e)
    {
        TransitDiscussionPost tw = new TransitDiscussionPost();

        tw.Subject = inputSubject.Text;
        if (string.IsNullOrEmpty(tw.Subject))
        {
            tw.Subject = "Untitled";
        }
        tw.Body = inputBody.Content;
        tw.Id   = PostId;
        tw.DiscussionPostParentId = ParentId;
        tw.DiscussionId           = DiscussionId;
        if (inputSticky.Enabled)
        {
            tw.Sticky = inputSticky.Checked;
        }
        SessionManager.CreateOrUpdate <TransitDiscussionPost>(
            tw, SessionManager.DiscussionService.CreateOrUpdateDiscussionPost);
        SessionManager.InvalidateCache <TransitDiscussion>();
        SessionManager.InvalidateCache <TransitDiscussionThread>();
        Redirect(linkCancel.NavigateUrl);
    }
Пример #9
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DomainClass cs = SessionManager.GetDomainClass("DiscussionPost");
            inputSubject.MaxLength = cs["Subject"].MaxLengthInChars;

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();

            this.addFile.Attributes["onclick"] = this.files.GetAddFileScriptReference() + "return false;";

            linkCancel.NavigateUrl = ReturnUrl;

            if (DiscussionId > 0)
            {
                TransitDiscussion td = SessionManager.GetPrivateInstance <TransitDiscussion, int>(
                    DiscussionId, SessionManager.DiscussionService.GetDiscussionById);

                inputSticky.Enabled = td.CanUpdate;

                if (!string.IsNullOrEmpty(td.ParentObjectName))
                {
                    sitemapdata.Add(new SiteMapDataAttributeNode(td.ParentObjectName, Request, td.ParentObjectUri));
                    discussionLabelLink.Text        = Renderer.Render(td.ParentObjectName);
                    discussionLabelLink.NavigateUrl = td.ParentObjectUri;
                }
                else
                {
                    discussionLabelLink.Text        = Renderer.Render(td.Name);
                    discussionLabelLink.NavigateUrl = string.Format("DiscussionView.aspx?id={0}", td.Id);
                    sitemapdata.Add(new SiteMapDataAttributeNode("Discussions", Request, "DiscussionsView.aspx"));
                    sitemapdata.Add(new SiteMapDataAttributeNode(td.Name, Request, string.Format("DiscussionView.aspx?id={0}", td.Id)));
                }
            }

            StringBuilder body = new StringBuilder();

            if (PostId > 0)
            {
                TransitDiscussionPost tw = SessionManager.DiscussionService.GetDiscussionPostById(SessionManager.Ticket, PostId);
                titleNewPost.Text   = Renderer.Render(tw.Subject);
                inputSubject.Text   = tw.Subject;
                inputSticky.Checked = tw.Sticky;
                body.Append(tw.Body);
                sitemapdata.Add(new SiteMapDataAttributeNode(tw.Subject, Request.Url));
            }
            else
            {
                sitemapdata.Add(new SiteMapDataAttributeNode("New Post", Request.Url));
            }

            if (ParentId > 0)
            {
                TransitDiscussionPost rp = SessionManager.DiscussionService.GetDiscussionPostById(SessionManager.Ticket, ParentId);
                panelReplyTo.Visible          = true;
                replytoSenderName.NavigateUrl = accountlink.HRef = "AccountView.aspx?id=" + rp.AccountId.ToString();
                replytoSenderName.Text        = Renderer.Render(rp.AccountName);
                replyToBody.Text               = base.RenderEx(rp.Body);
                replytoCreated.Text            = SessionManager.ToAdjustedString(rp.Created);
                replytoImage.ImageUrl          = string.Format("AccountPictureThumbnail.aspx?id={0}&width=75&height=75", rp.AccountPictureId);
                replytoSubject.Text            = Renderer.Render(rp.Subject);
                inputSubject.Text              = rp.Subject.StartsWith("Re:") ? rp.Subject : "Re: " + rp.Subject;
                rowsubject.Attributes["style"] = "display: none;";

                if (Quote)
                {
                    body.AppendFormat("<P>[quote]<DIV>on {0} {1} wrote:</DIV><DIV>{2}</DIV>[/quote]</P>",
                                      rp.Created.ToString("d"), rp.AccountName, rp.Body);
                }
            }

            if ((PostId == 0) && !string.IsNullOrEmpty(SessionManager.Account.Signature))
            {
                body.Append("<BR /><BR />");
                body.Append("<P>");
                body.Append(Renderer.RenderEx(SessionManager.Account.Signature));
                body.Append("</P>");
            }

            inputBody.Content = body.ToString();

            StackSiteMap(sitemapdata);
        }

        if (!SessionManager.HasVerified())
        {
            ReportWarning("You don't have any verified e-mail addresses and/or profile photos.\n" +
                          "You must add/confirm a valid e-mail address and upload a profile photo before posting.");

            panelPost.Visible = false;
            post.Enabled      = false;
        }

        SetDefaultButton(post);
    }
Пример #10
0
 public void post_Click(object sender, EventArgs e)
 {
     TransitDiscussionPost tw = new TransitDiscussionPost();
     tw.Subject = inputSubject.Text;
     if (string.IsNullOrEmpty(tw.Subject)) tw.Subject = "Untitled";
     tw.Body = inputBody.Content;
     tw.Id = PostId;
     tw.DiscussionPostParentId = ParentId;
     tw.DiscussionId = DiscussionId;
     if (inputSticky.Enabled) tw.Sticky = inputSticky.Checked;
     SessionManager.CreateOrUpdate<TransitDiscussionPost>(
         tw, SessionManager.DiscussionService.CreateOrUpdateDiscussionPost);
     SessionManager.InvalidateCache<TransitDiscussion>();
     SessionManager.InvalidateCache<TransitDiscussionThread>();
     Redirect(linkCancel.NavigateUrl);
 }
Пример #11
0
 public int CreateOrUpdateDiscussionPost(string ticket, TransitDiscussionPost post)
 {
     return WebServiceImpl<TransitDiscussionPost, ManagedDiscussionPost, DiscussionPost>.CreateOrUpdate(
         ticket, post);
 }
Пример #12
0
 public int CreateOrUpdateDiscussionPost(string ticket, TransitDiscussionPost post)
 {
     return(WebServiceImpl <TransitDiscussionPost, ManagedDiscussionPost, DiscussionPost> .CreateOrUpdate(
                ticket, post));
 }