Exemplo n.º 1
0
        public HttpResponseMessage UpdateSettings(AppInsightsSettings appInsightSettings)
        {
            try
            {
                var settings = new Dictionary <string, string>
                {
                    { "AppInsights.Enabled", appInsightSettings.Enabled.ToString() },
                    { "AppInsights.InstrumentationKey", appInsightSettings.InstrumentationKey }
                };
                HostController.Instance.Update(settings);

                // Update the configuration files
                AppInsightsConfig.ModifyLog4NetConfigFile(!appInsightSettings.Enabled);
                AppInsightsConfig.ModifyAppInsightsConfigFile(!appInsightSettings.Enabled);
                AppInsightsConfig.ModifyAppInsightsJsFile(!appInsightSettings.Enabled);
                AppInsightsConfig.ModifyWebConfigFile(!appInsightSettings.Enabled);

                // Increment the CRM version to avoid appinsights.js caching
                HostController.Instance.IncrementCrmVersion(true);


                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemplo n.º 2
0
 public HttpResponseMessage GetSettings()
 {
     try
     {
         var settings = new AppInsightsSettings()
         {
             Enabled            = HostController.Instance.GetBoolean("AppInsights.Enabled"),
             InstrumentationKey = HostController.Instance.GetString("AppInsights.InstrumentationKey")
         };
         return(Request.CreateResponse(HttpStatusCode.OK, settings));
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }