예제 #1
0
        public bool CreateCafmConnectTestFile(string ifcFullName)
        {
            EventType eventType = BaseObject.LockEvents();
            bool      result    = InternalCreateCafmConnectTestFile(ifcFullName);

            BaseObject.UnlockEvents(eventType);
            return(result);
        }
예제 #2
0
        //internal void ConvertToIso8859_1(string fullName)
        //{
        //    if (string.IsNullOrEmpty(fullName))
        //        return;

        //    string s = System.IO.File.ReadAllText(fullName);
        //    s = this.SpecialCharacterToUnicode(s);
        //    System.IO.File.WriteAllText(fullName, s, Encoding.ASCII);
        //}

        internal Document Open(string fullName, Ifc4.Document.IfcFileType ifcFileType = Document.IfcFileType.Auto)
        {
            EventType eventType = BaseObject.LockEvents();

            Document document = null;

            try
            {
                Workspace.CurrentWorkspace.RaiseBeforeCommandExceuted(this, "OpenDocument");

                document = this.Where(item => item.FullName.Equals(fullName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (document != null)
                {
                    ActiveDocument = document;
                    return(document);
                }

                // Sicherheitshalber alle Dokumente schließen
                Workspace.CurrentWorkspace.CloseDocument();

                //ConvertToIso8859_1(fullName);

                Ifc4.CcFacility.ResetVariables();

                document = AddNew() as Document;
                if (document == null)
                {
                    return(null);
                }

                document.IsInOpenProcess = true;
                string message;

                Workspace.CurrentWorkspace.RaiseMessageLogged(String.Format("Open document '{0}'...", fullName));

                //document.RaiseMessageLogged(String.Format("Open document '{0}'...", fullName));

                document.Open(fullName, out message, ifcFileType);
                document.Read(this);
                document.ResetDirty();

                Workspace.CurrentWorkspace.RaiseDocumentOpened(this, new Workspace.DocumentOpenedEventArgs(document));
                ActiveDocument = document;

                return(document);
            }
            catch (Exception exc)
            {
                Workspace.CurrentWorkspace.RaiseMessageLogged(this, exc);
                return(null);
            }
            finally
            {
                if (document != null)
                {
                    document.IsInOpenProcess = false;
                }
                BaseObject.UnlockEvents(eventType);
                Workspace.CurrentWorkspace.RaiseAfterCommandExceuted(this, "OpenDocument");
            }
        }