Exemple #1
0
        public ActionResult Send(string ToUserName, string ContentBody, string MsgType)
        {
            MsgParams msgParams = new MsgParams();


            msgParams.touser = ToUserName;

            msgParams.msgtype = MsgType;

            MsgContent msgContent = new MsgContent();

            msgContent.content = ContentBody;

            msgParams.text = msgContent;

            string req0 = JsonConvert.SerializeObject(msgParams);

            string r1 = MsgService.Send(msgParams);

            return(Content(req0 + r1));

            //SendMsgResponse response =(SendMsgResponse)JsonConvert.DeserializeObject(MsgService.Send(msgParams),typeof(SendMsgResponse));
            //if (response.errcode == "0")
            //{
            //    return View("SendForm");
            //}else
            //{
            //    return View("SendError");
            //}
        }
Exemple #2
0
        public static string Send(MsgParams msgParams)
        {
            string url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" + AccessTokenService.GetAccessToken();

            string msg = JsonConvert.SerializeObject(msgParams);

            return(AppService.WebRequestPost(url, msg));
        }
Exemple #3
0
        public async Task <IActionResult> GetMessagesForUser(int userId, [FromQuery] MsgParams msgParams)
        {
            if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            msgParams.UserId = userId;
            var msgs = await _repo.GetMessagesForUser(msgParams);

            var messages = _mapper.Map <IEnumerable <MessageToReturnDto> >(msgs);

            Response.AddPagination(msgs.CurrentPage, msgs.PageSize, msgs.TotalCount, msgs.TotalPages);

            return(Ok(messages));
        }
Exemple #4
0
 //返回值为true, 表示消息已被处理,不要再往后传递,因此消息被截获
 //返回值为false,表示消息未被处理,需要再往后传递,因此消息未被截获
 public bool PreFilterMessage(ref Message m)
 {
     if (m.Msg == BLWin32.WM_LBUTTONDOWN) // WM_LBUTTONDOWN  0x0201
     {
         //System.Windows.Forms.MessageBox.Show("鼠标左键按下:" + MsgParams.ToPoint(ref m).ToString());
         //return true;
     }
     else if (m.Msg == BLWin32.WM_NCACTIVATE)
     {
         System.Windows.Forms.MessageBox.Show("鼠标左键按下2:" + MsgParams.ToPoint(ref m).ToString());
         return(true);
     }
     else if (m.Msg == BLWin32.WM_ACTIVATE)
     {
         System.Windows.Forms.MessageBox.Show("鼠标左键按下3:" + MsgParams.ToPoint(ref m).ToString());
         return(true);
     }
     return(false);
 }
        public async Task <PagedList <Message> > GetMessagesForUser(MsgParams msgParams)
        {
            var msg = _context.Messages
                      .Include(u => u.Sender).ThenInclude(u => u.Photos)
                      .Include(u => u.Recipient).ThenInclude(u => u.Photos).AsQueryable();

            switch (msgParams.MessageContainer)
            {
            case "Inbox":
                msg = msg.Where(m => m.RecipientId == msgParams.UserId && !m.recipientDelete);
                break;

            case "Outbox":
                msg = msg.Where(m => m.SenderId == msgParams.UserId && !m.senderDelete);
                break;

            default:
                msg = msg.Where(m => m.RecipientId == msgParams.UserId && !m.isRead && !m.recipientDelete);
                break;
            }
            msg = msg.OrderByDescending(d => d.DateSent);

            return(await PagedList <Message> .CreateAsync(msg, msgParams.PageNumber, msgParams.PageSize));
        }