Load() public method

public Load ( ) : void
return void
        private static void GenerateExample(
            DocExample docExample,
            List<DocXsdFormat> listFormats,
            string path,
            List<int> indexpath,
            Dictionary<DocObject, bool> included,
            Dictionary<string, DocObject> mapEntity,
            Dictionary<string, string> mapSchema,
            Dictionary<string, Type> typemap,
            List<ContentRef> listFigures, 
            List<ContentRef> listTables,
            FormatHTM htmTOC,
            FormatHTM htmSectionTOC
            )
        {
            if (included == null || included.ContainsKey(docExample))
            {
                indexpath[indexpath.Count - 1]++;

                StringBuilder indexpathname = new StringBuilder();
                indexpathname.Append("E");
                foreach(int x in indexpath)
                {
                    indexpathname.Append(".");
                    indexpathname.Append(x);
                }
                string indexpathstring = indexpathname.ToString();

                string pathExample = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".htm";
                using (FormatHTM htmExample = new FormatHTM(pathExample, mapEntity, mapSchema, included))
                {
                    htmExample.WriteHeader(docExample.Name, 2);
                    htmExample.WriteScript(-5, indexpath[0], 0, 0);
                    htmExample.WriteLine("<h3 class=\"std\">" + indexpathstring + " " + docExample.Name + "</h3>");

                    // table of files
                    if (docExample.File != null)
                    {
                        htmExample.Write("<table class=\"gridtable\">");
                        htmExample.Write("<tr><th>Format</th><th>ASCII</th><th>HTML</th></tr>");

                        if (Properties.Settings.Default.ExampleSPF)
                        {
                            htmExample.Write("<tr><td>IFC-SPF</td><td><a href=\"" + MakeLinkName(docExample) + ".ifc\">File</a></td><td><a href=\"" + MakeLinkName(docExample) + ".ifc.htm\">Markup</a></td></tr>");
                        }
                        if (Properties.Settings.Default.ExampleXML)
                        {
                            htmExample.Write("<tr><td>IFC-XML</td><td><a href=\"" + MakeLinkName(docExample) + ".ifcxml\">File</a></td><td><a href=\"" + MakeLinkName(docExample) + ".ifcxml.htm\">Markup</a></td></tr>");
                        }
                        htmExample.Write("</table>");

                        htmExample.Write("<table class=\"gridtable\">");
                        htmExample.Write("<tr><th>View</th></tr>");
                        foreach (DocModelView docView in docExample.Views)
                        {
                            if (included != null && included.ContainsKey(docView))
                            {
                                string hyperlink = "../../schema/views/" + MakeLinkName(docView) + "/index.htm";
                                htmExample.Write("<tr><td><a href=\"" + hyperlink + "\">" + docView.Name + "</td></tr>");
                            }
                        }
                        htmExample.Write("</table>");

                        if (docExample.ApplicableType != null)
                        {
                            string[] ApplicableTypesArray = docExample.ApplicableType.Split(',');
                            htmExample.Write("<table class=\"gridtable\">");
                            htmExample.Write("<tr><th>Entity</th></tr>");
                            for (int i = 0; i < ApplicableTypesArray.Length; i++)
                            {
                                string hyperlink = "../../schema/" + mapSchema[ApplicableTypesArray.GetValue(i).ToString()].ToString().ToLower() + "/lexical/" + ApplicableTypesArray.GetValue(i).ToString().ToLower() + ".htm";
                                htmExample.Write("<tr><td><a href=" + hyperlink + ">" + ApplicableTypesArray.GetValue(i) + "</td></tr>");
                            }
                            htmExample.Write("</table>");
                        }
                    }

                    docExample.Documentation = UpdateNumbering(docExample.Documentation, listFigures, listTables, docExample);

                    htmExample.WriteDocumentationForISO(docExample.Documentation, docExample, false);
                    htmExample.WriteLinkTo(docExample);
                    htmExample.WriteFooter(Properties.Settings.Default.Footer);
                }

                if (docExample.File != null && !Properties.Settings.Default.SkipDiagrams)
                {
                    string pathIFC = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc";
                    using (System.IO.FileStream filestream = new System.IO.FileStream(pathIFC, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read))
                    {
                        filestream.Write(docExample.File, 0, docExample.File.Length);
                    }

                    using (FormatSPF spfExample = new FormatSPF(new System.IO.MemoryStream(docExample.File, false), typemap, null))
                    {
                        string pathListing = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc.htm";

                        if (Properties.Settings.Default.ExampleSPF)
                        {
                            using (FormatHTM htmListing = new FormatHTM(pathListing, mapEntity, mapSchema, included))
                            {
                                htmListing.WriteHeader(docExample.Name, 2);

                                htmListing.WriteLine("<tt class=\"spf\">");
                                string htm = null;
                                try
                                {
                                    htm = spfExample.LoadMarkup();
                                }
                                catch
                                {
                                }
                                htmListing.Write(htm);
                                htmListing.Write("</tt>");
                                htmListing.WriteFooter(String.Empty);
                            }
                        }
                        else if(Properties.Settings.Default.ExampleXML)
                        {
                            // must load file in any case in order to generate xml
                            try
                            {
                                spfExample.Load();
                            }
                            catch
                            {
                            }
                        }

                        if (Properties.Settings.Default.ExampleXML)
                        {
                            // find the IfcProject
                            SEntity rootproject = null;
                            foreach (SEntity ent in spfExample.Instances.Values)
                            {
                                if (ent.GetType().Name.Equals("IfcProject"))
                                {
                                    rootproject = ent;
                                    break;
                                }
                            }

                            string pathXML = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifcxml";
                            using (FormatSML xmlExample = new FormatSML(new System.IO.FileStream(pathXML, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), listFormats))
                            {
                                xmlExample.Instance = rootproject;
                                xmlExample.Save();
                            }

                            string pathXMH = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifcxml.htm";
                            using (FormatSML xmlExample = new FormatSML(new System.IO.FileStream(pathXMH, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), listFormats))
                            {
                                xmlExample.Instance = rootproject;
                                xmlExample.Markup = true;
                                xmlExample.Save();
                            }
                        }

                    }

                }

                using (FormatHTM htmLink = new FormatHTM(path + "/link/" + MakeLinkName(docExample) + ".htm", mapEntity, mapSchema, included))
                {
                    string linkurl = "../annex/annex-e/" + MakeLinkName(docExample) + ".htm";
                    htmLink.WriteLinkPage(linkurl);
                }

                string urlExample = "annex-e/" + MakeLinkName(docExample) + ".htm";
                htmTOC.WriteTOC(2, "<a class=\"listing-link\" href=\"annex/" + urlExample + "\" >" + indexpathstring + " " + docExample.Name + "</a>");

                string linkid = "";
                if(indexpath.Count == 1)
                {
                    linkid = indexpath[0].ToString();
                }
                string htmllink = "<a class=\"listing-link\" id=\"" + linkid + "\" href=\"" + urlExample + "\" target=\"info\">" + docExample.Name + "</a>";
                htmSectionTOC.WriteLine("<tr class=\"std\"><td class=\"menu\">" + indexpathstring + " " + htmllink + "</td></tr>");

                if (docExample.Examples.Count > 0)
                {
                    indexpath.Add(0);
                    foreach(DocExample docSub in docExample.Examples)
                    {
                        GenerateExample(docSub, listFormats, path, indexpath, included, mapEntity, mapSchema, typemap, listFigures, listTables, htmTOC, htmSectionTOC);
                    }
                    indexpath.RemoveAt(indexpath.Count - 1);
                }
            }

        }
