示例#1
0
 private static void InstantiateReport()
 {
     Report                         = new ReportObj();
     Report.ReportDate              = DateTime.Now;
     Report.AlalyzedFiles           = new List <FileAnalysis>();
     Report.UnauthorizedDirectories = new List <string>();
     Report.DuplicateKeys           = new List <AppSettingInfo>();
     Report.UnauthorizedDirectories = new List <string>();
     Report.Connections             = new List <TestedConnection>();
 }
示例#2
0
        private static void WriteReport()
        {
            EchoTotals();

            XmlSerializer serializer = new XmlSerializer(typeof(ReportObj));

            ReportObj ro = new ReportObj();

            ro.ReportDate              = Report.ReportDate;
            ro.AlalyzedFiles           = (from f in Report.AlalyzedFiles where f.Discrepancies.Count() > 0 select f).ToList <FileAnalysis>();
            ro.DuplicateKeys           = Report.DuplicateKeys;
            ro.UnauthorizedDirectories = Report.UnauthorizedDirectories;

            // Create the xml file
            string report = HelperMethods.CheckConfiguration("logPath");

            if (File.Exists(report))
            {
                try
                {
                    TextWriter textWriter = new StreamWriter(report, false);
                    serializer.Serialize(textWriter, ro);
                    textWriter.Close();
                }
                catch (UnauthorizedAccessException)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine();
                    Console.WriteLine(System.Environment.UserName + " Does not have access to the path " + report + ".  No log will be created.");
                    Console.WriteLine();
                    Console.ResetColor();
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine();
                Console.WriteLine("Could not find part of the path " + report + ".  No log will be created.");
                Console.WriteLine();
                Console.ResetColor();
            }

            string epPage = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ConfigCopPages");

            epPage = Path.Combine(epPage, "Endpoints.html");
            string html = GenEnpointPageHtml();

            if (File.Exists(epPage))
            {
                try
                {
                    using (StreamWriter sw = new StreamWriter(epPage, false))
                    {
                        sw.Write(html);
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine();
                    Console.WriteLine(System.Environment.UserName + " Does not have access to the path " + epPage + ".  Endpoints.html will not be created.");
                    Console.WriteLine();
                    Console.ResetColor();
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine();
                Console.WriteLine("Could not find part of the path " + epPage + ".  Endpoints.html will not be created.");
                Console.WriteLine();
                Console.ResetColor();
            }
        }