Пример #1
0
        public override Ret CreateMultipush(MessageIOS message, int environment)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            if (!ValidateMessageType(message, environment))
            {
                return(new Ret(-1, "message type or environment error!"));
            }

            if (!message.IsValid())
            {
                return(new Ret(-1, "message invalid!"));
            }

            IDictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("expire_time", message.ExpireTime);
            parameters.Add("message_type", 0);
            parameters.Add("message", message.ToJsonString());
            parameters.Add("environment", environment);

            return(CallRestful(XingeConfig.RESTAPI_CREATEMULTIPUSH, parameters));
        }
Пример #2
0
        public override Ret PushAccountList(int deviceType, List <string> accountList, MessageIOS message, int environment)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            if (accountList.Count <= 0)
            {
                throw new ArgumentNullException("accountList");
            }

            if (!ValidateMessageType(message, environment))
            {
                return(new Ret(-1, "message type or environment error!"));
            }

            if (!message.IsValid())
            {
                return(new Ret(-1, "message invalid!"));
            }

            IDictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("expire_time", message.ExpireTime);
            parameters.Add("device_type", deviceType);
            parameters.Add("account_list", new JArray(accountList).ToString());
            parameters.Add("message_type", 0);
            parameters.Add("message", message.ToJsonString());
            parameters.Add("environment", environment);

            return(CallRestful(XingeConfig.RESTAPI_PUSHACCOUNTLIST, parameters));
        }
Пример #3
0
        public override Ret PushAllDevice(int deviceType, MessageIOS message, int environment)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            if (!ValidateMessageType(message, environment))
            {
                return(new Ret(-1, "message type or environment error!"));
            }

            if (!message.IsValid())
            {
                return(new Ret(-1, "message invalid!"));
            }

            IDictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("expire_time", message.ExpireTime);
            parameters.Add("send_time", message.SendTime);
            parameters.Add("device_type", deviceType);
            parameters.Add("message_type", 0);
            parameters.Add("message", message.ToJsonString());
            parameters.Add("environment", environment);

            if (message.LoopInterval > 0 && message.LoopTimes > 0)
            {
                parameters.Add("loop_interval", message.LoopInterval);
                parameters.Add("loop_times", message.LoopTimes);
            }

            return(CallRestful(XingeConfig.RESTAPI_PUSHALLDEVICE, parameters));
        }
Пример #4
0
        public override Ret PushTags(int deviceType, List <string> tagList, string tagOp, MessageIOS message, int environment)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            if (!ValidateMessageType(message, environment))
            {
                return(new Ret(-1, "message type or environment error!"));
            }

            if (!message.IsValid() || tagList.Count == 0 || (!tagOp.Equals("AND") && !tagOp.Equals("OR")))
            {
                return(new Ret(-1, "param invalid!"));
            }

            IDictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("expire_time", message.ExpireTime);
            parameters.Add("send_time", message.SendTime);
            parameters.Add("device_type", deviceType);
            parameters.Add("message_type", 0);
            parameters.Add("tags_list", new JArray(tagList).ToString());
            parameters.Add("tags_op", tagOp);
            parameters.Add("message", message.ToJsonString());
            parameters.Add("environment", environment);

            if (message.LoopInterval > 0 && message.LoopTimes > 0)
            {
                parameters.Add("loop_interval", message.LoopInterval);
                parameters.Add("loop_times", message.LoopTimes);
            }

            return(CallRestful(XingeConfig.RESTAPI_PUSHTAGS, parameters));
        }
Пример #5
0
        public override Ret PushSingleAccount(int deviceType, string account, MessageIOS message, int environment)
        {
            //ErrorLog.Write(string.Format("deviceType: {0}\taccount: {1}\tmessage: {2}\tenvironment: {3}", deviceType, account, message.ToJsonString(), environment));

            if (message == null)
            {
                throw new ArgumentNullException("message");
            }
            if (string.IsNullOrEmpty(account))
            {
                throw new ArgumentNullException("account");
            }

            if (!ValidateMessageType(message, environment))
            {
                return(new Ret(-1, "message type or environment error!"));
            }

            if (!message.IsValid())
            {
                return(new Ret(-1, "message invalid!"));
            }

            IDictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("expire_time", message.ExpireTime);
            parameters.Add("send_time", message.SendTime);
            parameters.Add("device_type", deviceType);
            parameters.Add("account", account);
            parameters.Add("message_type", 0);
            parameters.Add("message", message.ToJsonString());
            parameters.Add("environment", environment);

            //ErrorLog.Write("C");
            return(CallRestful(XingeConfig.RESTAPI_PUSHSINGLEACCOUNT, parameters));
        }