Ejemplo n.º 1
0
 public void InitConfigurations()
 {
     try
     {
         Task.Factory.StartNew(async() => {
             // Do some work on a background thread, allowing the UI to remain responsive
             var response        = Synchronization.Configurations(user).Result;
             var responseContent = await response.Content.ReadAsStringAsync();
             configurations      = JsonConvert.DeserializeObject <List <Configuration> >(responseContent);
         }).ContinueWith(task => {
             Device.BeginInvokeOnMainThread(() =>
             {
                 progressIndicator.IsVisible = false;
                 if (configurations == null)
                 {
                     Task.Run(async() => await PopupNavigation.Instance.PushAsync(new MessageBox("Unfortunately, you have not been attached to any configuration, please get in touch with your team lead to attach you to one", MessageType.Regular, PromptPageState)));
                     AiDataStore.Logout();
                     App.Current.MainPage = new NavigationPage(new SignIn());
                 }
                 else
                 {
                     Init();
                     AiDataStore.SaveConfigurations(configurations);
                 }
             });
         }, TaskScheduler.FromCurrentSynchronizationContext());
     }
     catch (Exception ex)
     {
         Debug.Write(ex.StackTrace);
     }
 }
Ejemplo n.º 2
0
 private void InitClient()
 {
     try
     {
         Task.Factory.StartNew(async() => {
             // Do some work on a background thread, allowing the UI to remain responsive
             var response        = Synchronization.Client(user.ClientId).Result;
             var responseContent = await response.Content.ReadAsStringAsync();
             client = JsonConvert.DeserializeObject <Client>(responseContent);
         }).ContinueWith(task => {
             Device.BeginInvokeOnMainThread(() =>
             {
                 if (client != null)
                 {
                     AiDataStore.SaveClient(client);
                     InitConfigurations();
                 }
                 else
                 {
                     Task.Run(async() => await PopupNavigation.Instance.PushAsync(new MessageBox("Unfortunately, your account has no affiliation to any client, please contact your admin for a possible solution", MessageType.Regular, PromptPageState)));
                     AiDataStore.Logout();
                 }
             });
         }, TaskScheduler.FromCurrentSynchronizationContext());
     }
     catch (Exception ex)
     {
         Debug.Write(ex.StackTrace);
     }
 }
Ejemplo n.º 3
0
 public void OnExit()
 {
     try
     {
         AiDataStore.Logout();
         App.Current.MainPage = new NavigationPage(new SignIn());
     }
     catch (Exception ex)
     {
     }
 }