Пример #1
0
        public override List <cFilm> GetDevelopableVideo(string fileName)
        {
            Films = new List <cFilm>();

            foreach (var participant in Participants)
            {
                if (Directory.Exists(Path))
                {
                    string[] files = Directory.GetFiles(Path, fileName, SearchOption.AllDirectories);

                    bool          skip         = false;
                    DirectoryInfo parentToSkip = null;

                    foreach (string file in files)
                    {
                        DirectoryInfo parent = Directory.GetParent(file);

                        if (parent != null)
                        {
                            //It might be that the file has zero length
                            long length = new System.IO.FileInfo(file).Length;
                            if (length == 0)
                            {
                                continue;
                            }

                            if (skip)
                            {
                                if (parent.FullName == parentToSkip.FullName)
                                {
                                    continue;
                                }
                            }

                            bool exists = Films.Any(film => film.pPath == parent.FullName);

                            if (!exists)
                            {
                                FileInfo fi = new FileInfo(file);
                                cFilm    f  = new cFilm {
                                    pPath = parent.FullName
                                };

                                if (participant.Value.developPictureFile(f, fi.Name))
                                {
                                    f.pCameraDriver = participant.Value;
                                    //participant.Value.ReadFilesFromDisk(f);

                                    Films.Add(f);
                                }
                            }

                            skip         = true;
                            parentToSkip = parent;
                        }
                    }
                }
            }
            return(Films);
        }
Пример #2
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);
        }
Пример #3
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;
                            }
                        }
                    }
                }
            }
        }
Пример #4
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;
                            }
                        }
                    }
                }
            }
        }
Пример #5
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;
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
 private void mPhysicalStudioFilmAdded(object sender, cFilm film)
 {
     if (film.getFirstValidPictureFile() != null)
     {
         lblInfo.Text    = "Adding film session" + film.getFirstValidPictureFile().pSession + " for camera " + film.pCameraDriver.pName + " " + film.pCameraDriver.pVersion + ", " + film.getEncryptedPictureFiles().Count + " files...";
         lblInfo.Visible = true;
         Application.DoEvents();
     }
 }
        public void FilmKontrolTest()
        {
            cFilm kontrolDegeri = new cFilm();

            //İlgili film veri tabanında olup olmadığını döndüren kontrol fonksiyonu..
            //Girilen ilgili film ve yönetmeni isteğe göre veritabanındaki değerlerle değiştirilebilir..
            bool sonuc = kontrolDegeri.FilmKontrol("Karayip Korsanları", "Rob Marshall");

            Assert.IsTrue(sonuc);
        }
Пример #8
0
        public override void DevelopFilm(cFilm film)
        {
            cCamera cameraInterface = film.pCameraDriver;

            if (cameraInterface == null)
            {
                throw new Exception("This film does not belong to a camera!");
            }

            cameraInterface.developFilm(film);
        }
Пример #9
0
        public override string DevelopVideo(cFilm film, string fileName)
        {
            cCamera cameraInterface = film.pCameraDriver;

            if (cameraInterface == null)
            {
                throw new Exception("This film does not belong to a camera!");
            }

            return(cameraInterface.developVideo(film, Path, fileName));
        }
Пример #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 void btnGetir_Click(object sender, EventArgs e)
        {
            lvFilmler.Items.Clear();
            cFilm f = new cFilm();
            ArrayList alist = f.FilmleriGetir();

            int i = 0;
            foreach (cFilm film in alist)
            {
                lvFilmler.Items.Add(film.FilmNo.ToString());
                lvFilmler.Items[i].SubItems.Add(film.FilmAd);
                lvFilmler.Items[i].SubItems.Add(film.Yonetmen);
                lvFilmler.Items[i].SubItems.Add(film.Oyuncular);
                lvFilmler.Items[i].SubItems.Add(film.Miktar.ToString());
                i++;
            }

            dgvFilmler.DataSource = alist;
        }
Пример #12
0
        private IEnumerable <int> getFilesLogged(cFilm film)
        {
            ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings["CoreContext"];
            var data = new cDataAccess(setting.ConnectionString);

            var filesLogged = new List <int>();

            if (mUserId > 0)
            {
                int result;
                data.checkLoggedSessions(film, out result);
                data.getCurrentLoggedCases(film, mUserId, mImagePath, out filesLogged);
                if (data.pError.Length > 0)
                {
                    MessageBox.Show("WARNING! Could not checked Logged Cases - " + data.pError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            return(filesLogged);
        }
Пример #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 virtual string DevelopVideo(cFilm film, string fileName)
 {
     return(string.Empty);
 }
Пример #15
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);
            }
        }
Пример #16
0
 public override void ClearFilm(cFilm film)
 {
     film.clearFilm();
 }
Пример #17
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;
            }
        }
Пример #18
0
 public virtual void ClearFilm(cFilm film)
 {
 }
Пример #19
0
        /// <summary>
        ///     Gets all the films for the cameraInterface, developing a sample picture from each to
        ///     make sure the partici
        /// </summary>
        /// <param name = "filterAfterDate"></param>
        /// <returns></returns>
        public override List <cFilm> GetDevelopableFilms(DateTime?filterAfterDate)
        {
            Films = new List <cFilm>();

            string logTestIndicator = ConfigurationManager.AppSettings["LogTestIndicator"];

            foreach (var participant in Participants)
            {
                if (Directory.Exists(Path))
                {
                    string[] files = Directory.GetFiles(Path, participant.Value.pEncFileName, SearchOption.AllDirectories);

                    bool          skip         = false;
                    DirectoryInfo parentToSkip = null;

                    foreach (string file in files)
                    {
                        DirectoryInfo parent = Directory.GetParent(file);

                        if (parent != null && parent.Name.ToUpper() != "AVGSPEED" && parent.Name.ToUpper() != "VOSI")
                        {
                            if (parent.FullName.ToUpper().Contains("TEST") == true && logTestIndicator.ToUpper() == "FALSE")
                            {
                                continue;
                            }

                            //It might be that the file has zero length
                            long length = new System.IO.FileInfo(file).Length;
                            if (length == 0)
                            {
                                continue;
                            }

                            if (skip)
                            {
                                if (parent.FullName == parentToSkip.FullName)
                                {
                                    continue;
                                }
                            }

                            DateTime?lastWrite;
                            try
                            {
                                lastWrite = parent.LastWriteTime;
                            }
                            catch
                            {
                                lastWrite = null;
                            }

                            if (filterAfterDate == null || lastWrite == null || (lastWrite.Value.Date > filterAfterDate.Value.Date))
                            {
                                bool exists = Films.Any(film => film.pPath == parent.FullName);

                                if (!exists)
                                {
                                    FileInfo fi = new FileInfo(file);
                                    cFilm    f  = new cFilm {
                                        pPath = parent.FullName, pCreationTime = lastWrite
                                    };

                                    if (participant.Value.developPictureFile(f, fi.Name))
                                    {
                                        f.pCameraDriver = participant.Value;
                                        participant.Value.ReadFilesFromDisk(f);

                                        if (evFilmAdded != null)
                                        {
                                            evFilmAdded(this, f);
                                        }

                                        Films.Add(f);

                                        skip         = true;
                                        parentToSkip = parent;
                                    }
                                    else
                                    {
                                        f.Dispose();
                                    }
                                }
                            }

                            //skip = true;
                            //parentToSkip = parent;
                        }
                    }
                }
            }

            if (Films.Count > 0)
            {
                Films.Sort(compare);
            }

            return(Films);
        }
Пример #20
0
 public virtual void DevelopFilm(cFilm film)
 {
 }