public void GetChanges() { if (client.HasDatabase("test_changes")) { client.DeleteDatabase("test_changes"); } var db = client.GetDatabase("test_changes"); db.CreateDocument(null, "{}", new Result <string>()).Wait(); CouchChanges changes = db.GetChanges(new ChangeOptions(), new Result <CouchChanges>()).Wait(); Assert.AreEqual(1, changes.Results.Length); Assert.IsNotNull(changes.Results[0].Changes); Assert.IsNotNull(changes.Results[0].Id); Assert.IsNotNull(changes.Results[0].Sequence); }
/// <summary> /// Determine whether the given sequence number /// matches the most up-to-date status. /// </summary> public bool LastSequenceNumberChanged(int since) { using (JtTimer pt = new JtTimer( "LastSequenceNumberChanged")) { ChangeOptions opt = new ChangeOptions(); opt.Since = since; opt.IncludeDocs = false; CouchChanges <DbFurniture> changes = _db.GetChanges <DbFurniture>(opt); CouchChangeResult <DbFurniture> r = changes.Results.LastOrDefault < CouchChangeResult <DbFurniture> >(); Debug.Assert(null == r || since < r.Sequence, "expected monotone growing sequence number"); return(null != r && since < r.Sequence); } }
/// <summary> /// Apply all current cloud database /// changes to the BIM. /// </summary> public void UpdateBim() { Util.Log("UpdateBim begin"); using (JtTimer pt = new JtTimer("UpdateBim")) { Document doc = _uiapp.ActiveUIDocument.Document; // Retrieve all room unique ids in model: FilteredElementCollector rooms = new FilteredElementCollector(doc) .OfClass(typeof(SpatialElement)) .OfCategory(BuiltInCategory.OST_Rooms); IEnumerable <string> roomUniqueIds = rooms.Select <Element, string>( e => e.UniqueId); // Convert to a dictionary for faster lookup: _roomUniqueIdDict = new Dictionary <string, int>( roomUniqueIds.Count()); foreach (string s in roomUniqueIds) { _roomUniqueIdDict.Add(s, 1); } //string ids = "?keys=[%22" + string.Join( // "%22,%22", roomUniqueIds ) + "%22]"; // Retrieve all furniture transformations // after the last sequence number: CouchDatabase db = new RoomEditorDb().Db; ChangeOptions opt = new ChangeOptions(); opt.IncludeDocs = true; opt.Since = LastSequence; opt.View = "roomedit/map_room_to_furniture"; // I tried to add a filter to this view, but // that is apparently not supported by the // CouchDB or DreamSeat GetChanges functionality. //+ ids; // failed attempt to filter view by room id keys // Specify filter function defined in // design document to get updates //opt.Filter = CouchChanges <DbFurniture> changes = db.GetChanges <DbFurniture>(opt); CouchChangeResult <DbFurniture>[] results = changes.Results; foreach (CouchChangeResult <DbFurniture> result in results) { UpdateBimFurniture(result.Doc); LastSequence = result.Sequence; } } Util.Log("UpdateBim end"); }