Пример #1
0
        static void Main()
        {
            var result = new ValidationResult();

            try
            {
                Environment.ExitCode = 1;

                var context = GetConfig();
                Log.Info($"Starting validation on {context.SamplesApiBaseUrl}.");

                var runStartTime = DateTimeOffset.Now.ToUniversalTime();

                Validate(context, result);

                LastRunTimeKeeper.WriteDateTimeOffsetToFile(runStartTime);

                Environment.ExitCode = 0;
            }
            catch (Exception ex)
            {
                result.FatalException = ex;
            }
            finally
            {
                ReportValidationResult(result);
            }
        }
Пример #2
0
        private static Context GetConfig()
        {
            var appSettings       = ConfigurationManager.AppSettings;
            var authToken         = appSettings["authToken"];
            var samplesApiBaseUrl = appSettings["samplesApiBaseUrl"];
            var qualityFlag       = appSettings["qualityFlag"];

            if (string.IsNullOrWhiteSpace(authToken))
            {
                throw new ArgumentException("authToken is not set in the config file.");
            }
            if (string.IsNullOrWhiteSpace(samplesApiBaseUrl))
            {
                throw new ArgumentException("samplesApiBaseUrl is not set in the config file.");
            }

            return(new Context
            {
                SamplesApiBaseUrl = samplesApiBaseUrl,
                SamplesAuthToken = authToken,
                Flag = string.IsNullOrWhiteSpace(qualityFlag) ? Context.PredefinedFlag: qualityFlag,
                LastRunStartTimeUtc = LastRunTimeKeeper.GetLastRunStartTimeUtc()
            });
        }