Formatter for ISO 10303-28 (STEP-XML), supporting IFC-XML. Observes CNF file settings for output.
Inheritance: IfcDoc.Format.SMF.FormatSMF, IFormatData
示例#1
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);
                }
            }
        }
        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);
                }
            }

        }
示例#3
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;
                            }
                        }
                    }
                }
            }
            //...
        }