private async void SetupDevice() { Loading = true; _dialogService.ShowWait("Verifying,Please wait..."); //save device info Device.Serial = Serial; Device.Name = Name; _deviceSetupService.Register(Device); Device = _deviceSetupService.GetDefault(Device.Id); if (null != Device) { _settings.AddOrUpdateValue("device.id", JsonConvert.SerializeObject(Device)); } //get fac var practices = new List <Practice>(); try { practices = await _emrService.GetAllDefault(Url); } catch (Exception ex) { _dialogService.Alert("Server error please check with System Admin"); _dialogService.HideWait(); return; } Practices = practices; if (null != practices && practices.Any()) { foreach (var practice in practices) { //save fac _deviceSetupService.SavePractce(practice); } } else { _dialogService.Alert("Address could not be verified"); _dialogService.HideWait(); return; } //get users var users = new List <User>(); try { users = await _emrService.GetUsers(Url); } catch (Exception ex) { _dialogService.Alert("Server error please check with System Admin"); _dialogService.HideWait(); return; } _deviceSetupService.SaveUsers(users); Loading = false; _dialogService.HideWait(); if (Local.IsSetupComplete()) { _dialogService.ShowToast("Device setup successfully,Select Facility"); } else { _dialogService.Alert("Please select Facility before proceeding"); } }
private async void PullData() { int total = 16; int current = 0; IsBusy = true; CurrentStatus = $"connecting..."; var practice = await _activationService.GetLocal(Address); if (null != practice) { try { var devicePrefix = await _activationService.AttemptEnrollDevice(Address, RegisteredDevice); if (!string.IsNullOrEmpty(devicePrefix)) { _deviceSetupService.UpdateCode(devicePrefix); _settings.AddOrUpdateValue("livehts.devicecode", devicePrefix); } } catch (Exception e) { } current++; CurrentStatus = showPerc("Metas", current, total); var meta = await _metaSyncService.GetMetaData(Address); _syncDataService.UpdateMeta(meta); current++; CurrentStatus = showPerc("Counties", current, total); var counties = await _metaSyncService.GetCounties(Address); _syncDataService.Update(counties); current++; CurrentStatus = showPerc("Categories", current, total); var categories = await _metaSyncService.GetCategories(Address); _syncDataService.Update(categories); current++; CurrentStatus = showPerc("Items", current, total); var items = await _metaSyncService.GetItems(Address); _syncDataService.Update(items); current++; CurrentStatus = showPerc("Category Items", current, total); var catitems = await _metaSyncService.GetCatItems(Address); _syncDataService.Update(catitems); current++; CurrentStatus = showPerc("Modules", current, total); var modules = await _formsSyncService.GetModules(Address); _syncDataService.UpdateModules(modules); current++; CurrentStatus = showPerc("Forms", current, total); var forms = await _formsSyncService.GetForms(Address); _syncDataService.UpdateForms(forms); current++; CurrentStatus = showPerc("Concepts", current, total); var concepts = await _formsSyncService.GetConcepts(Address); _syncDataService.UpdateConcepts(concepts); current++; CurrentStatus = showPerc("Questions", current, total); var questions = await _formsSyncService.GetQuestions(Address); _syncDataService.UpdateQuestions(questions); current++; current++; current++; CurrentStatus = showPerc("Users", current, total); var users = await _emrService.GetUsers(Address); _deviceSetupService.SaveUsers(users); current++; CurrentStatus = showPerc("cohort lists", current, total); var cohorts = await _cohortSyncService.GetCohorts(Address); _syncDataService.Update(cohorts); CurrentStatus = "done!"; _dialogService.ShowToast("completed successfully"); } else { IsBusy = false; CurrentStatus = $"connection failed !!"; _dialogService.Alert("Could not connect to server"); } IsBusy = false; }