Esempio n. 1
0
 public void FixtureSetup()
 {
     Console.WriteLine("Connecting");
     var client = new DatabaseClient("*****@*****.**", "password");
     const string dbName = "IntegrationTests";
     Console.WriteLine("Opening or creating database");
     db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);
     const string tableName = "IntegrationTests";
     Console.WriteLine("Opening or creating table");
     table = db.GetTable<IntegrationEntity>(tableName) ?? db.CreateTable<IntegrationEntity>(tableName);
 }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Connecting");
            var          client = new DatabaseClient("*****@*****.**", "password");
            const string dbName = "testing";

            Console.WriteLine("Opening or creating database");
            var          db        = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);
            const string tableName = "testtable";

            Console.WriteLine("Opening or creating table");
            var t = db.GetTable <Entity>(tableName) ?? db.CreateTable <Entity>(tableName);

            Console.WriteLine("Feed url for this table is '{0}'", t.GetFeedUrl());
            var all = t.FindAll();

            Console.WriteLine("{0} elements", all.Count);
            var r = all.Count > 0 ? all[0] : t.Add(new Entity {
                Conteudo = "some content", Amount = 5
            });

            Console.WriteLine("conteudo: {0}", r.Element.Conteudo);
            r.Element.Conteudo = "nothing at all";
            Console.WriteLine("updating row");
            r.Update();
            Console.WriteLine("Now there are {0} elements", t.FindAll().Count);
            {
                Console.WriteLine("executing a few queries");
                foreach (var q in new[] { "amount=5", "amount<6", "amount>0", "amount!=6", "amount<>6", "conteudo=\"nothing at all\"" })
                {
                    Console.Write("querying '{0}': ", q);
                    var rows = t.FindStructured(q);
                    Console.WriteLine("{0} elements found", rows.Count);
                }
            }
            {
                Console.WriteLine("Linq queries");
                var rows = from e in t.AsQueryable()
                           where e.Conteudo == r.Element.Conteudo
                           orderby e.Amount
                           select e;
                Console.WriteLine("{0} elements found", rows.ToList().Count());
            }
            Console.WriteLine("deleting row");
            r.Delete();
            Console.WriteLine("deleting table");
            t.Delete();
            Console.WriteLine("deleting database");
            db.Delete();
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the table.
        /// </summary>
        /// <returns>The table.</returns>
        protected virtual ITable <TEntity> GetTable()
        {
            if (m_table == null)
            {
                var client = new DatabaseClient(m_clientEmail, m_privateKey);

                var db = client.GetDatabase(m_databaseName) ?? client.CreateDatabase(m_databaseName);

                m_table = db.GetTable <TEntity>(m_tableName) ?? db.CreateTable <TEntity>(m_tableName);
            }

            return(m_table);
        }
Esempio n. 4
0
		public void FixtureSetup() {
			Console.WriteLine("Connecting");
            var client = new DatabaseClient(
                clientEmail: "*****@*****.**",
                privateKey: File.ReadAllBytes(@"xxx.p12"));

            const string dbName = "IntegrationTests";
			Console.WriteLine("Opening or creating database");
			db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);
			const string tableName = "IntegrationTests";
			Console.WriteLine("Opening or creating table");
			table = db.GetTable<IntegrationEntity>(tableName) ?? db.CreateTable<IntegrationEntity>(tableName);
		}
Esempio n. 5
0
        public void FixtureSetup()
        {
            Console.WriteLine("Connecting");
            var          client = new DatabaseClient("*****@*****.**", "password");
            const string dbName = "IntegrationTests";

            Console.WriteLine("Opening or creating database");
            db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);
            const string tableName = "IntegrationTests";

            Console.WriteLine("Opening or creating table");
            table = db.GetTable <IntegrationEntity>(tableName) ?? db.CreateTable <IntegrationEntity>(tableName);
        }
Esempio n. 6
0
        public void FixtureSetup()
        {
            Console.WriteLine("Connecting");
            var client = new DatabaseClient(
                clientEmail: "*****@*****.**",
                privateKey: File.ReadAllBytes(@"xxx.p12"));

            const string dbName = "IntegrationTests";

            Console.WriteLine("Opening or creating database");
            db = client.GetDatabase(dbName) ?? client.CreateDatabase(dbName);
            const string tableName = "IntegrationTests";

            Console.WriteLine("Opening or creating table");
            table = db.GetTable <IntegrationEntity>(tableName) ?? db.CreateTable <IntegrationEntity>(tableName);
        }
Esempio n. 7
0
    public override bool Load()
    {
        if (!base.Load())
        {
            return(false);
        }

        MySpreadSheet targetData = target as MySpreadSheet;

        var client = new DatabaseClient(username, password);
        var db     = client.GetDatabase(targetData.SheetName) ?? client.CreateDatabase(targetData.SheetName);
        var table  = db.GetTable <MyData>(targetData.WorksheetName) ?? db.CreateTable <MyData>(targetData.WorksheetName);

        List <MyData> myDataList = new List <MyData>();

        var all = table.FindAll();

        foreach (var elem in all)
        {
            MyData data = new MyData();

            data = Cloner.DeepCopy <MyData>(elem.Element);
            myDataList.Add(data);
        }

#if UNITY_EDITOR
        Debug.Log("=== MyData ===");
        foreach (var e in myDataList)
        {
            Debug.Log("Key: " + e.Key);
            Debug.Log("Text: " + e.Text);
        }
#endif

        targetData.dataArray = myDataList.ToArray();

        EditorUtility.SetDirty(targetData);
        AssetDatabase.SaveAssets();

        return(true);
    }