Exemplo n.º 1
0
        /// <summary>
        /// Creates the new DB account.
        /// </summary>
        /// <param name="account">Account for a new user.</param>
        /// <param name="password">Password for a new user.</param>
        public void CreateNewDBAccount(Account account, string password)
        {
            SQLiteConnection con = new SQLiteConnection(ServerConstants.DB_PATH);

               DBAccount dbacc = new DBAccount(con);

               dbacc.CreateAccount(account, password);
        }
Exemplo n.º 2
0
		public static Task<DBDatastore> OpenDefaultStoreForAccountAsync (DBAccount account)
		{
			return Task.Factory.StartNew (p => {
				DBError err;
				var results = OpenDefaultStoreForAccount ((DBAccount)p, out err);
				if (err != null)
					throw new DBException (err);
				return results;
			}, account);
		}
Exemplo n.º 3
0
		public DropboxFileSystem (DBAccount account, DBFilesystem filesystem)
		{
			if (account == null)
				throw new ArgumentNullException ("account");
			if (filesystem == null)
				throw new ArgumentNullException ("filesystem");
			
			this.account = account;
			this.filesystem = filesystem;
			FileExtensions = new Collection<string> ();
		}
		public void Init (DBAccount account)
		{
			Console.WriteLine("Init");
			if (store != null)
				return;

			store = DBDatastore.OpenDefault (account);

			store.Sync ();

//			store.AddObserver (store, () => {
//				Console.Write("AddObserver");
//
//				DBError error2;
//				store.Sync(out error2); // needed?
//
//				var table = store.GetTable (tableName);
//				var results = table.Query (null, out error);
//
//				Console.WriteLine(results.Length);
//
//				ProccessResults (results);
//			});


			// TIMER TO AUTOUPDATE
			AutoUpdating = true;

			#if __IOS__
			store.BeginInvokeOnMainThread(()=>{
				timer = NSTimer.CreateRepeatingScheduledTimer(2,()=>{
					if(!AutoUpdating)
						return;
					//Console.WriteLine("AutoUpdating"); // SPAM
					DBError error3;
					store.Sync(out error3);
				});
			});
			#endif

		}
Exemplo n.º 5
0
        /// <summary>
        /// Gets the account data via DB login.
        /// </summary>
        /// <returns>The account data via DB login.</returns>
        /// <param name="account">Account for DB data.</param>
        /// <param name="password">Password for DB data.</param>
        public TableData GetAccountDataViaDBLogin(Account account, string password)
        {
            SQLiteConnection con = new SQLiteConnection(ServerConstants.DB_PATH);

               DBAccount dbacc = new DBAccount(con);
               TableData tb = new TableData();

               if (dbacc.Login(account.UserName, password))
               {
               var data = con.Query<TableAccount>("SELECT Id FROM Account WHERE UserName = ? LIMIT 1", account.UserName);
               tb.Id = data[0].Id;
               tb.Units = con.Query<TableUnit>("SELECT * FROM Unit WHERE Id = ?", tb.Id);
               tb.Buildings = con.Query<TableBuilding>("SELECT * FROM Building WHERE Id = ?", tb.Id);
               tb.Resources = con.Query<TableResource>("SELECT * FROM Ressources WHERE Id = ?", tb.Id);
               }

               return tb;
        }
Exemplo n.º 6
0
		//INICIALIZAMOS NUESTRO DATASTORE Y LE AGREGAMOS UN HADLE PARA IR VIENDO SI DESEAMOS EL ESTADO DE ESTA
		void InicializarDropboxDatastore (DBAccount account)
		{
			LogInfo("Inicializar DropboxDatastore");
			if (DropboxDatastore == null || !DropboxDatastore.IsOpen || DropboxDatastore.Manager.IsShutDown) {
				//INICIALIAZAMOS DropboxDatastore 
				DropboxDatastore = DBDatastore.OpenDefault (account ?? Account.LinkedAccount);
				DropboxDatastore.DatastoreChanged += HandleStoreChange;
			}
			//INVOCAMOS LA SINCRONIZACION DE DATASTORE
			DropboxDatastore.Sync();
		}
 void AccountUpdated(DBAccount account)
 {
     if (!account.Linked && CurrentAccount () == account) {
         NavigationController.PopToViewController (this, true);
         new UIAlertView ("Info", "Your account was unlinked!", null, "Ok", null).Show ();
     } else
         TableView.ReloadData ();
 }
Exemplo n.º 8
0
 void StartApp(DBAccount account = null)
 {
     InitializeDropbox(account);
     Sync();
 }
Exemplo n.º 9
0
 void StartApp(DBAccount account = null)
 {
     InitializeDropbox (account);
     Log("StartApp", "Syncing monkies...");
     DropboxDatastore.Sync();
     Monkeys = GetMonkeys ();
     DrawMonkeys (Monkeys);
 }
Exemplo n.º 10
0
 void InitializeDropbox(DBAccount account)
 {
     Log("InitializeDropbox");
     if (DropboxDatastore == null || !DropboxDatastore.IsOpen || DropboxDatastore.Manager.IsShutDown) {
         DropboxDatastore = DBDatastore.OpenDefault (account ?? Account.LinkedAccount);
         DropboxDatastore.DatastoreChanged += HandleStoreChange;
     }
 }
Exemplo n.º 11
0
		void StartApp (DBAccount account = null)
		{
			AppDelegate.Current.DropboxStore.Init (account);
			DropboxDatastore = AppDelegate.Current.DropboxStore.store;
			Console.WriteLine("StartApp" + "...");
			DropboxDatastore.Sync();

		}