protected void BtnSend_Click(object sender, EventArgs e) { try { string sk = TBSK.Text; string ak = TBAK.Text; BaiduPush Bpush = new BaiduPush("POST", sk); String apiKey = ak; String messages=""; String method = "push_msg"; TimeSpan ts = (DateTime.UtcNow - new DateTime(1970,1,1,0,0,0)); uint device_type=3; uint unixTime = (uint)ts.TotalSeconds; uint message_type; string messageksy="xxxxxx"; if (RbMessage.Checked) { message_type = 0; messages = TBMessage.Text; } else { message_type = 1; if (RBIOSPRO.Checked == true || RBIOSDEV.Checked == true) { device_type = 4; IOSNotification notification = new IOSNotification(); notification.title = TBTitle.Text; notification.description = TBDescription.Text; messages = notification.getJsonString(); } else { BaiduPushNotification notification = new BaiduPushNotification(); notification.title = TBTitle.Text; notification.description = TBDescription.Text; messages = notification.getJsonString(); } } PushOptions pOpts; if(RBUnicast.Checked) { pOpts = new PushOptions(method, apiKey, TBUserId.Text, TBChannelID.Text, device_type,messages, messageksy, unixTime); }else if(RBMulticast.Checked) { pOpts = new PushOptions(method, apiKey, TBTag.Text, device_type, messages, messageksy, unixTime); }else { pOpts = new PushOptions(method, apiKey, device_type, messages, messageksy, unixTime); } pOpts.message_type = message_type; if (RBIOSPRO.Checked == true) { pOpts.deploy_status = 2; } else if(RBIOSDEV.Checked == true) { pOpts.deploy_status = 1; } string response= Bpush.PushMessage(pOpts); TextBoxResponse.Text = response; } catch (Exception ex) { TextBoxResponse.Text = "Exception caught sending update: " + ex.ToString(); } }
protected void BtnSend_Click(object sender, EventArgs e) { try { string sk = TBSK.Text; string ak = TBAK.Text; BaiduPush Bpush = new BaiduPush("POST", sk); String apiKey = ak; String messages = ""; String method = "push_msg"; TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)); uint device_type = 3; uint unixTime = (uint)ts.TotalSeconds; uint message_type; string messageksy = "xxxxxx"; if (RbMessage.Checked) { message_type = 0; messages = TBMessage.Text; } else { message_type = 1; if (RBIOSPRO.Checked == true || RBIOSDEV.Checked == true) { device_type = 4; IOSNotification notification = new IOSNotification(); notification.title = TBTitle.Text; notification.description = TBDescription.Text; messages = notification.getJsonString(); } else { BaiduPushNotification notification = new BaiduPushNotification(); notification.title = TBTitle.Text; notification.description = TBDescription.Text; messages = notification.getJsonString(); } } PushOptions pOpts; if (RBUnicast.Checked) { pOpts = new PushOptions(method, apiKey, TBUserId.Text, TBChannelID.Text, device_type, messages, messageksy, unixTime); } else if (RBMulticast.Checked) { pOpts = new PushOptions(method, apiKey, TBTag.Text, device_type, messages, messageksy, unixTime); } else { pOpts = new PushOptions(method, apiKey, device_type, messages, messageksy, unixTime); } pOpts.message_type = message_type; if (RBIOSPRO.Checked == true) { pOpts.deploy_status = 2; } else if (RBIOSDEV.Checked == true) { pOpts.deploy_status = 1; } string response = Bpush.PushMessage(pOpts); TextBoxResponse.Text = response; } catch (Exception ex) { TextBoxResponse.Text = "Exception caught sending update: " + ex.ToString(); } }