Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async Task TryToLogin()
- {
- IsLoading = true;
- string emailAndPassword = String.Format("{0}:{1}", email, password);
- string encryptedCredentials = Convert.ToBase64String(Encoding.UTF8.GetBytes(emailAndPassword));
- var client = new System.Net.Http.HttpClient() {
- BaseAddress = new Uri("https://csp1.isolvetech.net:4433/isolvesd.svc")
- };
- var loginService = RestService.For<ILoginService>(client);
- try
- {
- CancellationTokenSource tokenSource = new CancellationTokenSource();
- tokenSource.CancelAfter(1000); // 10000 ms
- CancellationToken token = tokenSource.Token;
- var loggedUser = await loginService.Login(email, password, "2.0.0", token);
- }
- catch(ApiException)
- {
- await DialogService.DisplayAlertAsync("Error", App.WRONG_CREDENTIALS_ERROR, "OK");
- }
- catch(OperationCanceledException)
- {
- await DialogService.DisplayAlertAsync("Error", "Tardaste un chingo we", "OK");
- }
- //Task loginTask = new ApiService().InitiateLogin(Email, Password);
- //await Task.WhenAny(loginTask, Task.Delay(7000, cancellationToken.Token));
- //if (loginTask.IsCompleted)
- //{
- // if (AppSettings.IsLogged)
- // {
- // await ApplicationData.Instance.CheckAuthorization();
- // ApplicationData.Instance.FirstTime = true;
- // await NavigationService.NavigateAsync("app:///Navigator/UnauthorizedOrders", null, null, true);
- // }
- // else
- // {
- // await DialogService.DisplayAlertAsync("Error", App.WRONG_CREDENTIALS_ERROR, "OK");
- // }
- //}
- //else
- //{
- // await DialogService.DisplayAlertAsync("Timeout", App.TIMEOUT_ERROR, "OK");
- //}
- IsLoading = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement