MainForm.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Configuration;
  10. using OviNotificationsApi;
  11. namespace TestNotificationApplication
  12. {
  13. public partial class MainForm : Form
  14. {
  15. Notifications oviNotificationsApi;
  16. public MainForm()
  17. {
  18. InitializeComponent();
  19. // Load defaults from config
  20. string restBase = ConfigurationManager.AppSettings["restBase"];
  21. string serviceId = ConfigurationManager.AppSettings["serviceId"];
  22. string serviceSecret = ConfigurationManager.AppSettings["serviceSecret"];
  23. string apiVersion = ConfigurationManager.AppSettings["apiVersion"];
  24. string appId = ConfigurationManager.AppSettings["appId"];
  25. restBaseTextBox.Text = restBase;
  26. serviceIdTextBox.Text = serviceId;
  27. serviceSecretTextBox.Text = serviceSecret;
  28. apiVersionTextBox.Text = apiVersion;
  29. jid_applicationIdTextBox.Text = appId;
  30. pingjid_applicationIdTextBox.Text = appId;
  31. }
  32. private void initializeButton_Click(object sender, EventArgs e)
  33. {
  34. if (oviNotificationsApi == null)
  35. {
  36. oviNotificationsApi =
  37. new Notifications(
  38. this.restBaseTextBox.Text,
  39. this.apiVersionTextBox.Text,
  40. this.serviceIdTextBox.Text,
  41. this.serviceSecretTextBox.Text
  42. );
  43. }
  44. else
  45. {
  46. oviNotificationsApi.BaseUrl = this.restBaseTextBox.Text;
  47. oviNotificationsApi.ApiVersion = this.apiVersionTextBox.Text;
  48. oviNotificationsApi.ServiceID = this.serviceIdTextBox.Text;
  49. oviNotificationsApi.ServiceSecret = this.serviceSecretTextBox.Text;
  50. }
  51. tabControl1.Enabled = true;
  52. }
  53. private void nid_PushButton_Click(object sender, EventArgs e)
  54. {
  55. try
  56. {
  57. string response = oviNotificationsApi.SendNotification(
  58. notificationIdTextBox.Text,
  59. nid_wakeUpCheckBox.Checked,
  60. nid_payloadTextBox.Text,
  61. nid_contentTypeTextBox.Text,
  62. nid_encodingTextBox.Text);
  63. responseTextBox.Text = response;
  64. }
  65. catch (Exception ex)
  66. {
  67. MessageBox.Show(ex.Message);
  68. }
  69. }
  70. private void jid_PushButton_Click(object sender, EventArgs e)
  71. {
  72. try
  73. {
  74. string response = oviNotificationsApi.SendNotification(
  75. jidTextBox.Text,
  76. jid_applicationIdTextBox.Text,
  77. jid_wakeUpCheckBox.Checked,
  78. jid_payLoadTextBox.Text,
  79. jid_contentTypeTextBox.Text,
  80. jid_encodingTextBox.Text);
  81. responseTextBox.Text = response;
  82. }
  83. catch (Exception ex)
  84. {
  85. MessageBox.Show(ex.Message);
  86. }
  87. }
  88. private void pingNid_Button_Click(object sender, EventArgs e)
  89. {
  90. try
  91. {
  92. string response = oviNotificationsApi.PingClient(
  93. pingNotificationIdTextBox.Text);
  94. responseTextBox.Text = response;
  95. }
  96. catch (Exception ex)
  97. {
  98. MessageBox.Show(ex.Message);
  99. }
  100. }
  101. private void pingjid_Button_Click(object sender, EventArgs e)
  102. {
  103. try
  104. {
  105. string response = oviNotificationsApi.PingClient(
  106. pingJidTextBox.Text,
  107. pingjid_applicationIdTextBox.Text);
  108. responseTextBox.Text = response;
  109. }
  110. catch (Exception ex)
  111. {
  112. MessageBox.Show(ex.Message);
  113. }
  114. }
  115. private void versionButton_Click(object sender, EventArgs e)
  116. {
  117. try
  118. {
  119. string response = oviNotificationsApi.Version();
  120. responseTextBox.Text = response;
  121. }
  122. catch (Exception ex)
  123. {
  124. MessageBox.Show(ex.Message);
  125. }
  126. }
  127. private void pingServiceButton_Click(object sender, EventArgs e)
  128. {
  129. try
  130. {
  131. string response = oviNotificationsApi.PingService();
  132. responseTextBox.Text = response;
  133. }
  134. catch (Exception ex)
  135. {
  136. MessageBox.Show(ex.Message);
  137. }
  138. }
  139. private void queryLimitationsButton_Click(object sender, EventArgs e)
  140. {
  141. try
  142. {
  143. string response = oviNotificationsApi.QueryLimitations();
  144. responseTextBox.Text = response;
  145. }
  146. catch (Exception ex)
  147. {
  148. MessageBox.Show(ex.Message);
  149. }
  150. }
  151. }
  152. }