Example #1
0
        private void ProcessQueryResult(CloudDBZoneSnapshot snapshot)
        {
            CloudDBZoneObjectList bookInfoCursor = snapshot.SnapshotObjects;
            string bookNames = "";

            try
            {
                while (bookInfoCursor.HasNext)
                {
                    BookInfo bookInfo = Helpers.ObjectTypeHelper.ConvertJavaTypeToCSharpType(bookInfoCursor.Next());
                    bookNames += bookInfo.BookName + ", ";

                    if (bookInfo.Author.Equals(bookInfoTest.Author))
                    {
                        bookInfoTest.Id = bookInfo.Id;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Equals(Tag, "processQueryResult: " + e.Message);
            }
            finally
            {
                snapshot.Release();
            }
            if (bookNames.Equals(""))
            {
                ShowResultPopup("There is no record.");
            }
            else
            {
                ShowResultPopup(bookNames);
            }
        }
Example #2
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);
            }
        }
Example #3
0
        public void OnSnapshot(CloudDBZoneSnapshot cloudDBZoneSnapshot, AGConnectCloudDBException e)
        {
            if (e != null)
            {
                Log.Error(Tag, "OnSnapshot: " + e.Message);
                return;
            }
            CloudDBZoneObjectList snapshotObjects = cloudDBZoneSnapshot.SnapshotObjects;

            IList <BookInfo> bookInfoList = new List <BookInfo>();

            try
            {
                if (snapshotObjects != null)
                {
                    while (snapshotObjects.HasNext)
                    {
                        BookInfo bookInfo = Helpers.ObjectTypeHelper.ConvertJavaTypeToCSharpType(snapshotObjects.Next());
                        bookInfoList.Add(bookInfo);
                    }
                }
            }
            catch (AGConnectCloudDBException snapshotException)
            {
                Log.Error(Tag, "OnSnapshot:(getObject) " + snapshotException.Message);
            }
            finally
            {
                cloudDBZoneSnapshot.Release();
            }
        }
Example #4
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);
            }
        }
Example #5
0
 public override void onSnapshot(CloudDBZoneSnapshot <T> arg0, AGConnectCloudDBException arg1)
 {
     TestTip.Inst.ShowText("OnSnapshot success.");
     if (cb != null)
     {
         cb.Invoke(arg0, arg1);
     }
 }
 public override void onSnapshot(CloudDBZoneSnapshot <T> arg0, AGConnectCloudDBException arg1)
 {
     if (cb != null)
     {
         var exception = new AGConnectCloudDBException();
         exception.obj = arg1.obj;
         cb.Invoke(arg0, arg1);
     }
 }
 public static void testSnapShot(CloudDBZoneSnapshot <BookInfo> snapshot)
 {
     if (snapshot != null)
     {
         TestTip.Inst.ShowText("Snapshot hasPendingWrites: " + snapshot.hasPendingWrites());
         TestTip.Inst.ShowText("Snapshot isFromCloud: " + snapshot.isFromCloud());
         TestTip.Inst.ShowText("Snapshot getSnapshotObjects: " + snapshot.getSnapshotObjects().size());
         TestTip.Inst.ShowText("Snapshot getDeletedObjects: " + snapshot.getDeletedObjects().size());
         TestTip.Inst.ShowText("Snapshot getUpsertedObjects: " + snapshot.getUpsertedObjects().size());
     }
 }
    private void ProcessQueryResult(CloudDBZoneSnapshot <BookInfo> snapshot)
    {
        CloudDBZoneObjectList <BookInfo> bookInfoCursor = snapshot.GetSnapshotObjects();

        bookInfoList = new List <BookInfo>();
        try {
            while (bookInfoCursor.HasNext())
            {
                BookInfo bookInfo = bookInfoCursor.Next();
                bookInfoList.Add(bookInfo);
                Debug.Log($"{TAG} bookInfoCursor.HasNext() {bookInfo.Id}  {bookInfo.Author}");
            }
        } catch (Exception e) {
            Debug.Log($"{TAG} processQueryResult:  Exception => " + e.Message);
        } finally {
            snapshot.Release();
        }
    }
        private void processQueryResult(CloudDBZoneSnapshot <BookInfo> snapshot, string tag)
        {
            mObjectList = snapshot.getSnapshotObjects();
            List <BookInfo> bookInfoList = new List <BookInfo> ();

            try {
                string result = "";
                while (mObjectList.hasNext())
                {
                    BookInfo bookInfo = mObjectList.next();
                    bookInfoList.add(bookInfo);
                    result += $"{bookInfo.BookName} ";
                }
                TestTip.Inst.ShowText($"QueryResult {tag}: {result}");
            } catch (System.Exception e) {
                TestTip.Inst.ShowText($"QueryResult {tag}: {e.Message}");
            } finally {
                snapshot.release();
            }
        }
 private void OnExecuteQuerySuccess(CloudDBZoneSnapshot <BookInfo> snapshot) => ProcessQueryResult(snapshot);