Exemplo n.º 1
0
        public void AddChildComment(Journal.CommentsRow comment)
        {
            CommentNode tc = new CommentNode(comment, null);

            tc.depth = this.depth + 1;
            if (children == null)
            {
                children = new ArrayList();
            }
            children.Add(tc);
        }
Exemplo n.º 2
0
        static private void Merge(Journal j, EventCollection ec, CommentCollection ccMeta,
                                  CommentCollection ccBody, UserMapCollection umc, SyncItemCollection deletedsic, LoginResponse lr,
                                  string communityPicURL, DateTime lastSync)
        {
            j.AcceptChanges();             // row states must be set to unchanged for loaddatarow to merge properly

            // update moods
            j.Moods.BeginLoadData();
            foreach (Mood m in lr.moods)
            {
                j.Moods.LoadDataRow(new object[] { m.id, m.name, m.parent }, false);
            }
            j.Moods.EndLoadData();

            // update userpics
            j.UserPics.Clear();
            j.UserPics.BeginLoadData();
            for (int i = 0; i < lr.pickws.Length; ++i)
            {
                j.UserPics.AddUserPicsRow(lr.pickws[i], lr.pickwurls[i]);
            }
            j.UserPics.EndLoadData();

            // update users
            j.Users.BeginLoadData();
            foreach (UserMap u in umc)
            {
                j.Users.LoadDataRow(new object[] { u.id, u.user }, false);
            }
            j.Users.LoadDataRow(new object[] { 0, "anonymous" }, false);
            j.Users.EndLoadData();

            // update new/updated journal events
            j.Events.BeginLoadData();
            foreach (Event e in ec)
            {
                j.Events.LoadDataRow(new object[] {
                    e.itemid,
                    DateTime.Parse(e.eventtime, CultureInfo.InvariantCulture),
                    e.security,
                    e.allowmask,
                    e.subject,
                    e.eventText,
                    e.poster,
                    e.anum,
                    e.props.current_mood,
                    e.props.current_moodid,
                    e.props.current_music,
                    e.props.opt_preformatted == 1,
                    e.props.opt_nocomments == 1,
                    e.props.picture_keyword,
                    e.props.opt_backdated == 1,
                    e.props.opt_noemail == 1,
                    e.props.unknown8bit == 1,
                    e.props.hasscreened == 1,
                    e.props.revnum,
                    e.props.commentalter,
                    e.props.syn_link,
                    e.props.syn_id,
                    new DateTime(1970, 1, 1).AddSeconds(e.props.revtime),
                    e.props.taglist
                }, false);
            }
            j.Events.EndLoadData();

            // update comment meta (posterid and state can change)
            j.Comments.BeginLoadData();
            foreach (Comment c in ccMeta)
            {
                Journal.CommentsRow cr = j.Comments.FindByID(c.id);
                if (cr != null)
                {
                    cr.PosterID = c.posterid;
                    cr.State    = c.state;
                }
            }
            j.Comments.EndLoadData();

            // update comment bodies
            j.Comments.BeginLoadData();
            foreach (Comment c in ccBody)
            {
                j.Comments.LoadDataRow(new object[] {
                    c.id,
                    c.posterid,
                    c.state,
                    c.jitemid,
                    c.parentid,
                    c.body,
                    c.subject,
                    c.date
                }, false);
            }
            j.Comments.EndLoadData();

            // update deleted journal events
            if (deletedsic != null)
            {
                foreach (SyncItem s in deletedsic)
                {
                    Common.Journal.EventsRow er =
                        j.Events.FindByID(int.Parse(s.item.Substring(_syncitemtypelogprefix.Length)));
                    if (er != null)
                    {
                        j.Events.RemoveEventsRow(er);
                    }
                }
            }

            // update options
            j.Options.DefaultPicURL = (lr.defaultpicurl != null && lr.defaultpicurl.Length > 0 ?
                                       lr.defaultpicurl : null);
            j.Options.CommunityPicURL = communityPicURL;
            j.Options.FullName        = (lr.fullname != null && lr.fullname.Length > 0 ? lr.fullname : null);
            j.Options.LastSync        = lastSync;
        }
Exemplo n.º 3
0
 public CommentNode(Journal.CommentsRow comment, ArrayList children)
 {
     this.depth    = 0;
     this.comment  = comment;
     this.children = children;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Output a transformed comment to the HTML stream.
        /// </summary>
        private void WriteComment(TextWriter tw, Journal.CommentsRow cr, Journal.UsersDataTable udt, int spacerWidth)
        {
            // you'd think that using an actual System.Collections.Stack would be faster
            // but profiling shows that it's actually a tiny bit slower.  not sure why.
            ArrayList idstack = new ArrayList();

            foreach (string block in commentBlocks)
            {
                if (block.StartsWith("<%"))
                {
                    string id = block.Substring(2, block.Length - 4).Trim().ToLower();
                    // check the id stack for additions
                    if (id.StartsWith("!"))
                    {
                        string idToBlock = id.Substring(1);
                        switch (idToBlock)
                        {
                        case "nonanonymous":
                            if (cr.IsPosterIDNull() || cr.PosterID == 0)
                            {
                                idstack.Add(idToBlock);
                            }
                            break;

                        case "anonymous":
                            if (!cr.IsPosterIDNull() && cr.PosterID != 0)
                            {
                                idstack.Add(idToBlock);
                            }
                            break;

                        case "spacerwidth":
                            if (spacerWidth == 0)
                            {
                                idstack.Add(idToBlock);
                            }
                            break;

                        default:
                            if (!cr.Table.Columns.Contains(idToBlock) || cr.IsNull(idToBlock))
                            {
                                idstack.Add(idToBlock);
                            }
                            break;
                        }
                        continue;
                    }
                    // check the id stack for removals
                    else if (id.StartsWith("/!"))
                    {
                        idstack.Remove(id.Substring(2));
                        continue;
                    }
                    else
                    {
                        // we don't output anything until the stack is empty
                        if (idstack.Count > 0)
                        {
                            continue;
                        }
                        switch (id)
                        {
                        case "spacerwidth":
                            tw.Write(spacerWidth);
                            break;

                        case "commentbackgroundcolor":
                            if (cr.ID == selectedCommentID)
                            {
                                tw.Write(GetHTMLColor(hjws.SelectedCommentBackgroundColor));
                            }
                            else if (!cr.IsStateNull() && cr.State.ToLower() == "s")
                            {
                                tw.Write(GetHTMLColor(hjws.ScreenedCommentBackgroundColor));
                            }
                            else
                            {
                                tw.Write(GetHTMLColor(hjws.CommentBackgroundColor));
                            }
                            break;

                        case "commenttextcolor":
                            if (cr.ID == selectedCommentID)
                            {
                                tw.Write(GetHTMLColor(hjws.SelectedCommentTextColor));
                            }
                            else if (!cr.IsStateNull() && cr.State.ToLower() == "s")
                            {
                                tw.Write(GetHTMLColor(hjws.ScreenedCommentTextColor));
                            }
                            else
                            {
                                tw.Write(GetHTMLColor(hjws.CommentTextColor));
                            }
                            break;

                        default:
                            if (id == "subject" || id == "body")
                            {
                                WritePreparedText(tw, cr[id].ToString(), commentSearchString);
                            }
                            else if (cr.Table.Columns.Contains(id))
                            {
                                tw.Write(cr[id]);
                            }
                            break;
                        }
                    }
                }
                else
                {
                    if (idstack.Count == 0)
                    {
                        tw.Write(block);
                    }
                }
            }
        }