Example #2
0
        private void toolStripMenuItemToolsConvert_Click(object sender, EventArgs e)
        {
            using(OpenFileDialog dlgImport = new OpenFileDialog())
            {
                dlgImport.Title = "Convert [Step 1 of 2]: Choose the input file";
                dlgImport.Filter = "IFC-SPF (*.ifc)|*.ifc";
                if(dlgImport.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    using(SaveFileDialog dlgExport = new SaveFileDialog())
                    {
                        dlgExport.Filter =
                            "IFC-JSN (*.ifcjsn)|*.ifcjsn|"+
                            "IFC-RDF (*.ttl)|*.ttl|" +
                            "IFC-XML (*.ifcxml)|*.ifcxml";

                        dlgExport.Title = "Convert [Step 2 of 2]: Specify the output file and format";
                        dlgExport.FileName = System.IO.Path.GetFileNameWithoutExtension(dlgImport.FileName);
                        if(dlgExport.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                        {
                            //todo: run in background, show progress

                            Dictionary<string, Type> typemap = new Dictionary<string, Type>();

                            Compiler compiler = new Compiler(this.m_project, this.m_filterviews, this.m_filterexchange);
                            System.Reflection.Emit.AssemblyBuilder assembly = compiler.Assembly;
                            Type[] types = assembly.GetTypes();
                            foreach (Type t in types)
                            {
                                typemap.Add(t.Name.ToUpper(), t);
                            }

                            Dictionary<long, SEntity> instances = new Dictionary<long, SEntity>();
                            try
                            {
                                m_loading = true;
                                using (FormatSPF format = new FormatSPF(dlgImport.FileName, typemap, instances))
                                {
                                    format.Load();
                                }
                            }
                            catch(Exception xx)
                            {
                                MessageBox.Show(xx.Message);
                                return;
                            }
                            finally
                            {
                                this.m_loading = false;
                            }

                            // build dictionary to map IFC type name to entity and schema
                            Dictionary<string, DocObject> mapEntity = new Dictionary<string, DocObject>();

                            // build dictionary to map IFC type name to schema
                            Dictionary<string, string> mapSchema = new Dictionary<string, string>();

                            this.BuildMaps(mapEntity, mapSchema);

                            // find the IfcProject
                            SEntity rootproject = null;
                            foreach (SEntity ent in instances.Values)
                            {
                                if (ent.GetType().Name.Equals("IfcProject"))
                                {
                                    rootproject = ent;
                                    break;
                                }
                            }

                            //TODO: use schema according to source file, look up publication...
                            List<DocXsdFormat> xsdFormatBase = this.m_project.BuildXsdFormatList();
                            string xmlns = "http://www.buildingsmart-tech.org/ifcXML/IFC4/final";
                            string code = "IFC4";//...
                            string ifcowlns = "http://ifcowl.openbimstandards.org/IFC4_ADD1";

                            try
                            {
                                IFormatData formatter = null;
                                switch (dlgExport.FilterIndex)
                                {
                                    case 1:
                                        formatter = new FormatJSN(xsdFormatBase, xmlns, code);
                                        break;

                                    case 2:
                                        formatter = new FormatTTL_Stream(new System.IO.MemoryStream(), ifcowlns);
                                        break;

                                    case 3:
                                        formatter = new FormatSML(new System.IO.MemoryStream(), xsdFormatBase, xmlns, code);
                                        break;
                                }

                                if (formatter != null)
                                {
                                    string content = formatter.FormatData(this.m_project, null, null, mapEntity, instances, rootproject, false);

                                    using (System.IO.FileStream filestream = System.IO.File.OpenWrite(dlgExport.FileName))
                                    {
                                        System.IO.TextWriter writer = new System.IO.StreamWriter(filestream);
                                        writer.Write(content);
                                        writer.Flush();
                                        filestream.Close();
                                    }
                                }
                            }
                            catch (Exception yy)
                            {
                                MessageBox.Show(yy.Message);
                                return;
                            }
                        }
                    }
                }
            }
            //...
        }
Example #3
0
        private static void GenerateExample(
            DocPublication docPublication,
            DocExample docExample,
            List<DocXsdFormat> listFormats,
            string path,
            List<int> indexpath,
            Dictionary<DocObject, bool> included,
            Dictionary<string, DocObject> mapEntity,
            Dictionary<string, string> mapSchema,
            Dictionary<string, Type> typemap,
            List<ContentRef> listFigures, 
            List<ContentRef> listTables,
            FormatHTM htmTOC,
            FormatHTM htmSectionTOC,
            Dictionary<DocFormatSchemaEnum, IFormatData> mapFormats,
            Dictionary<long, SEntity> outerinstancemap, // instance data of parent example, if inherited
            SEntity outerinstanceroot
            )
        {
            if (included == null || included.ContainsKey(docExample))
            {
                indexpath[indexpath.Count - 1]++;

                StringBuilder indexpathname = new StringBuilder();
                indexpathname.Append("E");
                foreach(int x in indexpath)
                {
                    indexpathname.Append(".");
                    indexpathname.Append(x);
                }
                string indexpathstring = indexpathname.ToString();

                string pathExample = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".htm";
                using (FormatHTM htmExample = new FormatHTM(pathExample, mapEntity, mapSchema, included))
                {
                    htmExample.WriteHeader(docExample.Name, 2, docPublication.Header);
                    htmExample.WriteScript(-5, indexpath[0], 0, 0);
                    htmExample.WriteLine("<h3 class=\"std\">" + indexpathstring + " " + docExample.Name + "</h3>");

                    // table of files
                    if (docExample.File != null)
                    {
                        htmExample.Write("<table class=\"gridtable\">");
                        htmExample.Write("<tr><th>Format</th><th>ASCII</th><th>HTML</th></tr>");

                        foreach(DocFormat docFormat in docPublication.Formats)
                        {
                            if (docFormat.FormatOptions == DocFormatOptionEnum.Examples)
                            {
                                string ext = docFormat.ExtensionInstances;
                                htmExample.WriteLine("<tr><td>" + docFormat.FormatType.ToString() + "</td><td><a href=\"" + MakeLinkName(docExample) + "." + ext + "\">File</a></td><td><a href=\"" + MakeLinkName(docExample) + "." + ext + ".htm\">Markup</a></td></tr>");
                            }
                        }

                        htmExample.Write("</table>");

                        htmExample.Write("<table class=\"gridtable\">");
                        htmExample.Write("<tr><th>View</th></tr>");
                        foreach (DocModelView docView in docExample.Views)
                        {
                            if (included != null && included.ContainsKey(docView))
                            {
                                string hyperlink = "../../schema/views/" + MakeLinkName(docView) + "/index.htm";
                                htmExample.Write("<tr><td><a href=\"" + hyperlink + "\">" + docView.Name + "</td></tr>");
                            }
                        }
                        htmExample.Write("</table>");

                        if (docExample.ApplicableType != null)
                        {
                            string[] ApplicableTypesArray = docExample.ApplicableType.Split(',');
                            htmExample.Write("<table class=\"gridtable\">");
                            htmExample.Write("<tr><th>Entity</th></tr>");
                            for (int i = 0; i < ApplicableTypesArray.Length; i++)
                            {
                                string hyperlink = "../../schema/" + mapSchema[ApplicableTypesArray.GetValue(i).ToString()].ToString().ToLower() + "/lexical/" + ApplicableTypesArray.GetValue(i).ToString().ToLower() + ".htm";
                                htmExample.Write("<tr><td><a href=" + hyperlink + ">" + ApplicableTypesArray.GetValue(i) + "</td></tr>");
                            }
                            htmExample.Write("</table>");
                        }
                    }

                    docExample.Documentation = UpdateNumbering(docExample.Documentation, listFigures, listTables, docExample);

                    htmExample.WriteDocumentationMarkup(docExample.Documentation, docExample, docPublication);

                    if (docExample.File == null && outerinstancemap != null)
                    {
                        // if specific to exchange, capture inline
                        if (docExample.Views.Count > 0)
                        {
                            // hack for now based on example name matching exchange name -- make explicit later
                            foreach (DocExchangeDefinition docExchange in docExample.Views[0].Exchanges)
                            {
                                if (docExample.Name.Equals(docExchange.Name))
                                {
                                    // matches -- generate
                                    FormatSQL fmt = new FormatSQL();
                                    string content = fmt.FormatData(docPublication, docExchange, mapEntity, outerinstancemap, outerinstanceroot, false);
                                    htmExample.Write(content);
                                    break;
                                }
                            }
                        }
                    }

                    htmExample.WriteLinkTo(docExample);
                    htmExample.WriteFooter(docPublication.Footer);
                }

                if (docExample.File != null && !Properties.Settings.Default.SkipDiagrams)
                {
                    string pathIFC = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc";
                    using (System.IO.FileStream filestream = new System.IO.FileStream(pathIFC, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read))
                    {
                        filestream.Write(docExample.File, 0, docExample.File.Length);
                    }

                    using (FormatSPF spfExample = new FormatSPF(new System.IO.MemoryStream(docExample.File, false), typemap, null))
                    {
                        string pathListing = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifc.htm";

                        if (docPublication.GetFormatOption(DocFormatSchemaEnum.STEP) == DocFormatOptionEnum.Examples)//Properties.Settings.Default.ExampleSPF)
                        {
                            using (FormatHTM htmListing = new FormatHTM(pathListing, mapEntity, mapSchema, included))
                            {
                                htmListing.WriteHeader(docExample.Name, 2, docPublication.Header);

                                htmListing.WriteLine("<tt class=\"spf\">");
                                string htm = null;
                                try
                                {
                                    htm = spfExample.LoadMarkup();
                                    outerinstancemap = spfExample.Instances;
                                }
                                catch
                                {
                                }
                                htmListing.Write(htm);
                                htmListing.Write("</tt>");
                                htmListing.WriteFooter(String.Empty);
                            }
                        }
            #if false
                        else if(Properties.Settings.Default.ExampleXML)
                        {
                            // must load file in any case in order to generate xml
                            try
                            {
                                spfExample.Load();
                            }
                            catch
                            {
                            }
                        }
            #endif

                        // find the IfcProject
                        SEntity rootproject = null;
                        foreach (SEntity ent in spfExample.Instances.Values)
                        {
                            if (ent.GetType().Name.Equals("IfcProject"))
                            {
                                rootproject = ent;
                                break;
                            }
                        }

                        foreach (DocFormat docFormat in docPublication.Formats)
                        {
                            // generate example in other formats...
                            if (docFormat.FormatOptions == DocFormatOptionEnum.Examples)
                            {
                                switch(docFormat.FormatType)
                                {
                                    case DocFormatSchemaEnum.STEP:
                                        break; // do nothing

            #if false
                                    case DocFormatSchemaEnum.XML: // TODO: use generic formatter
                                        {
                                            // use xml namespace of first view
                                            string xmlns = "http://www.buildingsmart-tech.org/ifcXML/IFC4/final";
                                            if (docExample.Views.Count > 0 && !String.IsNullOrEmpty(docExample.Views[0].XsdUri))
                                            {
                                                xmlns = docExample.Views[0].XsdUri;
                                            }

                                            string pathXML = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifcxml";
                                            using (FormatSML xmlExample = new FormatSML(new System.IO.FileStream(pathXML, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), listFormats, xmlns, docPublication.Code))
                                            {
                                                xmlExample.Instance = rootproject;
                                                xmlExample.Save();
                                            }

                                            string pathXMH = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ifcxml.htm";
                                            using (FormatSML xmlExample = new FormatSML(new System.IO.FileStream(pathXMH, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), listFormats, xmlns, docPublication.Code))
                                            {
                                                xmlExample.Instance = rootproject;
                                                xmlExample.Markup = true;
                                                xmlExample.Save();
                                            }
                                        }
                                        break;
            #endif // now use generic formatters

                                    case DocFormatSchemaEnum.TTL:
                                        {
                                            string ns = "http://ifcowl.openbimstandards.org/IFC4_ADD1#";

                                            string pathTTL = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ttl";
                                            Console.Out.WriteLine("------------------------------------------------");
                                            Console.Out.WriteLine("converting file: " + MakeLinkName(docExample) + ".ttl");
                                            Console.Out.WriteLine("------------------------------------------------");
                                            using (FormatTTL_Stream TTLExample = new FormatTTL_Stream(new System.IO.FileStream(pathTTL, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), ns))
                                            {
                                                TTLExample.Instances = spfExample.Instances;
                                                TTLExample.Save();
                                            }

                                            //TODO: redo the HTM part later on
                                            //string pathTTLHTM = path + @"\annex\annex-e\" + MakeLinkName(docExample) + ".ttl.htm";
                                            //using (FormatTTL_Stream TTLExample = new FormatTTL_Stream(new System.IO.FileStream(pathTTLHTM, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite), ns))
                                            //{
                                            //    TTLExample.Instances = spfExample.Instances;
                                            //    TTLExample.Markup = true;
                                            //    TTLExample.Save();
                                            //}
                                        }
                                        break;

                                    #if false
                                    case DocFormatTypeEnum.SQL: // todo: support others...
                                        // use formatter
                                        {
                                            FormatSQL fmt = new FormatSQL();
                                            string content = fmt.FormatData(docPublication, null, mapEntity, spfExample.Instances);

                                            string pathRAW = path + @"\annex\annex-e\" + MakeLinkName(docExample) + "." + docFormat.ExtensionInstances;
                                            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(pathRAW, false))
                                            {
                                                writer.Write(content);
                                            }

                                            string pathHTM = pathRAW + ".htm";
                                            using (FormatHTM fmtHTM = new FormatHTM(pathHTM, mapEntity, mapSchema, included))
                                            {
                                                fmtHTM.WriteHeader(docExample.Name, 2, docPublication.Header);
                                                fmtHTM.Write(content);
                                                fmtHTM.WriteFooter("");
                                            }
                                        }
                                        break;
            #endif

                                    default: // pluggable formatters
                                        {
                                            IFormatData formatext = null;
                                            if(mapFormats.TryGetValue(docFormat.FormatType, out formatext))
                                            {
                                                string content = formatext.FormatData(docPublication, null, mapEntity, spfExample.Instances, rootproject, false);
                                                string pathRAW = path + @"\annex\annex-e\" + MakeLinkName(docExample) + "." + docFormat.ExtensionInstances;
                                                using (System.IO.StreamWriter writer = new System.IO.StreamWriter(pathRAW, false))
                                                {
                                                    writer.Write(content);
                                                }

                                                string conmark = formatext.FormatData(docPublication, null, mapEntity, spfExample.Instances, rootproject, true);
                                                string pathHTM = pathRAW + ".htm";
                                                using (FormatHTM fmtHTM = new FormatHTM(pathHTM, mapEntity, mapSchema, included))
                                                {
                                                    fmtHTM.WriteHeader(docExample.Name, 2, docPublication.Header);
                                                    fmtHTM.Write(conmark);
                                                    fmtHTM.WriteFooter("");
                                                }

                                            }
                                        }
                                        break;
                                }
                            }
                        }
                    }
                }

                using (FormatHTM htmLink = new FormatHTM(path + "/link/" + MakeLinkName(docExample) + ".htm", mapEntity, mapSchema, included))
                {
                    string linkurl = "../annex/annex-e/" + MakeLinkName(docExample) + ".htm";
                    htmLink.WriteLinkPage(linkurl, docPublication);
                }

                string urlExample = "annex-e/" + MakeLinkName(docExample) + ".htm";
                htmTOC.WriteTOC(2, "<a class=\"listing-link\" href=\"annex/" + urlExample + "\" >" + indexpathstring + " " + docExample.Name + "</a>");

                string linkid = "";
                if(indexpath.Count == 1)
                {
                    linkid = indexpath[0].ToString();
                }
                string htmllink = "<a class=\"listing-link\" id=\"" + linkid + "\" href=\"" + urlExample + "\" target=\"info\">" + docExample.Name + "</a>";
                htmSectionTOC.WriteLine("<tr class=\"std\"><td class=\"menu\">" + indexpathstring + " " + htmllink + "</td></tr>");

                if (docExample.Examples.Count > 0)
                {
                    indexpath.Add(0);
                    foreach(DocExample docSub in docExample.Examples)
                    {
                        GenerateExample(docPublication, docSub, listFormats, path, indexpath, included, mapEntity, mapSchema, typemap, listFigures, listTables, htmTOC, htmSectionTOC, mapFormats, outerinstancemap, outerinstanceroot);
                    }
                    indexpath.RemoveAt(indexpath.Count - 1);
                }
            }
        }
