コード例 #1
0
 public void ProcessRequest(HttpContext context)
 {
     this.context = context;
     context.Response.ContentType = "text/plain";
     if (this.context.Request.HttpMethod == "POST")
     {
         try
         {
             string json = getPostData();
             SeatManage.JsonModel.BaseSeatNotify basemsg = SeatManage.SeatManageComm.JSONSerializer.Deserialize <SeatManage.JsonModel.BaseSeatNotify>(json);
             if (basemsg.NotifyType == SeatManage.JsonModel.SeatNotifyType.Msg)
             {
                 SeatManage.JsonModel.JM_SeatNotice noticeNodel = SeatManage.SeatManageComm.JSONSerializer.Deserialize <SeatManage.JsonModel.JM_SeatNotice>(json);
                 pushMsg(noticeNodel);
             }
             else
             {
                 SeatManage.JsonModel.JM_NotifyEvent notifyEvent = SeatManage.SeatManageComm.JSONSerializer.Deserialize <SeatManage.JsonModel.JM_NotifyEvent>(json);
                 pushEvent(notifyEvent);
             }
         }
         catch (Exception ex)
         { SeatManage.SeatManageComm.WriteLog.Write("消息出错:" + ex.Message); }
         finally
         {
             context.Response.End();
         }
     }
 }
コード例 #2
0
        private void pushMsg(SeatManage.JsonModel.JM_SeatNotice notice)
        {
            AppUserInfo app_user = AMS.ServiceProxy.App_UserInfoProxy.GetAppUserInfoByCardNoAndSchoolNum(notice.CardNo, notice.SchoolNum);
            //TODO:根据学号获取channelId。
            BaiduPushNotification notification = new BaiduPushNotification();

            notification.title                    = notice.Title;
            notification.description              = notice.Context;
            notification.notification_builder_id  = 0;
            notification.notification_basic_style = 7;
            notification.custom_content           = new Custom_content();
            string msg = notification.getJsonString();

            PushOptions pOpts = new PushOptions(app_user.ChannelId, 1, msg, null, api_key, getTimestamp(), null, Device_Type.Android);

            BaiduPush.BaiduPush push = new BaiduPush.BaiduPush("POST", secret_key);
            push.PushSingleDevice(pOpts);
        }