Example #1
0
        private static void CheckForLine(StringBuilder found, List <string> contentList, bool ignoreCase)
        {
            string foundUse = found.ToString();

            if (ignoreCase == true)
            {
                foundUse = foundUse.ToUpper();
            }

            foreach (string line in contentList)
            {
                string lineUse = line;

                if (ignoreCase == true)
                {
                    lineUse = lineUse.ToUpper();
                }

                if (!foundUse.Contains(lineUse.Trim()))
                {
                    int sc = Errors.GetStatusCode("MissingContent");
                    if (sc != 0)
                    {
                        Console.ForegroundColor = Errors.GetColorByStatus(sc);
                        Console.WriteLine("File does not contain specified content!");
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.WriteLine(line);
                        Console.ResetColor();

                        Errors.MissingContent();
                    }
                }
            }
        }
Example #2
0
        private static void EchoTotals()
        {
            List <Discrepancy> discrepancies = new List <Discrepancy>();

            foreach (var file in Report.AlalyzedFiles)
            {
                foreach (Discrepancy d in file.Discrepancies)
                {
                    discrepancies.Add(d);
                }
            }

            Console.WriteLine();

            var sorted = from d in discrepancies group d by d.StatusCode into grpd select grpd;

            foreach (var grp in sorted)
            {
                Console.ForegroundColor = Errors.GetColorByStatus(grp.Key);
                Console.WriteLine(grp.Count() + " " + Errors.GetStatusNameByCode(grp.Key));
                Console.ResetColor();
            }

            Console.WriteLine();
        }
Example #3
0
        private static void ExtractLinesStd(FileInfo fi)
        {
            try
            {
                using (StreamReader sr = new StreamReader(fi.FullName))
                {
                    int    lineNum = 1;
                    string line    = sr.ReadLine();
                    while (line != null)
                    {
                        string commentChar = "";
                        try
                        {
                            commentChar = ConfigurationManager.AppSettings["comment" + fi.Extension.ToLower()];
                        }
                        catch
                        {
                            //No comment character defined
                        }


                        if (!string.IsNullOrEmpty(commentChar))
                        {
                            if (!line.Trim().StartsWith(commentChar))
                            {
                                TestLine(lineNum, line);
                            }
                        }
                        else
                        {
                            TestLine(lineNum, line);
                        }

                        line = sr.ReadLine();
                        lineNum++;
                    }
                }
            }
            catch (System.UnauthorizedAccessException ex)
            {
                int sc = Errors.GetStatusCode("UnauthorizedAccessException");
                Console.ForegroundColor = Errors.GetColorByStatus(sc);
                Console.WriteLine(ex.Message);
                Console.ResetColor();
                Errors.ReportDiscrepancy(0, "Unable to Analyze file.", "Access Denied", sc);

                return;
            }
            catch (Exception ex)
            {
                int sc = Errors.GetStatusCode("Default");
                Console.ForegroundColor = Errors.GetColorByStatus(sc);
                Console.WriteLine(ex.Message);
                Console.ResetColor();
                Errors.ReportDiscrepancy(0, "Unable to Analyze file.", "Unknown Error.", sc);


                return;
            }
        }
Example #4
0
        private static void ExtractLinesXML(FileInfo fi)
        {
            try
            {
                XmlReaderSettings readerSettings = new XmlReaderSettings();
                readerSettings.IgnoreComments = true;
                readerSettings.DtdProcessing  = DtdProcessing.Parse;
                string content = "";
                using (XmlReader reader = XmlTextReader.Create(fi.FullName, readerSettings))
                {
                    while (reader.Read())
                    {
                        content = reader.ReadOuterXml();
                    }
                }

                using (StringReader sr = new StringReader(content))
                {
                    int    lineNum = 2;
                    string line    = sr.ReadLine();
                    while (line != null)
                    {
                        line = line.Trim();
                        TestLine(lineNum, line);

                        if (fi.Extension.ToUpper() == ".CONFIG")
                        {
                            HelperMethods.CollectAppSetting(fi, line);
                        }

                        line = sr.ReadLine();
                        lineNum++;
                    }
                }
            }
            catch (System.UnauthorizedAccessException ex)
            {
                int sc = Errors.GetStatusCode("UnauthorizedAccessException");
                Console.ForegroundColor = Errors.GetColorByStatus(sc);
                Console.WriteLine(ex.Message);
                Console.ResetColor();
                Errors.ReportDiscrepancy(0, "Unable to Analyze file.", "Access Denied", sc);

                return;
            }
            catch (Exception ex)
            {
                int sc = Errors.GetStatusCode("Default");
                Console.ForegroundColor = Errors.GetColorByStatus(sc);
                Console.WriteLine(ex.Message);
                Console.ResetColor();
                Errors.ReportDiscrepancy(0, "Unable to Analyze file.", "Unknown Error.", sc);

                return;
            }
        }
Example #5
0
        private static void ContentsMatch(bool result)
        {
            if (result == false)
            {
                int sc = Errors.GetStatusCode("MissingContent");
                if (sc != 0)
                {
                    Console.ForegroundColor = Errors.GetColorByStatus(sc);
                    Console.WriteLine("File contents do not match!");
                    Console.ResetColor();

                    Errors.MissingContent();
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Contents match.");
                Console.ResetColor();
            }
        }