Example #1
0
        public async Task <PaginatedList <Message> > GetMessagesForUser(MessageListRequest request)
        {
            var messages = _context.Messages
                           .Include(u => u.Sender).ThenInclude(s => s.Photos)
                           .Include(u => u.Recipient).ThenInclude(r => r.Photos)
                           .AsQueryable();


            switch (request.MessageContainer)
            {
            case MessageContainer.Inbox:
                messages = messages.Where(m => m.RecipientId == request.UserId && !m.RecipientDeleted);
                break;

            case MessageContainer.Outbox:
                messages = messages.Where(m => m.SenderId == request.UserId && !m.SenderDeleted);
                break;

            default:
                messages = messages.Where(m => m.RecipientId == request.UserId && !m.IsRead && !m.RecipientDeleted);
                break;
            }

            messages = messages.OrderByDescending(m => m.MessageSent);
            return(await PaginatedList <Message> .CreateAsync(messages, request.Page, request.PerPage));
        }
Example #2
0
        public ActionResult GetMessages()
        {
            var twilio = new TwilioRestClient(AccountSid, AuthToken);
            // Build the parameters
            var options = new MessageListRequest();
            var ListMessagesResponse = twilio.ListMessages(options);

            return(View(ListMessagesResponse));
        }
Example #3
0
        public HttpResponseMessage MessageList([FromUri] MessageListRequest request)
        {
            _logAppInfo.Info(string.Format("消息列表获取接口请求串:{0}", Request.RequestUri));
            MessageListViewModel viewModel = new MessageListViewModel();
            var response = _messageService.MessageListNew(request, Request.GetQueryNameValuePairs());

            viewModel.BusinessStatus = response.ErrCode;
            viewModel.StatusMessage  = response.ErrMsg;
            viewModel.MsgList        = response.MsgList;
            viewModel.TotalCount     = response.TotalCount;
            return(viewModel.ResponseToJson());
        }
 private void Awake()
 {
     buttons = GetComponentsInChildren <ChatRoomButton>();
     for (int i = 0; i < buttons.Length; i++)
     {
         buttons[i].InitPanel(this);
     }
     logoutRequest               = GetComponent <LogoutRequest>();
     userListRequest             = GetComponent <OnlineUserListRequest>();
     messageListRequest          = GetComponent <MessageListRequest>();
     messageTextPrefab           = Resources.Load <GameObject>("UI/ChatRoomPanel/MessageText");
     messageBarContent.sizeDelta = Vector2.zero;
 }
Example #5
0
        public async Task <HttpResponseMessage> MessageList([FromUri] MessageListRequest request)
        {
            var t   = 1;
            var ctx = GlobalHost.ConnectionManager.GetHubContext <DrawingBoard>();
            var s   = await ctx.Clients.User("102").sendmessage("哈哈,我进来了");

            //var s = await ctx.Clients.All.sendmessage("哈哈,我进来了");
            //_logInfo.Info(string.Format("消息列表获取接口请求串:{0}", Request.RequestUri));
            //MessageListViewModel viewModel = new MessageListViewModel();
            //var response = _messageService.MessageList(request, Request.GetQueryNameValuePairs());
            //viewModel.MsgList = response.MsgList;
            //viewModel.TotalCount = response.TotalCount;
            //return viewModel.ResponseToJson();
            return(((new BaseViewModel()).BusinessStatus = 1).ResponseToJson());
        }
Example #6
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken  = "your_auth_token";
        var    twilio     = new TwilioRestClient(AccountSid, AuthToken);

        var request = new MessageListRequest();

        var messages = twilio.ListMessages(request);

        foreach (var message in messages.Messages)
        {
            Console.WriteLine(message.Body);
        }
    }
Example #7
0
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "AC5ef8732a3c49700934481addd5ce1659";
        string AuthToken  = "{{ auth_token }}";
        var    twilio     = new TwilioRestClient(AccountSid, AuthToken);

        var request = new MessageListRequest();

        // 10 days ago.
        request.DateSent = (DateTime.UtcNow - TimeSpan.FromDays(10));
        var messages = twilio.ListMessages(request);

        foreach (var message in messages.Messages)
        {
            Console.WriteLine(message.Body);
        }
    }
    static void Main(string [] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "";
        string AuthToken  = "";
        var    twilio     = new TwilioRestClient(AccountSid, AuthToken);

        var request = new MessageListRequest();

        var messages = twilio.ListMessages(request);

        while (messages.NextPageUri != null)
        {
            foreach (var message in messages.Messages)
            {
                Console.WriteLine(message.Body);
            }
            messages = twilio.GetNextPage <MessageResult> (messages);
        }
    }
        public async Task <BaseResponse <IEnumerable <MessageResponse> > > List(MessageListRequest model)
        {
            long            userId          = _principalService.GetUserId();
            ApplicationUser applicationUser = await _userManager.FindByIdAsync(userId.ToString());

            var userRoles = await _userManager.GetRolesAsync(applicationUser);

            IEnumerable <MessageResponse> employeeList = await _db.Messages
                                                         .Where(x => x.SentToText == userRoles.FirstOrDefault() || x.SentTo == MessageTarget.AllEmployees)
                                                         .OrderByDescending(x => x.CreatedAt)
                                                         .Skip((model.PageNumber - 1) * model.PageSize).Take(model.PageSize)
                                                         .Include(x => x.CreatedBy)
                                                         .Select(x => new MessageResponse
            {
                CreatedAt   = x.CreatedAt,
                CreatedBy   = x.CreatedBy.FullName,
                MessageText = x.MessageText
            })
                                                         .ToListAsync();

            int totalCount = _db.Messages.Where(x => x.SentToText == userRoles.FirstOrDefault() || x.SentTo == MessageTarget.AllEmployees).Count();

            if (employeeList != null)
            {
                return(new BaseResponse <IEnumerable <MessageResponse> >
                {
                    Code = RsponseCode.Success,
                    Message = "",
                    Data = employeeList,
                    TotalCount = totalCount
                });
            }


            return(new BaseResponse <IEnumerable <MessageResponse> >
            {
                Code = RsponseCode.NotFound,
                Message = "لا يوجد بيانات ",
                Data = null
            });
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string AuthToken  = "your_auth_token";
        var    twilio     = new TwilioRestClient(AccountSid, AuthToken);

        var request = new MessageListRequest
        {
            To                 = "+15558675309",
            From               = "+15017250604",
            DateSent           = new DateTime(2016, 8, 31),
            DateSentComparison = ComparisonType.GreaterThanOrEqualTo
        };

        var messages = twilio.ListMessages(request);

        foreach (var message in messages.Messages)
        {
            Console.WriteLine(message.Body);
        }
    }
Example #11
0
        public List <string> GetAllMessagesList()
        {
            var accountSid = ConfigurationManager.AppSettings["SMSAccountIdentification"];

            var authToken = ConfigurationManager.AppSettings["SMSAccountPassword"];

            var twilio = new TwilioRestClient(accountSid, authToken);

            var request = new MessageListRequest();

            var messages = twilio.ListMessages(request);

            var mList = new List <string>();

            foreach (var message in messages.Messages)
            {
                //Console.Write(message.Body);
                mList.Add(message.Body);
            }

            return(mList);
        }
        public MessageListResponse MessageListNew(MessageListRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var response = new MessageListResponse();

            //bhToken校验
            if (!AppTokenValidateReqest(request.BhToken, request.ChildAgent))
            {
                response.ErrCode = -300;
                response.ErrMsg  = "登录信息已过期,请重新登录";
                return(response);
            }
            IBxAgent agentModel = GetAgentModelFactory(request.Agent);

            //参数校验
            if (!agentModel.AgentCanUse())
            {
                response.ErrCode = -10001;
                response.ErrMsg  = "参数校验错误,请检查您的校验码";
                return(response);
            }
            if (!AppValidateReqest(pairs, request.SecCode))
            {
                response.ErrCode = -10001;
                response.ErrMsg  = "参数校验错误,请检查您的校验码";
                return(response);
            }
            var msgList = new List <BxMessage>();
            int total   = 0;//消息表的记录数

            msgList          = _messageRepository.FindNoReadAllList(request.ChildAgent, out total).ConvertToViewModel();
            response.MsgList =
                msgList.OrderByDescending(o => o.CreateTime)
                .Take(request.PageSize * request.CurPage)
                .Skip(request.PageSize * (request.CurPage - 1))
                .ToList();
            response.TotalCount = total;
            return(response);
        }
