Exemplo n.º 1
0
 public User(Bouncer.User native)
 {
     Bot                          = native.bot;
     CreatedAt                    = native.createdAt;
     FirstMessageTime             = native.firstMessageTime;
     FirstMessageTimeThisInstance = native.firstMessageTimeThisInstance;
     NeedsGreeting                = native.needsGreeting;
     Id                      = native.id;
     IsBanned                = native.isBanned;
     IsJoined                = native.isJoined;
     IsNewAccount            = native.isNewAccount;
     IsRecentChatter         = native.isRecentChatter;
     Watching                = native.watching;
     IsWhitelisted           = native.isWhitelisted;
     JoinTime                = native.joinTime;
     LastMessageTime         = native.lastMessageTime;
     Login                   = native.login;
     Name                    = native.name;
     Note                    = native.note;
     PartTime                = native.partTime;
     TotalViewTime           = native.totalViewTime;
     NumMessages             = native.numMessages;
     NumMessagesThisInstance = native.numMessagesThisInstance;
     Role                    = native.role;
     Timeout                 = native.timeout;
     for (int i = 0; i < native.lastChat.Count; ++i)
     {
         LastChat.Add(native.lastChat[i]);
     }
 }
Exemplo n.º 2
0
 public bool addNewLastChat(LastChat newLastChat)
 {
     try
     {
         _lastChatRepository.Add(newLastChat);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 public bool updateLastChat(LastChat lastChat)
 {
     try
     {
         _lastChatRepository.Update(lastChat);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 发送给特定组
        /// </summary>
        /// <param name="groupName">组名</param>
        /// <param name="name">发送者</param>
        /// <param name="message">消息内容</param>
        public void sendToGroup(string groupName, string name, string message, string userimg, string lastChatId)
        {
            //接受方没有在线,把信息保存到数据库,并标记为未读(a.没有最近聊天记录,则添加新的最近聊天记录和聊天信息;b.有最近聊天记录,
            //则添加新的聊天信息,并更新最近聊天记录)
            if (lastChatId != "") //有最近聊天记录
            {
                //添加新的聊天记录
                int     lastChatint = Convert.ToInt32(lastChatId);
                Message newMesssge  = new Message();
                newMesssge.lastChatId           = lastChatint;
                newMesssge.messageContent       = message;
                newMesssge.messageReceiveUserId = Convert.ToInt32(groupName);
                newMesssge.messageSendUserId    = Convert.ToInt32(name);
                newMesssge.messageTime          = DateTime.Now;
                db.Message.Add(newMesssge);
                //更新最近聊天信息
                LastChat uplastChat = db.LastChat.Where(o => o.lastChatId == lastChatint).FirstOrDefault();
                uplastChat.lastChatContent = message;
                db.SaveChanges();

                Clients.Group(groupName).recieveMessage(new MessageModel()
                {
                    MsgType = "1", UserName = name, Message = message, UserImg = userimg, lastChatId = lastChatId
                });
            }
            else
            {
                //添加新的最近联系人
                LastChat newLastChat = new LastChat();
                newLastChat.lastChatContent  = message;
                newLastChat.lastChatfriendId = Convert.ToInt32(groupName);
                newLastChat.lastChatTime     = DateTime.Now;
                newLastChat.lastChatUserId   = Convert.ToInt32(name);
                db.LastChat.Add(newLastChat);
                db.SaveChanges();
                //添加新的聊天记录
                Message newMesssge = new Message();
                newMesssge.messageContent       = message;
                newMesssge.messageReceiveUserId = Convert.ToInt32(groupName);
                newMesssge.messageSendUserId    = Convert.ToInt32(name);
                newMesssge.messageTime          = DateTime.Now;
                int id = db.LastChat.Where(o => o.lastChatfriendId == newLastChat.lastChatfriendId && o.lastChatUserId == newLastChat.lastChatUserId).FirstOrDefault().lastChatId;
                newMesssge.lastChatId = id;
                db.Message.Add(newMesssge);
                db.SaveChanges();

                string stringId = Convert.ToString(id);
                Clients.Group(groupName).recieveMessage(new MessageModel()
                {
                    MsgType = "1", UserName = name, Message = message, UserImg = userimg, lastChatId = stringId
                });
            }
        }
Exemplo n.º 5
0
        public ActionResult getLastChatId(long userId)
        {
            LastChat lastChat = _lastChatService.getLastChatByUserIdFriId(loginUser.userId, userId);

            if (lastChat != null)
            {
                JsonResult["boo_success"] = lastChat.lastChatId;
                return(Json(JsonResult));
            }
            else
            {
                JsonResult["boo_success"] = false;
                return(Json(JsonResult));
            }
        }
Exemplo n.º 6
0
        public void Update(Bouncer.User native)
        {
            if (Bot != native.bot)
            {
                Bot = native.bot;
                NotifyPropertyChanged("Bot");
                NotifyPropertyChanged("MarkBotMenuItemVisibility");
                NotifyPropertyChanged("MarkNotBotMenuItemVisibility");
                NotifyPropertyChanged("MarkPossibleBotMenuItemVisibility");
            }
            if (CreatedAt != native.createdAt)
            {
                CreatedAt = native.createdAt;
                NotifyPropertyChanged("CreatedAt");
                NotifyPropertyChanged("CreatedAtFormatted");
            }
            if (FirstMessageTime != native.firstMessageTime)
            {
                FirstMessageTime = native.firstMessageTime;
                NotifyPropertyChanged("FirstMessageTime");
                NotifyPropertyChanged("FirstMessageTimeFormatted");
                if (FirstMessageTimeThisInstance == native.firstMessageTimeThisInstance)
                {
                    NotifyPropertyChanged("FirstMessageTimeReport");
                }
            }
            if (FirstMessageTimeThisInstance != native.firstMessageTimeThisInstance)
            {
                FirstMessageTimeThisInstance = native.firstMessageTimeThisInstance;
                NotifyPropertyChanged("FirstMessageTimeThisInstance");
                NotifyPropertyChanged("FirstMessageTimeReport");
            }
            if (NeedsGreeting != native.needsGreeting)
            {
                NeedsGreeting = native.needsGreeting;
                NotifyPropertyChanged("NeedsGreeting");
                NotifyPropertyChanged("NeedsGreetingImage");
            }
            if (Id != native.id)
            {
                Id = native.id;
                NotifyPropertyChanged("Id");
            }
            if (IsBanned != native.isBanned)
            {
                IsBanned = native.isBanned;
                NotifyPropertyChanged("IsBanned");
                NotifyPropertyChanged("Foreground");
                NotifyPropertyChanged("BanMenuItemVisibility");
                NotifyPropertyChanged("UnbanMenuItemVisibility");
            }
            if (IsNewAccount != native.isNewAccount)
            {
                IsNewAccount = native.isNewAccount;
                NotifyPropertyChanged("IsNewAccount");
                NotifyPropertyChanged("Foreground");
            }
            if (IsRecentChatter != native.isRecentChatter)
            {
                IsRecentChatter = native.isRecentChatter;
                NotifyPropertyChanged("IsRecentChatter");
                NotifyPropertyChanged("Foreground");
            }
            if (IsWhitelisted != native.isWhitelisted)
            {
                IsWhitelisted = native.isWhitelisted;
                NotifyPropertyChanged("IsWhitelisted");
                NotifyPropertyChanged("WhitelistMenuItemVisibility");
                NotifyPropertyChanged("UnwhitelistMenuItemVisibility");
            }
            if (IsJoined != native.isJoined)
            {
                IsJoined = native.isJoined;
                NotifyPropertyChanged("IsJoined");
            }
            if (Watching != native.watching)
            {
                Watching = native.watching;
                NotifyPropertyChanged("Watching");
                NotifyPropertyChanged("Foreground");
                NotifyPropertyChanged("StartWatchingMenuItemVisibility");
                NotifyPropertyChanged("StopWatchingMenuItemVisibility");
            }
            if (JoinTime != native.joinTime)
            {
                JoinTime = native.joinTime;
                NotifyPropertyChanged("JoinTime");
                NotifyPropertyChanged("JoinTimeFormatted");
            }
            if (LastMessageTime != native.lastMessageTime)
            {
                LastMessageTime = native.lastMessageTime;
                NotifyPropertyChanged("LastMessageTime");
                NotifyPropertyChanged("LastMessageTimeFormatted");
            }
            if (Login != native.login)
            {
                Login = native.login;
                NotifyPropertyChanged("Login");
            }
            if (Name != native.name)
            {
                Name = native.name;
                NotifyPropertyChanged("Name");
                NotifyPropertyChanged("WindowTitle");
                NotifyPropertyChanged("BanMenuItemHeader");
                NotifyPropertyChanged("UnbanMenuItemHeader");
                NotifyPropertyChanged("StartWatchingMenuItemHeader");
                NotifyPropertyChanged("StopWatchingMenuItemHeader");
                NotifyPropertyChanged("UnwhitelistMenuItemHeader");
                NotifyPropertyChanged("WhitelistMenuItemHeader");
            }
            if (Note != native.note)
            {
                Note = native.note;
                NotifyPropertyChanged("Note");
            }
            if (PartTime != native.partTime)
            {
                PartTime = native.partTime;
                NotifyPropertyChanged("PartTime");
                NotifyPropertyChanged("PartTimeFormatted");
            }
            if (TotalViewTime != native.totalViewTime)
            {
                TotalViewTime = native.totalViewTime;
                NotifyPropertyChanged("TotalViewTime");
                NotifyPropertyChanged("TotalViewTimeFormatted");
            }
            if (NumMessages != native.numMessages)
            {
                NumMessages = native.numMessages;
                NotifyPropertyChanged("NumMessages");
                if (NumMessagesThisInstance != native.numMessagesThisInstance)
                {
                    NotifyPropertyChanged("NumMessagesReport");
                }
            }
            if (NumMessagesThisInstance != native.numMessagesThisInstance)
            {
                NumMessagesThisInstance = native.numMessagesThisInstance;
                NotifyPropertyChanged("NumMessagesThisInstance");
                NotifyPropertyChanged("NumMessagesReport");
            }
            if (Role != native.role)
            {
                Role = native.role;
                NotifyPropertyChanged("Role");
            }
            if (Timeout != native.timeout)
            {
                Timeout = native.timeout;
                NotifyPropertyChanged("Timeout");
                NotifyPropertyChanged("TimeoutFormatted");
                NotifyPropertyChanged("Foreground");
            }
            while (
                (LastChat.Count > 0) &&
                (
                    (native.lastChat.Count == 0) ||
                    (LastChat[0] != native.lastChat[0])
                )
                )
            {
                LastChat.RemoveAt(0);
            }
            int i = 0;

            while (
                (i < native.lastChat.Count) &&
                (i < LastChat.Count) &&
                (LastChat[i] == native.lastChat[i])
                )
            {
                ++i;
            }
            while (i < LastChat.Count)
            {
                LastChat.RemoveAt(i);
            }
            while (i < native.lastChat.Count)
            {
                LastChat.Add(native.lastChat[i]);
                ++i;
            }
        }