示例#1
0
        /// <summary>
        /// 全局公告发送
        /// </summary>
        /// <param name="msgTitle">消息标题</param>
        /// <param name="msgContent">消息内容</param>
        /// <param name="operatorId">操作人员Id</param>
        /// <param name="operatorName">操作人员</param>
        /// <param name="expireTime">过期时间</param>
        /// <param name="timingTime">定时日期</param>
        /// <returns></returns>
        public static int PostMobileGlobal(string msgTitle, string msgContent, int operatorId, string operatorName, DateTime expireTime, DateTime?timingTime = null)
        {
            int code  = -1;
            var model = new MobileMsgModel();

            model.fromAccId    = 0;
            model.priority     = 1;
            model.msgType      = 1;
            model.msgClass     = 3;
            model.msgTitle     = msgTitle;
            model.msgContent   = msgContent;
            model.operatorId   = operatorId;
            model.operatorName = operatorName;
            model.timingTime   = timingTime;
            model.expireTime   = expireTime;
            model.contentType  = "text";
            model.openType     = 2;

            var oResult = PostMobileGlobal(model);

            if (oResult.Status)
            {
                code = 1;
            }

            return(code);
        }
示例#2
0
        /// <summary>
        /// 手机端消息推送
        /// </summary>
        /// <param name="accIdList">店铺Id</param>
        /// <param name="msgTitle">消息标题</param>
        /// <param name="msgContent">消息内容</param>
        /// <param name="timingTime">定时发送日期</param>
        /// <param name="operatorId">操作Id</param>
        /// <param name="operatorName">操作人员</param>
        /// <returns></returns>
        public static int PostMobileMessageByAccid(int accid, string msgTitle, string msgContent, int operatorId, string operatorName, DateTime?timingTime = null)
        {
            int code  = -1;
            var model = new MobileMsgModel();

            model.accIdList    = accid.ToString();
            model.fromAccId    = 0;
            model.priority     = 1;
            model.msgType      = 1;
            model.msgClass     = 2;
            model.msgTitle     = msgTitle;
            model.msgContent   = msgContent;
            model.operatorId   = operatorId;
            model.operatorName = operatorName;
            model.timingTime   = timingTime;
            model.contentType  = "text";
            model.openType     = 2;

            var oResult = PostMobileMessage(model);

            if (oResult.Status)
            {
                code = 1;
            }

            return(code);
        }
示例#3
0
        /// <summary>
        /// 手机端公告发送
        /// </summary>
        /// <param name="message"></param>
        public static MsgItem PostMobileGlobal(MobileMsgModel message)
        {
            var model = new MsgItem();

            var authDict = GetAuth();

            var client  = new RestClient(MsgHost);
            var request = new RestRequest("push/all", Method.POST);

            request.AddHeader("appkey", authDict["appkey"]);
            request.AddHeader("timestamp", authDict["timestamp"]);
            request.AddHeader("nonce", authDict["nonce"]);
            request.AddHeader("signature", authDict["signature"]);

            request.AddParameter("fromAccId", message.fromAccId);
            request.AddParameter("priority", message.priority);
            request.AddParameter("msgType", message.msgType);
            request.AddParameter("msgClass", message.msgClass);
            request.AddParameter("msgTitle", message.msgTitle);
            request.AddParameter("msgContent", message.msgContent);
            request.AddParameter("operatorId", message.operatorId);
            request.AddParameter("operatorName", message.operatorName);
            request.AddParameter("expireTime", message.expireTime);
            request.AddParameter("contentType", message.contentType);
            request.AddParameter("openType", message.openType);

            if (message.timingTime != null)
            {
                request.AddParameter("timingTime", message.timingTime);
            }

            IRestResponse response = client.Execute(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var content = response.Content;
                //model = JsonConvert.DeserializeObject<MsgItem>(content);
                if (content == "ok")
                {
                    model.Status = true;
                }
                else
                {
                    model.Status = false;
                }
            }
            else
            {
                model.Status = false;
            }

            return(model);
        }