예제 #1
0
        public static void GetBrowseObjects()
        {
            Program.BrowseList = new List <BrowseObj>();
            string browseFile = HelperMethods.CheckConfiguration("browseFile");

            if (File.Exists(browseFile))
            {
                using (StreamReader sr = new StreamReader(browseFile))
                {
                    string line = sr.ReadLine();
                    while (line != null)
                    {
                        string[] parts = line.Split('|');
                        string   a     = parts[0];
                        string   b     = "";
                        if (parts.Count() > 1)
                        {
                            b = parts[1];
                        }

                        Program.BrowseList.Add(new BrowseObj
                        {
                            Configured = a,
                            ActualUrl  = b
                        });

                        line = sr.ReadLine();
                    }
                }
            }
        }
예제 #2
0
        public static string GetStatusNameByCode(int status)
        {
            string statusCode = HelperMethods.CheckConfiguration(status.ToString());

            string[] parts = statusCode.Split('|');
            return(parts[0]);
        }
예제 #3
0
        public static void GetIgnores()
        {
            Program.IgnoreList = new List <IgnoreObj>();
            string ignoreFile = HelperMethods.CheckConfiguration("ignoreFile");

            if (File.Exists(ignoreFile))
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("Configured to use " + ignoreFile + " to filter tests.");
                Console.ResetColor();

                using (StreamReader sr = new StreamReader(ignoreFile))
                {
                    string line = sr.ReadLine();
                    while (line != null)
                    {
                        AddIgnoresForFile(line);
                        line = sr.ReadLine();
                    }
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("No existing ignoreFile has been specified in the configuration.");
                Console.ResetColor();
            }
        }
예제 #4
0
        public static int GetStatusCode(string cKey)
        {
            string statusCode = HelperMethods.CheckConfiguration(cKey);
            int    sc;

            int.TryParse(statusCode, out sc);
            return(sc);
        }
예제 #5
0
        public static List <string> GetIgnoreFiles()
        {
            List <string> toIgnore = new List <string>();

            foreach (string id in HelperMethods.CheckConfiguration("ignoreFiles").Split(','))
            {
                toIgnore.Add(id.ToUpper());
            }

            return(toIgnore);
        }
예제 #6
0
 public static void CheckEndpoint(string line, int lineNumber)
 {
     string[] protocols = HelperMethods.CheckConfiguration("protocols").Split(',');
     foreach (string p in protocols)
     {
         if (line.ToUpper().Contains(p.ToUpper()))
         {
             TestConnection(line, lineNumber, p);
         }
     }
 }
예제 #7
0
        public static ConsoleColor GetColorByStatus(int status)
        {
            string statusCode = HelperMethods.CheckConfiguration(status.ToString());

            string[] parts = statusCode.Split('|');
            try
            {
                return((ConsoleColor)Enum.Parse(typeof(ConsoleColor), parts[1]));
            }
            catch
            {
                return(ConsoleColor.White);
            }
        }
예제 #8
0
        private static List <DirectorySearchInfo> GatherDirectoriesToSearch()
        {
            List <DirectorySearchInfo> searchDirectories = new List <DirectorySearchInfo>();

            //Get a list of directories to ignore from the config file
            List <string> toIgnore = IgnoreMethods.GetIgnoreDirectories();

            toIgnore.Add("FileContentChecks");
            toIgnore.Add("ConfigCopPages");

            //Get the file types to search for as configured for the directory
            List <string> fTypes = HelperMethods.CheckConfiguration("fileTypes").Split(',').ToList <string>();

            //Add passed directory or working directory if none was passed
            if (IgnoreMethods.IgnorePath(toIgnore, Program.SearchDir) == false)
            {
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine(Program.SearchDir);
                Console.ResetColor();
                AddSearchDirectory(searchDirectories, Program.SearchDir, fTypes, toIgnore);
            }

            //Get all the subdirectories
            List <string> subDirs = new List <string>();

            GetSubDirs(Program.SearchDir, toIgnore, subDirs);
            foreach (string subD in subDirs)
            {
                AddSearchDirectory(searchDirectories, subD, fTypes, toIgnore);
            }

            //Get all the additional directories to search from the config file
            string fullSearchDirs = HelperMethods.CheckConfiguration("searchDirsFull");

            if (!string.IsNullOrEmpty(fullSearchDirs))
            {
                string[] searchDirListFull = fullSearchDirs.Split(';');
                GatherConfiguredDirectories(searchDirectories, toIgnore, searchDirListFull, true);
            }
            string topSearchDirs = HelperMethods.CheckConfiguration("searchDirsTopOnly");

            if (!string.IsNullOrEmpty(topSearchDirs))
            {
                string[] searchDirListTop = topSearchDirs.Split(';');
                GatherConfiguredDirectories(searchDirectories, toIgnore, searchDirListTop, false);
            }

            return(searchDirectories);
        }
예제 #9
0
        public static void CheckForRegionDiscrepancies(string line, int lineNumber)
        {
            bool error = false;

            string[] regions = HelperMethods.CheckConfiguration("regions").Split(',');
            foreach (string r in regions)
            {
                if (IgnoreMethods.Ignore(r) == false)
                {
                    error = LineContainsRegion(line, error, r);

                    if (error == true)
                    {
                        Errors.RegionDiscrepancy(lineNumber, r, line);
                    }
                }
            }
        }
예제 #10
0
        private static List <string> ExtractFileTypesFromSearchDirs(string[] parts)
        {
            List <string> fTypes  = new List <string>();
            string        setting = "";

            if (parts.Count() == 2)
            {
                setting = parts[1];
            }

            if (string.IsNullOrEmpty(setting) || setting == "*")
            {
                //Use default file types
                fTypes = HelperMethods.CheckConfiguration("fileTypes").Split(',').ToList <string>();
            }
            else
            {
                fTypes = setting.Split(';').ToList <string>();
            }

            return(fTypes);
        }
예제 #11
0
        private static List <DBServerInfo> GetAllDatabaseServers()
        {
            List <DBServerInfo> dbServers = new List <DBServerInfo>();

            string[] regions = HelperMethods.CheckConfiguration("regions").Split(',');
            foreach (string r in regions)
            {
                string[] servers = HelperMethods.CheckConfiguration(r).Split(',');
                foreach (string svr in servers)
                {
                    string name;
                    string port;
                    ExtractPort(r, svr, out name, out port);

                    dbServers.Add(new DBServerInfo {
                        Name = name, Region = r, Port = port
                    });
                }
            }

            return(dbServers);
        }
예제 #12
0
        private static void SetArgs(string[] args)
        {
            string[] regions = HelperMethods.CheckConfiguration("regions").Split(',');
            if (args.Count() > 0)
            {
                foreach (string a in args)
                {
                    if (Directory.Exists(a))
                    {
                        SearchDir = a;
                    }
                    else
                    {
                        if (regions.Contains(a, StringComparer.OrdinalIgnoreCase))
                        {
                            Region = a;
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(SearchDir))
            {
                SearchDir = GetSearchDirectory(SearchDir);
            }

            if (string.IsNullOrEmpty(Region))
            {
                Region = AutoDetermineRegion(regions);
            }

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine();
            Console.WriteLine("Analyzing  as " + Region + " region...");
            Console.WriteLine();
            Console.ResetColor();
        }
예제 #13
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();
            }
        }