Exemple #1
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);
        }
Exemple #2
0
        private void loadFilms()
        {
            if (txtDirectory.Text.Length <= 0)
            {
                MessageBox.Show("You must enter a start directory first.", "No Directory Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDirectory.Focus();
                return;
            }

            var dirSelected = new DirectoryInfo(txtDirectory.Text);

            if (!dirSelected.Exists)
            {
                MessageBox.Show("The directory you selected does not exist.", "Directory does not Exist", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDirectory.Focus();
                return;
            }

            resetForm();

            lblInfo.Text    = "Loading Films...please be patient";
            lblInfo.Visible = true;
            ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings["CoreContext"];
            var data = new cDataAccess(setting.ConnectionString);

            Cursor.Current = Cursors.WaitCursor;

            lsvSessions.BeginUpdate();

            try
            {
                if (mTree.SelectedNode != null)
                {
                    if (mTree.SelectedNode.GetType() != typeof(DirectoryNode))
                    {
                        MessageBox.Show("You cannot select a file from the treeview. Select a directory and try again.", "No Dir Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    var node = (DirectoryNode)mTree.SelectedNode;
                    if (!node.UserSecurity.canRead())
                    {
                        MessageBox.Show("Your User Account Control does not allow you to read files in the selected directory. Remove UAC or contact your system Administrator.", "No Access", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (!node.UserSecurity.canWrite())
                    {
                        MessageBox.Show("Your User Account Control does not allow you to write to files in the selected directory. Remove UAC or contact your system Administrator.", "No Access", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }



                    //create the entry here for calling the new camera methods in a dll
                    //getdevelopablefilms will need to accept new paramter - path
                    mPhysicalStudio.Path = node.FullPath;

                    List <cFilm> films = chkFilter.Checked ? mPhysicalStudio.GetDevelopableFilms(dateTimePickerFilterAfter.Value) : mPhysicalStudio.GetDevelopableFilms(null);
                    if (films.Count == 0)
                    {
                        var sb = new StringBuilder();
                        sb.Append("The system could not decrypt files in the selected path.");
                        sb.Append(Environment.NewLine);
                        sb.Append("Possible Reasons:");
                        sb.Append(Environment.NewLine);
                        sb.Append("1. No Files could be found, check the filter or if the path contains files.");
                        sb.Append(Environment.NewLine);
                        sb.Append("2. The files exists but are corrupted and cannot be decrypted.");
                        sb.Append(Environment.NewLine);
                        sb.Append("3. Invalid deskey or deskey not found.");
                        MessageBox.Show(sb.ToString(), "No pictures found.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    foreach (cFilm film in films)
                    {
                        ListViewItem item = new ListViewItem(film.pGroup);

                        item.SubItems.Add(film.pCreationTime != null ? film.pCreationTime.Value.ToString("yyyy-MM-dd") : "*Cannot Read Date");

                        item.SubItems.Add(film.pCameraDriver.pName + " " + film.pCameraDriver.pVersion);

                        item.SubItems.Add(film.pHasErrors ? "Yes" : "No");

                        if (mUserId > 0)
                        {
                            int result;
                            data.checkLoggedSessions(film, out result);
                            item.BackColor = result == 1 ? Color.Purple : Color.Green;
                        }
                        else
                        {
                            item.BackColor = Color.Orange;
                        }

                        item.Tag = film;
                        lsvSessions.Items.Add(item);
                    }
                }
            }
            finally
            {
                lsvSessions.EndUpdate();
                lblInfo.Visible = false;
                Cursor.Current  = Cursors.Default;
            }
        }
Exemple #3
0
        private void btnLog_Click(object sender, EventArgs e)
        {
            if (mUserId <= 0)
            {
                MessageBox.Show("You must login with a valid username and password before you can log!", "Cannot Log", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

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

            data.evNewCaseLogged           += data_NewCaseLogged;
            data.evNewCaseLoggedError      += data_NewCaseLoggedError;
            data.evNewCasePreviouslyLogged += data_NewCasePreviouslyLogged;

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                if (lsvSessions.SelectedItems.Count > 0 && lsvSessions.Items.Count > 0)
                {
                    if (lsvSessions.SelectedItems.Count > 1)
                    {
                        if (MessageBox.Show("You have selected " + lsvSessions.SelectedItems.Count + " sessions to log. Are you sure you want to continue?", "Multi session Log mode", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            return;
                        }
                    }

                    foreach (ListViewItem selectedItem in lsvSessions.SelectedItems)
                    {
                        var film = (cFilm)selectedItem.Tag;

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

                            var sf = new StatsReport();
                            sf.userId = mUserId;
                            sf.BindFormData(reportFilm);
                            sf.Show(this);

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

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

                            Application.DoEvents();

                            int sessionLogged;
                            data.checkLoggedSessions(film, out sessionLogged);
                            selectedItem.BackColor = sessionLogged == 1 ? Color.Purple : Color.Green;
                        }

                        if (data.pError.Length > 0)
                        {
                            if (film.getFirstValidPictureFile() != null)
                            {
                                MessageBox.Show("ERROR with logging film " + film.getFirstValidPictureFile().pFormattedSession + " - " + data.pError, "Log Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                MessageBox.Show("ERROR with logging film <SESSION READ ERROR> - " + data.pError, "Log Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }

                        mPhysicalStudio.ClearFilm(film);
                    }
                }
                else
                {
                    MessageBox.Show("You must select a session with encrypted files before you can log!", "Cannot Log", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show("The system logged " + totalLoggedCases.ToString() + " new cases!", "Logged Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                lblInfo.Text = "The system logged " + totalLoggedCases + " new cases!";
            }
        }
Exemple #4
0
        private ListView GetUnLoggedDirectoryList()
        {
            string CameraFilePath = ConfigurationManager.AppSettings["CameraFilePath"];

            if (CameraFilePath.Length <= 0)
            {
                errorWriting.WriteErrorLog("Camera File path is not properly configured in config file");
                return(null);
            }

            var dirSelected = new DirectoryInfo(CameraFilePath);

            if (!dirSelected.Exists)
            {
                errorWriting.WriteErrorLog(CameraFilePath + ": This Camera File path does not exist.");
                return(null);
            }

            ListView unloggedList = new ListView();

            try
            {
                mPhysicalStudio.Path = CameraFilePath;

                List <cFilm> films = mPhysicalStudio.GetDevelopableFilms(null);
                if (films.Count == 0)
                {
                    var sb = new StringBuilder();
                    sb.Append("The system could not decrypt files in the selected path.");
                    sb.Append(Environment.NewLine);
                    sb.Append("Possible Reasons:");
                    sb.Append(Environment.NewLine);
                    sb.Append("1. No Files could be found, check the filter or if the path contains files.");
                    sb.Append(Environment.NewLine);
                    sb.Append("2. The files exists but are corrupted and cannot be decrypted.");
                    sb.Append(Environment.NewLine);
                    sb.Append("3. Invalid deskey or deskey not found.");

                    errorWriting.WriteErrorLog(sb.ToString());

                    return(null);
                }

                foreach (cFilm film in films)
                {
                    ListViewItem item = new ListViewItem(film.pGroup);

                    int result;
                    dataAccess.checkLoggedSessions(film, out result);


                    if (result != 1)
                    {
                        if (!RemoveOldFiles(film.pPath))
                        {
                            item.Tag = film;
                            item.SubItems.Add(film.pPath);
                            errorWriting.WriteErrorLog(string.Format("File directory: {0} on machine: {1} is ready to be processed.", film.pPath, Environment.MachineName));
                            unloggedList.Items.Add(item);
                        }
                    }
                    else
                    {
                        //Lets delete old directories here
                        RemoveOldFiles(film.pPath);
                    }
                }
                return(unloggedList);
            }

            finally
            {
            }
        }