Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.ServiceModel;
- using System.Collections;
- using mcews.ServiceReferenceLogin;
- namespace ClassLibrary2
- {
- public class Class1
- {
- //login
- public static readonly EndpointAddress EndPointLogin = new EndpointAddress("http://mce.masterlink.pt/Ws/Login.svc");
- public static string doLogin(String email, String password)
- {
- BasicHttpBinding binding = CreateBasicHttp();
- //Call the service
- //var client = new ClassLibrary2.ServiceReferenceRegisto.RegistoSoapClient(binding, EndPoint);
- var client = new mcews.ServiceReferenceLogin.LoginSoapClient(binding, EndPointLogin);
- var param = new mcews.ServiceReferenceLogin.LoginInsertParam
- {
- Email = email,
- WsPassword = password,
- /* Email = "iuri@ipvc.pt",
- WsPassword = "iuri",*/
- };
- var a = client.Insert(param);
- return a;
- }
- //registo-----------------------------------------------------
- public static readonly EndpointAddress EndPoint = new EndpointAddress("http://mce.masterlink.pt/Ws/Registo.svc");
- public static void doStuff(String email, String name, String password, String genderUser, ArrayList InterestsSelected)//, String[] Interests)
- {
- BasicHttpBinding binding = CreateBasicHttp();
- var client = new ClassLibrary2.ServiceReferenceRegisto.RegistoSoapClient(binding, EndPoint);
- // var client = new RegistoSoapClient();
- var ints = new ClassLibrary2.ServiceReferenceRegisto.InterestsItem[InterestsSelected.Count];
- List<ClassLibrary2.ServiceReferenceRegisto.InterestsItem> y = new List<ServiceReferenceRegisto.InterestsItem>();
- for (int a = 0; a < InterestsSelected.Count; a = a + 1)
- {
- int iap = a + 1;
- string sap = iap.ToString();
- /* int iap;
- string sap;
- if(InterestsSelected[a].ToString().Equals("Nature"))
- {
- iap = 1;
- sap = iap.ToString();
- }
- if (InterestsSelected[a].ToString().Equals("Sports"))
- {
- iap = 2;
- sap = iap.ToString();
- }
- if (InterestsSelected[a].ToString().Equals("Technology"))
- {
- iap = 3;
- sap = iap.ToString();
- }
- if (InterestsSelected[a].ToString().Equals("Science"))
- {
- iap = 4;
- sap = iap.ToString();
- }
- if (InterestsSelected[a].ToString().Equals("Religion"))
- {
- iap = 5;
- sap = iap.ToString();
- }*/
- var x = new ClassLibrary2.ServiceReferenceRegisto.InterestsItem { NameofInterest = InterestsSelected[a].ToString(), apInteresse = sap };
- y.Add(x);
- ints.SetValue(x,a);
- }
- var genderWS = ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam_Gender_Type.Male;
- if(genderUser.Equals("Male"))
- {
- genderWS = ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam_Gender_Type.Male;
- }
- if(genderUser.Equals("Female"))
- {
- genderWS = ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam_Gender_Type.Female;
- }
- if(genderUser.Equals("Other"))
- {
- genderWS = ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam_Gender_Type.Other;
- }
- var param = new ClassLibrary2.ServiceReferenceRegisto.RegistoInsertParam
- {
- Description = "Qualquer coisa",
- Email = email,
- FullName = name,
- WsPassword = password,
- Gender = genderWS,
- //Interests = new ClassLibrary2.ServiceReferenceRegisto.InterestsItem[] { new ClassLibrary2.ServiceReferenceRegisto.InterestsItem { NameofInterest = InterestsSelected[0].ToString(), apInteresse = "1" }, new ClassLibrary2.ServiceReferenceRegisto.InterestsItem { NameofInterest = "Science", apInteresse = "4" } },
- Interests = ints,
- Username = name
- };
- //channel.Insert(param);
- client.Insert(param);
- }
- private static BasicHttpBinding CreateBasicHttp()
- {
- BasicHttpBinding binding = new BasicHttpBinding
- {
- Name = "basicHttpBinding",
- MaxBufferSize = 2147483647,
- MaxReceivedMessageSize = 2147483647
- };
- System.TimeSpan timeout = new System.TimeSpan(0, 0, 30);
- binding.SendTimeout = timeout;
- binding.OpenTimeout = timeout;
- binding.ReceiveTimeout = timeout;
- return binding;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement