Exemplo n.º 1
0
        internal void OnUnsuccessfulCalibration(CalibrationContext context, PlateCalibration plateCalibration)
        {
            m_PlateToReport = null;
            try
            {
                string tempFilename = Path.GetTempFileName();
                plateCalibration.SaveContext(tempFilename);
                string zippedFileName = Path.GetFullPath(tempFilename + ".zip");
                ZipUnzip.Zip(tempFilename, zippedFileName);
                m_PlateToReport = File.ReadAllBytes(zippedFileName);
                File.Delete(tempFilename);
                File.Delete(zippedFileName);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }

            if (m_PlateToReport != null)
            {
                double mbSize = m_PlateToReport.Length * 1.0 / (1024 * 1024);
                btnSendProblemFit.Text    = string.Format("Report Unsolved Plate ({0} Mb)", mbSize.ToString("0.00"));
                btnSendProblemFit.Visible = true;
            }
        }
Exemplo n.º 2
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 { }
                }
            }
        }