Example #1
0
    void insertLevel(object obj)
    {
        lock (singletonLock)
        {
            try
            {
                Hashtable hash          = (Hashtable)obj;
                string    encryptLevel  = Encryption.Encrypt("" + hash [DatabaseManager.LEVEL]);
                string    encryptScore  = Encryption.Encrypt("" + hash [DatabaseManager.SCORE]);
                string    encryptRate   = Encryption.Encrypt("" + hash [DatabaseManager.RATE]);
                string    encryptReplay = Encryption.Encrypt("" + hash [DatabaseManager.REPLAY]);

                var p = new LevelTable {
                    Level  = encryptLevel,
                    Score  = encryptScore,
                    Rate   = encryptRate,
                    Replay = encryptReplay
                };
                int isSuccess = connection.Update(p);
                if (isSuccess == 0)
                {
                    connection.Insert(p);
                }
            }
            catch (Exception ex)
            {
                Debug.LogWarning(ex.Message);
            }
        }
    }
Example #2
0
    public void RemovePacote(int pacote_id, ISQLiteConnection c)
    {
        var pa = from u in c.Table <Pacote>()
                 where u.collection_id == Id && u.Id == pacote_id
                 select u;

        Pacote p = pa.FirstOrDefault();

        p.in_collection = false;
        pacotes_in_collection--;

        c.Update(p);
        c.Update(this);
    }
        /// <summary>
        /// Get Cloud rows updated since lastSync and store them in LocalDB
        /// </summary>
        /// <typeparam name="T">Object type</typeparam>
        /// <param name="lastSync">Date limit</param>
        /// <param name="getID">Function to get Template ID</param>
        async Task SyncLocalTable <T>(DateTime lastSync, Func <T, int> getID) where T : new()
        {
            // Trying to get all rows in the table T
            //LastSynt Funcionality not Working YET------ Reason: Delete needs extra coding
            var result = await MobileService.GetTable <T>().WithParameters(new Dictionary <string, string> {
                { "lastsync", lastSync.ToString("yyyy-MM-ddTHH:mm:sszzz", DateTimeFormatInfo.InvariantInfo) }
            }).LoadAllAsync();

            //  var result = await MobileService.GetTable<T>().Take(_takeNRows).WithParameters(new Dictionary<string, string> { { "lastsync", lastSync.ToString("yyyy-MM-ddTHH:mm:sszzz", DateTimeFormatInfo.InvariantInfo) } }).ToListAsync();



            string classname = typeof(T).Name;

            _liteConnection.DeleteAll <T>();

            /*       //If id exists in local db delete
             * foreach (var item in result)
             * {
             *      _liteConnection.Delete(item);
             * }*/

            //Insert all

            var storage = Mvx.Resolve <IMvxFileStore>();



            //   _liteConnection.Execute(string.Format("PRAGMA temp_store_directory = '{0}';", storage.NativePath(string.Empty)));
            _liteConnection.BeginTransaction();


            foreach (var tuple in result)
            {
                _liteConnection.Insert(tuple);
            }

            _liteConnection.Commit();



            //Update sync table


            var table_s = _liteConnection.Table <table_sync>().Where(t => t.table_name == classname).FirstOrDefault();

            if (table_s != null)
            {
                table_s.synced_at = DateTime.UtcNow;

                _liteConnection.Update(table_s);
            }
            else
            {
                Mvx.Trace("Table name not found in table_sync. Check SyncLocalTable Method line on WAMSRepositoryService");
                throw new NullReferenceException();
            }
        }
Example #4
0
    // Use this for initialization
    void Start()
    {
        var factory = new Factory();

        var dbPath = string.Format(@"Assets/StreamingAssets/{0}", "existing.db");

        _connection = factory.Create(dbPath);
        Debug.Log("Final PATH: " + dbPath);


        var people = _connection.Table <Person>();;

        print("people=" + people.Count());

        foreach (Person p1 in people)
        {
            print("p1.Name=" + p1.Name);
        }



        //CreateDB2();

        string query = "update Person set Name='あいうぇえおか'";

        string val1 = "あいうぇえおか";

        //val1 = "aaa";

        query = string.Format("update Person set Name=\"{0}\" ", val1);



        //System.Text.Encoding.UTF8.GetByteCount(query);
        //_connection.Execute(query);
        //_connection.ExecuteScalar

        Person pp = _connection.Table <Person>().Where(x => x.Name == "あいうぇえおか").FirstOrDefault();

        print(pp.Age);

        _connection.Update(new Person {
            Id = 1, Name = "탐", Surname = "あいうぇえおか", Age = 56
        });

        //_connection.Execute("update Person set Name='abc'");
    }
        /// <summary>
        /// Get Cloud rows updated since lastSync and store them in LocalDB
        /// </summary>
        /// <typeparam name="T">Object type</typeparam>
        /// <param name="lastSync">Date limit</param>
        /// <param name="getID">Function to get Template ID</param>
        async Task SyncLocalTable <T>(DateTime lastSync, Func <T, int> getID) where T : new()
        {
            //LastSynt Funcionality not Working YET------ Reason: Delete needs extra coding
            var result = await MobileService.GetTable <T>().Take(_takeNRows).WithParameters(new Dictionary <string, string> {
                { "lastsync", lastSync.ToString("yyyy-MM-ddTHH:mm:sszzz", DateTimeFormatInfo.InvariantInfo) }
            }).ToListAsync();


            string classname = typeof(T).Name;

            _liteConnection.DeleteAll <T>();

            /*       //If id exists in local db delete
             *  foreach (var item in result)
             *  {
             *      _liteConnection.Delete(item);
             *  }*/

            //Insert all

            foreach (var tuple in result)
            {
                _liteConnection.Insert(tuple);
            }


            //Update sync table


            var table_s = _liteConnection.Table <table_sync>().Where(t => t.table_name == classname).FirstOrDefault();

            if (table_s != null)
            {
                table_s.synced_at = DateTime.UtcNow;

                _liteConnection.Update(table_s);
            }
            else
            {
                Mvx.Trace("Table name not found in table_sync. Check SyncLocalTable Method line on WAMSRepositoryService");
                throw new NullReferenceException();
            }
        }
 public void Update(T item)
 {
     _connection.Update(item);
 }
Example #7
0
 public void Update(CollectedItem collectedItem)
 {
     _connection.Update(collectedItem);
 }
 public virtual void Update(T entity)
 {
     _sqliteConnection.Update(entity);
 }
 public void Update(Kitten kitten)
 {
     _connection.Update(kitten);
 }
Example #10
0
 public void UpdatePromotion(Promotion promo)
 {
     _connection.Update(promo);
 }
 public void Edit(BowTie bowTie)
 {
     _connection.Update(bowTie);
 }