/// <summary> /// <para> /// Initialize a new instance of the <see cref="InstanceNode"/> class with a <see cref="InstanceData"/> object. /// </para> /// </summary> /// <param name="instance"> /// <para>The <see cref="InstanceData"/> runtime configuration.</para> /// </param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="instance"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para> /// </exception> public InstanceNode(InstanceData instance) : base() { if (instance == null) { throw new ArgumentNullException("instance"); } this.instanceData = instance; this.databaseTypeRemovedHandler = new ConfigurationNodeChangedEventHandler(OnDatabaseTypeNodeRemoved); this.databaseTypeRenamedHandler = new ConfigurationNodeChangedEventHandler(OnDatabaseTypeNodeRenamed); this.connectionStringRemovedHandler = new ConfigurationNodeChangedEventHandler(OnConnectionStringNodeRemoved); this.connectionStringRenamedHandler = new ConfigurationNodeChangedEventHandler(OnConnectionStringNodeRenamed); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; Application app = uiapp.Application; Document doc = uiapp.ActiveUIDocument.Document; Transform projectLocationTransform = Util.GetProjectLocationTransform( doc ); // Loop through all family instance elements // and export their data. FilteredElementCollector instances = new FilteredElementCollector( doc ) .OfClass( typeof( FamilyInstance ) ); Result rc = Result.Succeeded; InstanceData instanceData; int n = 0; foreach( FamilyInstance e in instances ) { Debug.Print( e.Id.IntegerValue.ToString() ); instanceData = new InstanceData( e, projectLocationTransform ); if( !Util.Put( "instances/" + e.UniqueId, instanceData, out message ) ) { rc = Result.Failed; break; } ++n; } Debug.Print( "CompHound uploaded {0} instance{1}.", n, ( 1 == n ? "" : "s" ) ); return rc; }
public void CopyTo(InstanceData[] instances, int index) { base.Dictionary.Values.CopyTo(instances, index); }
internal void Add(string instanceName, InstanceData value) { object key = instanceName.ToLower(CultureInfo.InvariantCulture); base.Dictionary.Add(key, value); }
public void CopyTo(InstanceData[] instances, int index) { Contract.Ensures(this.Dictionary.Values != null); }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void CopyTo(InstanceData[] instances, int index) { Dictionary.Values.CopyTo((Array)instances, index); }
internal void Add(string instanceName, InstanceData value) { object objectName = instanceName.ToLower(CultureInfo.InvariantCulture); Dictionary.Add(objectName, value); }
internal InstanceData(InstanceData previous) { if(previous != null) { previous.next = this; } this.previous = previous; this.next = null; }
private void push(SliceType sliceType) { if(_current == null) { _current = new InstanceData(null); } else { _current = _current.next == null ? new InstanceData(_current) : _current.next; } _current.sliceType = sliceType; _current.skipFirstSlice = false; }
internal override Ice.SlicedData endInstance(bool preserve) { Ice.SlicedData slicedData = null; if(preserve) { slicedData = readSlicedData(); } if(_current.slices != null) { _current.slices.Clear(); _current.indirectionTables.Clear(); } _current = _current.previous; return slicedData; }
private int _valueIdIndex; // The ID of the next instance to unmarshal. #endregion Fields #region Constructors internal EncapsDecoder11(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f, ClassResolver cr, CompactIdResolver r) : base(stream, encaps, sliceValues, f, cr) { _compactIdResolver = r; _current = null; _valueIdIndex = 1; }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; Application app = uiapp.Application; Document doc = uiapp.ActiveUIDocument.Document; if( string.IsNullOrEmpty( doc.PathName ) ) { message = "Please store RVT file " + "before launching this command"; return Result.Failed; } // Retrieve LMV credentials. string client_key; string client_secret; if( !Util.GetLvmCredentials( out client_key, out client_secret ) ) { message = _key_secret_prompt; return Result.Failed; } // Upload and translate model file. // Todo: add linked files as well. ArrayList fileList = new ArrayList(); //fileList.Add( asm.FullFileName ); //fileList.Add( doc.PathName ); // Revit blocks the current file. // Copy it to a location with no spaces in the name. // From then on, the whole upload process could be spawned off into a separate thread. // Well, no, we do need the URN. string filename = Path.Combine( Path.GetTempPath(), Path.GetFileName( doc.PathName ) ); filename.Replace( ' ', '_' ); Debug.Print( filename ); File.Delete( filename ); File.Copy( doc.PathName, filename, true ); fileList.Add( filename ); //foreach( Document oRefDoc in asm.AllReferencedDocuments ) //{ // fileList.Add( oRefDoc.FullDocumentName ); //} MultiFileUploader.Util u = new MultiFileUploader.Util( "https://developer.api.autodesk.com" ); string urn = u.UploadFilesWithReferences( client_key, client_secret, "comphoundrvtbucket", fileList, null, true ); if( string.IsNullOrEmpty( urn ) ) { message = "View and Data API upload and " + "translation failed."; return Result.Failed; } Transform projectLocationTransform = Util.GetProjectLocationTransform( doc ); // Loop through all family instance elements // and export their data. FilteredElementCollector instances = new FilteredElementCollector( doc ) .OfClass( typeof( FamilyInstance ) ); Result rc = Result.Succeeded; InstanceData instanceData; int n = 0; foreach( FamilyInstance e in instances ) { Debug.Print( e.Id.IntegerValue.ToString() ); instanceData = new InstanceData( e, projectLocationTransform, urn ); if( !Util.Put( "instances/" + e.UniqueId, instanceData, out message ) ) { rc = Result.Failed; break; } ++n; } Debug.Print( "CompHound uploaded {0} instance{1}.", n, ( 1 == n ? "" : "s" ) ); return rc; }
internal void Add(string instanceName, InstanceData value) { string objectName = instanceName.ToLowerInvariant(); Dictionary.Add(objectName, value); }
/// <summary> /// PUT JSON document data into /// the specified mongoDB collection. /// </summary> public static bool Put( string collection_name_and_id, InstanceData data, out string result) { var client = new RestClient( RestApiBaseUrl ); var request = new RestRequest( _api_version + "/" + collection_name_and_id, Method.PUT ); request.RequestFormat = DataFormat.Json; // Check what we actually send. //Debug.Print( request.JsonSerializer.Serialize( data ) ); request.AddBody( data ); // uses JsonSerializer // Didn't work for me //request.AddObject( data ); // http://matthewschrager.com/2013/02/19/restsharp-post-body/ // POST params instead of body is more efficient // since there's no serialization to JSON. // But our data is a bit large for that. //request.AddParameter("A", "foo"); //request.AddParameter("B", "bar"); IRestResponse response = client.Execute( request ); bool rc = System.Net.HttpStatusCode.Accepted == response.StatusCode; if( rc ) { result = response.Content; // raw content as string } else { //if( response.ErrorMessage.Equals( // "Unable to connect to the remote server" ) ) // "does the database exist at all?" result = response.ErrorMessage; Debug.Print( "HTTP PUT error: " + result ); } return rc; }
public void CopyTo (InstanceData[] instances, int index) { Dictionary.CopyTo (instances, index); }
// Copy the contents of this collection to an array. public void CopyTo(InstanceData[] array, int index) { ((IDictionary)this).CopyTo(array, index); }