Exemplo n.º 1
0
        public async void ExecuteQueryUnsynced()
        {
            if (mCloudDBZone == null)
            {
                ShowResultPopup("Please open CloudDBZone first!");
                return;
            }

            CloudDBZoneQuery           query             = CloudDBZoneQuery.Where(Java.Lang.Class.ForName("com.company.project.BookInfo"));
            Task <CloudDBZoneSnapshot> unsyncedQueryTask = mCloudDBZone.ExecuteQueryUnsyncedAsync(query);

            try
            {
                await unsyncedQueryTask;
                if (unsyncedQueryTask.Result != null)
                {
                    CloudDBZoneSnapshot snapshot = unsyncedQueryTask.Result;
                    ProcessQueryResult(snapshot);
                }
            }
            catch (Exception e)
            {
                ShowResultPopup("Unsynced query is failed:" + e.Message);
            }
        }
Exemplo n.º 2
0
        public async void ExecuteMinimalQuery()
        {
            if (mCloudDBZone == null)
            {
                ShowResultPopup("Please open CloudDBZone first!");
                return;
            }

            CloudDBZoneQuery        query            = CloudDBZoneQuery.Where(Java.Lang.Class.ForName("com.company.project.BookInfo"));
            Task <Java.Lang.Number> minimalQueryTask = mCloudDBZone.ExecuteMinimalQueryAsync(query, BookEditFields.Price,
                                                                                             CloudDBZoneQuery.CloudDBZoneQueryPolicy.PolicyQueryFromCloudOnly);

            try
            {
                await minimalQueryTask;
                if (minimalQueryTask.Result != null)
                {
                    ShowResultPopup("Minimum price is " + minimalQueryTask.Result.ToString());
                }
            }
            catch (Exception e)
            {
                ShowResultPopup("Minimum query is failed:" + e.Message);
            }
        }
Exemplo n.º 3
0
        public async void ExecuteQuery()
        {
            if (mCloudDBZone == null)
            {
                ShowResultPopup("Please open CloudDBZone first!");
                return;
            }

            Task <CloudDBZoneSnapshot> queryTask = mCloudDBZone.ExecuteQueryAsync(
                CloudDBZoneQuery.Where(Java.Lang.Class.ForName("com.company.project.BookInfo")),
                CloudDBZoneQuery.CloudDBZoneQueryPolicy.PolicyQueryFromCloudOnly);

            try
            {
                await queryTask;
                if (queryTask.Result != null)
                {
                    CloudDBZoneSnapshot snapshot = queryTask.Result;
                    ProcessQueryResult(snapshot);
                }
            }
            catch (Exception e)
            {
                ShowResultPopup("QueryAllBooks failed: " + e.Message);
            }
        }
Exemplo n.º 4
0
 public void SubscribeSnapshot()
 {
     if (mCloudDBZone == null)
     {
         ShowResultPopup("Please open CloudDBZone first!");
         return;
     }
     try
     {
         CloudDBZoneQuery snapshotQuery = CloudDBZoneQuery
                                          .Where(Java.Lang.Class.ForName("com.company.project.BookInfo"))
                                          .EqualTo(BookEditFields.ShadowFlag, true);
         mRegister = mCloudDBZone.SubscribeSnapshot(snapshotQuery,
                                                    CloudDBZoneQuery.CloudDBZoneQueryPolicy.PolicyQueryFromCloudOnly, this);
         ShowResultPopup("SubscribeSnapshot executed successfully.");
     }
     catch (Exception e)
     {
         ShowResultPopup("subscribeSnapshot failed: " + e.Message);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Delete overdue books.
        /// </summary>
        public async void RunTransaction()
        {
            if (mCloudDBZone == null)
            {
                ShowResultPopup("Please open CloudDBZone first!");
                return;
            }

            CloudDBZoneQuery query = CloudDBZoneQuery.Where(Java.Lang.Class.ForName("com.company.project.BookInfo")).
                                     LessThan(BookEditFields.PublishTime, DateUtils.ParseDate("2020-12-04"));

            Transaction.IFunction function = new TransactionFunction((transaction) => {
                try
                {
                    System.Collections.IList bookInfos = transaction.ExecuteQuery(query);
                    IList <CloudDBZoneObject> bookList = new List <CloudDBZoneObject>();
                    foreach (Java.Lang.Object item in bookInfos)
                    {
                        bookList.Add((CloudDBZoneObject)item);
                    }
                    transaction.ExecuteDelete(bookList);
                }
                catch (AGConnectCloudDBException e)
                {
                    ShowResultPopup("Transaction.IFunction exception: " + e.ErrMsg);
                }
            });

            try
            {
                await mCloudDBZone.RunTransactionAsync(function);

                ShowResultPopup("RunTransaction executed successfully");
            }
            catch (Exception e)
            {
                ShowResultPopup("RunTransaction failed: " + e.Message);
            }
        }
Exemplo n.º 6
0
        public async void ExecuteCountQuery()
        {
            if (mCloudDBZone == null)
            {
                ShowResultPopup("Please open CloudDBZone first!");
                return;
            }

            CloudDBZoneQuery query          = CloudDBZoneQuery.Where(Java.Lang.Class.ForName("com.company.project.BookInfo"));
            Task <long>      countQueryTask = mCloudDBZone.ExecuteCountQueryAsync(query, BookEditFields.BookID,
                                                                                  CloudDBZoneQuery.CloudDBZoneQueryPolicy.PolicyQueryFromCloudOnly);

            try
            {
                await countQueryTask;
                ShowResultPopup("Count is " + countQueryTask.Result.ToString());
            }
            catch (Exception e)
            {
                ShowResultPopup("Count query is failed:" + e.Message);
            }
        }
Exemplo n.º 7
0
        public async void ExecuteAverageQuery()
        {
            if (mCloudDBZone == null)
            {
                ShowResultPopup("Please open CloudDBZone first!");
                return;
            }

            CloudDBZoneQuery query            = CloudDBZoneQuery.Where(Java.Lang.Class.ForName("com.company.project.BookInfo"));
            Task <double>    averageQueryTask = mCloudDBZone.ExecuteAverageQueryAsync(query, BookEditFields.Price,
                                                                                      CloudDBZoneQuery.CloudDBZoneQueryPolicy.PolicyQueryFromCloudOnly);

            try
            {
                await averageQueryTask;
                ShowResultPopup("Average price is " + averageQueryTask.Result);
            }
            catch (Exception e)
            {
                ShowResultPopup("Average query is failed: " + e.Message);
            }
        }
    public void ExecuteCountQuery()
    {
        CloudDBZoneQuery mCloudQuery = CloudDBZoneQuery.Where(new AndroidJavaClass(BookInfoClass));

        cloudDBManager.ExecuteCountQuery(mCloudQuery, "price", CloudDBZoneQuery.CloudDBZoneQueryPolicy.CLOUDDBZONE_LOCAL_ONLY);
    }