Beispiel #1
0
        public string PushMsg(string strJson)
        {
            string result  = string.Empty;
            string message = string.Empty;

            try
            {
                Dictionary <string, string> dic = json.Deserialize <Dictionary <string, string> >(strJson);
                BaiduPush Bpush       = new BaiduPush("POST");
                String    messages    = "";
                String    method      = "push_msg";
                TimeSpan  ts          = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
                uint      device_type = uint.Parse(dic["deviceType"]);
                uint      unixTime    = (uint)ts.TotalSeconds;
                string    messageksy  = "pushkeys";
                string    apiKey      = SysFunction.GetConfigValue("ApiKey");

                if (device_type == 4)
                {
                    IOSNotification notification = new IOSNotification();
                    notification.title       = dic["title"];
                    notification.description = dic["des"];
                    messages = notification.getJsonString();
                }
                else if (device_type == 3)
                {
                    AndroidNotification notification = new AndroidNotification();
                    notification.title       = dic["title"];
                    notification.description = dic["des"];
                    messages = notification.getJsonString();
                }

                PushOptions pOpts;
                if (dic["pushType"].Equals("1"))
                {
                    pOpts = new PushOptions(method, apiKey, dic["userID"], dic["channelID"], device_type, messages, messageksy, unixTime);
                }
                else if (dic["pushType"].Equals("2"))
                {
                    pOpts = new PushOptions(method, apiKey, dic["tag"], device_type, messages, messageksy, unixTime);
                }
                else
                {
                    pOpts = new PushOptions(method, apiKey, device_type, messages, messageksy, unixTime);
                }

                pOpts.message_type = uint.Parse(dic["msgType"]);

                message = Bpush.PushMessage(pOpts);
                result  = "0";
            }
            catch (Exception ex)
            {
                HandleException(ex, ref result, ref message);
            }
            return(GetResultStr(result, message));
        }
        public string PushMsg(string strJson)
        {
            string result = string.Empty;
            string message = string.Empty;
            try
            {
                Dictionary<string, string> dic = json.Deserialize<Dictionary<string, string>>(strJson);
                BaiduPush Bpush = new BaiduPush("POST");
                String messages = "";
                String method = "push_msg";
                TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
                uint device_type = uint.Parse(dic["deviceType"]);
                uint unixTime = (uint)ts.TotalSeconds;
                string messageksy = "pushkeys";
                string apiKey = SysFunction.GetConfigValue("ApiKey");

                if (device_type == 4)
                {
                    IOSNotification notification = new IOSNotification();
                    notification.title = dic["title"];
                    notification.description = dic["des"];
                    messages = notification.getJsonString();
                }
                else if (device_type == 3)
                {
                    AndroidNotification notification = new AndroidNotification();
                    notification.title = dic["title"];
                    notification.description = dic["des"];
                    messages = notification.getJsonString();
                }

                PushOptions pOpts;
                if (dic["pushType"].Equals("1"))
                {
                    pOpts = new PushOptions(method, apiKey, dic["userID"], dic["channelID"], device_type, messages, messageksy, unixTime);
                }
                else if (dic["pushType"].Equals("2"))
                {
                    pOpts = new PushOptions(method, apiKey, dic["tag"], device_type, messages, messageksy, unixTime);
                }
                else
                {
                    pOpts = new PushOptions(method, apiKey, device_type, messages, messageksy, unixTime);
                }

                pOpts.message_type = uint.Parse(dic["msgType"]);

                message = Bpush.PushMessage(pOpts);
                result = "0";
            }
            catch (Exception ex)
            {
                HandleException(ex, ref result, ref message);
            }
            return GetResultStr(result, message);
        }
Beispiel #3
0
 public string PushMessage(PushOptions opts)
 {
     return(Submit <PushOptions>(opts));
 }