コード例 #1
0
ファイル: TartarosClient.cs プロジェクト: zsy960/PDFCreator
        public bool SendErrorReport(Report report)
        {
            var request = (HttpWebRequest)WebRequest.Create(TartarosUri);

            request.Method      = "POST";
            request.ContentType = "application/json;utf-8";
            request.Accept      = "application/json";
            request.Headers.Add(HttpRequestHeader.AcceptCharset, "utf-8");
            request.Headers.Add(HttpRequestHeader.Authorization, ApiKey);

            using (Stream requestStream = request.GetRequestStream())
                using (TextWriter streamWriter = new StreamWriter(requestStream, Encoding.UTF8))
                {
                    streamWriter.Write(ReportSerializer.ConvertToJson(report));
                }

            try
            {
                var response = (HttpWebResponse)request.GetResponse();
                return(response.StatusCode == HttpStatusCode.OK);
            }

            /*catch (WebException wex)
             * {
             *  var httpResponse = wex.Response as HttpWebResponse;
             *  httpResponse.StatusCode ...
             * }*/
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #2
0
        private bool ShowReportWindow(string errorFile)
        {
            try
            {
                var report = ReportSerializer.LoadReport(errorFile);

                var err = new ErrorReportWindow(report, false);
                err.ShowDialog();

                File.Delete(errorFile);

                return(true);
            }
            catch
            {
                return(false);
            }
        }