Пример #1
0
        private static void LogException(object exceptionObject)
        {
            // log exception
            try
            {
                var logPath = Util.GetAppDataFolder("logs") + "\\service.exceptions.log";
                System.IO.File.AppendAllText(logPath, "Service Exception :: [" + DateTime.Now + "] :: " + ((Exception)exceptionObject).ToString());
            }
            catch { }

            //submit diagnostic info if connection available and status reporting enabled
            if (Management.CoreAppSettings.Current.EnableStatusReporting)
            {
                var client = new HttpClient();

                var appVersion = new Certify.Management.Util().GetAppVersion();

                var jsonRequest = Newtonsoft.Json.JsonConvert.SerializeObject(
                    new Models.Shared.FeedbackReport
                {
                    EmailAddress   = "(service exception)",
                    Comment        = "An unhandled service exception has occurred.: " + ((Exception)exceptionObject).ToString(),
                    IsException    = true,
                    AppVersion     = appVersion.ToString(),
                    SupportingData = new
                    {
                        Framework   = Certify.Management.Util.GetDotNetVersion(),
                        OS          = Environment.OSVersion.ToString(),
                        AppVersion  = new Certify.Management.Util().GetAppVersion(),
                        IsException = true
                    }
                });

                var data = new StringContent(jsonRequest, System.Text.Encoding.UTF8, "application/json");
                try
                {
                    Task.Run(async() =>
                    {
                        await client.PostAsync(Models.API.Config.APIBaseURI + "feedback/submit", data);
                    });
                }
                catch (Exception exp)
                {
                    System.Diagnostics.Debug.WriteLine(exp.ToString());
                }
            }
        }