public CMessage(CChat _chat, IWebElement cluster)
        {
            this.chat   = _chat;
            this.result = new List <Message_t>();

            this.ProcessMessageCluster(cluster);
        }
Exemple #2
0
        public CBaseReply(CChat _chat, List <Message_t> msgs)
        {
            this.chat     = _chat;
            this.messages = msgs;

            this.state = new Dictionary <string, object>();
        }
 public void MessageReceived(CChatController cChatController, CChat chat, List <IWebElement> messages)
 {
     // messages are a bunch of message 'clusters'. We must now create actual message objects out of these, then respond.
     for (int i = 0; i < messages.Count; i++)
     {
         ProcessMessageCluster(chat, messages[i]);
     }
 }
Exemple #4
0
        public void Enviar(CChat objChat)
        {
            bool BolRegistro = false;

            if (ExisteConexion())
            {
                BolRegistro = miChat.EnviarMensaje(2, objChat);
            }
        }
        private void ProcessMessageCluster(CChat _chat, IWebElement cluster)
        {
            // Here we want to turn a 'cluster' into a series of actual messages.
            // CMessage will expose  a list of structures for each message within the cluster.
            CMessage message = new CMessage(_chat, cluster);

            // According to the reply mode, we can now process all these messages.
            reply.TargetChat(_chat, message.Messages);
            reply.PerformReply();

            // Event finishes here, execution continues in CChat.
        }
Exemple #6
0
        public void ListarConversacion(int opcion, CChat objChat)
        {
            bool    ExistenDatos = false;
            DataSet dtsDatos     = new DataSet();

            if (ExisteConexion())
            {
                ExistenDatos = miChat.listarConversacion(opcion, ref dtsDatos, objChat);
                if (ExistenDatos == true)
                {
                    interfaceChat.DatosChat = dtsDatos;
                }
            }
        }
Exemple #7
0
        public ActionResult Insert()
        {
            int     i      = Convert.ToInt32(HttpContext.Request.Form["fMemberTo"]);
            string  m      = HttpContext.Request.Form["fMessage"];
            CMember member = (CMember)Session[CMemberSession.Session_Login_User];//會員
            CChat   c      = new CChat();

            c.fSubmitDateTime = DateTime.UtcNow.AddHours(08);
            c.fMessage        = m;
            c.fIsRead         = false;
            c.fIsRetract      = false;
            c.fMemberFrom     = member.fMemberId;
            c.fMemberTo       = i;
            c.fProductId      = 0;
            CChatFactory.fn聊聊新增(c);
            GlobalHost.ConnectionManager.GetHubContext <ChatHub>().Clients.Group(i.ToString()).newMessage(member.fMemberId, m, DateTime.UtcNow.AddHours(08), 0);
            return(new ApiResult());
        }
        private void GenerateAndProcessStructure(CChat _chat, IWebElement msg)
        {
            // data-store now contains some JSON with cool info like timestamp
            // C# doesn't really have much support for JSON, but fortunately we're just looking for a single number.
            string dataStore = msg.GetAttribute("data-store");

            if (dataStore == null)
            {
                return;
            }

            Regex exp  = new Regex("\"timestamp\":(\\d+)");
            Match time = Regex.Match(dataStore, "\"timestamp\":(\\d+)");

            long timeReceived = 0;

            if (time.Success)
            {
                timeReceived = long.Parse(time.Groups[1].Value);
            }
            else
            {
                timeReceived = 0;
            }

            IWebElement msgElement = msg.FindElement(By.TagName("span"));
            string      msgString  = msgElement.Text;

            Message_t result = new Message_t();

            result.chat         = _chat;
            result.timeReceived = timeReceived;
            result.sMessage     = msgString;

            ProcessMessage(result);
        }
Exemple #9
0
 public WChat(IChat InterfaceChat)
 {
     Manager            = new ManagerBD();
     this.interfaceChat = InterfaceChat;
     miChat             = new CChat();
 }
