예제 #1
0
        public string AddTextMsg(string sender, TextMsgViewModel textMsg)
        {
            int nowServing = NowServing();
            int msgCnt     = Convert.ToInt32(SessionHelper.Get("MsgCnt"));

            if (nowServing != 0)
            {
                bool stopConversation = Clients.AddTextMsg(nowServing, sender, textMsg);

                if (stopConversation)
                {
                    msgCnt -= 1;
                }
                else
                {
                    msgCnt += 1;
                }

                SessionHelper.Set("MsgCnt", msgCnt.ToString());

                DailyHub.Refresh();
                DailyHub.RefreshConversation(nowServing, msgCnt);
                return("Success");
            }

            return("Failure");
        }
예제 #2
0
        public JsonResult NowConversing(SearchParameters sps, int page, int frontdesk = 0, int?nowConversing = 0, int?rows = 15)
        {
            // Log.Debug(string.Format("Enter NowConversing: nowConversing = {0}", nowConversing));

            int agencyId = ReferringAgency();
            int msgCnt   = Convert.ToInt32(SessionHelper.Get("MsgCnt"));

            NowServing(nowConversing);

            List <ClientViewModel> clients;

            if (agencyId == 0)
            {
                if (frontdesk == 1)
                {
                    clients = Clients.GetClients(sps, Extras.DateTimeToday());
                }
                else
                {
                    clients = Clients.GetDashboardClients(sps);
                }
            }
            else
            {
                clients = Clients.GetMyClients(agencyId);
            }

            int pageIndex = page - 1;
            int pageSize  = (int)rows;

            int totalRecords = clients.Count;
            int totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            clients = clients.Skip(pageIndex * pageSize).Take(pageSize).ToList();

            //  Log.Debug(string.Format("NowConversing: page = {0}, rows = {1}, totalPages = {2}", page, rows, totalPages));

            DailyHub.RefreshConversation((int)nowConversing, msgCnt);

            var jsonData = new
            {
                total   = totalPages,
                page    = page,
                records = totalRecords,
                rows    = clients
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public string EditTextMsg(TextMsgViewModel textMsg)
        {
            int nowServing = NowServing();
            int msgCnt     = Convert.ToInt32(SessionHelper.Get("MsgCnt"));

            if (nowServing != 0)
            {
                Clients.EditTextMsg(nowServing, textMsg);
                DailyHub.Refresh();
                DailyHub.RefreshConversation(nowServing, msgCnt);
                return("Success");
            }

            return("Failure");
        }