Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  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 WindowsFormsServiceClient.ServiceReference;
  10. using Contracts;
  11.  
  12. namespace WindowsFormsServiceClient
  13. {
  14. public partial class Form1 : Form
  15. {
  16. ServiceConsumer sc = null;
  17.  
  18. public Form1()
  19. {
  20. try
  21. {
  22. ServiceCommunicationConfigorator sc = new ServiceCommunicationConfigorator();
  23. InitializeComponent();
  24. if (sc.getEndPointNames().Count > 0)
  25. {
  26. this.comboBox1.DataSource = sc.getEndPointNames();
  27. }
  28. }
  29. catch (Exception ex)
  30. {
  31. Console.WriteLine(ex.Message);
  32. }
  33. }
  34.  
  35. private ServiceConsumer connect()
  36. {
  37. ServiceConsumer sc = new ServiceConsumer(this.comboBox1.SelectedItem.ToString());
  38. sc.setConnection(null);
  39. return sc;
  40. }
  41.  
  42. private void button1_Click(object sender, EventArgs e)
  43. {
  44. this.textBox1.Enabled = false;
  45. if (this.sc == null)
  46. {
  47. this.sc = connect();
  48. }
  49. else
  50. {
  51. if (this.sc.getClient().State.Equals(System.ServiceModel.CommunicationState.Faulted))
  52. {
  53. this.sc = connect();
  54. }
  55. }
  56.  
  57. try
  58. {
  59. int limit = Convert.ToInt32(this.textBox1.Text.ToString());
  60. StringBuilder sb = new StringBuilder();
  61. Box<Person> container = null;
  62. for (; limit > 0; limit-=100)
  63. {
  64. if (this.checkBox1.Checked)
  65. {
  66. container = sc.listOfPersons(limit, true);
  67. }
  68. else
  69. {
  70. container = sc.listOfPersons(limit, false);
  71. }
  72.  
  73. if (container != null)
  74. {
  75. sb.Append("Element: " + limit + " Time: " + container.time + "\r\n");
  76. }
  77. }
  78. this.textBox2.Text = sb.ToString();
  79. // List<Person> com = sc.getKommunikationForPerson(container.payload.ToList<Person>());
  80. //this.label3.Text = this.label3.Text + "Length: " + container.payload.Length + " Limit:" + this.textBox1.Text + " Time: " + container.time +" Lists:" + ServiceConsumer.timeInMillis + "\r\n";
  81. this.textBox1.Enabled = true;
  82. }
  83. catch (Exception ex)
  84. {
  85. this.textBox1.Enabled = false;
  86. }
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement