Beispiel #1
0
        private OpenrecMessageContext CreateMessageContext(Tools.IComment comment, IOpenrecCommentData commentData, bool isInitialComment)
        {
            var userId = commentData.UserId;
            var user   = GetUser(userId) as IUser2;

            if (!_userDict.ContainsKey(userId))
            {
                _userDict.AddOrUpdate(user.UserId, user, (id, u) => u);
            }
            bool isFirstComment;

            if (_userCommentCountDict.ContainsKey(userId))
            {
                _userCommentCountDict[userId]++;
                isFirstComment = false;
            }
            else
            {
                _userCommentCountDict.Add(userId, 1);
                isFirstComment = true;
            }

            var nameItems = new List <IMessagePart>();

            nameItems.Add(MessagePartFactory.CreateMessageText(commentData.Name));
            nameItems.AddRange(commentData.NameIcons);
            user.Name = nameItems;

            var messageItems = new List <IMessagePart>();

            if (commentData.Message != null)
            {
                messageItems.Add(MessagePartFactory.CreateMessageText(commentData.Message));
            }

            OpenrecMessageContext messageContext = null;
            IOpenrecMessage       message;

            if (commentData.IsYell)
            {
                message = new OpenrecYell("")
                {
                    YellPoints = commentData.YellPoints,
                    Id         = commentData.Id,
                    NameItems  = nameItems,
                    PostTime   = commentData.PostTime,
                    UserId     = commentData.UserId,
                    Message    = commentData.Message,
                };
            }
            else if (commentData.Stamp != null)
            {
                message = new OpenrecStamp("")
                {
                    Stamp     = commentData.Stamp,
                    Id        = commentData.Id,
                    NameItems = nameItems,
                    PostTime  = commentData.PostTime,
                    UserId    = commentData.UserId,
                };
            }
            else
            {
                message = new OpenrecComment("")
                {
                    MessageItems = messageItems,
                    Id           = commentData.Id,
                    NameItems    = nameItems,
                    PostTime     = commentData.PostTime,
                    UserId       = commentData.UserId,
                };
            }
            var metadata = new MessageMetadata(message, _options, _siteOptions, user, this, isFirstComment)
            {
                IsInitialComment = isInitialComment,
                SiteContextGuid  = SiteContextGuid,
            };
            var methods = new OpenrecMessageMethods();

            messageContext = new OpenrecMessageContext(message, metadata, methods);
            return(messageContext);
        }
Beispiel #2
0
        private OpenrecMessageContext CreateMessageContext(Tools.IComment comment, IOpenrecCommentData commentData, bool isInitialComment)
        {
            var userId = commentData.UserId;
            var user   = GetUser(userId) as IUser2;

            if (!_userDict.ContainsKey(userId))
            {
                _userDict.AddOrUpdate(user.UserId, user, (id, u) => u);
            }
            bool isFirstComment;

            if (_userCommentCountDict.ContainsKey(userId))
            {
                _userCommentCountDict[userId]++;
                isFirstComment = false;
            }
            else
            {
                _userCommentCountDict.Add(userId, 1);
                isFirstComment = true;
            }

            var nameItems = new List <IMessagePart>();

            nameItems.Add(MessagePartFactory.CreateMessageText(commentData.Name));
            nameItems.AddRange(commentData.NameIcons);
            user.Name = nameItems;

            var messageItems = new List <IMessagePart>();

            if (commentData.IsYell)
            {
                //MessageType = MessageType.BroadcastInfo;
                messageItems.Add(MessagePartFactory.CreateMessageText("エールポイント:" + commentData.YellPoints + Environment.NewLine));
            }
            messageItems.Add(commentData.Message);
            if (commentData.Stamp != null)
            {
                //MessageType = MessageType.BroadcastInfo;
                messageItems.Add(commentData.Stamp);
            }

            OpenrecMessageContext messageContext = null;

            if (commentData.IsYell)
            {
                //2020/01/18、ここ空欄だけど大丈夫?
            }
            else if (commentData.Stamp != null)
            {
                //2020/01/18、ここ空欄だけど大丈夫?
            }
            else
            {
                var message = new OpenrecComment("")
                {
                    MessageItems = messageItems,
                    Id           = commentData.Id,
                    NameItems    = nameItems,
                    PostTime     = commentData.PostTime.ToString("HH:mm:ss"),
                    UserId       = commentData.UserId,
                };
                var metadata = new MessageMetadata(message, _options, _siteOptions, user, this, isFirstComment)
                {
                    IsInitialComment = isInitialComment,
                    SiteContextGuid  = SiteContextGuid,
                };
                var methods = new OpenrecMessageMethods();
                messageContext = new OpenrecMessageContext(message, metadata, methods);
            }
            return(messageContext);
        }