Example #13
0
        public void Execute(IUBotStudio ubotStudio, Dictionary <string, string> parameters)
        {
            string twiliosid   = parameters["Twilio SID"];
            string twiliotoken = parameters["Twilio Token"];

            var accountSid = twiliosid;
            var authToken  = twiliotoken;

            var twilio = new TwilioRestClient(accountSid, twiliotoken);

            var request = new MessageListRequest();

            var messages = twilio.ListMessages(request);

            foreach (var message in messages.Messages)
            {
                Console.WriteLine(message.Body);
            }

            var consoleData = Console.Read();

            _returnValue = consoleData.ToString();
        }
    static void Main(string[] args)
    {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "AC5ef8732a3c49700934481addd5ce1659";
        string AuthToken  = "{{ auth_token }}";
        var    twilio     = new TwilioRestClient(AccountSid, AuthToken);

        var request = new MessageListRequest();

        // 10 days ago.
        request.DateSent = (DateTime.UtcNow - TimeSpan.FromDays(10));

        // this will do the comparison for greater than or equal to
        request.DateSentComparison = ComparisonType.GreaterThanOrEqualTo;
        // use following if want to do less than or equal to
        //request.DateSentComparison = ComparisonType.LessThanOrEqualTo;

        var messages = twilio.ListMessages(request);

        foreach (var message in messages.Messages)
        {
            Console.WriteLine(message.Body);
        }
    }
        public List <_TwilioMSGViewModel> GetAllMessages()
        {
            // Twilio request of list of messages
            TwilioRestClient   client  = new TwilioRestClient(AuthTwilio.ACCOUNT_SID, AuthTwilio.AUTH_TOKEN);
            MessageListRequest request = new MessageListRequest();
            DateTime           today   = DateTime.Now;

            request.DateSent = today;
            var messages = client.ListMessages(request);
            List <_TwilioMSGViewModel> msg;

            msg = messages.Messages.Select(s => new _TwilioMSGViewModel()
            {
                Body     = s.Body,
                From     = s.From,
                To       = s.To,
                Sid      = s.Sid,
                DateSent = s.DateSent
            }).ToList();

            // Takes Msg looks into Active Campaigns for Keyword, assigns SurveyClient to Campaign
            List <string> TwilioSid = msg.Select(t => t.Sid).ToList();
            List <_TwilioMSGViewModel> newMessages;
            List <_TwilioMSGViewModel> newSurveyClient;

            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                List <TwilioMSG> previousMessages = db.TwilioMSGs.Where(m => TwilioSid.Contains(m.TwiilioMSGSid)).ToList();
                newMessages = msg.Where(m => !previousMessages.Any(m2 => m2.TwiilioMSGSid == m.Sid)).ToList();
                if (newMessages.Count != 0)
                {
                    using (ApplicationDbContext context = new ApplicationDbContext())
                    {
                        foreach (_TwilioMSGViewModel element in newMessages)
                        {
                            TwilioMSG dbModel = context.TwilioMSGs.Create();
                            dbModel.TwilioMSGBody = element.Body;
                            dbModel.TwilioMSGFrom = element.From;
                            dbModel.TwilioMSGTo   = element.To;
                            dbModel.TwiilioMSGSid = element.Sid;
                            dbModel.TwilioMSGDate = element.DateSent;
                            context.TwilioMSGs.Add(dbModel);
                        }
                        context.SaveChanges();
                    }
                    List <Campaign>            activeCampaings = db.Campaigns.Where(c => c.CampaignActive == true).ToList();
                    List <string>              activeKeywords  = activeCampaings.Select(k => k.CampaignKeyword).ToList();
                    List <_TwilioMSGViewModel> MsgWithKeywords = newMessages.Where(c => activeKeywords.Contains(c.Body)).ToList();
                    if (MsgWithKeywords.Count != 0)
                    {
                        List <string>       activePhoneNumbers    = db.SurveyClients.Select(p => p.SurveyClientPhone).ToList();
                        List <SurveyClient> previousSurveyClients = db.SurveyClients.Where(s => activePhoneNumbers.Contains(s.SurveyClientPhone)).ToList();
                        newSurveyClient = MsgWithKeywords.Where(q => !previousSurveyClients.Any(q2 => q2.SurveyClientPhone == q.From)).ToList();
                        if (newSurveyClient.Count != 0)
                        {
                            foreach (_TwilioMSGViewModel SClient in newSurveyClient)
                            {
                                using (ApplicationDbContext context = new ApplicationDbContext())
                                {
                                    SurveyClient dbClient = context.SurveyClients.Create();
                                    dbClient.SurveyClientPhone = SClient.From;
                                    context.SurveyClients.Add(dbClient);
                                    context.SaveChanges();
                                }
                                using (ApplicationDbContext context = new ApplicationDbContext())
                                {
                                    SurveyClientControl SCdb = context.SurveyClientControls.Create();
                                    SCdb.SurveyClientId        = context.SurveyClients.Where(x => x.SurveyClientPhone == SClient.From).FirstOrDefault().SurveyClientId;
                                    SCdb.SurveyClientControlId = context.SurveyClients.Where(x => x.SurveyClientPhone == SClient.From).FirstOrDefault().SurveyClientId;
                                    SCdb.SurveyClientPhone     = SClient.From;
                                    SCdb.CampaignId            = context.Campaigns.Where(y => y.CampaignKeyword == SClient.Body).FirstOrDefault().CampaignId;
                                    SCdb.Questions             = context.Questions.Where(q => q.CampaignId == SCdb.CampaignId).ToList();
                                    context.SurveyClientControls.Add(SCdb);
                                    context.SaveChanges();
                                }
                                using (ApplicationDbContext questionDb = new ApplicationDbContext())
                                {
                                    SurveyClientControl dbQuestions = questionDb.SurveyClientControls.Include(s => s.Questions).Where(q => q.SurveyClientPhone == SClient.From).FirstOrDefault();
                                    if (dbQuestions.Questions.Count != 0)
                                    {
                                        foreach (var element in dbQuestions.Questions)
                                        {
                                            using (ApplicationDbContext progressDb = new ApplicationDbContext())
                                            {
                                                Progress dbProgress = progressDb.ProgressSwitches.Create();
                                                dbProgress.ProgressSwitch        = false;
                                                dbProgress.QuestionId            = element.QuestionId;
                                                dbProgress.SurveyClientControlId = dbQuestions.SurveyClientControlId;
                                                progressDb.ProgressSwitches.Add(dbProgress);
                                                progressDb.SaveChanges();
                                            }

                                            using (ApplicationDbContext currentQuestionDb = new ApplicationDbContext())
                                            {
                                                CurrentQuestion dbCQuestion = currentQuestionDb.CurrentQuestionSwitches.Create();
                                                dbCQuestion.CurrentQuestionSwitch = false;
                                                dbCQuestion.QuestionId            = element.QuestionId;
                                                dbCQuestion.SurveyClientControlId = dbQuestions.SurveyClientControlId;
                                                currentQuestionDb.CurrentQuestionSwitches.Add(dbCQuestion);
                                                currentQuestionDb.SaveChanges();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // If Msg does not includes a Keyword, is considered as san Answer and it comes here
                    else
                    {
                        using (ApplicationDbContext questionsCompare = new ApplicationDbContext())
                        {
                            List <SurveyClientControl> SurveyClients = questionsCompare.SurveyClientControls.ToList();
                            List <string> Questions             = questionsCompare.Questions.Select(q => q.QuestionBody).ToList();
                            List <_TwilioMSGViewModel> leftMsgs = newMessages.Where(m => !Questions.Contains(m.Body)).ToList();
                            if (leftMsgs.Count != 0)
                            {
                                foreach (var MsgElement in leftMsgs)
                                {
                                    if (MsgElement.From != "+18324101832")
                                    {
                                        using (ApplicationDbContext LogResponse = new ApplicationDbContext())
                                        {
                                            List <int> Progress_QuestionId      = LogResponse.ProgressSwitches.Where(d => d.ProgressSwitch == true).Select(c => c.QuestionId).ToList();
                                            int        Last_Progress_QuestionId = Progress_QuestionId.LastOrDefault();
                                            Response   AddResponse = LogResponse.Responses.Create();
                                            AddResponse.ResponseBody          = MsgElement.Body;
                                            AddResponse.QuestionId            = Last_Progress_QuestionId;
                                            AddResponse.SurveyClientControlId = SurveyClients.Where(b => b.SurveyClientPhone == MsgElement.From).FirstOrDefault().SurveyClientControlId;
                                            LogResponse.Responses.Add(AddResponse);
                                            LogResponse.SaveChanges();
                                            break;
                                        }
                                    }
                                }
                                using (ApplicationDbContext StatusChangeCurrentQuestion = new ApplicationDbContext())
                                {
                                    foreach (var ClientElement in leftMsgs)
                                    {
                                        List <int> Progress_QuestionId      = StatusChangeCurrentQuestion.ProgressSwitches.Where(d => d.ProgressSwitch == true).Select(c => c.QuestionId).ToList();
                                        List <int> Current_Switches_False   = StatusChangeCurrentQuestion.CurrentQuestionSwitches.Where(c => c.CurrentQuestionSwitch == false).Select(d => d.QuestionId).ToList();
                                        int        Last_Progress_QuestionId = Progress_QuestionId.LastOrDefault();
                                        if (Progress_QuestionId.Count != 0 && Current_Switches_False.Count != 0 && ClientElement.From != "+18324101832")
                                        {
                                            SurveyClientControl CurrentClient = SurveyClients.Where(q => q.SurveyClientPhone == ClientElement.From).FirstOrDefault();
                                            CurrentQuestion     CurrentStatus = StatusChangeCurrentQuestion.CurrentQuestionSwitches.Where(c => c.QuestionId == Last_Progress_QuestionId && c.SurveyClientControlId == CurrentClient.SurveyClientControlId).FirstOrDefault();
                                            CurrentStatus.CurrentQuestionSwitch = true;
                                            StatusChangeCurrentQuestion.SaveChanges();
                                            break;
                                        }
                                        if (Progress_QuestionId.Count != 0 && Current_Switches_False.Count != 0 && ClientElement.From == "+18324101832")
                                        {
                                            SurveyClientControl CurrentClient = SurveyClients.Where(q => q.SurveyClientPhone == ClientElement.To).FirstOrDefault();
                                            CurrentQuestion     CurrentStatus = StatusChangeCurrentQuestion.CurrentQuestionSwitches.Where(c => c.QuestionId == Last_Progress_QuestionId && c.SurveyClientControlId == CurrentClient.SurveyClientControlId).FirstOrDefault();
                                            CurrentStatus.CurrentQuestionSwitch = true;
                                            StatusChangeCurrentQuestion.SaveChanges();
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                // If Not new message, system will send questions to Survey Clients
                else
                {
                    List <SurveyClientControl> SurveyClientsReady;
                    using (ApplicationDbContext serviceReady = new ApplicationDbContext())
                    {
                        SurveyClientsReady = serviceReady.SurveyClientControls.Include(s => s.Questions).Include(s => s.ProgressSwitches).Include(s => s.CurrentQuestionSwitches).Where(q => q.BlackList == false).ToList();
                        foreach (var ClientElement in SurveyClientsReady)
                        {
                            List <int> ProgressIds        = ClientElement.ProgressSwitches.Where(o => o.ProgressSwitch == false).Select(p => p.QuestionId).ToList();
                            List <int> ProgressTrue       = ClientElement.ProgressSwitches.Where(p => p.ProgressSwitch == true).Select(z => z.QuestionId).ToList();
                            List <int> CurrentQuestionIds = ClientElement.CurrentQuestionSwitches.Where(q => q.CurrentQuestionSwitch == true).Select(r => r.CurrentQuestionId).ToList();
                            if (ProgressIds.Count != 0 && CurrentQuestionIds.Count != 0 && ProgressTrue.Count == CurrentQuestionIds.Count)
                            {
                                Question         Question_Filter_Progress = ClientElement.Questions.Where(q => ProgressIds.Contains(q.QuestionId)).FirstOrDefault();
                                TwilioRestClient clientSendMsg            = new TwilioRestClient(AuthTwilio.ACCOUNT_SID, AuthTwilio.AUTH_TOKEN);
                                clientSendMsg.SendSmsMessage("832-410-1832", ClientElement.SurveyClientPhone, Question_Filter_Progress.QuestionBody);
                                using (ApplicationDbContext changeProgress = new ApplicationDbContext())
                                {
                                    Progress ProgressChangeStatus = changeProgress.ProgressSwitches.Where(i => i.QuestionId == Question_Filter_Progress.QuestionId).FirstOrDefault();
                                    ProgressChangeStatus.ProgressSwitch = true;
                                    changeProgress.SaveChanges();
                                }
                            }
                            else
                            {
                                if (ProgressTrue.Count == 0 && CurrentQuestionIds.Count == 0)
                                {
                                    Question         Question_Filter_Progress = ClientElement.Questions.Where(q => ProgressIds.Contains(q.QuestionId)).FirstOrDefault();
                                    TwilioRestClient clientSendMsg            = new TwilioRestClient(AuthTwilio.ACCOUNT_SID, AuthTwilio.AUTH_TOKEN);
                                    clientSendMsg.SendSmsMessage("832-410-1832", ClientElement.SurveyClientPhone, Question_Filter_Progress.QuestionBody);
                                    using (ApplicationDbContext changeProgress = new ApplicationDbContext())
                                    {
                                        Progress ProgressChangeStatus = changeProgress.ProgressSwitches.Where(i => i.QuestionId == Question_Filter_Progress.QuestionId).FirstOrDefault();
                                        ProgressChangeStatus.ProgressSwitch = true;
                                        changeProgress.SaveChanges();
                                    }
                                }
                            }
                            if (ProgressIds.Count == 0 && ClientElement.BlackList == false)
                            {
                                Campaign Coupon;
                                using (ApplicationDbContext lastMsg = new ApplicationDbContext())
                                {
                                    Coupon = lastMsg.Campaigns.Where(q => q.CampaignId == ClientElement.CampaignId).FirstOrDefault();
                                }
                                TwilioRestClient clientSendMsg = new TwilioRestClient(AuthTwilio.ACCOUNT_SID, AuthTwilio.AUTH_TOKEN);
                                clientSendMsg.SendMessage("832-410-1832", ClientElement.SurveyClientPhone, "Thank you for Participating", new string[] { Coupon.CampaignGift });
                                ClientElement.BlackList = true;
                                serviceReady.SaveChanges();
                            }
                        }
                    }
                }
            }
            return(msg);
        }
        public ActionResult <RequestResult> MessageList([FromServices] ITokens tokens, [FromServices] IConfiguration config,
                                                        [FromServices] MessageData data, [FromBody] MessageListRequest messages)
        {
            var result = new RequestResult();

            Console.WriteLine($"Messages for Conversation {messages.ConversationID} have been loaded");
            foreach (var message in messages.Messages)
            {
                message.sentSuccessfully = true;
            }
            // Update state
            data.ConversationToMessages[messages.ConversationID] = messages.Messages;
            data.ConversationToMessages[messages.ConversationID].Sort();

            // Notify the client that the data has been updated and is ready to retrieve
            var dict = new Dictionary <string, object>()
            {
                { "Token", tokens.ClientToken },
                { "ConversationID", messages.ConversationID.ToString() }
            };

            var response = Utilities.FirebaseUtilities.Notify(config, tokens.ClientToken, "MessageList", dict);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                result.ResultMessage = "Successfully notified client of message list availability";
                result.Status        = ResultStatus.Success;
                return(Ok(result));
            }
            else
            {
                result.ErrorMessage = response.ErrorMessage;
                result.Status       = ResultStatus.Failure;
                return(BadRequest(result));
            }
        }
Example #17
0
 private void OnMessageList(NetConnection <NetSession> sender, MessageListRequest message)
 {
     sender.Session.Character.messageManager.SetDirty();
     sender.Session.Response.Update = new StatusUpdate();
     sender.SendResponse();
 }
        public MessageListResponse MessageList(MessageListRequest request, IEnumerable <KeyValuePair <string, string> > pairs)
        {
            var response = new MessageListResponse();

            //bhToken校验
            if (!AppTokenValidateReqest(request.BhToken, request.ChildAgent))
            {
                response.ErrCode = -300;
                response.ErrMsg  = "登录信息已过期,请重新登录";
                return(response);
            }
            IBxAgent agentModel = GetAgentModelFactory(request.Agent);

            //参数校验
            if (!agentModel.AgentCanUse())
            {
                response.ErrCode = -10001;
                response.ErrMsg  = "参数校验错误,请检查您的校验码";
                return(response);
            }
            if (!AppValidateReqest(pairs, request.SecCode))
            {
                response.ErrCode = -10001;
                response.ErrMsg  = "参数校验错误,请检查您的校验码";
                return(response);
            }

            var         msgList = new List <BxMessage>();
            BxMessage   bmsg;
            bx_agent    bxAgent;
            bx_userinfo bxUserinfo;
            int         totalmsg = 0; //消息表的记录数
            int         totalxb  = 0; //续保表的记录数
            int         totalrw  = 0; //回访通知表的记录数

            //从bx_message里取数据
            List <bx_message> listMsg = _messageRepository.FindNoReadList(request.ChildAgent, out totalmsg);
            //从bx_noticexb里取数据
            List <bx_notice_xb> listXb = _noticexbRepository.FindNoReadList(request.ChildAgent, out totalxb);
            //从bx_consumer_review里取数据
            List <bx_consumer_review> listRw = _consumerReviewRepository.FindNoReadList(request.ChildAgent, out totalrw);

            #region bx_message表数据
            if (listMsg.Any())
            {
                foreach (var itemMsg in listMsg)
                {
                    bmsg = new BxMessage
                    {
                        StrId     = "Msg_" + itemMsg.Id,
                        Id        = itemMsg.Id,
                        MsgLevel  = itemMsg.Msg_Level.HasValue ? itemMsg.Msg_Level.Value : 0,
                        MsgStatus = itemMsg.Msg_Status.HasValue ? itemMsg.Msg_Status.Value : 0,
                        MsgType   = itemMsg.Msg_Type,
                        SendTime  =
                            itemMsg.Send_Time.HasValue ? itemMsg.Send_Time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                        Title      = itemMsg.Title,
                        Body       = itemMsg.Body,
                        UpdateTime =
                            itemMsg.Update_Time.HasValue
                                ? itemMsg.Update_Time.Value.ToString("yyyy-MM-dd HH:mm:ss")
                                : "",
                        Url     = itemMsg.Url,
                        AgentId = itemMsg.Agent_Id.HasValue ? itemMsg.Agent_Id.Value : 0
                    };
                    //Agent
                    bxAgent        = _agentRepository.GetAgent(bmsg.AgentId);
                    bmsg.AgentName = bxAgent != null ? bxAgent.AgentName : "";
                    //CreateAgent
                    bmsg.CreateAgentId   = itemMsg.Create_Agent_Id;
                    bxAgent              = _agentRepository.GetAgent(bmsg.CreateAgentId);
                    bmsg.CreateAgentName = bxAgent != null ? bxAgent.AgentName : "";

                    bmsg.CreateTime = itemMsg.Create_Time.HasValue ? itemMsg.Create_Time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";

                    if (itemMsg.Buid.HasValue)
                    {
                        bmsg.Buid       = itemMsg.Buid.Value;
                        bmsg.LicenseNo  = itemMsg.License_No;
                        bxUserinfo      = new bx_userinfo();
                        bxUserinfo      = _userInfoRepository.FindByBuid(itemMsg.Buid.Value);
                        bmsg.OwnerAgent = bxUserinfo != null?int.Parse(bxUserinfo.Agent) : 0;
                    }
                    msgList.Add(bmsg);
                }
            }
            #endregion
            #region bx_noticexb表数据
            if (listXb.Any())
            {
                foreach (var itemXb in listXb)
                {
                    bmsg = new BxMessage
                    {
                        StrId      = "Xb_" + itemXb.id,
                        Id         = itemXb.id,
                        MsgLevel   = 1,
                        MsgStatus  = itemXb.stauts,
                        MsgType    = 1,
                        SendTime   = itemXb.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
                        Title      = "到期通知",
                        Body       = string.Format("{0},车险{1}天后到期", itemXb.license_no, itemXb.day_num.Value.ToString()),
                        UpdateTime = "",
                        Url        = "",
                        AgentId    = itemXb.agent_id
                    };
                    //Agent
                    bxAgent        = _agentRepository.GetAgent(bmsg.AgentId);
                    bmsg.AgentName = bxAgent != null ? bxAgent.AgentName : "";
                    //CreateAgent
                    bmsg.CreateAgentId   = itemXb.agent_id;
                    bmsg.CreateAgentName = bxAgent != null ? bxAgent.AgentName : "";
                    bmsg.CreateTime      = itemXb.create_time.ToString("yyyy-MM-dd HH:mm:ss");

                    bmsg.LicenseNo          = itemXb.license_no;
                    bmsg.LastForceEndDate   = itemXb.last_force_end_date.HasValue ? itemXb.last_force_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
                    bmsg.LastBizEndDate     = itemXb.Last_biz_end_date.HasValue ? itemXb.Last_biz_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
                    bmsg.NextForceStartDate = itemXb.next_force_start_date.HasValue ? itemXb.next_force_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
                    bmsg.NextBizStartDate   = itemXb.next_biz_start_date.HasValue ? itemXb.next_biz_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
                    bmsg.Source             = itemXb.source;
                    bmsg.Days = itemXb.days.HasValue ? itemXb.days.Value : 0;
                    bmsg.Buid = itemXb.b_uid;

                    //根据buid获取当前的userinfo的agent,方便查看详情
                    bxUserinfo      = new bx_userinfo();
                    bxUserinfo      = _userInfoRepository.FindByBuid(itemXb.b_uid);
                    bmsg.OwnerAgent = bxUserinfo != null?int.Parse(bxUserinfo.Agent) : 0;

                    msgList.Add(bmsg);
                }
            }
            #endregion
            #region bx_consumer_review表数据
            if (listRw.Any())
            {
                foreach (var itemRw in listRw)
                {
                    bmsg = new BxMessage
                    {
                        StrId     = "Rw_" + itemRw.id,
                        Id        = itemRw.id,
                        MsgLevel  = 1,
                        MsgStatus = itemRw.read_status.Value,
                        MsgType   = 2,
                        SendTime  = itemRw.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                        Title     = "回访通知"
                    };
                    if (itemRw.b_uid.HasValue)
                    {
                        bmsg.Buid       = itemRw.b_uid.Value;
                        bxUserinfo      = new bx_userinfo();
                        bxUserinfo      = _userInfoRepository.FindByBuid(itemRw.b_uid.Value);
                        bmsg.LicenseNo  = bxUserinfo != null ? bxUserinfo.LicenseNo : "";
                        bmsg.OwnerAgent = bxUserinfo != null?int.Parse(bxUserinfo.Agent) : 0;
                    }
                    DateTime dt = itemRw.next_review_date.Value;
                    bmsg.Body       = string.Format("{0}月{1}日{2} 需回访{3}", dt.Month, dt.Day, dt.ToString("hh:mm"), bmsg.LicenseNo);
                    bmsg.UpdateTime = "";
                    bmsg.Url        = "";
                    //Agent
                    bmsg.AgentId   = itemRw.operatorId.Value;
                    bmsg.AgentName = itemRw.operatorName;
                    //CreateAgent
                    bmsg.CreateAgentId   = itemRw.operatorId.Value;
                    bmsg.CreateAgentName = itemRw.operatorName;
                    bmsg.CreateTime      = itemRw.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss");

                    bmsg.Buid = itemRw.b_uid.Value;

                    msgList.Add(bmsg);
                }
            }
            #endregion
            response.MsgList =
                msgList.OrderByDescending(o => o.CreateTime)
                .Take(request.PageSize * request.CurPage)
                .Skip(request.PageSize * (request.CurPage - 1))
                .ToList();
            response.TotalCount = totalmsg + totalxb + totalrw;
            return(response);
        }
Example #19
0
        public MessageResult GetAllMessages()
        {
            var messageList = new MessageListRequest();

            return(Client.ListMessages(messageList));
        }
Example #20
0
        public async Task <IActionResult> List([FromBody] MessageListRequest model)
        {
            var result = await _messageService.List(model);

            return(Ok(result));
        }
Example #21
0
        public async Task <PaginatedResponseEnvelope <MessageListResponse> > GetMessagesForUser(MessageListRequest request)
        {
            if (request.UserId != _userAccessor.getCurrentUserId())
            {
                throw new RestException(HttpStatusCode.Forbidden);
            }

            var messages = await _repo.GetMessagesForUser(request);

            var response = _mapper.Map <List <MessageListResponse> >(messages);

            return(new PaginatedResponseEnvelope <MessageListResponse>
            {
                Response = response,
                PaginationHeaders = _mapper.Map <PaginationHeaders>(messages)
            });
        }
Example #22
0
        public async Task <ActionResult <List <MessageListResponse> > > GetMessagesForUser(int userId, [FromQuery] MessageListRequest request)
        {
            request.UserId = userId;
            var envelope = await _serv.GetMessagesForUser(request);

            Response.AddPaginationHeaders(envelope.PaginationHeaders);
            return(envelope.Response);
        }
Example #23
0
        static void Main(string[] args)
        {
            IMAPConfig config = new IMAPConfig("imap.gmail.com", "atmospherian", "Xr3pr1s3Y", true, true, "");

            config.SaveConfig(@"c:\settings.cfg");
            //IMAPConfig config = new IMAPConfig(@"c:\test1.cfg");
            IMAPAsyncClient client = new IMAPAsyncClient(config, 5);

            client.MailboxManager.CreateNewMailbox(@"c:\test.mbx");


            client.Start();
            FolderTreeRequest ftr = new FolderTreeRequest("\"\"", null);

            client.RequestManager.SubmitAndWait(ftr, false);

            IBatchRequest batch = new SimpleBatchRequest();

            foreach (IFolder folder in client.MailboxManager.GetAllFolders())
            {
                FolderDataRequest fdr = new FolderDataRequest(folder, null);
                fdr.RequestCompleted += delegate(IRequest req)
                {
                    FolderDataProcessor fdp = req.GetProcessorAsType <FolderDataProcessor>();
                    IFolder             f   = fdp.Request.Command.ParameterObjects[0] as IFolder;
                    Console.WriteLine("Data for {0} loaded. {1} Messages found.", f.Name, f.Exists);
                };
                batch.Requests.Add(fdr);
            }

            client.RequestManager.SubmitBatchAndWait(batch, false);
            batch.Requests.Clear();
            foreach (IFolder folder in client.MailboxManager.GetAllFolders())
            {
                MessageListRequest mlr = new MessageListRequest(folder, null);
                mlr.RequestCompleted += delegate(IRequest req)
                {
                    MessageListProcessor fdp = req.GetProcessorAsType <MessageListProcessor>();
                    IFolder f = fdp.Request.Command.ParameterObjects[0] as IFolder;
                    Console.WriteLine("Message List for {0} loaded. {1} Messages found.", f.Name, f.Exists);
                };

                batch.Requests.Add(mlr);
            }

            client.RequestManager.SubmitBatchAndWait(batch, false);

            client.MailboxManager.DownloadEntireAccount(delegate(int messagesCompleted, int totalMessages, IFolder currentFolder)
            {
                Console.WriteLine();
                Console.WriteLine("Message {0} of {1} downloaded from {2}", messagesCompleted, totalMessages, currentFolder.Name);
            }, delegate(int totalFolders, int totalMessages, long totalTime)
            {
                Console.WriteLine("{0} Messages in {1} folders downloaded in {2} minutes.", totalMessages, totalFolders, new TimeSpan(totalTime).Minutes);
            });


            //config.CacheFi

            Console.WriteLine("Press any key");
            Console.ReadLine();



            client.Stop();
        }