private string CreateFileName()
        {
            string result;
            string ticks = DateTime.Now.Ticks.ToString();

            if (LogFileName.Contains("."))
            {
                string extension = LogFileName.Substring(LogFileName.LastIndexOf("."));
                string fileName  = LogFileName.Substring(0, LogFileName.LastIndexOf("."));
                fileName = string.Format("{0}[{1}]{2}", fileName, ticks, extension);
                result   = fileName;
            }
            else
            {
                string fileName = string.Format("{0}[{1}]", LogFileName, ticks);
                result = fileName;
            }

            SavedLogFileName = result;
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Close the log file, writing out final cached information.
        /// </summary>
        public void Close()
        {
            if (LoggingEnabled && m_LogFile != null)
            {
                int total = 0;
                ProcessLogTableStart("Entities Processed", "Entity Type");
                foreach (KeyValuePair <IFCEntityType, int> entry in m_ProcessedEntities)
                {
                    WriteLineNoBreak("<tr><td>" + entry.Key.ToString() + "<td>" + entry.Value);
                    total += entry.Value;
                }
                ProcessLogTableEnd(total);

                total = 0;
                ProcessLogTableStart("Elements Created", "Element Type");
                foreach (KeyValuePair <CreatedElementsKey, int> entry in m_CreatedElements)
                {
                    Write("<tr><td>");
                    if (!string.IsNullOrWhiteSpace(entry.Key.CatName))
                    {
                        Write("(" + entry.Key.CatName + ") ");
                    }
                    WriteLineNoBreak(entry.Key.ElemName + "<td>" + entry.Value);
                    total += entry.Value;
                }
                ProcessLogTableEnd(total);

                // Copy existing .log file, if any, to this file.
                // For now, assume name of original log file = logFileName - ".html"
                if (LogFileName.EndsWith(".log.html"))
                {
                    string originalLogFileName = LogFileName.Substring(0, LogFileName.Length - 5);
                    try
                    {
                        // ODA_TODO: Remove this when we remove the EDM toolkit.
                        if (File.Exists(originalLogFileName))
                        {
                            StreamReader originalLogFile = new StreamReader(originalLogFileName);
                            if (originalLogFile != null)
                            {
                                WriteLineNoBreak("<A NAME=\"ToolkitMessage\"></A>");
                                WriteLineNoBreak("Toolkit Log");
                                WriteLine("");

                                string originalLogContents = null;
                                while ((originalLogContents = originalLogFile.ReadLine()) != null)
                                {
                                    WriteLine(originalLogContents);
                                }
                                originalLogFile.Close();
                                File.Delete(originalLogFileName);
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                WriteLine("");
                WriteLine("Importer Version: " + IFCImportOptions.ImporterVersion);

                m_LogFile.Close();
            }

            m_LogFile      = null;
            LoggingEnabled = false;
            LogFileName    = null;
        }