public NotificationManager(ISettingsController aSettingsController){
			theCouchClient = new CouchClient(aSettingsController.Host, aSettingsController.Port, aSettingsController.Username, aSettingsController.Password);
			theCouchDatabase = theCouchClient.GetDatabase(aSettingsController.DatabaseName);
			theOptions = new ChangeOptions();
			theOptions.Heartbeat = 10000;
			theOptions.Since = GetSequence();
		}
示例#2
0
 private void DatabaseLoaded()
 {
     if (theDatabase != null)
     {
         Items.Clear();
         ChangeOptions changes = new ChangeOptions();
         changes.Heartbeat = 10000;
         changes.Since = GetSequence();
         theContinuousChangeManager = theDatabase.GetCoutinuousChanges(changes, (x, y) => BeginInvoke((MethodInvoker)(() => OnContactChanged(y))));
     }
 }
示例#3
0
    /// <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" );
    }