Exemplo n.º 1
0
        ///// <summary>
        ///// 创建ChatStore
        ///// </summary>
        ///// <param name="userName"></param>
        ///// <param name="chatType"></param>
        //public static void CreateChatStore(string userName, ChatType chatType)
        //{
        //    if (_chatList.Any(d => d.ChatUserName == userName))
        //    {
        //        return;
        //    }
        //    ChatStore info = new ChatStore();
        //    info.ChatType = chatType;
        //    info.ChatUserName = userName;
        //    info.MessageList = new List<ChatMessage>();
        //    _chatList.Add(info);

        //}


        public static ChatStore GetOrCreateChatStore(string sendUserName, ChatType chatType)
        {
            ChatStore info = _chatList.FirstOrDefault(d => d.ChatUserName == sendUserName);

            if (info == null)
            {
                info              = new ChatStore();
                info.ChatType     = chatType;
                info.ChatUserName = sendUserName;
                info.MessageList  = new List <ChatMessage>();
                _chatList.Add(info);
            }
            return(info);
        }
Exemplo n.º 2
0
        public static void AddNewChat(ChatMessage request)
        {
            ChatStore info = GetOrCreateChatStore(request.SendUserName, request.ChatType);

            if (!string.IsNullOrWhiteSpace(request.Message))
            {
                if (info.NewMessageList == null)
                {
                    info.NewMessageList = new List <ChatMessage>();
                }
                request.SendTime = DateTime.Now;
                info.NewMessageList.Add(request);
            }
        }
Exemplo n.º 3
0
        public static ChatStore CreateGroupChat(string groupId)
        {
            if (_chatList.Any(d => d.ChatType == ChatType.GroupChat))
            {
                return(null);
            }
            ChatStore info = new ChatStore();

            info.ChatType     = ChatType.GroupChat;
            info.ChatUserName = groupId;
            info.MessageList  = new List <ChatMessage>();
            _chatList.Add(info);
            IsTeamChatChanged = true;
            return(info);
        }
Exemplo n.º 4
0
        public static void AddNewChat(ChatMessage request)
        {
            ChatStore info = CreateChatStore(request);

            if (!string.IsNullOrWhiteSpace(request.Message))
            {
                //ChatBoxContent content = new ChatBoxContent(request.Message, messageFont, messageColor);
                //   var message = request.ToChatMessage();// new ChatMessage(request.UserName, request.DisplayName, LoginUserInfo.UserName, content);

                if (info.NewMessageList == null)
                {
                    info.NewMessageList = new List <ChatMessage>();
                }
                request.SendTime = DateTime.Now;
                info.NewMessageList.Add(request);
            }
        }
Exemplo n.º 5
0
        //   public static List<ChatStore> ChatList { get; set; }



        //public static void AddNewChat(AddChatRequest request)
        //{
        //    ChatStore info = ChatList.FirstOrDefault(d => d.ChatUserName == request.UserName);

        //    if (info == null)
        //    {
        //        info = new ChatStore();
        //        info.ChatDisplayName = request.DisplayName;
        //        info.ChatStartTime = DateTime.Now;
        //        info.ChatType = request.ChatType;
        //        info.ChatUserName = request.UserName;
        //        info.UserType = request.UserType;
        //        info.MessageList = new List<ChatMessage>();
        //        ChatList.Add(info);
        //    }

        //    if (!string.IsNullOrWhiteSpace(request.Message))
        //    {
        //        //ChatBoxContent content = new ChatBoxContent(request.Message, messageFont, messageColor);
        //        var message = request.ToChatMessage();// new ChatMessage(request.UserName, request.DisplayName, LoginUserInfo.UserName, content);

        //        if (info.NewMessageList == null)
        //        {
        //            info.NewMessageList = new List<ChatMessage>();

        //        }
        //        info.NewMessageList.Add(message);
        //    }

        //}

        private static ChatStore CreateChatStore(ChatMessage request)
        {
            ChatStore info = _chatList.FirstOrDefault(d => d.ChatUserName == request.SendUserName);

            if (info == null)
            {
                info = new ChatStore();
                //  info.ChatDisplayName = request.SendDisplayName;
                // info.ChatStartTime = DateTime.Now;
                info.ChatType     = request.ChatType;
                info.ChatUserName = request.SendUserName;
                //    info.UserType = request.UserType;
                info.MessageList = new List <ChatMessage>();
                _chatList.Add(info);
            }
            return(info);
        }
Exemplo n.º 6
0
        public static void CreateChatStore(string userName, ChatType chatType)
        {
            if (_chatList.Any(d => d.ChatUserName == userName))
            {
                return;
            }

            ChatStore info = new ChatStore();

            //   info.ChatDisplayName = "全体成员";
            //   info.ChatStartTime = DateTime.Now;
            info.ChatType     = chatType;
            info.ChatUserName = userName;
            //  info.UserType = ClientRole.Teacher;
            info.MessageList = new List <ChatMessage>();
            _chatList.Add(info);
        }
Exemplo n.º 7
0
        public static ChatStore CreateGroupChat(string groupId)
        {
            if (ChatList.Any(d => d.ChatType == ChatType.GroupChat))
            {
                return(null);
            }


            ChatStore info = new ChatStore();

            info.ChatDisplayName = "所有人";
            info.ChatStartTime   = DateTime.Now;
            info.ChatType        = ChatType.GroupChat;
            info.ChatUserName    = groupId;
            info.UserType        = ClientRole.Teacher;
            info.MessageList     = new List <ChatMessage>();
            ChatList.Add(info);
            IsTeamChatChanged = true;
            return(info);
        }
Exemplo n.º 8
0
 public ChatItem2(ChatListItem ParentItem, ChatStore chatStore)
 {
     CreateChatItem(ParentItem, chatStore.ChatUserName,
                    chatStore.ChatDisplayName, chatStore.ChatType, chatStore.UserType);
 }