示例#1
0
        /// <summary>
        /// Extract the Created On date from the passed entity
        /// </summary>
        /// <returns></returns>
        protected string GetCreatedOnDateAsFmtString(IIfcOwnerHistory ownerHistory, bool requiresTime = true)
        {
            var date = GetCreatedOnDate(ownerHistory);

            //return default date of now
            return(date ?? (requiresTime ? Context.RunDateTime : Context.RunDate)); //if we don't have a date then use the context date or datetime
        }
示例#2
0
 /// <summary>
 /// Extract the email address lists for the owner of the IfcOwnerHistory passed
 /// </summary>
 /// <param name="ifcOwnerHistory">Entity to extract the email addresses for</param>
 /// <returns>string of comma delimited addresses</returns>
 protected string GetTelecomEmailAddress(IIfcOwnerHistory ifcOwnerHistory)
 {
     if ((ifcOwnerHistory != null) &&
         (ifcOwnerHistory.OwningUser != null) &&
         (ifcOwnerHistory.OwningUser.ThePerson != null)
         )
     {
         var ifcPerson = ifcOwnerHistory.OwningUser.ThePerson;
         if (Context.EMails.ContainsKey(ifcPerson.EntityLabel))
         {
             return(Context.EMails[ifcPerson.EntityLabel]);
         }
         else
         {
             var ifcOrganization = ifcOwnerHistory.OwningUser.TheOrganization;
             var email           = GetEmail(ifcOrganization, ifcPerson);
             //save to the email directory for quick retrieval
             Context.EMails.Add(ifcPerson.EntityLabel, email);
             return(email);
         }
     }
     else if (Context.EMails.Count == 1) //if only one then no contact are probably set up so use as default
     {
         return(Context.EMails.First().Value);
     }
     else
     {
         return(Constants.DEFAULT_EMAIL);
     }
 }
示例#3
0
        protected IfcBuilder(IfcStore aStore, Assembly[] ifcAssemblies, string typeSpace, ILoggerFactory loggerFactory = null) : base(ifcAssemblies)
        {
            // Principle properties
            Log          = loggerFactory?.CreateLogger <IfcBuilder>();
            Store        = aStore;
            IfcTypeSpace = typeSpace;
            // Container stack
            _ContainerScope = new Stack <IIfcObjectDefinition>();
            // Type scopes
            IfcProductScope  = new IfcEntityScope <IIfcProduct>(this);
            IfcPropertyScope = new IfcEntityScope <IIfcProperty>(this);
            IfcValueScope    = new IfcEntityScope <IIfcValue>(this);

            // Initialization
            var project = Store.Instances.OfType <IIfcProject>().FirstOrDefault();

            if (null == project)
            {
                Wrap(s =>
                {
                    project        = InitProject();
                    CurrentVersion = NewOwnerHistoryEntry("Initial contribution");
                });
            }
            else
            {
                Wrap(s => CurrentVersion = NewOwnerHistoryEntry("Adding new data"));
            }
            _ContainerScope.Push(project);
        }
示例#4
0
        public static string GetCreatedOnDate(IIfcOwnerHistory ownerHistory)
        {
            if (ownerHistory != null)
            {
                var createdOnTStamp = (int)ownerHistory.CreationDate;
                if (createdOnTStamp != 0) //assume not set, but could it be 1970/1/1 00:00:00!!!
                {
                    //to remove trailing decimal seconds use a set format string as "o" option is to long.

                    //We have a day light saving problem with the comparison with other COBie Export Programs. if we convert to local time we get a match
                    //but if the time stamp is Coordinated Universal Time (UTC), then daylight time should be ignored. see http://msdn.microsoft.com/en-us/library/bb546099.aspx
                    //IfcTimeStamp.ToDateTime(CreatedOnTStamp).ToLocalTime()...; //test to see if corrects 1 hour difference, and yes it did, but should we?

                    return(IfcTimeStamp.ToDateTime(createdOnTStamp).ToString(Constants.DATETIME_FORMAT));
                }
            }
            return(null);
        }