Exemple #10
0
 void ChatListener(User user, CChat packet)
 {
     // ? will chat string need sanitization later
     // TODO: test if strings can break stuff by not being sanitized
     GlobalMessage(user.Nickname + " : " + packet.Message, ConsoleColor.White);
 }
        // GET: Chat
        public ActionResult Index(int?productid, int?sellerid, string message)
        {
            if (Session[CMemberSession.Session_Login_User] == null)
            {
                return(RedirectToAction("../Member/Login"));
            }
            CMember member = (CMember)Session[CMemberSession.Session_Login_User];

            if (productid == null || productid == 0)
            {
                var lsChatBeau = CChatFactory.fn聊聊查詢(member).Select(n => new { from = n.fMemberFrom, to = n.fMemberTo, time = n.fSubmitDateTime }).OrderByDescending(n => n.time).Distinct().ToList();
                var lsChat     = CChatFactory.fn聊聊查詢(member).Select(n => n).ToList();
                List <CChatViewModel>     lsChatVM     = new List <CChatViewModel>();
                List <CChatBeauViewModel> lsChatBeauVM = new List <CChatBeauViewModel>();

                foreach (var q in lsChatBeau)
                {
                    if (q.from == member.fMemberId)
                    {
                        var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.to).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList();
                        var e = CChatFactory.fn聊聊未讀查詢(q.from, q.to).ToList();
                        if (lsChatBeauVM.Any(n => n.BeauId == q.to) == false)
                        {
                            lsChatBeauVM.Add(new CChatBeauViewModel()
                            {
                                Beau   = w.Single().surname + w.Single().name,
                                BeauId = q.to,
                                MyID   = q.from,
                                nRead  = e.Single().fProductId
                            });
                        }
                    }
                    else
                    {
                        var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.from).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList();
                        var e = CChatFactory.fn聊聊未讀查詢(q.from, q.to).ToList();
                        if (lsChatBeauVM.Any(n => n.BeauId == q.from) == false)
                        {
                            lsChatBeauVM.Add(new CChatBeauViewModel()
                            {
                                Beau   = w.Single().surname + w.Single().name,
                                BeauId = q.from,
                                MyID   = q.to,
                                nRead  = e.Single().fProductId
                            });
                        }
                    }
                }
                return(View(lsChatBeauVM));
            }
            else
            {
                CChat c = new CChat();
                c.fSubmitDateTime = DateTime.UtcNow.AddHours(08);
                c.fMessage        = message;
                c.fIsRead         = false;
                c.fIsRetract      = false;
                c.fMemberFrom     = member.fMemberId;
                c.fMemberTo       = Convert.ToInt32(sellerid);
                c.fProductId      = Convert.ToInt32(productid);
                CChatFactory.fn聊聊新增(c);
                GlobalHost.ConnectionManager.GetHubContext <ChatHub>().Clients.Group(sellerid.ToString()).newMessage(member.fMemberId, message, DateTime.UtcNow.AddHours(08), Convert.ToInt32(productid));
                var lsChatBeau = CChatFactory.fn聊聊查詢(member).Select(n => new { from = n.fMemberFrom, to = n.fMemberTo, time = n.fSubmitDateTime }).OrderByDescending(n => n.time).Distinct().ToList();
                var lsChat     = CChatFactory.fn聊聊查詢(member).Select(n => n).ToList();
                List <CChatViewModel>     lsChatVM     = new List <CChatViewModel>();
                List <CChatBeauViewModel> lsChatBeauVM = new List <CChatBeauViewModel>();

                foreach (var q in lsChatBeau)
                {
                    if (q.from == member.fMemberId)
                    {
                        var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.to).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList();
                        if (lsChatBeauVM.Any(n => n.BeauId == q.to) == false)
                        {
                            lsChatBeauVM.Add(new CChatBeauViewModel()
                            {
                                Beau   = w.Single().surname + w.Single().name,
                                BeauId = q.to,
                                MyID   = q.from
                            });
                        }
                    }
                    else
                    {
                        var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.from).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList();
                        if (lsChatBeauVM.Any(n => n.BeauId == q.from) == false)
                        {
                            lsChatBeauVM.Add(new CChatBeauViewModel()
                            {
                                Beau   = w.Single().surname + w.Single().name,
                                BeauId = q.from,
                                MyID   = q.to
                            });
                        }
                    }
                }
                return(View(lsChatBeauVM));
            }


            //foreach (var q in lsChat)
            //{
            //    var p = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.fMemberFrom ).Select(n => new { surname = n.fFirstName,name = n.fLastName}).ToList();
            //    var o = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.fMemberTo).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList();
            //    if(q.fMemberFrom == member.fMemberId)
            //    {
            //        var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.fMemberTo).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList();
            //        lsChatVM.Add(new CChatViewModel()
            //        {
            //            beau = w.Single().surname+w.Single().name,
            //            beauId = q.fMemberTo,
            //            fromchatname = p.Single().surname + p.Single().name,
            //            tochatname = o.Single().surname + o.Single().name,
            //            fChatId = q.fChatId,
            //            fSubmitDateTime = q.fSubmitDateTime,
            //            fMessage = q.fMessage,
            //            fIsRead = q.fIsRead,
            //            fIsRetract = q.fIsRetract,
            //            fMemberFrom = q.fMemberFrom,
            //            fMemberTo = q.fMemberTo,
            //            fProductId = q.fProductId
            //        });
            //    }
            //    else
            //    {
            //        var w = CMemberFactory.fn會員查詢().Where(t => t.fMemberId == q.fMemberFrom).Select(n => new { surname = n.fFirstName, name = n.fLastName }).ToList();
            //        lsChatVM.Add(new CChatViewModel()
            //        {
            //            beau = w.Single().surname + w.Single().name,
            //            beauId = q.fMemberFrom,
            //            fromchatname = p.Single().surname + p.Single().name,
            //            tochatname = o.Single().surname + o.Single().name,
            //            fChatId = q.fChatId,
            //            fSubmitDateTime = q.fSubmitDateTime,
            //            fMessage = q.fMessage,
            //            fIsRead = q.fIsRead,
            //            fIsRetract = q.fIsRetract,
            //            fMemberFrom = q.fMemberFrom,
            //            fMemberTo = q.fMemberTo,
            //            fProductId = q.fProductId
            //        });
            //    }

            //}
        }
Exemple #12
0
 public void TargetChat(CChat _chat, List <Message_t> msgs)
 {
     this.chat     = _chat;
     this.messages = msgs;
 }