Esempio n. 1
0
        public static bool Check()
        {
            var settings = new List <string>
            {
                NAH_EHLISTENER_CONNECTIONSTRING,
                NAH_EHLISTENER_EVENTHUBPATH,
                NAH_EHLISTENER_CONSUMERGROUP,
                NAH_EHLISTENER_STORAGECONNECTIONSTRING,
                NAH_EHLISTENER_LEASECONTAINERNAME,
                NAH_AAD_Domain,
                NAH_AAD_CLIENTID,
                NAH_AAD_CLIENTSECRET,
                NAH_AZURE_SUBSCRIPTIONID,
                NAH_AZURE_DLSOUTPUTMANAGER_ACCOUNTNAME,
                NAH_AZURE_DLA_ACCOUNTNAME,
                NAH_FILEOUTPUTMANAGER_LOCALDATAFOLDER
            };

            const int maxValueLengthPrinted = 100;

            Console.WriteLine("Using the following configuration values:");
            Console.WriteLine();

            var missingSettings = new List <string>();

            foreach (var setting in settings)
            {
                var val = Config.Root[setting];

                if (string.IsNullOrWhiteSpace(val))
                {
                    missingSettings.Add(setting);
                }
                else
                {
                    ConsoleEx.Write(ConsoleColor.DarkGray, setting);
                    Console.WriteLine(" : ");
                    ConsoleEx.WriteLine(ConsoleColor.Yellow, "  " + (val.Length < maxValueLengthPrinted ? val : val.Substring(0, maxValueLengthPrinted - 3) + "..."));
                }
            }

            Console.WriteLine();

            if (missingSettings.Count > 0)
            {
                Console.WriteLine("The following setting(s) are missing values:");
                Console.WriteLine();


                foreach (var setting in missingSettings)
                {
                    ConsoleEx.WriteLine(ConsoleColor.Magenta, $"  {setting}");
                }

                Console.WriteLine();
                Console.WriteLine($"Make sure to set all the above configuration parameters in {Config.AppSettingsFile} or using Environment Variables.");
                Console.WriteLine("Then start Nether.Analytics.Host again.");
                Console.WriteLine();

                return(false);
            }
            else
            {
                return(true);
            }
        }