示例#5
0
        /// <summary>
        /// Gets the name of the application that is linked with the supplied item
        /// </summary>
        /// <param name="ifcOwnerHistory"></param>
        /// <returns></returns>
        public string GetExternalSystem(IIfcOwnerHistory ifcOwnerHistory)
        {
            var appName = "";

            if (ifcOwnerHistory != null)
            {
                if (ifcOwnerHistory.LastModifyingApplication != null)
                {
                    appName = ifcOwnerHistory.LastModifyingApplication.ApplicationFullName;
                }
                if ((string.IsNullOrEmpty(appName)) &&
                    (ifcOwnerHistory.OwningApplication != null)
                    )
                {
                    appName = ifcOwnerHistory.OwningApplication.ApplicationFullName;
                }
            }

            return(string.IsNullOrEmpty(appName) ? DEFAULT_STRING : appName);
        }
示例#6
0
        private ProcessResult ProcessFile(string ifcFile, StreamWriter writer)
        {
            RemoveFiles(ifcFile);
            long geomTime = -1;  long parseTime = -1;

            using (EventTrace eventTrace = LoggerFactory.CreateEventTrace())
            {
                ProcessResult result = new ProcessResult()
                {
                    Errors = -1
                };
                try
                {
                    Stopwatch watch = new Stopwatch();
                    watch.Start();
                    using (var model = ParseModelFile(ifcFile, Params.Caching))
                    {
                        parseTime = watch.ElapsedMilliseconds;
                        string             xbimFilename = BuildFileName(ifcFile, ".xbim");
                        Xbim3DModelContext context      = new Xbim3DModelContext(model);
                        context.CreateContext();
                        //}
                        geomTime = watch.ElapsedMilliseconds - parseTime;
                        //XbimSceneBuilder sb = new XbimSceneBuilder();
                        //string xbimSceneName = BuildFileName(ifcFile, ".xbimScene");
                        //sb.BuildGlobalScene(model, xbimSceneName);
                        // sceneTime = watch.ElapsedMilliseconds - geomTime;
                        IStepFileHeader header = model.Header;
                        watch.Stop();
                        IIfcOwnerHistory ohs = model.Instances.OfType <IIfcOwnerHistory>().FirstOrDefault();
                        using (var geomReader = model.GeometryStore.BeginRead())
                        {
                            result = new ProcessResult
                            {
                                ParseDuration    = parseTime,
                                GeometryDuration = geomTime,
                                // SceneDuration = sceneTime,
                                FileName            = ifcFile.Remove(0, Params.TestFileRoot.Length).TrimStart('\\'),
                                Entities            = model.Instances.Count,
                                IfcSchema           = header.FileSchema.Schemas.FirstOrDefault(),
                                IfcDescription      = String.Format("{0}, {1}", header.FileDescription.Description.FirstOrDefault(), header.FileDescription.ImplementationLevel),
                                GeometryEntries     = geomReader.ShapeInstances.Count(),
                                IfcLength           = ReadFileLength(ifcFile),
                                XbimLength          = ReadFileLength(xbimFilename),
                                SceneLength         = 0,
                                IfcProductEntries   = model.Instances.OfType <IIfcProduct>().Count(),
                                IfcSolidGeometries  = model.Instances.OfType <IIfcSolidModel>().Count(),
                                IfcMappedGeometries = model.Instances.OfType <IIfcMappedItem>().Count(),
                                BooleanGeometries   = model.Instances.OfType <IIfcBooleanResult>().Count(),
                                BReps       = model.Instances.OfType <IIfcFaceBasedSurfaceModel>().Count() + model.Instances.OfType <IIfcShellBasedSurfaceModel>().Count() + model.Instances.OfType <IIfcManifoldSolidBrep>().Count(),
                                Application = ohs == null ? "Unknown" : ohs.OwningApplication.ToString(),
                            };
                        }
                        model.Close();
                    }
                }

                catch (Exception ex)
                {
                    Logger.Error(String.Format("Problem converting file: {0}", ifcFile), ex);
                    result.Failed = true;
                }
                finally
                {
                    result.Errors = (from e in eventTrace.Events
                                     where (e.EventLevel == EventLevel.ERROR)
                                     select e).Count();
                    result.Warnings = (from e in eventTrace.Events
                                       where (e.EventLevel == EventLevel.WARN)
                                       select e).Count();
                    result.FileName = ifcFile.Remove(0, Params.TestFileRoot.Length).TrimStart('\\');
                    if (eventTrace.Events.Count > 0)
                    {
                        CreateLogFile(ifcFile, eventTrace.Events);
                    }


                    writer.WriteLine(result.ToCsv());
                    writer.Flush();
                }
                return(result);
            }
        }