Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.ServiceModel;
  7. using System.Collections;
  8.  
  9.  
  10. using mcews.ServiceReferenceLogin;
  11.  
  12.  
  13.  
  14.  
  15. namespace ClassLibrary2
  16. {
  17. public class Class1
  18. {
  19.  
  20. //login
  21. public static readonly EndpointAddress EndPointLogin = new EndpointAddress("http://mce.masterlink.pt/Ws/Login.svc");
  22.  
  23. public static string doLogin(String email, String password)
  24. {
  25. BasicHttpBinding binding = CreateBasicHttp();
  26.  
  27. //Call the service
  28. //var client = new ClassLibrary2.ServiceReferenceRegisto.RegistoSoapClient(binding, EndPoint);
  29. var client = new mcews.ServiceReferenceLogin.LoginSoapClient(binding, EndPointLogin);
  30.  
  31. var param = new mcews.ServiceReferenceLogin.LoginInsertParam
  32. {
  33.  
  34. Email = email,
  35. WsPassword = password,
  36. /* Email = "iuri@ipvc.pt",
  37. WsPassword = "iuri",*/
  38.  
  39. };
  40.  
  41.  
  42.  
  43. var a = client.Insert(param);
  44. return a;
  45.  
  46.  
  47. }
  48.  
  49.  
  50. //registo-----------------------------------------------------
  51. public static readonly EndpointAddress EndPoint = new EndpointAddress("http://mce.masterlink.pt/Ws/Registo.svc");
  52.  
  53. public static void doStuff(String email, String name, String password, String genderUser, ArrayList InterestsSelected)//, String[] Interests)
  54. {
  55.  
  56. BasicHttpBinding binding = CreateBasicHttp();
  57.  
  58. var client = new ClassLibrary2.ServiceReferenceRegisto.RegistoSoapClient(binding, EndPoint);
  59. // var client = new RegistoSoapClient();
  60. var ints = new ClassLibrary2.ServiceReferenceRegisto.InterestsItem[InterestsSelected.Count];
  61. List<ClassLibrary2.ServiceReferenceRegisto.InterestsItem> y = new List<ServiceReferenceRegisto.InterestsItem>();
  62. for (int a = 0; a < InterestsSelected.Count; a = a + 1)
  63. {
  64. int iap = a + 1;
  65. string sap = iap.ToString();
  66. /* int iap;
  67. string sap;
  68. if(InterestsSelected[a].ToString().Equals("Nature"))
  69. {
  70. iap = 1;
  71. sap = iap.ToString();
  72. }
  73. if (InterestsSelected[a].ToString().Equals("Sports"))
  74. {
  75. iap = 2;
  76. sap = iap.ToString();
  77. }
  78. if (InterestsSelected[a].ToString().Equals("Technology"))
  79. {
  80. iap = 3;
  81. sap = iap.ToString();
  82. }
  83. if (InterestsSelected[a].ToString().Equals("Science"))
  84. {
  85. iap = 4;
  86. sap = iap.ToString();
  87. }
  88. if (InterestsSelected[a].ToString().Equals("Religion"))
  89. {
  90. iap = 5;
  91. sap = iap.ToString();
  92. }*/
  93. var x = new ClassLibrary2.ServiceReferenceRegisto.InterestsItem { NameofInterest = InterestsSelected[a].ToString(), apInteresse = sap };
  94. y.Add(x);
  95. ints.SetValue(x,a);
  96. }
  97.  
  98.  
  99.  
  100.  
  101. var genderWS = ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam_Gender_Type.Male;
  102.  
  103. if(genderUser.Equals("Male"))
  104. {
  105. genderWS = ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam_Gender_Type.Male;
  106. }
  107. if(genderUser.Equals("Female"))
  108. {
  109. genderWS = ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam_Gender_Type.Female;
  110. }
  111. if(genderUser.Equals("Other"))
  112. {
  113. genderWS = ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam_Gender_Type.Other;
  114. }
  115.  
  116. var param = new ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam
  117. {
  118. Description = "Qualquer coisa",
  119. Email = email,
  120. FullName = name,
  121. WsPassword = password,
  122. Gender = genderWS,
  123. //Interests = new ClassLibrary2.ServiceReferenceRegisto.InterestsItem[] { new ClassLibrary2.ServiceReferenceRegisto.InterestsItem { NameofInterest = InterestsSelected[0].ToString(), apInteresse = "1" }, new ClassLibrary2.ServiceReferenceRegisto.InterestsItem { NameofInterest = "Science", apInteresse = "4" } },
  124. Interests = ints,
  125.  
  126. Username = name
  127. };
  128.  
  129.  
  130. //channel.Insert(param);
  131. client.Insert(param);
  132.  
  133. }
  134.  
  135. private static BasicHttpBinding CreateBasicHttp()
  136. {
  137. BasicHttpBinding binding = new BasicHttpBinding
  138. {
  139. Name = "basicHttpBinding",
  140. MaxBufferSize = 2147483647,
  141. MaxReceivedMessageSize = 2147483647
  142. };
  143. System.TimeSpan timeout = new System.TimeSpan(0, 0, 30);
  144. binding.SendTimeout = timeout;
  145. binding.OpenTimeout = timeout;
  146. binding.ReceiveTimeout = timeout;
  147. return binding;
  148. }
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement