Ejemplo n.º 1
0
    void ProcessRows(QueryEnumerator rows)
    {
        foreach (var row in rows)
        {
            GameObject obj;
            var        foundObj = _spheres.TryGetValue(row.DocumentId, out obj);

            if (row.Document.Deleted)
            {
                if (foundObj)
                {
                    // Remove obj.
                    Destroy(obj);
                    _spheres.Remove(row.DocumentId);
                }
            }
            else
            {
                if (foundObj)
                {
                    // Update obj.
                    obj.GetComponent <CouchbaseSphere>().RestoreFromDocument(row.Document);
                }
                else
                {
                    var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    sphere.AddComponent <SphereCollider> ();
                    sphere.AddComponent <DraggableSphere> ();
                    sphere.AddComponent <CouchbaseSphere>().RestoreFromDocument(row.Document);
                    _spheres[row.DocumentId] = sphere;
                }
            }
        }
    }
Ejemplo n.º 2
0
        private int GetCurrentSelectedPosition(QueryEnumerator enumerator)
        {
            if (enumerator == null)
            {
                return(-1);
            }
            var    application   = (Application)Activity.Application;
            string currentListId = application.GetCurrentListId();

            if (currentListId == null)
            {
                return(enumerator.Count() > 0 ? 0 : -1);
            }
            int position = 0;

            foreach (var row in enumerator)
            {
                if (currentListId.Equals(row.Document.Id))
                {
                    break;
                }
                ++position;
            }
            return(position);
        }
Ejemplo n.º 3
0
 public ListsAdapter(ListDrawerFragment _enclosing, Context context, QueryEnumerator
                     enumerator)
 {
     this._enclosing = _enclosing;
     this.context    = context;
     this.enumerator = enumerator;
 }
Ejemplo n.º 4
0
        internal static XDocument QueryEnumeratorToXml(QueryEnumerator queryEnumerator)
        {
            var       json = QueryEnumeratorToJson(queryEnumerator);
            XDocument xml  = C8oFullSyncTranslator.FullSyncJsonToXml(json);

            return(xml);
        }
        public virtual void ReloadFromQuery()
        {
            var enumerator = Query.Rows;

            if (enumerator == null)
            {
                return;
            }

            var oldRows = Rows;

            Rows = new QueryEnumerator(enumerator);

            var evt = WillReload;

            if (evt != null)
            {
                var args = new ReloadEventArgs(Query);
                evt(this, args);
            }

            var reloadEvt = Reload;

            if (reloadEvt != null)
            {
                var args = new ReloadEventArgs(Query, oldRows);
                reloadEvt(this, args);
            }
            else
            {
                TableView.ReloadData();
            }
        }
Ejemplo n.º 6
0
 public virtual void Update(QueryEnumerator enumerator)
 {
     ((Activity)this.context).RunOnUiThread(new Action(() =>
     {
         this.enumerator = enumerator;
         NotifyDataSetChanged();
     }));
 }
Ejemplo n.º 7
0
        private void UpdateDataContextSync(QueryEnumerator results)
        {
            var rows = results.Select(row => row.Document);

            Todos.Clear();
            foreach (var row in rows)
            {
                Todos.Add(row);
            }
        }
Ejemplo n.º 8
0
        private static void WaitForSDKUpdates(TestDatabase[] testDbs, TimeSpan timeout)
        {
            var    sw             = Stopwatch.StartNew();
            double timeoutSeconds = timeout.TotalSeconds;

            while (true)
            {
                var elapsedSeconds = sw.Elapsed.TotalSeconds;
                Console.WriteLine($"Elapsed: {elapsedSeconds}s, Timeout: {timeoutSeconds}s");
                if (elapsedSeconds > timeoutSeconds)
                {
                    // If timeout has been hit, and not all of the docs have been found, throw exception
                    throw new Exception("Could not find all updates before timeout");
                }


                int dbsWithExpectedDocs = 0;
                Console.WriteLine("Scanning local databases for expected updates ...");
                foreach (var testdb in testDbs)
                {
                    int             sdkUpdatedCount = 0;
                    Query           query           = testdb.Database.CreateAllDocumentsQuery();
                    QueryEnumerator queryRows       = query.Run();
                    foreach (var row in queryRows)
                    {
                        var docProps = row.Document.Properties;
                        if (docProps.ContainsKey("sdk_touched"))
                        {
                            sdkUpdatedCount += 1;
                        }
                    }

                    // Check to see if all of the sdk updates replicated
                    if (sdkUpdatedCount == testdb.ExpectedNumDocs)
                    {
                        Console.WriteLine($" Found all expected SDK updates for '{testdb.UserName}' ({sdkUpdatedCount})");
                        dbsWithExpectedDocs += 1;
                    }
                    else
                    {
                        Console.WriteLine($"Missing updates for '{testdb.UserName}'. (Found: {sdkUpdatedCount}, Expected: {testdb.ExpectedNumDocs})");
                    }
                }

                if (dbsWithExpectedDocs == testDbs.Length)
                {
                    // All docs were found! Exit the loop
                    Console.WriteLine("Found all sdk updates!\n");
                    break;
                }

                Console.WriteLine("Could not find all expected updates. Retrying ...\n");
                Thread.Sleep(5000);
            }
        }
Ejemplo n.º 9
0
        public ConversationListViewAdapter(Context context, LiveQuery query)
        {
            this.Context   = context;
            this.query     = query;
            query.Changed += (sender, e) => {
                enumerator = e.Rows;
                ((Activity)context).RunOnUiThread(new Action(NotifyDataSetChanged));
            };

            //TODO: Revise
            query.Start();
        }
Ejemplo n.º 10
0
        public static List <T> ToList <T>(this QueryEnumerator query)
        {
            var collection = new List <T>();

            foreach (QueryRow obj in query)
            {
                var str = JsonConvert.SerializeObject(obj.Document.Properties);
                var n   = JsonConvert.DeserializeObject <T>(str);
                collection.Add(n);
            }
            return(collection);
        }
Ejemplo n.º 11
0
        /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
        public virtual void TestViewReducePerformance()
        {
            long  startMillis = Runtime.CurrentTimeMillis();
            Query query       = database.GetView("vacant").CreateQuery();

            query.SetMapOnly(false);
            QueryEnumerator rowEnum = query.Run();
            QueryRow        row     = rowEnum.GetRow(0);

            Log.V("PerformanceStats", Tag + ":testViewReducePerformance," + Sharpen.Extensions.ValueOf
                      (Runtime.CurrentTimeMillis() - startMillis).ToString() + "," + GetNumberOfDocuments
                      ());
        }
Ejemplo n.º 12
0
 public static Couchbase.Lite.Document GetUserProfileById(Database database, string
                                                          userId)
 {
     Couchbase.Lite.Document profile = null;
     try
     {
         QueryEnumerator enumerator = Profile.GetQueryById(database, userId).Run();
         profile = enumerator != null && enumerator.GetCount() > 0 ? enumerator.GetRow(0).
                   GetDocument() : null;
     }
     catch (CouchbaseLiteException)
     {
     }
     return(profile);
 }
Ejemplo n.º 13
0
 public LiveQueryAdapter(Context context, LiveQuery query)
 {
     this.context   = context;
     this.query     = query;
     query.Changed += async(sender, e) => {
         enumerator = e.Rows;
         var evt = DataSetChanged;
         if (evt == null)
         {
             return;
         }
         ((Activity)context).RunOnUiThread(new Action(() => evt(e)));
     };
     //TODO: Revise
     query.Start();
 }
Ejemplo n.º 14
0
        protected virtual IEnumerator <T> GetEnumerator(DbBuffering buffering, T target = default(T))
        {
            //TODO: Target is going to be assigned to the wrong record for ElementAt and Take because it always uses the first
            // in querybuilder, we always select the first one directly.

            var enumerator = new QueryEnumerator <T>(Context.Connection, Context.DataStorageController, GetQuery());

            enumerator.Buffered = buffering;
            enumerator.Target   = Target;

            // Do not assign OnLoad event in QueryT because this should only run for nontyped/nonbound objects
            // Override in QueryBuilderT to assign the event handler.

            Enumerator = enumerator;
            return(enumerator);
        }
Ejemplo n.º 15
0
        private static void WaitForImport(TestDatabase[] testDbs, TimeSpan timeout)
        {
            var    sw             = Stopwatch.StartNew();
            double timeoutSeconds = timeout.TotalSeconds;

            while (true)
            {
                var elapsedSeconds = sw.Elapsed.TotalSeconds;
                Console.WriteLine($"Elapsed: {elapsedSeconds}s, Timeout: {timeoutSeconds}s");
                if (elapsedSeconds > timeoutSeconds)
                {
                    // If timeout has been hit, and not all of the docs have been found, throw exception
                    throw new Exception("Could not find all docs before timeout");
                }

                Console.WriteLine("Scanning local databases for expected docs ...");

                var dbsWithExpectedDocs = 0;
                foreach (var testDb in testDbs)
                {
                    Query           query     = testDb.Database.CreateAllDocumentsQuery();
                    QueryEnumerator queryRows = query.Run();
                    int             docCount  = queryRows.Count;
                    // Check that each db has the expected number of docs
                    if (docCount == testDb.ExpectedNumDocs)
                    {
                        Console.WriteLine($" Found all expected docs for '{testDb.UserName}' ({docCount})");
                        dbsWithExpectedDocs += 1;
                    }
                    else
                    {
                        Console.WriteLine($"Missing docs for '{testDb.UserName}'. (Found: {docCount}, Expected: {testDb.ExpectedNumDocs})");
                    }
                }

                if (dbsWithExpectedDocs == testDbs.Length)
                {
                    // All docs were found! Exit the loop
                    Console.WriteLine("Found all docs");
                    break;
                }

                // Docs not found
                Console.WriteLine("Missing docs. Will retry in 5 seconds ...\n");
                Thread.Sleep(5000);
            }
        }
Ejemplo n.º 16
0
        private void ReadHistoryData()
        {
            Database database = Couchbase.Lite.Manager.SharedInstance.GetDatabase(RunData.LOCAL_DB_NAME);

            if (mHistory.Count != database.GetDocumentCount())
            {
                mHistory = new List <RunData>();

                QueryEnumerator enumerator = database.CreateAllDocumentsQuery().Run();
                foreach (QueryRow row in enumerator)
                {
                    mHistory.Add(new RunData(row.Document.Properties));
                }

                listHistory.ItemsSource = mHistory;
            }
        }
Ejemplo n.º 17
0
        //*** QueryEnumerator ***//
        //*** GetAllDocuments ***//

        internal static JObject QueryEnumeratorToJson(QueryEnumerator queryEnumerator)
        {
            var json      = new JObject();
            var rowsArray = new JArray();

            var queryRows = queryEnumerator.GetEnumerator();

            while (queryRows.MoveNext())
            {
                var queryRow     = queryRows.Current;
                var queryRowJson = C8oFullSyncTranslator.DictionaryToJson(queryRow.AsJSONDictionary());
                rowsArray.Add(queryRowJson);
            }

            json[C8oFullSyncTranslator.FULL_SYNC_RESPONSE_KEY_COUNT] = queryEnumerator.Count;
            json[C8oFullSyncTranslator.FULL_SYNC_RESPONSE_KEY_ROWS]  = rowsArray;

            return(json);
        }
Ejemplo n.º 18
0
        private string GetCurrentListId()
        {
            var    application   = (CouchbaseSample.Android.Application)Application;
            string currentListId = application.GetCurrentListId();

            if (currentListId == null)
            {
                try
                {
                    QueryEnumerator enumerator = List.GetQuery(GetDatabase()).Run();
                    if (enumerator.Count() > 0)
                    {
                        currentListId = enumerator.GetRow(0).Document.Id;
                    }
                }
                catch (CouchbaseLiteException)
                {
                }
            }
            return(currentListId);
        }
