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); } }
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(); } }
public void deleteBookInfo() { if (mCloudDBZone == null) { TestTip.Inst.ShowText("CloudDBZone is null, try re-open it"); return; } mQuery = CloudDBZoneQuery.where (new AndroidJavaClass(bookInfoClass)); Task queryTask = mCloudDBZone.executeQuery(mQuery, CloudDBZoneQuery.CloudDBZoneQueryPolicy.POLICY_QUERY_FROM_CLOUD_ONLY); queryTask.addOnSuccessListener(new HmsSuccessListener <CloudDBZoneSnapshot <BookInfo> > ((snapshot) => { mObjectList = snapshot.getSnapshotObjects(); BookInfo bookInfo = mObjectList.get(3); Task deleteTask = mCloudDBZone.executeDelete(bookInfo); deleteTask.addOnSuccessListener(new HmsSuccessListener <int> ((cloudDBZoneResult) => { TestTip.Inst.ShowText("delete " + cloudDBZoneResult + " records"); })).addOnFailureListener(new HmsFailureListener((exception) => { TestTip.Inst.ShowText("delete bookinfo failed: " + exception.toString()); })); List <BookInfo> list = new List <BookInfo> (); list.add(mObjectList.get(4)); list.add(mObjectList.get(5)); Task deleteTask2 = mCloudDBZone.executeDelete(list); deleteTask2.addOnSuccessListener(new HmsSuccessListener <int> ((cloudDBZoneResult) => { TestTip.Inst.ShowText("delete " + cloudDBZoneResult + " records"); })).addOnFailureListener(new HmsFailureListener((exception) => { TestTip.Inst.ShowText("delete bookinfo failed: " + exception.toString()); })); })).addOnFailureListener(new HmsFailureListener((exception) => { TestTip.Inst.ShowText("Query book list from cloud failed: " + exception.toString()); })); }
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(); } }