public async Task<PatientProcedureInfo> AuthGatway(string username,string password) { if (Consts.BaseServerURL == string.Empty) Consts.BaseServerURL = "http://test.iprocedures.com"; Uri uri = new Uri(Consts.BaseServerURL+"/anesservices/Authenticate"); PatientProcedureInfo pats = new PatientProcedureInfo(); FacilityInfo facilities = new FacilityInfo (); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "GET"; request.Headers ["Username"] = username; request.Headers ["Password"] = password; string received; using (var response = (HttpWebResponse)(await Task<WebResponse>.Factory.FromAsync(request.BeginGetResponse, request.EndGetResponse, null))) { using (var responseStream = response.GetResponseStream()) { using (var sr = new StreamReader(responseStream)) { received = await sr.ReadToEndAsync(); } } } AuthGateway responseObj = (AuthGateway)JsonConvert.DeserializeObject(received , typeof(AuthGateway)); if (responseObj.status == "ok") { Consts.BaseServerURL = "http://test.iprocedures.com";//authenticatedUser.url; Consts.SelectedFacilityID = responseObj.result[0].DefaultFacilityID.ToString(); Consts.AuthenticationToken = responseObj.result[0].Token;// authenticatedUser.token; Consts.Role = responseObj.result[0].Role; Consts.UserFirstName = responseObj.result [0].FirstName.Trim (); Consts.UserLastName = responseObj.result [0].LastName.Trim (); Consts.LoginUserFullName = responseObj.result[0].LastName.Trim() + ", " + responseObj.result[0].FirstName.Trim(); facilities = await GetFacilities (Consts.BaseServerURL); pats = await GetProcedurePatientList (); string url = Consts.BaseServerURL+ "/anesservices/users"; ReceiveContext users = await GetDetails(url); if (users != null && users.result != null) { Consts.lstOfUsers = (List<UserDetails>)JsonConvert.DeserializeObject (users.result.ToString (), typeof(List<UserDetails>)); } Consts.ProcAttribTypes = await GetProcAttribTypes (Consts.BaseServerURL+"/anesservices/ProcAttribTypes"); Consts.ProcAttribTypes.result.Types.Sort((xx,yy)=> xx.Priority.CompareTo(yy.Priority)); } return pats; }
public PatientListView (PatientProcedureInfo rootObj) : base ("PatientListView", null) { this.rootObj = rootObj; isViewPushed = true; }
private async void RefreshData() { UIActivityIndicatorView actView = new UIActivityIndicatorView(); actView.Frame = this.View.Bounds; actView.BackgroundColor = UIColor.LightTextColor; actView.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge; actView.Color = UIColor.Black; actView.HidesWhenStopped = true; this.View.Add(actView); //actView.StartAnimating(); AppDelegate.pb.Start (this.View, "Loading"); NetworkStatus internetStatus = Reachability.InternetConnectionStatus(); if (internetStatus != NetworkStatus.NotReachable) { this.rootObj = await AppDelegate.Current.pqrsMgr.GetPatientProcedureInfo (); this.BeginInvokeOnMainThread( () => { if(rootObj.result!=null && rootObj.status !=null && rootObj.status.ToUpper() =="OK") { AppDelegate.pb.Stop(); PopulateTableItems(); searchTable(); } else NavigationController.PopToRootViewController(true); //this.mTableView.Source = tableSource; //this.mTableView.ReloadData(); }); }else{ AppDelegate.pb.Stop(); } }
public async Task<PatientProcedureInfo> DownloadData() { UIActivityIndicatorView actView = new UIActivityIndicatorView(); actView.Frame = this.View.Bounds; actView.BackgroundColor = UIColor.LightTextColor; actView.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge; actView.Color = UIColor.Black; actView.HidesWhenStopped = true; //this.View.Add(actView); //actView.StartAnimating(); AppDelegate.pb.Start (this.View, "Loading"); NetworkStatus internetStatus = Reachability.InternetConnectionStatus(); if (internetStatus != NetworkStatus.NotReachable) { this.rootObj = await AppDelegate.Current.pqrsMgr.GetPatientProcedureInfo (); this.BeginInvokeOnMainThread( () => { //actView.StopAnimating(); AppDelegate.pb.Stop(); PopulateTableItems(); this.mTableView.Source = tableSource; this.mTableView.ReloadData(); }); }else{ //actView.StopAnimating(); AppDelegate.pb.Stop(); } return this.rootObj; }