Ejemplo n.º 19
0
        /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
        public virtual void TestViewQueryPerformance()
        {
            long  startMillis = Runtime.CurrentTimeMillis();
            Query query       = database.GetView("vacant").CreateQuery();

            query.SetDescending(false);
            query.SetMapOnly(true);
            QueryEnumerator rowEnum = query.Run();
            object          key;
            object          value;

            while (rowEnum.HasNext())
            {
                QueryRow row = rowEnum.Next();
                key   = (string)row.GetKey();
                value = (bool)row.GetValue();
            }
            Log.V("PerformanceStats", Tag + ":testViewQueryPerformance," + Sharpen.Extensions.ValueOf
                      (Runtime.CurrentTimeMillis() - startMillis).ToString() + "," + GetNumberOfDocuments
                      ());
        }
Ejemplo n.º 20
0
        private static void TouchAllDocs(TestDatabase[] testDbs)
        {
            foreach (var testDb in testDbs)
            {
                Query           query     = testDb.Database.CreateAllDocumentsQuery();
                QueryEnumerator queryRows = query.Run();
                int             docCount  = queryRows.Count;

                foreach (QueryRow row in queryRows)
                {
                    Document doc = testDb.Database.GetExistingDocument(row.DocumentId);
                    Console.WriteLine($"Touching: {row.DocumentId}");
                    doc.Update((UnsavedRevision newRevision) =>
                    {
                        var properties             = newRevision.Properties;
                        properties["lite_touched"] = true;
                        return(true);
                    });
                }
            }
        }
 private int GetCurrentSelectedPosition(QueryEnumerator enumerator)
 {
     if (enumerator == null)
     {
         return -1;
     }
     var application = (Application)Activity.Application;
     string currentListId = application.GetCurrentListId();
     if (currentListId == null)
     {
         return enumerator.Count() > 0 ? 0 : -1;
     }
     int position = 0;
     foreach(var row in enumerator)
     {
         if (currentListId.Equals(row.Document.Id))
         {
             break;
         }
         ++position;
     }
     return position;
 }
Ejemplo n.º 22
0
        /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
        public static void AssignOwnerToListsIfNeeded(Database database, Couchbase.Lite.Document
                                                      user)
        {
            QueryEnumerator enumerator = GetQuery(database).Run();

            if (enumerator == null)
            {
                return;
            }
            foreach (var row in enumerator)
            {
                Couchbase.Lite.Document document = row.Document;
                string owner = (string)document.GetProperty("owner");
                if (owner != null)
                {
                    continue;
                }
                IDictionary <string, object> properties = new Dictionary <string, object>();
                properties.PutAll(document.Properties);
                properties.Put("owner", user.Id);
                document.PutProperties(properties);
            }
        }
        public virtual void ReloadFromQuery ()
        {
            var enumerator = Query.Rows;
            if (enumerator == null) return;

            var oldRows = Rows;
            Rows = new QueryEnumerator(enumerator);

            var evt = WillReload;
            if (evt != null)
            {
                var args = new ReloadEventArgs(Query);
                evt(this, args);
            }

            var reloadEvt = Reload;
            if (reloadEvt != null) {
                var args = new ReloadEventArgs(Query, oldRows);
                reloadEvt(this, args);
            } else {
                TableView.ReloadData();
            }
        }
Ejemplo n.º 24
0
        public CouchDbGeoObjectsService()
        {
            var url  = new Uri("http://104.236.29.68:4985/sync_gateway/");
            var auth = AuthenticatorFactory.CreateBasicAuthenticator("mobile", "123123");

            var pull = _db.CreatePullReplication(url);

            pull.Continuous    = true;
            pull.Channels      = new[] { "geo" };
            pull.Authenticator = auth;
            pull.Start();

            var view = _db.GetView("geo");

            view.SetMap((document, emit) =>
            {
                if (document.ContainsKey("geometry") && document.ContainsKey("name"))
                {
                    emit(new[] { document["geometry"] }, document);
                }
            }, "1");

            _docs = view.CreateQuery().Run();
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Implements the updating of the <see cref="Rows"/> collection.
        /// </summary>
        private void Update()
        {
            lock(updateLock)
            {
                Log.D(Tag, "update() called.");

                if (View == null)
                {
                    throw new CouchbaseLiteException("Cannot start LiveQuery when view is null");
                }

                if (!runningState)
                {
                    Log.D(Tag, "update() called, but running state == false.  Ignoring.");
                    return;
                }

                if (UpdateQueryTask != null &&
                    UpdateQueryTask.Status != TaskStatus.Canceled && 
                    UpdateQueryTask.Status != TaskStatus.RanToCompletion)
                {
                    Log.D(Tag, "already a query in flight, scheduling call to update() once it's done");
                    if (ReRunUpdateQueryTask != null &&
                        ReRunUpdateQueryTask.Status != TaskStatus.Canceled && 
                        ReRunUpdateQueryTask.Status != TaskStatus.RanToCompletion)
                    {
                        ReRunUpdateQueryTokenSource.Cancel();
                        Log.D(Tag, "cancelled rerun update query token source.");
                    }

                    var updateQueryTaskToWait = UpdateQueryTask;
                    var updateQueryTaskToWaitTokenSource = UpdateQueryTokenSource;

                    ReRunUpdateQueryTokenSource = new CancellationTokenSource();
                    Database.Manager.RunAsync(() => 
                    { 
                        RunUpdateAfterQueryFinishes(updateQueryTaskToWait, updateQueryTaskToWaitTokenSource); 
                    }, ReRunUpdateQueryTokenSource.Token);

                    Log.D(Tag, "RunUpdateAfterQueryFinishes() is fired.");

                    return;
                }

                UpdateQueryTokenSource = new CancellationTokenSource();

                UpdateQueryTask = RunAsync(base.Run, UpdateQueryTokenSource.Token)
                    .ContinueWith(runTask =>
                    {
                        if (runTask.Status != TaskStatus.RanToCompletion) {
                            Log.W(String.Format("Query Updated task did not run to completion ({0})", runTask.Status), runTask.Exception);
                            return; // NOTE: Assuming that we don't want to lose rows we already retrieved.
                        }

                        rows = runTask.Result; // NOTE: Should this be 'append' instead of 'replace' semantics? If append, use a concurrent collection.
                        LastError = runTask.Exception;

                        var evt = Changed;
                        if (evt == null)
                            return; // No delegates were subscribed, so no work to be done.

                        var args = new QueryChangeEventArgs (this, rows, LastError);
                        evt (this, args);
                    }, Database.Manager.CapturedContext.Scheduler);
            }
        }
Ejemplo n.º 26
0
			public void Completed(QueryEnumerator rows, Exception error)
			{
				Log.I(LiteTestCase.Tag, "Async query finished!");
				NUnit.Framework.Assert.IsNotNull(rows);
				NUnit.Framework.Assert.IsNull(error);
				NUnit.Framework.Assert.AreEqual(rows.GetCount(), 11);
				int expectedKey = 23;
				for (IEnumerator<QueryRow> it = rows; it.HasNext(); )
				{
					QueryRow row = it.Next();
					NUnit.Framework.Assert.AreEqual(row.GetDocument().GetDatabase(), db);
					NUnit.Framework.Assert.AreEqual(row.GetKey(), expectedKey);
					++expectedKey;
				}
				doneSignal.CountDown();
			}
 private void UpdateDataContextSync(QueryEnumerator results)
 {
     var rows = results.Select(row => row.Document);
     Todos.Clear();
     foreach (var row in rows) {
         Todos.Add(row);
     }
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="query">The query being used to drive the source that has been reloaded</param>
 /// <param name="rows">The result rows, or null</param>
 public ReloadEventArgs(Query query, QueryEnumerator rows = null)
 {
     Query = query;
     Rows  = rows;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="query">The query being used to drive the source that has been reloaded</param>
 /// <param name="rows">The result rows, or null</param>
 public ReloadEventArgs(Query query, QueryEnumerator rows = null)
 {
     Query = query;
     Rows = rows;
 }
 public ListsAdapter(ListDrawerFragment _enclosing, Context context, QueryEnumerator
      enumerator)
 {
     this._enclosing = _enclosing;
     this.context = context;
     this.enumerator = enumerator;
 }
Ejemplo n.º 31
0
			public void Run()
			{
				try
				{
					if (!this._enclosing.GetDatabase().IsOpen())
					{
						throw new InvalidOperationException("The database has been closed.");
					}
					string viewName = this._enclosing.view.GetName();
					QueryOptions options = this._enclosing.GetQueryOptions();
					IList<long> outSequence = new AList<long>();
					IList<QueryRow> rows = this._enclosing.database.QueryViewNamed(viewName, options, 
						outSequence);
					long sequenceNumber = outSequence[0];
					QueryEnumerator enumerator = new QueryEnumerator(this._enclosing.database, rows, 
						sequenceNumber);
					onComplete.Completed(enumerator, null);
				}
				catch (Exception t)
				{
					onComplete.Completed(null, t);
				}
			}
 public virtual void Update(QueryEnumerator enumerator)
 {
     ((Activity)this.context).RunOnUiThread(new Action(() =>
         {
             this.enumerator = enumerator;
             NotifyDataSetChanged();
         }));
 }
Ejemplo n.º 33
0
        private static void BuildLookup(QueryEnumerator rows)
        {
            lock (emailLookup)
            {
                emailLookup.Clear ();

                foreach (var row in rows)
                {
                    string key = (string)row.Value;

                    if (emailLookup.ContainsKey(key))
                        emailLookup [key] = (string)row.Key;
                    else
                        emailLookup.Add (key, (string)row.Key);
                }
            }
        }
	void ProcessRows(QueryEnumerator rows)
	{
		foreach(var row in rows) {
			GameObject obj;
			var foundObj = _spheres.TryGetValue(row.DocumentId, out obj);

			if (row.Document.Deleted) {
				if (foundObj)
				{
					// Remove obj.
					Destroy(obj);
					_spheres.Remove(row.DocumentId);
				}
			} else {
				if (foundObj) {
					// Update obj.
					obj.GetComponent<CouchbaseSphere>().RestoreFromDocument(row.Document);
				} else {
					var sphere = GameObject.CreatePrimitive (PrimitiveType.Sphere);
					sphere.AddComponent<SphereCollider> ();
					sphere.AddComponent<DraggableSphere> ();
					sphere.AddComponent<CouchbaseSphere>().RestoreFromDocument(row.Document);
					_spheres[row.DocumentId] = sphere;
				}
			}
		}
	}
Ejemplo n.º 35
0
 internal QueryChangeEventArgs (LiveQuery liveQuery, QueryEnumerator enumerator, Exception error)
 {
     Source = liveQuery;
     Rows = enumerator;
     Error = error;
 }
Ejemplo n.º 36
0
        /// <summary>Sends the query to the server and returns an enumerator over the result rows (Synchronous).
        ///     </summary>
        /// <remarks>
        /// Sends the query to the server and returns an enumerator over the result rows (Synchronous).
        /// Note: In a CBLLiveQuery you should add a ChangeListener and call start() instead.
        /// </remarks>
        /// <exception cref="Couchbase.Lite.CouchbaseLiteException"></exception>
        public override QueryEnumerator Run()
        {
            while (true) {
                try {
                    if (UpdateQueryTask.Status != TaskStatus.Canceled || UpdateQueryTask.Status != TaskStatus.RanToCompletion) {
                        Log.To.Query.W(TAG, "Run called white update query task still running.");
                    }
                    WaitForRows();
                    break;
                } catch (OperationCanceledException) { //TODO: Review
                    Log.To.Query.V(TAG, "Run() caught OperationCanceledException, retrying...");
                    continue;
                } catch (Exception e) {
                    LastError = e;
                    _rows = null;
                    Log.To.Query.W(TAG, "Exception caught during Run(), returning null...", e);
                }
            }

            return _rows == null ? null : new QueryEnumerator (_rows);
        }
Ejemplo n.º 37
0
        private void UpdateFinished(Task<QueryEnumerator> runTask)
        {
            _isUpdatingAtSequence = 0;

            if (UpdateQueryTokenSource.IsCancellationRequested)
                return;

            UpdateQueryTask = null;
            if (_updateAgain) {
                Update();
            }

            if (runTask.Status != TaskStatus.RanToCompletion) {
                Log.W(String.Format("Query Updated task did not run to completion ({0})", runTask.Status), runTask.Exception);
                return; // NOTE: Assuming that we don't want to lose rows we already retrieved.
            }

            _rows = runTask.Result; // NOTE: Should this be 'append' instead of 'replace' semantics? If append, use a concurrent collection.
            Log.D(TAG, "UpdateQueryTask results obtained.");
            LastError = runTask.Exception;

            var evt = _changed;
            if (evt == null)
                return; // No delegates were subscribed, so no work to be done.

            var args = new QueryChangeEventArgs (this, _rows, LastError);
            evt (this, args);
        }
Ejemplo n.º 38
0
 internal ChangeEvent(LiveQuery source, QueryEnumerator queryEnumerator)
 {
     this.source = source;
     this.queryEnumerator = queryEnumerator;
 }
Ejemplo n.º 39
0
			public void Completed(QueryEnumerator rowsParam, Exception error)
			{
				if (error != null)
				{
					foreach (LiveQuery.ChangeListener observer in this._enclosing.observers)
					{
						observer.Changed(new LiveQuery.ChangeEvent(error));
					}
					this._enclosing.lastError = error;
				}
				else
				{
					if (rowsParam != null && !rowsParam.Equals(this._enclosing.rows))
					{
						this._enclosing.SetRows(rowsParam);
						foreach (LiveQuery.ChangeListener observer in this._enclosing.observers)
						{
							Log.D(Database.Tag, this._enclosing + ": update() calling back observer with rows"
								);
							observer.Changed(new LiveQuery.ChangeEvent(this._enclosing, this._enclosing.rows)
								);
						}
					}
					this._enclosing.lastError = null;
				}
			}
Ejemplo n.º 40
0
 public void Completed(QueryEnumerator rowsParam, Exception error)
 {
     if (error != null)
     {
         foreach (LiveQuery.ChangeListener observer in this._enclosing.observers)
         {
             observer.Changed(new LiveQuery.ChangeEvent(error));
         }
         this._enclosing.lastError = error;
     }
     else
     {
         if (this._enclosing.runningState.Get() == false)
         {
             Log.D(Log.TagQuery, "%s: update() finished query, but running state == false.", this
                 );
             return;
         }
         if (rowsParam != null && !rowsParam.Equals(this._enclosing.rows))
         {
             this._enclosing.SetRows(rowsParam);
             foreach (LiveQuery.ChangeListener observer in this._enclosing.observers)
             {
                 Log.D(Log.TagQuery, "%s: update() calling back observer with rows", this._enclosing
                     );
                 observer.Changed(new LiveQuery.ChangeEvent(this._enclosing, this._enclosing.rows)
                     );
             }
         }
         this._enclosing.lastError = null;
     }
 }
Ejemplo n.º 41
0
 private void SetRows(QueryEnumerator queryEnumerator)
 {
     lock (this)
     {
         rows = queryEnumerator;
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Couchbase.Lite.QueryCompletedEventArgs"/> class.
 /// </summary>
 /// <param name="rows">Rows.</param>
 /// <param name="errorInfo">Error info.</param>
 public QueryCompletedEventArgs(QueryEnumerator rows, Exception errorInfo) {
     Rows = rows;
     ErrorInfo = errorInfo;
 }