Ejemplo n.º 1
0
        public void InsertChatUserMessage(Chat msg)
        {
            tblMessageUser c = new tblMessageUser()
            {
                MSG_USER_FROM = msg.FromUserID,
                MSG_USER_TO = msg.ToUserID,
                MSG_ID = dc.tblMessages.Where(z => z.TBL_MSG_TIME == msg.Time).First().TBL_MSG_ID,

            };
            dc.tblMessageUsers.InsertOnSubmit(c);
            dc.SubmitChanges();
        }
Ejemplo n.º 2
0
        public void InsertChatMessage(Chat msg)
        {
            var m = new tblMessage()
            {
                TBL_MSG_TEXT = msg.Message,
                TBL_MSG_TIME = msg.Time,
            };

            dc.tblMessages.InsertOnSubmit(m);
            dc.SubmitChanges();

        }
Ejemplo n.º 3
0
        public void SetDocViewed(bool Viewed, Chat Msg)
        {
            var M = dc.tblMessageUsers.Where(z => z.MSG_ID == Msg.MessageID && z.MSG_USER_TO == UserID);
            if (M != null) M.First().MSG_VIEWED = Viewed;

        }
Ejemplo n.º 4
0
        private void chatSendButton_Click(object sender, EventArgs e)
        {
            var msg = new StringBuilder();
            msg.Append(chatInputTextBox.Text);

            int index = 0;
            DateTime time = new DateTime();
            foreach (var tu in SendToList)
            {
                var c = new Chat();
                c.FromUserID = admin.UserID;
                c.ToUserID = tu;
                if (index == 0) time = service.GetChatTime();
                c.Time = time;
                c.Message = msg.ToString();
                if (index == 0) t.InsertChatMessage(c);
                t.InsertChatUserMessage(c);
                index++;
            }

            chatInputTextBox.Clear();

        }
Ejemplo n.º 5
0
 void t_NewMessage(object sender, Chat.NewMessageEventArgs e)
 {
     if (_SelectedUser.ID != e.FromUserID)
     {
         var msg = AlsiUtils.Utilities.WrapWords(e.Message, 30);
         balloonNotify(App.NewMessage, e.FromUser + " :", msg, newMsgNotify);
     }
 }
Ejemplo n.º 6
0
        private void LoadChat()
        {
            t = new Chat();
            t.NewMessage += new Chat.OnNewMessage(t_NewMessage);
            Utilities.SetWindowTheme(userListView.Handle, "Explorer", null);
            Utilities.SetWindowTheme(chatHistoryListView.Handle, "Explorer", null);
            chatSendButton.BackgroundImage = Properties.Resources.Messages_DisAbled_icon;
            chatSendButton.Enabled = false;
            userUpdateBW.DoWork += new DoWorkEventHandler(userUpdateBW_DoWork);
            ToolTip userInfoTootltip = new ToolTip();
            userInfoTootltip.SetToolTip(userListView, "Check to select users to send message to.\nHighlight a user to view chat.");
            PopulateUserListView();
            Text = Text + "  Logged in as " + admin.UserList.Where(x => x.ID == admin.UserID).First().USER_NAME;

            try
            {
                userListView.Items[0].Selected = true;
               // SendTEST();
               // Environment.Exit(0);
            }
            catch { }

        }
Ejemplo n.º 7
0
        public List<Chat> GetChatMessages(int ThisUser, int FromUser)
        {
            var msgList = new List<Chat>();
            var Sent = dc.tblMessageUsers.Where(z => z.MSG_USER_FROM == ThisUser && z.MSG_USER_TO == FromUser);
            var Inbox = dc.tblMessageUsers.Where(z => z.MSG_USER_TO == ThisUser && z.MSG_USER_FROM == FromUser);
            var All = Sent.Union(Inbox).OrderBy(z => z.tblMessage.TBL_MSG_TIME);//.Where(z => z.tblMessage.TBL_MSG_TIME >= DateTime.Now.AddDays(-1));
            if (Inbox.Count() == 0) return new List<Chat>();
            int fromid = Inbox.AsEnumerable().Last().MSG_USER_FROM;
                e = new NewMessageEventArgs();
                e.FromUser = dc.tblUsers.Where(z => z.ID == fromid).First().USER_NAME;
                e.FromUserID = dc.tblUsers.Where(z => z.ID == fromid).First().ID;
                e.Message = Inbox.ToList().Last().tblMessage.TBL_MSG_TEXT;
            
                InboxMsgCount = dc.tblMessageUsers.Where(z => z.MSG_USER_TO == ThisUser).Count();
            
            foreach (var msg in All)
            {
                bool V = false;
                if (msg.MSG_VIEWED == null) V = false;
                else
                    V = (bool)msg.MSG_VIEWED;


                var c = new Chat()
                 {
                     FromUserID = (int)msg.MSG_USER_FROM,
                     ToUserID = (int)msg.MSG_USER_TO,
                     Time = (DateTime)msg.tblMessage.TBL_MSG_TIME,
                     Message = msg.tblMessage.TBL_MSG_TEXT,
                     MessageID = (int)msg.MSG_ID,
                     Viewed = V,

                 };
                msgList.Add(c);

            }
            return msgList;
        }