public Global() { NetworkManager = new NetworkManager (); //ImageManager = new ImageManager (); //db set up string sqliteFilename = "TAP5050_DB.db3"; string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder string dbPath = Path.Combine(documentsPath, sqliteFilename); DatabaseManager = new DatabaseManager (dbPath); }
public async void Locating(MsgHandler handler){ Tap5050WebResponse response = new Tap5050WebResponse (); response.available = false; response.parsedobject = null; response.exceptionreport = new ExceptionReport (""); Position position; try{ position=await locator.GetPositionAsync (10000); }catch{ response.available = false; response.exceptionreport = new ExceptionReport ("Can not get Info from GPS"); response.parsedobject = null; if (handler != null) { handler (response); } return; } //try to get city name if (position != null) { NetworkManager manager = new NetworkManager (); Dictionary<string,string> parameters = new Dictionary<string,string> (); parameters.Add ("lat",position.Latitude.ToString()); parameters.Add ("lng",position.Longitude.ToString()); parameters.Add ("username",LocationManager.geonameusername); manager.GetLocationfromGEO (parameters,(Tap5050WebResponse webresponse)=>{ if(webresponse.available){ var result=(GeonamesCountry)webresponse.parsedobject; response.available = true; response.exceptionreport=null; response.parsedobject=result; if (handler != null) { handler (response); } }else{ response.available = false; response.exceptionreport=webresponse.exceptionreport; if (handler != null) { handler (response); } } }); } }
public override void OnCreate() { base.OnCreate (); AndroidEnvironment.UnhandledExceptionRaiser += MyApp_UnhandledExceptionHandler; TapGlobal tapglobal = new TapGlobal (this); taputil= new TapUtil (this); GlobalVariable staticvalue = new GlobalVariable (); networknamager = new NetworkManager (); imagemanager = new ImageManager (); debugreport = new DebugReport (this); string databasename="tap5050seller.db"; string path = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/Tap5050/"; Java.IO.File basefile = new Java.IO.File (global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath+"/Tap5050/"); Java.IO.File internalbasefile = new Java.IO.File (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal)); string appinternalpath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal); var personalpath=appinternalpath+databasename; bool success = true; if (!internalbasefile.Exists()){ success=internalbasefile.Mkdirs(); Java.IO.File file =new Java.IO.File(personalpath); file.CreateNewFile (); } if (success){ databasemanager = new DatabaseManager (personalpath); } INSTANCE = this; }