Ejemplo n.º 1
0
 private void CloseAndDeleteTemporaryFiles()
 {
     try
     {
         if (_worker != null && _worker.IsBusy)
         {
             _worker.CancelAsync(); //tell it to stop
         }
         _openedModelFileName = null;
         if (_model == null)
         {
             return;
         }
         _model.Dispose();
         _model = null;
     }
     finally
     {
         if (!(_worker != null && _worker.IsBusy && _worker.CancellationPending)) //it is still busy but has been cancelled
         {
             if (!string.IsNullOrWhiteSpace(_temporaryXbimFileName) && File.Exists(_temporaryXbimFileName))
             {
                 File.Delete(_temporaryXbimFileName);
             }
             _temporaryXbimFileName = null;
         } //else do nothing it will be cleared up in the worker thread
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Dispose method, close host model, and run through referencedModel list in the XBimModel itself and close all referenced models
        /// </summary>
        public void Dispose()
        {
            if (_fedModel != null)
            {
                //TODO:  hate this work around to avoid header Object set to null in XBimModel Close method, but small file so time hit limited
                //Check with steve as to why header set to null

                //save the xbim model back to a temp ifc
                //string tempFile = Path.GetTempFileName();
                //tempFile = Path.ChangeExtension(tempFile, ".ifc");
                //_fedModel.SaveAs(tempFile, XbimExtensions.Interfaces.XbimStorageType.IFC);

                //dispose of fed xbim databse
                _fedModel.Close();   //will close referenced models as well
                _fedModel.Dispose(); //might not need this, as close method can call dispose
                _fedModel = null;

                //create new xbimf database from temp file ifc
                //using (var model = new XbimModel())
                //{
                //    model.CreateFrom(tempFile, FileNameXbimf.FullName, null, true, true);
                //}
                //if (File.Exists(tempFile))
                //{
                //    File.Delete(tempFile);
                //}
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Tidies up any open files and closes any open models
 /// </summary>
 private void CloseAndDeleteTemporaryFiles()
 {
     try
     {
         if (_worker != null && _worker.IsBusy)
         {
             _worker.CancelAsync(); //tell it to stop
         }
         XbimModel model = ModelProvider.ObjectInstance as XbimModel;
         _openedModelFileName = null;
         if (model != null)
         {
             model.Dispose();
             ModelProvider.ObjectInstance = null;
             ModelProvider.Refresh();
         }
     }
     finally
     {
         if (!(_worker != null && _worker.IsBusy && _worker.CancellationPending)) //it is still busy but has been cancelled
         {
             if (!string.IsNullOrWhiteSpace(_temporaryXbimFileName) && File.Exists(_temporaryXbimFileName))
             {
                 File.Delete(_temporaryXbimFileName);
             }
             _temporaryXbimFileName = null;
         } //else do nothing it will be cleared up in the worker thread
     }
 }
Ejemplo n.º 4
0
 internal void Dispose()
 {
     Model.Dispose();
 }