/// <summary> /// This method takes the stylesheet filename as input /// </summary> /// <param name="styleSheetFileName"></param> public void EndReporting(bool generateSupportFiles) { Logger.EnteredMethod(LogSource.Common); if (m_writer == null) { Logger.Write(LogSource.Common, TraceLevel.Error, "The method EndReporting called without calling StartReporting"); return; } // Check if the file is already generated before. if (!triedOnce) { if (summaryField.Status == null) { summaryField.Status = CommonResource.ProcessIncomplete; } DateTime endDateTime = DateTime.Now; summaryField.EndTime = endDateTime.ToString(CultureInfo.CurrentCulture); TimeSpan totalTime = endDateTime.Subtract(m_startDateTime); //Do not report milliseconds int days = totalTime.Days; int hours = totalTime.Hours; int mins = totalTime.Minutes; int seconds = totalTime.Seconds; totalTime = new TimeSpan(days, hours, mins, seconds); summaryField.TotalTime = totalTime.ToString(); // I dont know if this will be an issue for glob/loc. I dont think so. this.RunBy = Environment.UserDomainName + Path.DirectorySeparatorChar + Environment.UserName; try { GenerateXml(m_writer, generateSupportFiles); triedOnce = true; } finally { m_writer.Close(); if (generateSupportFiles) { //Create the directory first; FileInfo info = new FileInfo(m_fileName); string parentPath = info.Directory.FullName; string outputDirName = Path.Combine(parentPath, Report.SupportFileDirectory); UtilityMethods.CreateDirectory(outputDirName); //Then copy the files foreach (string str in Report.SupportFiles) { UtilityMethods.CopyFromAssemblyToDestination(str, Path.Combine(outputDirName, str)); } } // If the previous attempt to write failed // Write the report into the new backup file // Any exceptions here would be propagated to the caller!! if (!triedOnce) { triedOnce = true; m_backupFileName = Path.GetTempPath() + "MigrationReport.xml"; // The name of the file is not yet finalized in spec. m_fileName = m_backupFileName; // Set the file name to the new name GenerateXml(new StreamWriter(m_backupFileName), generateSupportFiles); } } } #if DEBUG //only in debug mode validate the generated xml file against the reportschema xsd file. try { UtilityMethods.ValidateXmlFile(m_fileName, m_xsdFileName); } catch (ConverterException e) { Logger.WriteException(LogSource.Common, e); UtilityMethods.DisplayError("The generated Report file does not comply with the xsd file"); } #endif Logger.ExitingMethod(LogSource.Common); }