Example #4
0
        private void toolStripMenuItemFileImport_Click(object sender, EventArgs e)
        {
            StringBuilder sbErrors = new StringBuilder();

            DialogResult res = this.openFileDialogImport.ShowDialog(this);
            if (res == DialogResult.OK)
            {
                List<DocSchema> importedschemas = new List<DocSchema>();

                bool updateDescriptions = false;
                if(this.openFileDialogImport.FileName.EndsWith(".vex"))
                {
                    DialogResult resUpdate = MessageBox.Show(this, "Do you want to update the documentation? Click Yes to update documentation and definitions, or No to update just definitions.", "Import VEX", MessageBoxButtons.YesNoCancel);
                    if (resUpdate == System.Windows.Forms.DialogResult.Cancel)
                        return;

                    if (resUpdate == System.Windows.Forms.DialogResult.Yes)
                        updateDescriptions = true;
                }

                foreach (string filename in this.openFileDialogImport.FileNames)
                {
                    string ext = System.IO.Path.GetExtension(filename).ToLower();
                    switch (ext)
                    {
                        case ".vex":
                            using (FormatSPF format = new FormatSPF(filename, SchemaVEX.Types, null))
                            {
                                format.Load();

                                // get the root schemata
                                SCHEMATA vexschema = null;
                                foreach (SEntity entity in format.Instances.Values)
                                {
                                    if (entity is SCHEMATA)
                                    {
                                        vexschema = (SCHEMATA)entity;
                                        break;
                                    }
                                }

                                if (vexschema != null)
                                {
                                    DocSchema schema = Program.ImportVex(vexschema, this.m_project, updateDescriptions);
                                    importedschemas.Add(schema); // add schemas from multiple files first, process later
                                }
                            }
                            break;

                        case ".xml":
                            if (filename.Contains("Pset_"))
                            {
                                using (FormatXML format = new FormatXML(filename, typeof(PropertySetDef), "http://buildingSMART-tech.org/xml/psd/PSD_IFC4.xsd"))
                                {
                                    format.Load();
                                    PropertySetDef psd = (PropertySetDef)format.Instance;

                                    string schema = null;
                                    if (psd.Versions != null && psd.Versions.Count > 0)
                                    {
                                        schema = psd.Versions[0].schema;
                                    }

                                    if (String.IsNullOrEmpty(schema))
                                    {
                                        // guess the schema according to applicable type value
                                        if (psd.ApplicableTypeValue != null)
                                        {
                                            string[] parts = psd.ApplicableTypeValue.Split(new char[] { '/', '[' });
                                            TreeNode tnEntity = null;
                                            if (this.m_mapTree.TryGetValue(parts[0].ToLowerInvariant(), out tnEntity))
                                            {
                                                DocSchema docschema = (DocSchema)tnEntity.Parent.Parent.Tag;
                                                schema = docschema.Name;
                                            }
                                        }
                                    }

                                    if(schema == null)
                                    {
                                        schema = "IfcProductExtension";//fallback
                                    }

                                    // find the schema
                                    TreeNode tn = null;
                                    if (schema != null && this.m_mapTree.TryGetValue(schema.ToLowerInvariant(), out tn))
                                    {
                                        DocSchema docschema = (DocSchema)tn.Tag;

                                        // find existing pset if applicable
                                        DocPropertySet pset = docschema.RegisterPset(psd.Name);

                                        // use hashed guid
                                        if (pset.Uuid == Guid.Empty)
                                        {
                                            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
                                            byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(pset.Name));
                                            pset.Uuid = new Guid(hash);
                                        }

                                        pset.Name = psd.Name;
                                        if (psd.Definition != null)
                                        {
                                            pset.Documentation = psd.Definition.Trim();
                                        }
                                        if (psd.ApplicableTypeValue != null)
                                        {
                                            pset.ApplicableType = psd.ApplicableTypeValue.Replace("Type", "").Replace("[PerformanceHistory]", ""); // organize at occurrences; use pset type to determine type applicability
                                        }

                                        // for now, rely on naming convention (better to capture in pset schema eventually)
                                        if (psd.Name.Contains("PHistory")) // special naming convention
                                        {
                                            pset.PropertySetType = "PSET_PERFORMANCEDRIVEN";
                                        }
                                        else if (psd.Name.Contains("Occurrence"))
                                        {
                                            pset.PropertySetType = "PSET_OCCURRENCEDRIVEN";
                                        }
                                        else
                                        {
                                            pset.PropertySetType = "PSET_TYPEDRIVENOVERRIDE";
                                        }

                                        // import localized definitions
                                        if (psd.PsetDefinitionAliases != null)
                                        {
                                            foreach (PsetDefinitionAlias pl in psd.PsetDefinitionAliases)
                                            {
                                                pset.RegisterLocalization(pl.lang, null, pl.Value);
                                            }
                                        }

                                        foreach (PropertyDef subdef in psd.PropertyDefs)
                                        {
                                            DocProperty docprop = pset.RegisterProperty(subdef.Name);
                                            Program.ImportPsdPropertyTemplate(subdef, docprop);
                                        }

                                        // add to Use Definition at applicable entity
            #if false
                                        if (pset.ApplicableType != null)
                                        {
                                            string[] apptypes = pset.ApplicableType.Split('/');
                                            if (this.m_mapTree.TryGetValue(apptypes[0].ToLowerInvariant(), out tn))
                                            {
                                                DocEntity entity = (DocEntity)tn.Tag;

                                                if (this.m_project.ModelViews.Count == 0)
                                                {
                                                    // must have at least one model view for populating property set links
                                                    this.m_project.ModelViews.Add(new DocModelView());
                                                }

                                                foreach (DocModelView docView in this.m_project.ModelViews)
                                                {
                                                    DocConceptRoot docRoot = null;
                                                    foreach (DocConceptRoot eachRoot in docView.ConceptRoots)
                                                    {
                                                        if (eachRoot.ApplicableEntity == entity)
                                                        {
                                                            docRoot = eachRoot;
                                                            break;
                                                        }
                                                    }

                                                    if (docRoot == null)
                                                    {
                                                        docRoot = new DocConceptRoot();
                                                        docRoot.ApplicableEntity = entity;
                                                        docView.ConceptRoots.Add(docRoot);
                                                    }

                                                    // find the pset template
                                                    DocTemplateUsage templateuse = null;
                                                    foreach (DocTemplateUsage eachtemplateuse in docRoot.Concepts)
                                                    {
                                                        if (eachtemplateuse.Definition != null && eachtemplateuse.Definition.Name.StartsWith("Property"))
                                                        {
                                                            templateuse = eachtemplateuse;
                                                            break;
                                                        }
                                                    }

                                                    DocTemplateDefinition docdefpset = this.m_project.GetTemplate(new Guid("f74255a6-0c0e-4f31-84ad-24981db62461"));
                                                    if (docdefpset != null)
                                                    {
                                                        // if no template, add it
                                                        if (templateuse == null)
                                                        {
                                                            // get the pset template
                                                            templateuse = new DocTemplateUsage();
                                                            docRoot.Concepts.Add(templateuse);
                                                            templateuse.Definition = docdefpset;
                                                        }

                                                        DocTemplateItem templateitem = new DocTemplateItem();
                                                        templateuse.Items.Add(templateitem);
                                                        templateitem.RuleInstanceID = "IfcPropertySet";

                                                        if (apptypes.Length == 2)
                                                        {
                                                            templateitem.RuleParameters += "PredefinedType=" + apptypes[1] + ";";
                                                        }
                                                        templateitem.RuleParameters += "Name=" + pset.Name + ";";
                                                        templateitem.RuleParameters += "TemplateType=" + pset.PropertySetType + ";";
                                                        // don't include documentation -- too wordy templateitem.Documentation = pset.Documentation;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                sbErrors.Append(System.IO.Path.GetFileNameWithoutExtension(filename) + ": unrecognized ApplicableTypeValue; ");
                                            }
                                        }
            #endif
                                    }
                                    else
                                    {
                                        sbErrors.Append(System.IO.Path.GetFileNameWithoutExtension(filename) + ": unrecognized schema; ");
                                    }

                                }
                            }
                            else if (filename.Contains("Qto_"))
                            {
                                using (FormatXML format = new FormatXML(filename, typeof(QtoSetDef)))
                                {
                                    format.Load();
                                    QtoSetDef qto = (QtoSetDef)format.Instance;

                                    string schema = qto.Versions[0].schema;
                                    TreeNode tn = null;
                                    if (schema != null && this.m_mapTree.TryGetValue(schema.ToLowerInvariant(), out tn))
                                    {
                                        DocSchema docschema = (DocSchema)tn.Tag;

                                        // find existing pset if applicable
                                        DocQuantitySet qset = docschema.RegisterQset(qto.Name);

                                        // use hashed guid
                                        if (qset.Uuid == Guid.Empty)
                                        {
                                            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
                                            byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(qset.Name));
                                            qset.Uuid = new Guid(hash);
                                        }

                                        // everything is currently named "Base Quantities"; get name from file instead; e.g. "Qto_Beam"
                                        qset.Name = System.IO.Path.GetFileNameWithoutExtension(filename);
                                        qset.Documentation = qto.Definition;
                                        qset.ApplicableType = qto.ApplicableClasses[0].Value;

                                        // fix: remove "Type"
                                        if (qset.ApplicableType.EndsWith("Type"))
                                        {
                                            qset.ApplicableType = qset.ApplicableType.Substring(0, qset.ApplicableType.Length - 4);
                                        }

                                        // import localized definitions
                                        if (qto.QtoDefinitionAliases != null)
                                        {
                                            foreach (QtoDefinitionAlias pl in qto.QtoDefinitionAliases)
                                            {
                                                qset.RegisterLocalization(pl.lang, null, pl.Value);
                                            }
                                        }

                                        foreach (QtoDef qtodef in qto.QtoDefs)
                                        {
                                            DocQuantity q = qset.RegisterQuantity(qtodef.Name);
                                            q.Documentation = qtodef.Definition;

                                            switch (qtodef.QtoType)
                                            {
                                                case "IfcQuantityCount":
                                                    q.QuantityType = DocQuantityTemplateTypeEnum.Q_COUNT;
                                                    break;

                                                case "IfcQuantityLength":
                                                    q.QuantityType = DocQuantityTemplateTypeEnum.Q_LENGTH;
                                                    break;

                                                case "IfcQuantityArea":
                                                    q.QuantityType = DocQuantityTemplateTypeEnum.Q_AREA;
                                                    break;

                                                case "IfcQuantityVolume":
                                                    q.QuantityType = DocQuantityTemplateTypeEnum.Q_VOLUME;
                                                    break;

                                                case "IfcQuantityWeight":
                                                    q.QuantityType = DocQuantityTemplateTypeEnum.Q_WEIGHT;
                                                    break;

                                                case "IfcQuantityTime":
                                                    q.QuantityType = DocQuantityTemplateTypeEnum.Q_TIME;
                                                    break;
                                            }

                                            foreach (NameAlias namealias in qtodef.NameAliases)
                                            {
                                                string desc = null;
                                                foreach (DefinitionAlias docalias in qtodef.DefinitionAliases)
                                                {
                                                    if (docalias.lang.Equals(namealias.lang))
                                                    {
                                                        desc = docalias.Value;
                                                        break;
                                                    }
                                                }

                                                q.RegisterLocalization(namealias.lang, namealias.Value, desc);
                                            }

                                        }

                                        // map to use definition
                                        if (this.m_mapTree.TryGetValue(qset.ApplicableType.ToLowerInvariant(), out tn))
                                        {
                                            DocEntity entity = (DocEntity)tn.Tag;

                                            if (this.m_project.ModelViews.Count == 0)
                                            {
                                                // must have at least one model view for populating property set links
                                                this.m_project.ModelViews.Add(new DocModelView());
                                            }

                                            foreach (DocModelView docView in this.m_project.ModelViews)
                                            {
                                                DocConceptRoot docRoot = null;
                                                foreach (DocConceptRoot eachRoot in docView.ConceptRoots)
                                                {
                                                    if (eachRoot.ApplicableEntity == entity)
                                                    {
                                                        docRoot = eachRoot;
                                                        break;
                                                    }
                                                }

                                                if (docRoot == null)
                                                {
                                                    docRoot = new DocConceptRoot();
                                                    docRoot.ApplicableEntity = entity;
                                                    docView.ConceptRoots.Add(docRoot);
                                                }

                                                // find the qset template
                                                DocTemplateUsage templateuse = null;
                                                foreach (DocTemplateUsage eachtemplateuse in docRoot.Concepts)
                                                {
                                                    if (eachtemplateuse.Definition.Name.StartsWith("Quantity"))
                                                    {
                                                        templateuse = eachtemplateuse;
                                                        break;
                                                    }
                                                }

                                                // if no template, add it
                                                if (templateuse == null)
                                                {
                                                    // get the pset template
                                                    templateuse = new DocTemplateUsage();
                                                    docRoot.Concepts.Add(templateuse);
                                                    templateuse.Definition = this.m_project.GetTemplate(new Guid("6652398e-6579-4460-8cb4-26295acfacc7"));
                                                }

                                                if (templateuse != null)
                                                {
                                                    DocTemplateItem templateitem = new DocTemplateItem();
                                                    templateuse.Items.Add(templateitem);
                                                    templateitem.RuleInstanceID = "IfcElementQuantity";
                                                    templateitem.RuleParameters = "Name=" + qset.Name + ";TemplateType=QTO_OCCURRENCEDRIVEN;";
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        sbErrors.Append(System.IO.Path.GetFileNameWithoutExtension(filename) + ": unrecognized schema; ");
                                    }
                                }
                            }
                            else if (filename.Contains("ifcXML"))
                            {
                                using (FormatXML format = new FormatXML(filename, typeof(configuration), null, SchemaCNF.Prefixes))
                                {
                                    try
                                    {
                                        this.m_loading = true; // prevent constructors from registering instances (xml serializer instantiates)
                                        format.Load();

                                        DocModelView docView = null;
                                        using(FormSelectView form = new FormSelectView(this.m_project, null))
                                        {
                                            if(form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK && form.Selection != null && form.Selection.Length == 1)
                                            {
                                                docView = form.Selection[0];
                                            }
                                        }

                                        configuration cnf = (configuration)format.Instance;
                                        Program.ImportCnf(cnf, this.m_project, docView);
                                    }
                                    catch (Exception xx)
                                    {
                                        MessageBox.Show(this, xx.Message, "Import CNFXML");
                                    }
                                    finally
                                    {
                                        this.m_loading = false;
                                    }
                                }
                            }
                            break;

                        case ".mvdxml":
                            this.ImportMVD(filename);
                            break;

                        case ".txt":
                            using (FormatCSV format = new FormatCSV(filename))
                            {
                                try
                                {
                                    format.Instance = this.m_project;
                                    format.Load();
                                }
                                catch (System.Exception xx)
                                {
                                    MessageBox.Show(this, xx.Message, "Import CSV");
                                }
                            }
                            break;

                        case ".ifd":
                            using (FormatIFD format = new FormatIFD(filename))
                            {
                                try
                                {
                                    format.Instance = this.m_project;
                                    format.Load();
                                }
                                catch (System.Exception xx)
                                {
                                    MessageBox.Show(this, xx.Message, "Import IFD");
                                }
                            }
                            break;

                        case ".xsd":
                            using (FormatXML format = new FormatXML(filename, typeof(IfcDoc.Schema.XSD.schema), IfcDoc.Schema.XSD.SchemaXsd.DefaultNamespace))
                            {
                                try
                                {
                                    format.Load();
                                    DocSchema docSchema = Program.ImportXsd((IfcDoc.Schema.XSD.schema)format.Instance, this.m_project);
                                    if(docSchema.Name == null)
                                    {
                                        docSchema.Name = System.IO.Path.GetFileNameWithoutExtension(filename);
                                    }
                                }
                                catch(System.Exception xx)
                                {
                                    MessageBox.Show(this, xx.Message, "Import XSD");
                                }
                            }
                            break;
                    }

                }

                // load tree before generating use definitions
                this.LoadTree();

                // load tree again to pick up definitions
                if (importedschemas.Count > 0)
                {
                    LoadTree();
                }
            }

            if (sbErrors.Length > 0)
            {
                MessageBox.Show(this, "Import succeeded, however one or more definitions have missing or incorrect information:\r\n" + sbErrors.ToString(), "Import Errors");
            }
        }
Example #5
0
        private void toolStripMenuItemFileUpdate_Click(object sender, EventArgs e)
        {
            DialogResult res = this.openFileDialogUpdate.ShowDialog(this);
            if (res == DialogResult.OK)
            {
                foreach (string filename in this.openFileDialogUpdate.FileNames)
                {
                    string ext = System.IO.Path.GetExtension(filename).ToLower();
                    switch (ext)
                    {
                        case ".vex":
                            using (FormatSPF format = new FormatSPF(filename, SchemaVEX.Types, null))
                            {
                                format.Load();

                                // loop through relevent entities, update from database
                                foreach (SEntity entity in format.Instances.Values)
                                {
                                    if (entity is ENTITIES)
                                    {
                                        ENTITIES ent = (ENTITIES)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            // get corresponding instance in documentation database
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.text.ToLowerInvariant(), out tn))
                                            {
                                                DocEntity docEntity = (DocEntity)tn.Tag;

                                                ent.comment.text.text = docEntity.Documentation;

                                                // also update attributes
                                                if (ent.attributes != null)
                                                {
                                                    foreach (ATTRIBUTE_DEF attr in ent.attributes)
                                                    {
                                                        if (attr.comment != null && attr.comment.text != null)
                                                        {
                                                            foreach (DocAttribute docattr in docEntity.Attributes)
                                                            {
                                                                if (docattr.Name.Equals(attr.name.text))
                                                                {
                                                                    attr.comment.text.text = docattr.Documentation;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }

                                                // where rules
                                                if (ent.wheres != null)
                                                {
                                                    foreach (WHERE_RULE attr in ent.wheres)
                                                    {
                                                        if (attr.comment != null && attr.comment.text != null)
                                                        {
                                                            foreach (DocWhereRule docattr in docEntity.WhereRules)
                                                            {
                                                                if (docattr.Name.Equals(attr.name))
                                                                {
                                                                    attr.comment.text.text = docattr.Documentation;
                                                                    attr.rule_context = docattr.Expression; // update where rule expression
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else if (entity is ENUMERATIONS)
                                    {
                                        ENUMERATIONS ent = (ENUMERATIONS)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.text.ToLowerInvariant(), out tn))
                                            {
                                                DocEnumeration docEntity = (DocEnumeration)tn.Tag;
                                                ent.comment.text.text = docEntity.Documentation;
                                            }

                                        }
                                    }
                                    else if (entity is DEFINED_TYPE)
                                    {
                                        DEFINED_TYPE ent = (DEFINED_TYPE)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.text.ToLowerInvariant(), out tn))
                                            {
                                                DocDefined docEntity = (DocDefined)tn.Tag;
                                                ent.comment.text.text = docEntity.Documentation;
                                            }
                                        }
                                    }
                                    else if (entity is SELECTS)
                                    {
                                        SELECTS ent = (SELECTS)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.text.ToLowerInvariant(), out tn))
                                            {
                                                DocSelect docEntity = (DocSelect)tn.Tag;
                                                ent.comment.text.text = docEntity.Documentation;
                                            }
                                        }
                                    }
                                    else if (entity is GLOBAL_RULE)
                                    {
                                        GLOBAL_RULE rule = (GLOBAL_RULE)entity;
                                        if (rule.comment != null && rule.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(rule.name.ToLowerInvariant(), out tn))
                                            {
                                                DocGlobalRule docEntity = (DocGlobalRule)tn.Tag;
                                                rule.comment.text.text = docEntity.Documentation;
                                                rule.rule_context = docEntity.Expression;
                                            }
                                        }
                                    }
                                    else if (entity is USER_FUNCTION)
                                    {
                                        USER_FUNCTION func = (USER_FUNCTION)entity;
                                        TreeNode tn = null;
                                        if (func.name != null && this.m_mapTree.TryGetValue(func.name.ToLowerInvariant(), out tn))
                                        {
                                            DocFunction docFunc = (DocFunction)tn.Tag;
                                            if (func.comment != null && func.comment.text != null)
                                            {
                                                func.comment.text.text = docFunc.Documentation;
                                            }
                                            func.rule_context = docFunc.Expression;
                                        }
                                    }
                                    else if (entity is USER_PROCEDURE)
                                    {
                                        //?? unused for IFC
                                    }
                                    else if (entity is SCHEMATA)
                                    {
                                        SCHEMATA ent = (SCHEMATA)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.ToLowerInvariant(), out tn))
                                            {
                                                DocSchema docSchema = (DocSchema)tn.Tag;
                                                ent.comment.text.text = docSchema.Documentation;
                                            }
                                        }
                                    }
                                }

                                format.Save();
                            }
                            break;
                    }
                }
            }
        }
