public void ShowLoginDialog() { loginDialog = new TFLLoginViewController(delegate { TflTripLog.ClearTflData(); DownloadTripLog(); }); loginController = new UINavigationController(loginDialog); ParentViewController.PresentModalViewController(loginController, true); }
public void DownloadTripLog() { if (!updating) { updating = true; TflTripLog.RefreshTripLogList(delegate { updating = false; InvokeOnMainThread(delegate { DisplayTflData(); }); }); } }
public TflTripLogElement(TflTripLog tripLog) : base("", "", null) { Trip = tripLog; if (Trip == null) { Caption = "Error downloading trip log"; } else { if (Trip.Command == "Admin" || Trip.Command == "Payment" || Trip.Command == "Subscription" || Trip.Command == "Balance") { Caption = Trip.Command; } else { Caption = string.Format("{0} to {1}", Trip.StartStation, Trip.EndStation); } } Value = GetValueString(); Accessory = UITableViewCellAccessory.None; }
public static void RefreshTripLogList(NSAction onDone) { if (HasUsernamePassword) { ThreadPool.QueueUserWorkItem(delegate { using (NSAutoreleasePool pool = new NSAutoreleasePool()) { LastWasError = false; ErrorType = ErrorType.None; var newTripList = new List <TflTripLog>(); Util.Log("updating trip log....."); if (Util.IsReachable("londonbikeapp.appspot.com")) { Util.TurnOnNetworkActivity(); try { var wc = new WebClient(); // this used to talk to AppEngine, but this now hits a static file string url = string.Format("http://www.fastchicken.co.nz/lba/accountinfo.txt"); //url = string.Format("http://localhost:8085/account/get?key=foo"); string logindata = string.Format("username={0}&password={1}", HttpUtility.UrlEncode(TflUsername), HttpUtility.UrlEncode(TflPassword)); //Util.Log(logindata); string s = wc.UploadString(url, "POST", logindata); Util.Log(s); //Util.Log(s); if (s.StartsWith("ERROR")) { LastWasError = true; switch (s.Trim()) { case "ERROR-SITEERROR": ErrorType = ErrorType.SiteError; break; case "ERROR-LOGGINGIN": case "ERROR-LOGGINGIN2": ErrorType = ErrorType.Login; break; case "ERROR-OUTPUT": case "ERROR-LOGINPAGE": ErrorType = ErrorType.Unknown; break; } all = null; onDone(); Util.Log("Trip log error: " + s + " " + url); return; } string[] items = s.Split('^'); foreach (var item in items) { string[] bits = item.Split('|'); try { TflTripLog log = new TflTripLog(bits); newTripList.Add(log); } catch { //do nothing } //51.48802-0.16688|Flood Street|51.48802358|-0.16687854|True|18|14 } all = newTripList; onDone(); Util.Log("updated trip log"); } catch (Exception ex) { LastWasError = true; ErrorType = ErrorType.Unknown; all = null; onDone(); } finally { Util.TurnOffNetworkActivity(); } } else { Util.Log("No network or website not reachable"); } } }); } }
public TflTripLogElement(TflTripLog tripLog) : base("","",null) { Trip = tripLog; if (Trip == null) { Caption = "Error downloading trip log"; } else { if (Trip.Command == "Admin" || Trip.Command == "Payment" || Trip.Command == "Subscription" || Trip.Command == "Balance") { Caption = Trip.Command; } else { Caption = string.Format("{0} to {1}", Trip.StartStation, Trip.EndStation); } } Value = GetValueString(); Accessory = UITableViewCellAccessory.None; }
public static void RefreshTripLogList(NSAction onDone) { if (HasUsernamePassword) { ThreadPool.QueueUserWorkItem(delegate { using (NSAutoreleasePool pool = new NSAutoreleasePool()) { LastWasError = false; ErrorType = ErrorType.None; var newTripList = new List<TflTripLog>(); Util.Log("updating trip log....."); if (Util.IsReachable("londonbikeapp.appspot.com")) { Util.TurnOnNetworkActivity(); try { var wc = new WebClient(); // this used to talk to AppEngine, but this now hits a static file string url = string.Format("http://www.fastchicken.co.nz/lba/accountinfo.txt"); //url = string.Format("http://localhost:8085/account/get?key=foo"); string logindata = string.Format("username={0}&password={1}", HttpUtility.UrlEncode(TflUsername), HttpUtility.UrlEncode(TflPassword)); //Util.Log(logindata); string s = wc.UploadString(url, "POST", logindata); Util.Log (s); //Util.Log(s); if (s.StartsWith("ERROR")) { LastWasError = true; switch (s.Trim()) { case "ERROR-SITEERROR": ErrorType = ErrorType.SiteError; break; case "ERROR-LOGGINGIN": case "ERROR-LOGGINGIN2": ErrorType = ErrorType.Login; break; case "ERROR-OUTPUT": case "ERROR-LOGINPAGE": ErrorType = ErrorType.Unknown; break; } all = null; onDone(); Util.Log("Trip log error: " + s + " " + url); return; } string[] items = s.Split('^'); foreach(var item in items) { string[] bits = item.Split('|'); try { TflTripLog log = new TflTripLog(bits); newTripList.Add(log); } catch { //do nothing } //51.48802-0.16688|Flood Street|51.48802358|-0.16687854|True|18|14 } all = newTripList; onDone(); Util.Log("updated trip log"); } catch (Exception ex) { LastWasError = true; ErrorType = ErrorType.Unknown; all = null; onDone(); } finally { Util.TurnOffNetworkActivity(); } } else Util.Log("No network or website not reachable"); } }); } }