示例#1
0
        protected void SendErrors()
        {
            // Check for errors (do nothing when none)
            var errorFiles = LocalErrorStore.List();

            if (errorFiles == null || errorFiles.Length == 0)
            {
                return;
            }

            // Report all errors
            foreach (var errorFile in errorFiles)
            {
                // Get next error
                var error = LocalErrorStore.Get(errorFile);

                // Post error to service
                using var client = new HttpClient();
                using var buffer = new MemoryStream();
                var serializer = new DataContractJsonSerializer(typeof(ErrorReportData[]));
                serializer.WriteObject(buffer, error);
                var json = Encoding.UTF8.GetString(buffer.ToArray(), 0, (int)buffer.Length);
                using var content  = new StringContent(json, Encoding.UTF8, "application/json");
                using var response = client.PostAsync(ErrorReportUri, content).Result;
                if (response.IsSuccessStatusCode || response.StatusCode == HttpStatusCode.BadRequest)
                {
                    // Remove when successful or invalid data
                    LocalErrorStore.Remove(errorFile);
                }
            }
        }
示例#2
0
        public async void CheckErrors()
        {
            // Check for errors (do nothing when none)
            var errors = LocalErrorStore.List();

            if (errors == null || errors.Length == 0)
            {
                return;
            }

            // Prompt user
            await ShowSendErrorsDialog().ConfigureAwait(false);
        }
示例#3
0
        protected static void DiscardErrors()
        {
            // Check for errors (do nothing when none)
            var errors = LocalErrorStore.List();

            if (errors == null)
            {
                return;
            }

            // Delete all errors
            foreach (var errorFileName in errors)
            {
                LocalErrorStore.Remove(errorFileName);
            }
        }