Example #6
0
        private void backgroundWorkerValidate_DoWork(object sender, DoWorkEventArgs e)
        {
            if (this.m_filterviews == null)
                return;

            // reset state
            foreach(DocTemplateDefinition template in this.m_project.Templates)
            {
                TemplateReset(template);
            }

            // count active roots
            int progressTotal = 2;
            foreach (DocModelView docView in this.m_filterviews)
            {
                // reset state
                foreach(DocConceptRoot docRoot in docView.ConceptRoots)
                {
                    foreach(DocTemplateUsage docUsage in docRoot.Concepts)
                    {
                        docUsage.ResetValidation();
                    }
                }

                progressTotal += docView.ConceptRoots.Count;
            }
            this.m_formProgress.SetProgressTotal(progressTotal);
            int progress = 0;

            // build schema dynamically
            this.backgroundWorkerValidate.ReportProgress(++progress, "Compiling schema...");
            Dictionary<string, Type> typemap = new Dictionary<string, Type>();

            Compiler compiler = new Compiler(this.m_project, this.m_filterviews, this.m_filterexchange);
            System.Reflection.Emit.AssemblyBuilder assembly = compiler.Assembly;

            this.m_assembly = assembly;

            Type[] types = assembly.GetTypes();
            foreach (Type t in types)
            {
                typemap.Add(t.Name.ToUpper(), t);
            }

            int grandtotallist = 0;
            int grandtotalskip = 0;
            int grandtotalpass = 0;
            StringBuilder sb = new StringBuilder();

            // Example:
            // | IfcWall   | #2, #3 | PASS (30/30) |
            // | +Identity | #2     | FAIL (23/30) |

            try
            {
                m_loading = true;
                Dictionary<long, SEntity> instances = new Dictionary<long, SEntity>();
                this.backgroundWorkerValidate.ReportProgress(++progress, "Loading file...");
                using (FormatSPF format = new FormatSPF(Properties.Settings.Default.ValidateFile, typemap, instances))
                {
                    format.Load();

                    string[] errors = format.Errors;
                    if (errors != null && errors.Length > 0)
                    {
                        sb.AppendLine("This file contains format errors which may impact data validation results:");
                        sb.AppendLine("<ul>");
                        for (int i = 0; i < errors.Length; i++)
                        {
                            sb.AppendLine("<li>" + errors[i] + "</li>");
                        }
                        sb.AppendLine("</ul>");
                    }

                    // now iterate through each concept root
                    foreach (DocModelView docView in this.m_filterviews)
                    {
                        foreach (DocConceptRoot docRoot in docView.ConceptRoots)
                        {
                            if (this.backgroundWorkerValidate.CancellationPending)
                                return;

                            this.backgroundWorkerValidate.ReportProgress(++progress, docRoot);

                            Type typeEntity = null;
                            if (typemap.TryGetValue(docRoot.ApplicableEntity.Name.ToUpper(), out typeEntity))
                            {
                                // build list of instances
                                List<SEntity> list = new List<SEntity>();
                                foreach (SEntity instance in format.Instances.Values)
                                {
                                    if (typeEntity.IsInstanceOfType(instance))
                                    {
                                        list.Add(instance);
                                    }
                                }

                                //if (list.Count > 0)
                                {
                                    sb.AppendLine("<h3>" + docRoot.ApplicableEntity.Name + " (" + list.Count + ")</h3>");

                                    foreach (DocTemplateUsage docUsage in docRoot.Concepts)
                                    {
                                        ValidateConcept(docUsage, docView, DocExchangeRequirementEnum.NotRelevant, typeEntity, list, sb, typemap, ref grandtotalpass, ref grandtotalskip, ref grandtotallist);
                                    }
                                }
                            }
                        }
                    }
                    this.m_formatTest = format;
                }
            }
            catch (Exception x)
            {
                this.m_exception = x;
            }
            finally
            {
                m_loading = false;
            }

            sb.AppendLine("</table>");

            // create html doc
            int grandtotalpercent = 0;
            if (grandtotallist > 0)
            {
                grandtotalpercent = 100 * (grandtotalpass + grandtotalskip) / grandtotallist;
            }

            if (Properties.Settings.Default.ValidateReport)
            {
                string path = Properties.Settings.Default.ValidateFile + ".htm";
                using (System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create))
                {
                    using (System.IO.StreamWriter writer = new System.IO.StreamWriter(fs))
                    {
                        writer.WriteLine("<html>");
                        writer.WriteLine("<body>");

                        string exchange = null;
                        if (this.m_filterexchange != null)
                        {
                            exchange = this.m_filterexchange.Name;
                        }

                        writer.WriteLine("<h1>Validation Results</h1>");
                        writer.WriteLine("<table border='1'>");
                        writer.WriteLine("<tr><td>Instance File</td><td>" + Properties.Settings.Default.ValidateFile + "</td></tr>");
                        writer.WriteLine("<tr><td>Project File</td><td>" + this.m_file + "</td></tr>");
                        writer.WriteLine("<tr><td>Model View</td><td>" + this.m_filterviews[0].Name + "</td></tr>");
                        writer.WriteLine("<tr><td>Exchange</td><td>" + exchange + "</td></tr>");
                        writer.WriteLine("<tr><td>Tests Executed</td><td>" + grandtotallist + "</td></tr>");
                        writer.WriteLine("<tr><td>Tests Passed</td><td>" + grandtotalpass + "</td></tr>");
                        writer.WriteLine("<tr><td>Tests Ignored</td><td>" + grandtotalskip + "</td></tr>");
                        writer.WriteLine("<tr><td>Tests Percentage</td><td>" + grandtotalpercent + "%</td></tr>");
                        writer.WriteLine("</table>");

                        writer.WriteLine(sb.ToString());

                        writer.WriteLine("</body>");
                        writer.WriteLine("</html>");
                    }
                }

                // launch
                System.Diagnostics.Process.Start(path);
            }
        }
