public WechatController(IHostingEnvironment hostingEnvironment, ISHA1Encryptor encryptor, IWechatClient connector, IDirectLineConnector directLineConnector, IDeviceRegistrar deviceRegistrar, ILogger <WechatController> logger) { _hostingEnvironment = hostingEnvironment; _encryptor = encryptor; _connector = connector; _directLineConnector = directLineConnector; _deviceRegistrar = deviceRegistrar; _logger = logger; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IWechatClient wechatClient) { loggerFactory.AddNLog(); var nlogConfig = "nlog.config"; var nlogEnvSpecific = "nlog." + env.EnvironmentName + ".config"; if (File.Exists(nlogEnvSpecific)) { nlogConfig = nlogEnvSpecific; } //needed for non-NETSTANDARD platforms: configure nlog.config in your project root env.ConfigureNLog(nlogConfig); bool isRunningInAzureWebApp = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("HOME")) && !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME")); if (isRunningInAzureWebApp) { string homeDir = Environment.GetEnvironmentVariable("HOME"); string logFilesRoot = Path.Combine(homeDir, "LogFiles", "NLog"); NLog.LogManager.Configuration.Variables["logroot"] = logFilesRoot; } app.UseMvc(); app.UseDefaultFiles(); app.UseStaticFiles(); //Disable app insight headers for outbound wechat requests var modules = app.ApplicationServices.GetServices <ITelemetryModule>(); var dependencyModule = modules.OfType <DependencyTrackingTelemetryModule>().FirstOrDefault(); if (dependencyModule != null) { var domains = dependencyModule.ExcludeComponentCorrelationHttpHeadersOnDomains; domains.Add("file.api.wechat.com"); domains.Add("file.api.weixin.qq.com"); } //Setup the menu if we have to await wechatClient.UpdateDefaultMenu(); }