示例#1
0
        private void data_NewCaseLogged(object sender, cPictureFile pictureFile, int fileNumber, int numberLogged)
        {
            lblInfo.Visible = true;
            lblInfo.Text    = "Logging " + pictureFile.pEncryptedPicture.pEncryptedFileName + ", " + numberLogged + " images";

            cFilm film = pictureFile.pBelongsToFilm;

            film.pCameraDriver.UpdateFileNumber(pictureFile, fileNumber);

            foreach (ListViewItem item in lsvFiles.Items)
            {
                if (item.Group != null)
                {
                    var groupFilm = (cFilm)item.Group.Tag;

                    cPictureFile pic      = film.getFirstValidPictureFile();
                    cPictureFile picGroup = groupFilm.getFirstValidPictureFile();

                    if (pic != null && picGroup != null)
                    {
                        if (pic.pFormattedSession == picGroup.pFormattedSession)
                        {
                            if (item.Text == pictureFile.pEncryptedPicture.pEncryptedFileName)
                            {
                                updateFilesListItem(item, pictureFile, true, true);
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        private void data_NewCasePreviouslyLogged(object sender, cFilm film, cEncryptedPictureFile encryptedPictureFile)
        {
            lblInfo.Visible = true;
            lblInfo.Text    = "Previously Logged at " + encryptedPictureFile.pEncryptedFileName;

            foreach (ListViewItem item in lsvFiles.Items)
            {
                if (item.Group != null)
                {
                    var groupFilm = (cFilm)item.Group.Tag;

                    cPictureFile pic      = film.getFirstValidPictureFile();
                    cPictureFile picGroup = groupFilm.getFirstValidPictureFile();

                    if (pic != null && picGroup != null)
                    {
                        if (pic.pFormattedSession == picGroup.pFormattedSession)
                        {
                            if (item.Text == encryptedPictureFile.pEncryptedFileName)
                            {
                                updateFilesListItemPreviouslyLogged(item, "Previously Logged");
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#3
0
        private void data_NewCaseLoggedError(object sender, cPictureFile pictureFile, string errorDescription)
        {
            ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings["CoreContext"];
            var data = new cDataAccess(setting.ConnectionString);

            lblInfo.Visible = true;
            lblInfo.Text    = "Errors at " + pictureFile.pEncryptedPicture.pEncryptedFileName;

            foreach (ListViewItem item in lsvFiles.Items)
            {
                cFilm film = pictureFile.pBelongsToFilm;

                if (item.Group != null)
                {
                    var groupFilm = (cFilm)item.Group.Tag;

                    cPictureFile pic      = film.getFirstValidPictureFile();
                    cPictureFile picGroup = groupFilm.getFirstValidPictureFile();

                    if (pic != null && picGroup != null)
                    {
                        if (pic.pFormattedSession == picGroup.pFormattedSession)
                        {
                            if (item.Text == pictureFile.pEncryptedPicture.pEncryptedFileName)
                            {
                                updateFilesListItemError(item, pictureFile, errorDescription);
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        public bool AddPictureFile(cPictureFile pic, bool fitToFrame)
        {
            try
            {
                foreach (objImageViewer viewer in Controls)
                {
                    viewer.Image = null;
                }

                Controls.Clear();

                cCamera         driver = pic.pBelongsToFilm.pCameraDriver;
                List <cPicture> pictures;
                string          message;

                if (!driver.developPicture(pic, out pictures, out message))
                {
                    return(false);
                }

                int i = 0;
                foreach (cPicture picture in pictures)
                {
                    AddToPanel(i, picture, fitToFrame);
                    i++;
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#5
0
        private static int compare(cFilm a, cFilm b)
        {
            int diff;

            if (a.pCreationTime != null && b.pCreationTime != null)
            {
                diff = DateTime.Compare(b.pCreationTime.Value, a.pCreationTime.Value);
                if (diff != 0)
                {
                    return(diff);
                }
            }

            cPictureFile aPictureFile = a.getFirstValidPictureFile();
            cPictureFile bPictureFile = b.getFirstValidPictureFile();

            if (aPictureFile == null || bPictureFile == null)
            {
                return(0);
            }

            diff = System.String.CompareOrdinal(bPictureFile.pLocationCode, aPictureFile.pLocationCode);
            if (diff != 0)
            {
                return(diff);
            }

            diff = System.String.CompareOrdinal(bPictureFile.pFormattedSession, aPictureFile.pFormattedSession);

            return(diff);
        }
示例#6
0
        public bool AddPictureFile(cPictureFile pic, bool fitToFrame)
        {
            try
            {
                foreach (TabPage tabPage in tabControlImages.TabPages)
                {
                    if (tabPage.Controls.Count > 0)
                    {
                        var viewer = (objImageViewer)tabPage.Controls[0];
                        viewer.Image = null;
                        viewer.Dispose();
                    }
                }

                tabControlImages.TabPages.Clear();

                cCamera         driver = pic.pBelongsToFilm.pCameraDriver;
                List <cPicture> pictures;
                string          message;

                if (!driver.developPicture(pic, out pictures, out message))
                {
                    return(false);
                }

                int i = 0;
                foreach (cPicture picture in pictures)
                {
                    tabControlImages.TabPages.Add("Image " + i);

                    if (fitToFrame)
                    {
                        Image img    = ResizeImage(cImage.ByteArrToImage(picture.pJpeg), new Size(tabControlImages.TabPages[i].Width, tabControlImages.TabPages[i].Height));
                        var   viewer = new objImageViewer {
                            Image = img, Dock = DockStyle.Fill
                        };
                        tabControlImages.TabPages[i].Controls.Add(viewer);
                    }
                    else
                    {
                        var viewer = new objImageViewer {
                            Image = cImage.ByteArrToImage(picture.pJpeg), Dock = DockStyle.Fill
                        };
                        tabControlImages.TabPages[i].Controls.Add(viewer);
                    }

                    i++;
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#7
0
        private void updateFilesListItem(ListViewItem item, cPictureFile picture, bool isLogging, bool showPicture)
        {
            lsvFiles.BeginUpdate();

            item.SubItems[1].Text = picture.pOffenceDate != null?picture.pOffenceDate.Value.ToString("yyyy-MM-dd HH:mm") : "No Date";

            item.SubItems[2].Text = (picture.pZone.ToString());
            item.SubItems[3].Text = (picture.pSpeed.ToString());

            if (picture.pHasError)
            {
                item.SubItems[4].Text = ("Yes");

                var sb = new StringBuilder();
                foreach (string s in picture.pErrorCollection)
                {
                    sb.Append(s);
                }

                item.SubItems[4].Text = (sb.ToString());
            }
            else
            {
                item.SubItems[4].Text = ("No");
                item.SubItems[4].Text = ("");
            }

            if (picture.pIsTest)
            {
                item.BackColor = Color.Blue;
            }
            else if (picture.pHasDecryptedData == false)
            {
                item.BackColor = Color.Red;
            }
            else if (isLogging)
            {
                item.BackColor = Color.Purple;
            }

            if (showPicture)
            {
                if (!addPictureFileToTab(picture))
                {
                    item.SubItems[4].Text = ("Yes");
                    item.SubItems[5].Text = ("Cannot Decrypt Picture File");
                    item.BackColor        = Color.Red;
                }
            }

            item.EnsureVisible();

            lsvFiles.EndUpdate();

            Application.DoEvents();
        }
示例#8
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            const string delimiter = ",";

            if (txtDirectory.Text.Length == 0)
            {
                MessageBox.Show("Cannot Export. Please select a directory to export to!", "Cannot Export", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!_film.pHasErrors)
            {
                cPictureFile pic = _film.getFirstValidPictureFile();

                using (StreamWriter sw = File.CreateText(Path.Combine(txtDirectory.Text, pic.pSession + ".txt")))
                {
                    TimeSpan duration = new TimeSpan();

                    if (_film.pStartDate.HasValue && _film.pEndDate.HasValue)
                    {
                        duration = _film.pEndDate.Value - _film.pStartDate.Value;

                        sw.WriteLine(_film.pStartDate.Value.ToString("ddMMyyyy") + delimiter +
                                     pic.pSession + delimiter +
                                     pic.pLocationCode + delimiter +
                                     _film.pInfringements + delimiter +
                                     "0" + delimiter +
                                     "0" + delimiter +
                                     "1" + delimiter +
                                     DateTime.Today + delimiter +
                                     _film.pStartDate.Value + delimiter +
                                     _film.pEndDate.Value + delimiter +
                                     duration.TotalMinutes + delimiter +
                                     _film.pVehiclesChecked + delimiter +
                                     _film.pInfringements + delimiter +
                                     _film.pHighestSpeed + delimiter +
                                     "0" + delimiter +
                                     _film.pAverageSpeed
                                     );
                        sw.Close();
                    }
                    else
                    {
                        MessageBox.Show("Cannot Export. Stats file does not have start and end date!", "Cannot Export", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                MessageBox.Show("Done", "Exported", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Cannot Export Stats file - Film Error!", "Cannot Export", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#9
0
        private void data_NewCaseLoggedError(object sender, cPictureFile pictureFile, string errorDescription)
        {
            dataAccess.ExceptionLog(Environment.MachineName, errorDescription, pictureFile.pFormattedSession,
                                    pictureFile.pOffenceDate, pictureFile.pLocationCode,
                                    pictureFile.pEncryptedPicture.pEncryptedFilePath, pictureFile.pEncryptedPicture.pEncryptedFileName);

            errorWriting.WriteErrorLog(errorDescription, "Session: " + pictureFile.pFormattedSession +
                                       "; OffenceDate: " + pictureFile.pOffenceDateStringYYYYMMDD +
                                       "; Location: " + pictureFile.pLocationCode +
                                       "; FilePath: " + pictureFile.pEncryptedPicture.pEncryptedFilePath +
                                       "; FileName: " + pictureFile.pEncryptedPicture.pEncryptedFileName);
        }
示例#10
0
        public void BindFormData(cFilm film)
        {
            _film = film;

            if (_film.pHasEncryptedPictureFiles)
            {
                _film.applyStats();

                clearDisplay();

                if (!_film.pHasErrors)
                {
                    cPictureFile pic = film.getFirstValidPictureFile();

                    lblCamDate.Text       = pic.pOffenceDateStringDD_MM_YYYY;
                    lblAveSpeed.Text      = film.pAverageSpeed.ToString("0.0") + " km/h";
                    lblCaptureErrors.Text = film.pCaptureErrors.ToString();
                    if (film.pEndDate.HasValue)
                    {
                        lblEndDate.Text = film.pEndDate.Value.ToString("dd MMM yyyy HH:mm:ss");
                    }
                    else
                    {
                        lblEndDate.Text = "";
                    }

                    lblHighestSpeed.Text  = film.pHighestSpeed + " km/h";
                    lblHighSpeed.Text     = film.pHighSpeedCount.ToString();
                    lblInfringements.Text = film.pInfringements.ToString();
                    lblLocationCode.Text  = pic.pLocationCode;
                    lblLowSpeed.Text      = film.pLowSpeedCount.ToString();
                    lblMeasureErrors.Text = film.pMeasurementErrors.ToString();
                    lblTestPhotos.Text    = film.pTestPhotos.ToString();
                    lblSessionName.Text   = pic.pSession;
                    if (film.pStartDate.HasValue)
                    {
                        lblStartDate.Text = film.pStartDate.Value.ToString("dd MMM yyyy HH:mm:ss");
                    }
                    else
                    {
                        lblStartDate.Text = "";
                    }
                    lblVehiclesChecked.Text = film.pVehiclesChecked.ToString();
                    lblJammers.Text         = film.pJammerCount.ToString();
                }
            }
        }
示例#11
0
        private bool addPictureFileToTab(cPictureFile pictureFile)
        {
            foreach (Control control in contentPanel.Controls)
            {
                if (control is IImageViewer)
                {
                    var viewer = (IImageViewer)control;

                    if (!viewer.AddPictureFile(pictureFile, chkAutoSizeToFrame.Checked))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
示例#12
0
        private void updateFilesListItemError(ListViewItem item, cPictureFile picture, string errorDescription)
        {
            lsvFiles.BeginUpdate();

            item.SubItems[1].Text = picture.pOffenceDate != null?picture.pOffenceDate.Value.ToString("yyyy-MM-dd HH:mm") : "No Date";

            item.SubItems[2].Text = (picture.pZone.ToString());
            item.SubItems[3].Text = (picture.pSpeed.ToString());
            item.SubItems[4].Text = ("Yes");
            item.SubItems[5].Text = errorDescription;
            item.BackColor        = Color.Orange;

            item.EnsureVisible();

            lsvFiles.EndUpdate();

            Application.DoEvents();
        }
示例#13
0
        private void checkForValidFilesInSession(cFilm film)
        {
            cPictureFile pictureFile = new cPictureFile();

            string result = string.Empty;

            string[] pdfFile = Directory.GetFiles(film.pPath, "*.pdf");

            if (pdfFile == null || pdfFile.Length == 0)
            {
                result = "No Fieldsheet. ";
            }

            string[] statsFile = Directory.GetFiles(film.pPath, "stat*.txt");

            if (statsFile == null || statsFile.Length == 0)
            {
                result = result + "Enc files can not be validated against stats file as stats file missing. ";
            }

            if ((statsFile != null || statsFile.Length >= 0) && (film.pTestPhotos + film.pInfringements != film.pEncryptedPictureFileCollection.Count))
            {
                result = result + "Enc files do not match stats file";
            }

            if (result != string.Empty)
            {
                pictureFile = film.getFirstValidPictureFile();

                dataAccess.ExceptionLog(Environment.MachineName, result, pictureFile.pFormattedSession,
                                        pictureFile.pOffenceDate, pictureFile.pLocationCode,
                                        pictureFile.pEncryptedPicture.pEncryptedFilePath, pictureFile.pEncryptedPicture.pEncryptedFileName);

                errorWriting.WriteErrorLog(result, "Session: " + pictureFile.pFormattedSession +
                                           "; OffenceDate: " + pictureFile.pOffenceDateStringYYYYMMDD +
                                           "; Location: " + pictureFile.pLocationCode +
                                           "; FilePath: " + pictureFile.pEncryptedPicture.pEncryptedFilePath +
                                           "; FileName: " + pictureFile.pEncryptedPicture.pEncryptedFileName);
            }
        }
示例#14
0
        public void BindFormData(cFilm film)
        {
            string statsFileName;

            if (film.pHasEncryptedPictureFiles)
            {
                film.applyStats();

                //*****First Record is the Operator and Stats
                ReportSource rsMain = new ReportSource
                {
                    AverageSpeed         = film.pAverageSpeed,
                    CountOfInfringements = film.pInfringements,
                    ErrorsCount          = film.pCaptureErrors,
                    HighestSpeed         = film.pHighestSpeed,
                    JammerCount          = film.pJammerCount,
                    TestPhotoCount       = film.pTestPhotos,
                    VehiclesChecked      = film.pVehiclesChecked
                };

                statsFileName = film.pStatsFileName == string.Empty ? "None" : film.pStatsFileName;

                if (film.pStartDate != null && film.pEndDate != null)
                {
                    rsMain.Time = film.pStartDate.Value.ToString("HH:mm:ss tt") + "-" + film.pEndDate.Value.ToString("HH:mm:ss tt");
                }

                _rs.Add(rsMain);

                int locationCounter = 0;

                var groupByDate = from f in film.getPicturesFiles()
                                  where f.pHasError == false
                                  group f by f.pOffenceDateStringDD_MM_YYYY into g
                                  select g;

                List <string> lst   = new List <string>();
                List <string> camId = new List <string>();

                foreach (IGrouping <string, cPictureFile> pictureFilesDate in groupByDate)
                {
                    var groupByLocation = from f in pictureFilesDate
                                          where f.pHasError == false
                                          group f by f.pLocationCode into g
                                          select g;

                    foreach (IGrouping <string, cPictureFile> pictureFilesLocation in groupByLocation)
                    {
                        locationCounter++;
                        ReportSource rs = new ReportSource {
                            CamDate = pictureFilesLocation.First().pOffenceDateStringDD_MM_YYYY, Session = "Actual", LocationCode = pictureFilesLocation.First().pLocationCode
                        };

                        foreach (cPictureFile pictureFile in pictureFilesLocation)
                        {
                            if (!lst.Contains(pictureFile.pOperatorId))
                            {
                                lst.Add(pictureFile.pOperatorId);
                            }

                            if (pictureFile.pIsTest)
                            {
                                rs.TestPhotoCount++;
                            }
                            else if (pictureFile.pIsJammer)
                            {
                                rs.JammerCount++;
                            }
                            else if (pictureFile.pHasError)
                            {
                                rs.ErrorsCount++;
                            }
                            else
                            {
                                rs.CountOfInfringements++;
                            }

                            if (!camId.Contains(pictureFile.pMachineId))
                            {
                                camId.Add(pictureFile.pMachineId);
                            }
                        }

                        DateTime?start = pictureFilesLocation.First().pOffenceDate;
                        DateTime?end   = pictureFilesLocation.Last().pOffenceDate;
                        if (start != null && end != null)
                        {
                            rs.Time = start.Value.ToString("HH:mm:ss tt") + "-" + end.Value.ToString("HH:mm:ss tt");
                        }

                        _rs.Add(rs);
                    }
                }

                StringBuilder sb = new StringBuilder();
                foreach (string s in lst)
                {
                    sb.Append(s);
                    sb.Append(",");
                }

                rsMain.Operators = sb.ToString().TrimEnd(',');

                cPictureFile pic = film.getFirstValidPictureFile();

                if (pic != null)
                {
                    rsMain.LocationCode = locationCounter > 1 ? "*VARIOUS" : pic.pLocationCode;
                    rsMain.CamDate      = pic.pOffenceDateStringDD_MM_YYYY;
                    rsMain.Session      = pic.pFormattedSession;
                }

                sb.Clear();
                foreach (string c in camId)
                {
                    sb.Append(c);
                    sb.Append(",");
                }

                rsMain.CamID = sb.ToString().TrimEnd(',');

                rsMain.StatsFileName = string.IsNullOrWhiteSpace(statsFileName) ? "No  File" : statsFileName;

                ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings["CoreContext"];
                var data = new cDataAccess(setting.ConnectionString);

                string userDetail = data.getUserDetail(userId);
                rsMain.LoggedBy = userDetail;
            }
        }