Example #7
0
        private void mergeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult res = this.openFileDialogMerge.ShowDialog();
            if (res != DialogResult.OK)
                return;

            // load file into different context, compare
            this.m_loading = true;

            Dictionary<long, SEntity> instances = new Dictionary<long, SEntity>();
            using (FormatSPF format = new FormatSPF(this.openFileDialogMerge.FileName, SchemaDOC.Types, instances))
            {
                format.Load();
            }

            this.m_loading = false;

            // now import changes
            DocProject docProjectBase = null;
            foreach (SEntity o in instances.Values)
            {
                if (o is DocProject)
                {
                    docProjectBase = (DocProject)o;
                }
            }

            // create guid map for rapid lookup
            Dictionary<Guid, DocObject> mapGuid = new Dictionary<Guid, DocObject>();
            foreach (SEntity o in this.m_instances.Values)
            {
                if (o is DocObject)
                {
                    DocObject docObj = (DocObject)o;
                    try
                    {
                        mapGuid.Add(docObj.Uuid, docObj);
                    }
                    catch
                    {
                        System.Diagnostics.Debug.WriteLine("Duplicate Guid: " + docObj.Uuid.ToString() + " - " + docObj.GetType().ToString() + " - " + docObj.Name);
                    }
                }
            }

            using (FormMerge formMerge = new FormMerge(mapGuid, docProjectBase))
            {
                res = formMerge.ShowDialog(this);
                if(res == System.Windows.Forms.DialogResult.OK)
                {
                    this.LoadTree();
                }
            }
        }
