123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Configuration;
- using OviNotificationsApi;
- namespace TestNotificationApplication
- {
- public partial class MainForm : Form
- {
- Notifications oviNotificationsApi;
- public MainForm()
- {
- InitializeComponent();
- // Load defaults from config
- string restBase = ConfigurationManager.AppSettings["restBase"];
- string serviceId = ConfigurationManager.AppSettings["serviceId"];
- string serviceSecret = ConfigurationManager.AppSettings["serviceSecret"];
- string apiVersion = ConfigurationManager.AppSettings["apiVersion"];
- string appId = ConfigurationManager.AppSettings["appId"];
- restBaseTextBox.Text = restBase;
- serviceIdTextBox.Text = serviceId;
- serviceSecretTextBox.Text = serviceSecret;
- apiVersionTextBox.Text = apiVersion;
- jid_applicationIdTextBox.Text = appId;
- pingjid_applicationIdTextBox.Text = appId;
- }
- private void initializeButton_Click(object sender, EventArgs e)
- {
- if (oviNotificationsApi == null)
- {
- oviNotificationsApi =
- new Notifications(
- this.restBaseTextBox.Text,
- this.apiVersionTextBox.Text,
- this.serviceIdTextBox.Text,
- this.serviceSecretTextBox.Text
- );
- }
- else
- {
- oviNotificationsApi.BaseUrl = this.restBaseTextBox.Text;
- oviNotificationsApi.ApiVersion = this.apiVersionTextBox.Text;
- oviNotificationsApi.ServiceID = this.serviceIdTextBox.Text;
- oviNotificationsApi.ServiceSecret = this.serviceSecretTextBox.Text;
- }
- tabControl1.Enabled = true;
- }
- private void nid_PushButton_Click(object sender, EventArgs e)
- {
- try
- {
- string response = oviNotificationsApi.SendNotification(
- notificationIdTextBox.Text,
- nid_wakeUpCheckBox.Checked,
- nid_payloadTextBox.Text,
- nid_contentTypeTextBox.Text,
- nid_encodingTextBox.Text);
- responseTextBox.Text = response;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void jid_PushButton_Click(object sender, EventArgs e)
- {
- try
- {
- string response = oviNotificationsApi.SendNotification(
- jidTextBox.Text,
- jid_applicationIdTextBox.Text,
- jid_wakeUpCheckBox.Checked,
- jid_payLoadTextBox.Text,
- jid_contentTypeTextBox.Text,
- jid_encodingTextBox.Text);
- responseTextBox.Text = response;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void pingNid_Button_Click(object sender, EventArgs e)
- {
- try
- {
- string response = oviNotificationsApi.PingClient(
- pingNotificationIdTextBox.Text);
- responseTextBox.Text = response;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void pingjid_Button_Click(object sender, EventArgs e)
- {
- try
- {
- string response = oviNotificationsApi.PingClient(
- pingJidTextBox.Text,
- pingjid_applicationIdTextBox.Text);
- responseTextBox.Text = response;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void versionButton_Click(object sender, EventArgs e)
- {
- try
- {
- string response = oviNotificationsApi.Version();
- responseTextBox.Text = response;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void pingServiceButton_Click(object sender, EventArgs e)
- {
- try
- {
- string response = oviNotificationsApi.PingService();
- responseTextBox.Text = response;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void queryLimitationsButton_Click(object sender, EventArgs e)
- {
- try
- {
- string response = oviNotificationsApi.QueryLimitations();
- responseTextBox.Text = response;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
|