static Metric() { ConfigurationManager.Build(builder => { builder.AddJsonFile("appsettings.json", true, true) .AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", true, true) .Build(); }); globalContext = new DefaultMetricsContext(GetGlobalContextName()); if (MetricsConfig.GloballyDisabledMetrics) { globalContext.CompletelyDisableMetrics(); log.Info(() => "Metrics: Metrics.NET Library is completely disabled. Set Metrics.CompletelyDisableMetrics to false to re-enable."); } config = new MetricsConfig(globalContext); config.ApplySettingsFromConfigFile(); }
static void Main(string[] args) { System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); ConfigurationManager.Build(new string[] { "appsettings.json", "appsettings.development.json" }, Directory.GetCurrentDirectory()); //var sb = ConfigurationManager.Configuration["PersistToMySQL"]; // args =new string[]{ "app=sendEmail", @"template=\\fnp1423mp01.lowes.com\Data1\SHARE\EVERYONE\C-QA\Operation Team\Email Template\IA_Template_Reject.msg","[email protected]", "content=json", "[email protected]", @"text={""Error1"":""F3"",""Error2"":""Factory is not inspection allow""}","subject=233", @"resultMap=\\fnp1423mp01.lowes.com\Data1\SHARE\EVERYONE\C-QA\Operation Team\Email Template\invalidStatusMapping.yaml" }; var argsMap = args.Select(e => e.Split("=")).Where(e => !String.IsNullOrWhiteSpace(e[0])).ToDictionary(prop => prop[0], prop => prop.Length > 1?String.Join('=', prop.Skip(1)):""); if (argsMap.Keys.Contains("app")) { switch (argsMap["app"]) { case "sendEmail": if (argsMap.ContainsKey("yaml")) { var yaml = new YamlStream(); using (var sr = new FileInfo(argsMap["yaml"]).OpenText()) yaml.Load(sr); OA.sendEmail(((YamlMappingNode)yaml.Documents[0].RootNode).Children.Select(entry => new KeyValuePair <string, string>(entry.Key.ToString(), entry.Value.ToString())).ToDictionary(prop => prop.Key, prop => prop.Value)); } else { OA.sendEmail(argsMap); } break; case "automateEmail": if (argsMap.ContainsKey("path")) { OA.StartOAHelper(argsMap["path"]); } else { Console.WriteLine("Please provide path to configuration yaml files!"); } break; } } else { Console.WriteLine("Please provide arguments!"); } //OA.StartOAHelper(); }