Exemplo n.º 1
0
        private void btnViewStats_Click(object sender, EventArgs e)
        {
            if (lsvSessions.SelectedItems != null && lsvSessions.Items.Count > 0 && lsvSessions.SelectedItems.Count == 1)
            {
                foreach (ListViewItem selectedItem in lsvSessions.SelectedItems)
                {
                    var film = (cFilm)selectedItem.Tag;

                    Cursor = Cursors.WaitCursor;
                    mPhysicalStudio.DevelopFilm(film);
                    Cursor = Cursors.Default;

                    var sf = new StatsForm();
                    sf.BindFormData(film);
                    try
                    {
                        sf.ShowDialog(this);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    mPhysicalStudio.ClearFilm(film);
                }
            }
            else
            {
                MessageBox.Show("You have to select one item from the list in order to view the stats!", "Select one item!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
Exemplo n.º 2
0
        private void Log_Case(ListViewItem sessionItem)
        {
            int totalLoggedCases      = 0;
            int totalPreviouslyLogged = 0;

            mUserId            = 2; //AutoiLog user on Credentials
            SavedStatsFilePath = ConfigurationManager.AppSettings["SavedStatsFilePath"];
            SavedStatsFilePath = SavedStatsFilePath + "\\" + serverDateTime.Date.ToString("yyyyMMdd");

            Directory.CreateDirectory(SavedStatsFilePath);
            cFilm film = new cFilm();

            try
            {
                if (sessionItem != null)
                {
                    film = (cFilm)sessionItem.Tag;

                    int   numberLoggedCases;
                    int   previouslyLogged;
                    cFilm reportFilm;
                    if (dataAccess.logNewCases(film, mUserId, mImagePath, out numberLoggedCases, out reportFilm, out previouslyLogged))
                    {
                        totalLoggedCases      += numberLoggedCases;
                        totalPreviouslyLogged += previouslyLogged;

                        if (totalPreviouslyLogged > 0)
                        {
                            errorWriting.WriteErrorLog(string.Format("Total Infringements logged {0} out of {1} and Total Previously logged {2} out of {1}", totalLoggedCases, film.pEncryptedPictureFileCollection.Count(), totalPreviouslyLogged));
                        }
                        else
                        {
                            errorWriting.WriteErrorLog(string.Format("Total Infringements logged {0} out of {1}", totalLoggedCases, film.pEncryptedPictureFileCollection.Count()));
                        }

                        if (numberLoggedCases > 0)
                        {
                            //Check if session is missing any files for SAfETYCAM infringements only
                            if (film.pCameraDriver.pName.ToUpper() == "SAFETYCAM")
                            {
                                checkForValidFilesInSession(film);
                            }

                            string date = DateTime.Now.ToString("yyyyMMdd HHmmss");

                            //Generate stats file here and save it.
                            var sf = new StatsReport();
                            sf.BindFormData(reportFilm);
                            sf.Save(String.Format("{0}\\{1}-{2}.pdf",
                                                  SavedStatsFilePath,
                                                  sessionItem.Text,
                                                  date));

                            //Process vosi list
                            dataAccess.logVosiFile(film);

                            if (!string.IsNullOrEmpty(film.pStatsFileName))
                            {
                                FileInfo fileInfo         = new FileInfo(film.pStatsFileName);
                                var      encStatsFileList = dataAccess.ReadStatsFile(fileInfo);
                                dataAccess.SubmitStatsFile(encStatsFileList);
                            }

                            Application.DoEvents();

                            int sessionLogged;
                            dataAccess.checkLoggedSessions(film, out sessionLogged);
                        }
                    }

                    if (dataAccess.pError.Length > 0)
                    {
                        if (film.getFirstValidPictureFile() != null)
                        {
                            errorWriting.WriteErrorLog("ERROR with logging film in path:" + film.pPath + "; Session: " + film.getFirstValidPictureFile().pFormattedSession + "; Error:  " + dataAccess.pError);
                        }
                        else
                        {
                            errorWriting.WriteErrorLog("ERROR with logging film <SESSION READ ERROR> - " + dataAccess.pError);
                        }
                    }

                    mPhysicalStudio.ClearFilm(film);
                }
            }
            catch (Exception ex)
            {
                dataAccess.ExceptionLog(Environment.MachineName, ex.Message + " Inner: " + ex.InnerException, film.getFirstValidPictureFile().pFormattedSession,
                                        film.getFirstValidPictureFile().pOffenceDate, film.getFirstValidPictureFile().pLocationCode, film.pPath, "");

                errorWriting.WriteErrorLog(ex.Message + " Inner: " + ex.InnerException, "Session: " + film.getFirstValidPictureFile().pFormattedSession +
                                           "; OffenceDate: " + film.getFirstValidPictureFile().pOffenceDate +
                                           "; FilePath: " + film.pPath);
            }
        }