Example #8
0
        private void LoadFile(string filename)
        {
            this.SetCurrentFile(filename);

            this.m_lastid = 0;
            this.m_instances.Clear();
            this.m_mapTree.Clear();
            this.m_clipboard = null;
            this.m_project = null;

            List<DocChangeAction> listChange = new List<DocChangeAction>(); //temp

            string ext = System.IO.Path.GetExtension(this.m_file).ToLower();
            try
            {
                switch (ext)
                {
                    case ".ifcdoc":
                        using (FormatSPF format = new FormatSPF(this.m_file, SchemaDOC.Types, this.m_instances))
                        {
                            format.Load();
                        }
                        break;

            #if MDB
                    case ".mdb":
                        using (FormatMDB format = new FormatMDB(this.m_file, SchemaDOC.Types, this.m_instances))
                        {
                            format.Load();
                        }
                        break;
            #endif
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(this, x.Message, "Error", MessageBoxButtons.OK);

                // force new as state is now invalid
                this.m_modified = false;
                this.toolStripMenuItemFileNew_Click(this, EventArgs.Empty);
                return;
            }

            List<SEntity> listDelete = new List<SEntity>();
            List<DocTemplateDefinition> listTemplate = new List<DocTemplateDefinition>();

            // get the project, determine the next OID to use
            foreach (SEntity o in this.m_instances.Values)
            {
                if (o is DocProject)
                {
                    this.m_project = (DocProject)o;
                }
                else if (o is DocEntity)
                {
                    DocEntity docent = (DocEntity)o;

            #if false
                    // files before V5.3 had Description field; no longer needed so use regular Documentation field again.
                    if (docent._Description != null)
                    {
                        docent.Documentation = docent._Description;
                        docent._Description = null;
                    }
            #endif
                }
                else if(o is DocAttribute)
                {
            #if false
                    // files before V8.7 didn't have nullable tagless
                    DocAttribute docAttr = (DocAttribute)o;
                    if (docAttr.XsdTagless == false)
                    {
                        docAttr.XsdTagless = null;
                    }
            #endif
                }
                else if(o is DocSchema)
                {
                    DocSchema docSchema = (DocSchema)o;

                    // renumber page references
                    foreach (DocPageTarget docTarget in docSchema.PageTargets)
                    {
                        int page = docSchema.GetDefinitionPageNumber(docTarget);
                        int item = docSchema.GetPageTargetItemNumber(docTarget);
                        docTarget.Name = page + "," + item + " " + docTarget.Definition.Name;

                        foreach(DocPageSource docSource in docTarget.Sources)
                        {
                            docSource.Name = docTarget.Name;
                        }
                    }
                }
                else if (o is DocExchangeDefinition)
                {
                    // files before V4.9 had Description field; no longer needed so use regular Documentation field again.
                    DocExchangeDefinition docexchange = (DocExchangeDefinition)o;
                    if (docexchange._Description != null)
                    {
                        docexchange.Documentation = docexchange._Description;
                        docexchange._Description = null;
                    }
                }
                else if (o is DocTemplateDefinition)
                {
                    // files before V5.0 had Description field; no longer needed so use regular Documentation field again.
                    DocTemplateDefinition doctemplate = (DocTemplateDefinition)o;
                    if (doctemplate._Description != null)
                    {
                        doctemplate.Documentation = doctemplate._Description;
                        doctemplate._Description = null;
                    }

                    listTemplate.Add((DocTemplateDefinition)o);
                }
                else if(o is DocChangeAction)
                {
                    // tempdebug -- delete old change actions -- need to clean up
                    //o.Delete();
                    listChange.Add((DocChangeAction)o);
                }

                // ensure all objects have valid guid
                if (o is DocObject)
                {
                    DocObject docobj = (DocObject)o;
                    if (docobj.Uuid == Guid.Empty)
                    {
                        docobj.Uuid = Guid.NewGuid();
                    }

            #if false
                    // ensure any image references are in lowercase
                    if(docobj.Documentation != null && docobj.Documentation.Length > 0)
                    {
                        int i = 0;
                        while (i != -1)
                        {
                            i = docobj.Documentation.IndexOf("../figures/", i + 1);
                            if(i != -1)
                            {
                                int start = i + 11;
                                int end = docobj.Documentation.IndexOf('"', start);
                                if(end > start)
                                {
                                    string strold = docobj.Documentation.Substring(start, end - start);
                                    string strnew = strold.ToLower();

                                    docobj.Documentation = docobj.Documentation.Substring(0, start) + strnew + docobj.Documentation.Substring(end);
                                    System.Diagnostics.Debug.WriteLine(strnew);
                                }
                            }
                        }
                    }
            #endif
                }

                if (o.OID > this.m_lastid)
                {
                    this.m_lastid = o.OID;
                }
            }

            if (this.m_project == null)
            {
                MessageBox.Show(this, "File is invalid; no project is defined.", "Error", MessageBoxButtons.OK);
                return;
            }

            //tempcleanip
            //for (int i = listChange.Count - 1; i >= 0;i-- )
            {
                //listChange[i].Delete();
            }

                // now capture any template definitions (upgrade in V3.5)
                foreach (DocModelView docModelView in this.m_project.ModelViews)
                {
                    if (docModelView.ConceptRoots == null)
                    {
                        // must convert to new format
                        docModelView.ConceptRoots = new List<DocConceptRoot>();

                        foreach (DocSection docSection in this.m_project.Sections)
                        {
                            foreach (DocSchema docSchema in docSection.Schemas)
                            {
                                foreach (DocEntity docEntity in docSchema.Entities)
                                {
                                    if (docEntity.__Templates != null)
                                    {
                                        foreach (DocTemplateUsage docTemplateUsage in docEntity.__Templates)
                                        {
                                            // must generate or use existing concept root

                                            DocConceptRoot docConceptRoot = null;
                                            foreach (DocConceptRoot eachConceptRoot in docModelView.ConceptRoots)
                                            {
                                                if (eachConceptRoot.ApplicableEntity == docEntity)
                                                {
                                                    docConceptRoot = eachConceptRoot;
                                                    break;
                                                }
                                            }

                                            if (docConceptRoot == null)
                                            {
                                                docConceptRoot = new DocConceptRoot();
                                                docConceptRoot.ApplicableEntity = docEntity;
                                                docModelView.ConceptRoots.Add(docConceptRoot);
                                            }

                                            docConceptRoot.Concepts.Add(docTemplateUsage);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

            // upgrade to Publications (V9.6)
            if (this.m_project.Annotations.Count == 4)
            {
                this.m_project.Publications.Clear();

                DocAnnotation docCover = this.m_project.Annotations[0];
                DocAnnotation docContents = this.m_project.Annotations[1];
                DocAnnotation docForeword = this.m_project.Annotations[2];
                DocAnnotation docIntro = this.m_project.Annotations[3];

                DocPublication docPub = new DocPublication();
                docPub.Name = "Default";
                docPub.Documentation = docCover.Documentation;
                docPub.Owner = docCover.Owner;
                docPub.Author = docCover.Author;
                docPub.Code = docCover.Code;
                docPub.Copyright = docCover.Copyright;
                docPub.Status = docCover.Status;
                docPub.Version = docCover.Version;

                docPub.Annotations.Add(docForeword);
                docPub.Annotations.Add(docIntro);

                this.m_project.Publications.Add(docPub);

                docCover.Delete();
                docContents.Delete();
                this.m_project.Annotations.Clear();
            }

            LoadTree();
        }
Example #9
0
        private void generateChangeLogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult res = this.openFileDialogChanges.ShowDialog(this);
            if (res != DialogResult.OK)
                return;

            Dictionary<long, SEntity> instances = new Dictionary<long, SEntity>();
            this.m_loading = true;
            try
            {
                using (FormatSPF format = new FormatSPF(this.openFileDialogChanges.FileName, SchemaDOC.Types, instances))
                {
                    format.Load();
                }
            }
            catch(Exception x)
            {
                MessageBox.Show(x.Message);
                return;
            }
            finally
            {
                this.m_loading = false;
            }

            // now import changes
            DocProject docProjectBase = null;
            foreach (SEntity o in instances.Values)
            {
                if (o is DocProject)
                {
                    docProjectBase = (DocProject)o;
                    break;
                }
            }

            ChangeLogGenerator.Generate(docProjectBase, this.m_project);
            this.LoadTree();
        }
Example #10
0
        private void LoadFile(string filename)
        {
            this.SetCurrentFile(filename);


            this.m_lastid = 0;
            this.m_instances.Clear();
            this.m_mapTree.Clear();
            this.m_clipboard = null;
            this.m_project = null;

            string ext = System.IO.Path.GetExtension(this.m_file).ToLower();
            try
            {
                switch (ext)
                {
                    case ".ifcdoc":
                        using (FormatSPF format = new FormatSPF(this.m_file, SchemaDOC.Types, this.m_instances))
                        {
                            format.Load();
                        }
                        break;

                    case ".mdb":
                        using (FormatMDB format = new FormatMDB(this.m_file, SchemaDOC.Types, this.m_instances))
                        {
                            format.Load();
                        }
                        break;
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(this, x.Message, "Error", MessageBoxButtons.OK);

                // force new as state is now invalid
                this.m_modified = false;
                this.toolStripMenuItemFileNew_Click(this, EventArgs.Empty);
                return;
            }

            List<SEntity> listDelete = new List<SEntity>();
            List<DocTemplateDefinition> listTemplate = new List<DocTemplateDefinition>();

            // get the project, determine the next OID to use
            foreach (SEntity o in this.m_instances.Values)
            {
                if (o is DocProject)
                {
                    this.m_project = (DocProject)o;
                }
                else if (o is DocEntity)
                {
                    DocEntity docent = (DocEntity)o;

#if false
                    // files before V5.3 had Description field; no longer needed so use regular Documentation field again.
                    if (docent._Description != null)
                    {
                        docent.Documentation = docent._Description;
                        docent._Description = null;
                    }
#endif
                }
                else if(o is DocAttribute)
                {
#if false
                    // files before V8.7 didn't have nullable tagless
                    DocAttribute docAttr = (DocAttribute)o;
                    if (docAttr.XsdTagless == false)
                    {
                        docAttr.XsdTagless = null;
                    }
#endif
                }
                else if (o is DocExchangeDefinition)
                {
                    // files before V4.9 had Description field; no longer needed so use regular Documentation field again.
                    DocExchangeDefinition docexchange = (DocExchangeDefinition)o;
                    if (docexchange._Description != null)
                    {
                        docexchange.Documentation = docexchange._Description;
                        docexchange._Description = null;
                    }
                }
                else if (o is DocTemplateDefinition)
                {
                    // files before V5.0 had Description field; no longer needed so use regular Documentation field again.
                    DocTemplateDefinition doctemplate = (DocTemplateDefinition)o;
                    if (doctemplate._Description != null)
                    {
                        doctemplate.Documentation = doctemplate._Description;
                        doctemplate._Description = null;
                    }

                    listTemplate.Add((DocTemplateDefinition)o);
                }

                // ensure all objects have valid guid
                if (o is DocObject)
                {
                    DocObject docobj = (DocObject)o;
                    if (docobj.Uuid == Guid.Empty)
                    {
                        docobj.Uuid = Guid.NewGuid();
                    }

#if false
                    // ensure any image references are in lowercase
                    if(docobj.Documentation != null && docobj.Documentation.Length > 0)
                    {
                        int i = 0;
                        while (i != -1)
                        {
                            i = docobj.Documentation.IndexOf("../figures/", i + 1);
                            if(i != -1)
                            {
                                int start = i + 11;
                                int end = docobj.Documentation.IndexOf('"', start);
                                if(end > start)
                                {
                                    string strold = docobj.Documentation.Substring(start, end - start);
                                    string strnew = strold.ToLower();

                                    docobj.Documentation = docobj.Documentation.Substring(0, start) + strnew + docobj.Documentation.Substring(end);
                                    System.Diagnostics.Debug.WriteLine(strnew);
                                }
                            }
                        }
                    }
#endif
                }


                if (o.OID > this.m_lastid)
                {
                    this.m_lastid = o.OID;
                }
            }

            if (this.m_project == null)
            {
                MessageBox.Show(this, "File is invalid; no project is defined.", "Error", MessageBoxButtons.OK);
                return;
            }

            // now capture any template definitions (upgrade in V3.5)
            foreach (DocModelView docModelView in this.m_project.ModelViews)
            {
                if (docModelView.ConceptRoots == null)
                {
                    // must convert to new format
                    docModelView.ConceptRoots = new List<DocConceptRoot>();

                    foreach (DocSection docSection in this.m_project.Sections)
                    {
                        foreach (DocSchema docSchema in docSection.Schemas)
                        {
                            foreach (DocEntity docEntity in docSchema.Entities)
                            {
                                if (docEntity.__Templates != null)
                                {
                                    foreach (DocTemplateUsage docTemplateUsage in docEntity.__Templates)
                                    {
                                        // must generate or use existing concept root

                                        DocConceptRoot docConceptRoot = null;
                                        foreach (DocConceptRoot eachConceptRoot in docModelView.ConceptRoots)
                                        {
                                            if (eachConceptRoot.ApplicableEntity == docEntity)
                                            {
                                                docConceptRoot = eachConceptRoot;
                                                break;
                                            }
                                        }

                                        if (docConceptRoot == null)
                                        {
                                            docConceptRoot = new DocConceptRoot();
                                            docConceptRoot.ApplicableEntity = docEntity;
                                            docModelView.ConceptRoots.Add(docConceptRoot);
                                        }

                                        docConceptRoot.Concepts.Add(docTemplateUsage);
                                    }
                                }
                            }
                        }
                    }
                }
            }

#if false
            // temp fixup
            foreach (DocSection docSection in this.m_project.Sections)
            {
                foreach (DocSchema docSchema in docSection.Schemas)
                {
                    //docSchema.PropertyEnums.Sort();

                    foreach (DocPropertyEnumeration docEnum in docSchema.PropertyEnums)
                    {
                        foreach(DocPropertyConstant docConst in docEnum.Constants)
                        {
                            docConst.Name = docConst.Name.ToUpper(); // ensure uppercase throughout

                            switch(docConst.Name)
                            {
                                case "OTHER":
                                    docConst.RegisterLocalization("en", "(other)", "Value is not listed.");
                                    break;

                                case "NOTKNOWN":
                                    docConst.RegisterLocalization("en", "(unknown)", "Value is unknown.");
                                    break;

                                case "UNSET":
                                    docConst.RegisterLocalization("en", "(unset)", "Value has not been specified.");
                                    break;
                            }
                        }
                    }
                }
            }
#endif

#if false
            // ensure property enumerations are defined (upgrade to V5.8) and provide localizations
            Dictionary<string, DocPropertyEnumeration> mapEnums = new Dictionary<string, DocPropertyEnumeration>();

            foreach(DocSection docSection in this.m_project.Sections)
            {
                foreach(DocSchema docSchema in docSection.Schemas)
                {
                    foreach(DocType docType in docSchema.Types)
                    {
                        EnsureLocalized(docType);
                    }

                    foreach(DocEntity docEntity in docSchema.Entities)
                    {
                        EnsureLocalized(docEntity);
                    }

                    foreach(DocFunction docFunction in docSchema.Functions)
                    {
                        EnsureLocalized(docFunction);
                    }

                    foreach(DocGlobalRule docRule in docSchema.GlobalRules)
                    {
                        EnsureLocalized(docRule);
                    }

                    foreach(DocPropertySet docPset in docSchema.PropertySets)
                    {
                        EnsureLocalized(docPset);

                        foreach(DocProperty docProp in docPset.Properties)
                        {
                            EnsureLocalized(docProp);

                            if (docProp.PropertyType == DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE)
                            {
                                // temporary migration
                                string match = "PEnum_Status:";
                                if (docProp.SecondaryDataType.StartsWith(match))
                                {
                                    docProp.SecondaryDataType = "PEnum_ElementStatus:" + docProp.SecondaryDataType.Substring(match.Length);
                                }

                                string[] enumhost = docProp.SecondaryDataType.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                                if (enumhost.Length == 2)
                                {
                                    string enumname = enumhost[0];


                                    DocPropertyEnumeration docEnum = null;
                                    if (docProp.PrimaryDataType != null && !mapEnums.TryGetValue(enumname, out docEnum))
                                    {
                                        docEnum = new DocPropertyEnumeration();
                                        docEnum.Name = enumname;
                                        docSchema.PropertyEnums.Add(docEnum);

                                        mapEnums.Add(docEnum.Name, docEnum);

                                        string[] enumvals = enumhost[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                        foreach (string val in enumvals)
                                        {
                                            DocPropertyConstant docConstant = new DocPropertyConstant();
                                            docConstant.Name = val;
                                            docEnum.Constants.Add(docConstant);

                                            // localize constant
                                            StringBuilder sb = new StringBuilder();

                                            // if constant is entirely uppercase, then convert such that only first character is uppercase
                                            for (int i = 0; i < val.Length; i++ )
                                            {
                                                char ch = val[i];
                                                if (ch == '_')
                                                {
                                                    ch = ' ';
                                                }
                                                else if (Char.IsUpper(ch) && i > 0 && !Char.IsUpper(val[i - 1]))
                                                {
                                                    sb.Append(" ");
                                                }
                                                else if(Char.IsUpper(ch) && i > 0 && Char.IsUpper(val[i-1]))
                                                {
                                                    ch = Char.ToLower(ch);
                                                }

                                                sb.Append(ch);
                                            }

                                            // find description for constant
                                            string doc = null;
                                            int iDoc = docProp.Documentation.IndexOf(docConstant.Name + ":");
                                            if(iDoc > 0)
                                            {
                                                int iTail = docProp.Documentation.IndexOfAny(new char[] { '.', ';', '\r', '\n'}, iDoc+1);
                                                if (iTail == -1)
                                                {
                                                    iTail = docProp.Documentation.Length;
                                                }
                                                doc = docProp.Documentation.Substring(iDoc + docConstant.Name.Length + 2, iTail - iDoc - docConstant.Name.Length - 2);
                                            }

                                            docConstant.RegisterLocalization("en", sb.ToString(), doc);
                                        }

                                    }
                                }
                            }
                        }

                    }

                    foreach(DocQuantitySet docQset in docSchema.QuantitySets)
                    {
                        EnsureLocalized(docQset);

                        foreach(DocQuantity docQuantiy in docQset.Quantities)
                        {
                            EnsureLocalized(docQuantiy);
                        }
                    }
                }
            }
#endif


#if false
            // temp: garbage collection for files that didn't clean up properly
            StringBuilder sb = new StringBuilder();
            this.m_project.Mark();
            List<SEntity> collect = new List<SEntity>();
            foreach (SEntity o in this.m_instances.Values)
            {
                if(!o.Existing)
                {
                    collect.Add(o);
                }
            }

            for (int i = collect.Count - 1; i >= 0; i--)
            {
                SEntity ent = collect[i];
                if(!ent.Existing)
                {
                    sb.AppendLine("#" + ent.OID + "=" + ent.GetType().Name + ";");
                    this.m_instances.Remove(ent.OID);
                }
            }
            string sss = sb.ToString();
#endif

            // now clear out the lists going forward.
            LoadTree();
        }