示例#1
0
        public static void SendOcrErrorReport(VideoController videoController, string errorMessage, ITimestampOcr timestampOCR, Dictionary <string, Tuple <uint[], int, int> > images, uint[] lastUnmodifiedImage, Bitmap ocdDebugImage, string email)
        {
            string tempDir  = Path.GetFullPath(Path.GetTempPath() + @"\" + Guid.NewGuid().ToString());
            string tempFile = Path.GetTempFileName();

            try
            {
                Directory.CreateDirectory(tempDir);

                int fieldAreaWidth  = timestampOCR.InitializationData.OSDFrame.Width;
                int fieldAreaHeight = timestampOCR.InitializationData.OSDFrame.Height;
                int frameWidth      = timestampOCR.InitializationData.FrameWidth;
                int frameHeight     = timestampOCR.InitializationData.FrameHeight;

                foreach (string key in images.Keys)
                {
                    uint[] pixels = images[key].Item1;
                    Bitmap img    = null;
                    if (pixels.Length == fieldAreaWidth * fieldAreaHeight)
                    {
                        img = Pixelmap.ConstructBitmapFromBitmapPixels(pixels, fieldAreaWidth, fieldAreaHeight);
                    }
                    else if (pixels.Length == frameWidth * frameHeight)
                    {
                        img = Pixelmap.ConstructBitmapFromBitmapPixels(pixels, frameWidth, frameHeight);
                    }
                    else if (pixels.Length == images[key].Item2 * images[key].Item3)
                    {
                        img = Pixelmap.ConstructBitmapFromBitmapPixels(pixels, images[key].Item2, images[key].Item3);
                    }

                    if (img != null)
                    {
                        img.Save(Path.GetFullPath(string.Format(@"{0}\{1}", tempDir, key)), ImageFormat.Bmp);
                    }
                }

                if (lastUnmodifiedImage != null)
                {
                    Bitmap fullFrame = Pixelmap.ConstructBitmapFromBitmapPixels(lastUnmodifiedImage, frameWidth, frameHeight);
                    fullFrame.Save(Path.GetFullPath(string.Format(@"{0}\full-frame.bmp", tempDir)), ImageFormat.Bmp);
                }

                if (ocdDebugImage != null)
                {
                    ocdDebugImage.Save(Path.GetFullPath(string.Format(@"{0}\ocr-debug-image.bmp", tempDir)), ImageFormat.Bmp);
                }

                ZipUnzip.Zip(tempDir, tempFile, false);
                byte[] attachment = File.ReadAllBytes(tempFile);

                var binding = new BasicHttpBinding();
                var address = new EndpointAddress("http://www.tangra-observatory.org/TangraErrors/ErrorReports.asmx");
                var client  = new TangraService.ServiceSoapClient(binding, address);

                string errorReportBody = errorMessage + "\r\n\r\n" +
                                         "OCR OSD Engine: " + timestampOCR.NameAndVersion() + "\r\n" +
                                         "OSD Type: " + timestampOCR.OSDType() + "\r\n" +
                                         "Frames Range: [" + videoController.VideoFirstFrame + ", " + videoController.VideoLastFrame + "]\r\n" +
                                         "File Name: " + videoController.FileName + "\r\n" +
                                         "Video File Type:" + videoController.CurrentVideoFileType + "\r\n\r\n" +
                                         "Contact Email: " + email + "\r\n\r\n" +
                                         frmSystemInfo.GetFullVersionInfo();

                List <string> errorMesages = timestampOCR.GetCalibrationErrors();
                if (errorMesages != null && errorMesages.Count > 0)
                {
                    errorReportBody += "\r\n\r\n" + string.Join("\r\n", errorMesages);
                }

                client.ReportErrorWithAttachment(
                    errorReportBody,
                    string.Format("CalibrationFrames-{0}.zip", Guid.NewGuid().ToString()),
                    attachment);
            }
            finally
            {
                if (Directory.Exists(tempDir))
                {
                    try
                    {
                        Directory.Delete(tempDir, true);
                    }
                    catch { }
                }

                if (File.Exists(tempFile))
                {
                    try
                    {
                        File.Delete(tempFile);
                    }
                    catch { }
                }
            }
        }
        public static void SendOcrErrorReport(ITimestampOcr timestampOCR, Dictionary<string, uint[]> images, uint[] lastUnmodifiedImage, string email)
        {
            string tempDir = Path.GetFullPath(Path.GetTempPath() + @"\" + Guid.NewGuid().ToString());
            string tempFile = Path.GetTempFileName();

            try
            {
                Directory.CreateDirectory(tempDir);

                int fieldAreaWidth = timestampOCR.InitializationData.OSDFrame.Width;
                int fieldAreaHeight = timestampOCR.InitializationData.OSDFrame.Height;
                int frameWidth = timestampOCR.InitializationData.FrameWidth;
                int frameHeight = timestampOCR.InitializationData.FrameHeight;

                foreach (string key in images.Keys)
                {
                    uint[] pixels = images[key];
                    Bitmap img = null;
                    if (pixels.Length == fieldAreaWidth * fieldAreaHeight)
                        img = Pixelmap.ConstructBitmapFromBitmapPixels(pixels, fieldAreaWidth, fieldAreaHeight);
                    else if (pixels.Length == frameWidth * frameHeight)
                        img = Pixelmap.ConstructBitmapFromBitmapPixels(pixels, frameWidth, frameHeight);

                    if (img != null)
                        img.Save(Path.GetFullPath(string.Format(@"{0}\{1}", tempDir, key)), ImageFormat.Bmp);
                }

                if (lastUnmodifiedImage != null)
                {
                    Bitmap fullFrame = Pixelmap.ConstructBitmapFromBitmapPixels(lastUnmodifiedImage, frameWidth, frameHeight);
                    fullFrame.Save(Path.GetFullPath(string.Format(@"{0}\full-frame.bmp", tempDir)), ImageFormat.Bmp);
                }

                ZipUnzip.Zip(tempDir, tempFile, false);
                byte[] attachment = File.ReadAllBytes(tempFile);

                var binding = new BasicHttpBinding();
                var address = new EndpointAddress("http://www.tangra-observatory.org/TangraErrors/ErrorReports.asmx");
                var client = new TangraService.ServiceSoapClient(binding, address);

                string errorReportBody = "OSD OCR Calibration Error\r\n\r\n" +
                                         "OCR OSD Engine: " + timestampOCR.NameAndVersion() + "\r\n" +
                                         "OSD Type: " + timestampOCR.OSDType() + "\r\n\r\n" +
                                         "Contact Email: " + email + "\r\n\r\n" +
                                         frmSystemInfo.GetFullVersionInfo();

                List<string> errorMesages = timestampOCR.GetCalibrationErrors();
                if (errorMesages != null && errorMesages.Count > 0)
                    errorReportBody += "\r\n\r\n" + string.Join("\r\n", errorMesages);

                client.ReportErrorWithAttachment(
                    errorReportBody,
                    string.Format("CalibrationFrames-{0}.zip", Guid.NewGuid().ToString()),
                    attachment);
            }
            finally
            {
                if (Directory.Exists(tempDir))
                {
                    try
                    {
                        Directory.Delete(tempDir, true);
                    }
                    catch { }
                }

                if (File.Exists(tempFile))
                {
                    try
                    {
                        File.Delete(tempFile);
                    }
                    catch { }
                }
            }
        }
示例#3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            string errorReport = GetErrorReport();

            Cursor = Cursors.WaitCursor;
            try
            {
                var binding = new BasicHttpBinding();
                var address = new EndpointAddress("http://www.tangra-observatory.org/TangraErrors/ErrorReports.asmx");
                var client = new TangraService.ServiceSoapClient(binding, address);
                client.ReportError(errorReport);

                TangraConfig.Settings.LastUsed.EmailAddressForErrorReporting = tbxEmailAddress.Text;
                TangraConfig.Settings.Save();

                if (MessageBox.Show(
                    "The error report was sent successfully. Press 'Retry' to try to continue or 'Cancel' to restart Tangra.",
                    "Question",
                    MessageBoxButtons.RetryCancel,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button1) == DialogResult.Cancel)
                {
                    Application.Restart();
                }
            }
            finally
            {
                Cursor = Cursors.Default;
                Close();
            }
        }