コード例 #1
0
        private void ImageGroupGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            if (dgv.Columns[e.ColumnIndex].Name != "Delete")
            {
                return;
            }

            if (!allowUpdates)
            {
                PicesSipperVariables.UpdatesNotAllowed("Group Maintenance");
                return;
            }

            if (e.RowIndex < 0)
            {
                return;
            }

            PicesDataBaseImageGroup ig = dbConn.ImageGroupLoad((String)dgv.Rows[e.RowIndex].Cells[1].Value);

            if (ig == null)
            {
                return;
            }
            DialogResult dr = MessageBox.Show(this, "Are you sure you want to delete this group ?", "Delete " + ig.Name, MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                dbConn.ImageGroupDelete(ig.ImageGroupId);
                LoadGroups();
            }
        }
コード例 #2
0
        PlanktonClassStatisticsLoader statsLoader = null; // To determine total number of images that will be saved.


        public SavePlanktonData(PicesDataBase _dbConn,
                                PicesDataBaseImageGroup _group,
                                String _cruise,
                                String _station,
                                String _deployment,
                                String _sipperFileName,
                                PicesClass _mlClass,
                                char _classKeyToUse,
                                float _probMin,
                                float _probMax,
                                int _sizeMin,
                                int _sizeMax,
                                float _depthMin,
                                float _depthMax
                                )
        {
            dbConn         = _dbConn;
            group          = _group;
            cruise         = (_cruise == null) ? "" : _cruise;
            station        = (_station == null) ? "" : _station;
            deployment     = (_deployment == null) ? "" : _deployment;
            sipperFileName = (_sipperFileName == null) ? "" : _sipperFileName;
            mlClass        = _mlClass;
            classKeyToUse  = _classKeyToUse;

            probMin  = _probMin;
            probMax  = _probMax;
            sizeMin  = _sizeMin;
            sizeMax  = _sizeMax;
            depthMin = _depthMin;
            depthMax = _depthMax;

            runLog = new PicesRunLog();
            InitializeComponent();
        }
コード例 #3
0
        } /* ValidateSourceDirectory */

        private void  ValidateGroupName()
        {
            errorProvider1.SetError(GroupName, "");
            String errorDesc = "";
            bool   valid     = false;

            groupName = GroupName.Text;
            PicesDataBaseImageGroup.ValidName(ref groupName, ref errorDesc, ref valid);
            if (!valid)
            {
                errorProvider1.SetError(GroupName, errorDesc);
                validationErrorFound = true;
            }
            GroupName.Text = groupName;
        } /* ValidateGroupName */
コード例 #4
0
ファイル: Harvester.cs プロジェクト: PalakDave/Pices
        } /* GetDatabaseImageRecords */

        private void  UpdateImageGroupTables(PicesDataBase threadConn,
                                             PicesDataBaseImageList harvestedImages
                                             )
        {
            RunLogAddMsg("Create Image Group Entries" + "\n");
            PicesDataBaseImageGroup existingGroup = threadConn.ImageGroupLoad(groupName);

            if (existingGroup != null)
            {
                // Since the group already exists we will have to delete it.
                threadConn.ImageGroupDelete(existingGroup.ImageGroupId);
            }

            String description = "Created by Harvester" + "\n" +
                                 "DateTime" + "\t" + DateTime.Now.ToLongDateString() + "\n" +
                                 "NumImages" + "\t" + harvestedImages.Count.ToString("#,###,##0") + "\n";

            PicesDataBaseImageGroup group = new PicesDataBaseImageGroup(-1, groupName, description, (uint)harvestedImages.Count);

            threadConn.ImageGroupInsert(group);

            int idx = 0;

            while (idx < harvestedImages.Count)
            {
                PicesDataBaseImageList updateGroup = new PicesDataBaseImageList();

                while ((idx < harvestedImages.Count) && (updateGroup.Count < 50))
                {
                    updateGroup.Add(harvestedImages[idx]);
                    idx++;
                }

                threadConn.ImageGroupEntriesInsert(group.ImageGroupId, updateGroup);
                RunLogAddMsg("Added To ImageGroup[" + idx + "]  of  [" + harvestedImages.Count + "]" + "\n");
            }

            if (threadConn.Valid())
            {
                RunLogAddMsg("Image Group Tables Updated" + "\n");
            }
            else
            {
                RunLogAddMsg("\n" + "\n" +
                             "Image Group Tables Update FAILED   ***ERROR***" + "\n"
                             );
            }
        } /* UpdateImageGroupTables*/
コード例 #5
0
        } /* ValidateGroupName */

        private void  ValidateGroupNameDoesntExist()
        {
            group = mainWinConn.ImageGroupLoad(groupName);
            if (group != null)
            {
                DialogResult dr = MessageBox.Show
                                      (this,
                                      "Group[" + groupName + "] already exists" + "\n\n" +
                                      "Do you want to replace it ?",
                                      "Group Already Exists",
                                      MessageBoxButtons.YesNo
                                      );

                if (dr == DialogResult.No)
                {
                    validationErrorFound = true;
                    errorProvider1.SetError(GroupName, "Group already exists");
                }
            }
        } /* ValidateGroupNameDoesntExist */
コード例 #6
0
        } /* ValidateGroupName */

        private void  UpdateDatabase()
        {
            PicesDataBaseImageGroup ig = new PicesDataBaseImageGroup(-1, GroupName.Text, Description.Text, 0);

            dbConn.ImageGroupInsert(ig);
            if (!dbConn.Valid())
            {
                MessageBox.Show(this,
                                "Error Creating new Image Group" + "\n" + dbConn.LastErrorDesc(),
                                "Assign Selected Images to Group",
                                MessageBoxButtons.OK
                                );
            }
            else
            {
                int zed = 0;
                while (zed < selImages.Count)
                {
                    PicesDataBaseImageList subSet = new PicesDataBaseImageList();
                    while ((subSet.Count < 100) && (zed < selImages.Count))
                    {
                        subSet.Add(selImages[zed]);
                        ++zed;
                    }
                    dbConn.ImageGroupEntriesInsert(ig.ImageGroupId, subSet);
                    if (!dbConn.Valid())
                    {
                        break;
                    }
                }
                if (dbConn.Valid())
                {
                    newGroupCreated = true;
                    MessageBox.Show(this, "Group[" + GroupName.Text + "] Created successfully.", "Assign Selected Images to Group", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show(this, "Error Creating new Image Group" + "\n" + dbConn.LastErrorDesc(), "Assign Selected Images to Group", MessageBoxButtons.OK);
                }
            }
        } /* UpdateDatabase */
コード例 #7
0
        public PlanktonClassStatisticsLoader(PicesDataBaseImageGroup _selectedImageGroup,
                                             String _cruiseName,
                                             String _stationName,
                                             String _deploymentNum,
                                             String _sipperFileName,
                                             PicesClass _mlClass,
                                             char _classKeyToUse,
                                             float _probMin,
                                             float _probMax,
                                             int _sizeMin,
                                             int _sizeMax,
                                             float _depthMin,
                                             float _depthMax
                                             )
        {
            runLog = new PicesRunLog();

            dbConn             = null;
            selectedImageGroup = _selectedImageGroup;
            cruiseName         = _cruiseName;
            stationName        = _stationName;
            deploymentNum      = _deploymentNum;
            sipperFileName     = _sipperFileName;
            mlClass            = _mlClass;
            classKeyToUse      = _classKeyToUse;
            probMin            = _probMin;
            probMax            = _probMax;
            sizeMin            = _sizeMin;
            sizeMax            = _sizeMax;
            depthMin           = _depthMin;
            depthMax           = _depthMax;

            imageCountTotal = 0;

            blocker = new PicesGoalKeeper("PlanktonClassStatisticsLoader");

            loaderThread = new Thread(new ThreadStart(LoadStatsThread));
            loaderThread.Start();
        }
コード例 #8
0
        private void  ValidateGroupName()
        {
            errorProvider1.SetError(GroupName, "");
            String errorDesc = "";
            bool   valid     = false;

            groupName = GroupName.Text;
            PicesDataBaseImageGroup.ValidName(ref groupName, ref errorDesc, ref valid);
            if (!valid)
            {
                errorProvider1.SetError(GroupName, errorDesc);
                validationErrorFound = true;
            }

            if (dbConn.ImageGroupLoad(groupName) != null)
            {
                errorDesc = "This Group name already exists.";
                errorProvider1.SetError(GroupName, errorDesc);
                validationErrorFound = true;
            }

            GroupName.Text = groupName;
        } /* ValidateGroupName */
コード例 #9
0
ファイル: SaveImagesToDisk2.cs プロジェクト: PalakDave/Pices
        PlanktonClassStatisticsLoader statsLoader = null; // To determine total number of images that will be saved.


        public SaveImagesToDisk2(PicesDataBase _dbConn,
                                 PicesDataBaseImageList _images,  // If '_images' is not null then you do not need to include any of the following parameters.
                                 PicesDataBaseImageGroup _group,
                                 String _cruise,
                                 String _station,
                                 String _deployment,
                                 String _sipperFileName,
                                 PicesClass _mlClass,
                                 char _classKeyToUse,
                                 float _probMin,
                                 float _probMax,
                                 int _sizeMin,
                                 int _sizeMax,
                                 float _depthMin,
                                 float _depthMax
                                 )
        {
            dbConn         = _dbConn;
            images         = (_images == null) ? null : _images;
            group          = _group;
            cruise         = (_cruise == null) ? ""   : _cruise;
            station        = (_station == null) ? ""   : _station;
            deployment     = (_deployment == null) ? ""   : _deployment;
            sipperFileName = (_sipperFileName == null) ? ""   : _sipperFileName;
            mlClass        = _mlClass;
            classKeyToUse  = _classKeyToUse;

            probMin  = _probMin;
            probMax  = _probMax;
            sizeMin  = _sizeMin;
            sizeMax  = _sizeMax;
            depthMin = _depthMin;
            depthMax = _depthMax;

            runLog = new PicesRunLog();
            InitializeComponent();
        }
コード例 #10
0
        public ChartAbundancePredictedAndValidated(String _cruise,
                                                   String _station,
                                                   String _deployment,
                                                   PicesDataBaseImageGroup _group,
                                                   PicesClass _classToPlot,
                                                   int _sizeMin,
                                                   int _sizeMax,
                                                   float _probMin,
                                                   float _probMax,
                                                   float _depthMin,
                                                   float _depthMax,
                                                   PicesClassList _classes,
                                                   PicesClassList _activeClasses,
                                                   String _rootDir
                                                   )
        {
            cruise     = _cruise;
            station    = _station;
            deployment = _deployment;
            group      = _group;
            if (group != null)
            {
                groupName = group.Name;
            }
            classToPlot   = _classToPlot;
            sizeMin       = _sizeMin;
            sizeMax       = _sizeMax;
            probMin       = _probMin;
            probMax       = _probMax;
            depthMin      = _depthMin;
            depthMax      = _depthMax;
            classes       = _classes;
            activeClasses = _activeClasses;
            rootDir       = _rootDir;

            if ((sizeMin > 0) && (sizeMax <= 0))
            {
                sizeMax = int.MaxValue;
            }
            if ((probMin >= 0.0f) && (probMax <= 0.0f))
            {
                probMax = 1.0f;
            }
            if ((depthMin > 0.0f) && (depthMax <= 0.0f))
            {
                depthMax = float.MaxValue;
            }

            filterSize  = (sizeMin > 0) || ((sizeMax > 0) && (sizeMax > sizeMin));
            filterProb  = ((probMin > 0.0f) || (probMax < 1.0f)) && (probMax > probMin);
            filterDepth = ((depthMax > 0) && (depthMax > depthMin));

            statusMsgs = new PicesMsgQueue("ChartAbundancePredictedAndValidated-StatusMsgs");
            msgQueue   = new PicesMsgQueue("ChartAbundancePredictedAndValidated-RunLog");
            runLog     = new PicesRunLog(msgQueue);

            mainWinConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            configFileName = OSservices.AddSlash(PicesSipperVariables.ConfigurationDirectory()) + "ChartAbundancePredictedAndValidated.cfg";

            BuildCriteriaString();

            InitializeComponent();
        }
コード例 #11
0
        } /* StartTheHarvestingProcedure */

        private void  ImportAssignments()
        {
            PicesDataBase.ThreadInit();
            backGroundRunning   = true;
            backGroundCompleted = false;

            PicesDataBase threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            RunLogAddMsg("Source Directory [" + sourceDirectory + "]");
            RunLogAddMsg("Group Name       [" + groupName + "]");
            RunLogAddMsg("Start Date/Time  [" + DateTime.Now.ToString("yyyy-MMM-dd HH:mm:ss") + "]");
            RunLogAddMsg("Active DataBase  [" + threadConn.Server.Description + "]");

            importedFileNames = new List <String> ();

            group = threadConn.ImageGroupLoad(groupName);
            if (group != null)
            {
                // Group already exists;  will delete it.
                RunLogAddMsg("\n" + "Group[" + groupName + "] already exists.   Will remove and replace with new one." + "\n");

                threadConn.ImageGroupDelete(group.ImageGroupId);
            }

            group = new PicesDataBaseImageGroup(-1, groupName, groupDesc, 0);
            threadConn.ImageGroupInsert(group);

            ImportAssignmentsImportDir(sourceDirectory);
            if (cancelBackGround)
            {
                RunLogAddMsg("\n" + "Importing Assignments has been Canceled." + "\n");
            }
            else
            {
                RunLogAddMsg("\n\n" + "Total Images[" + importedFileNames.Count.ToString("###,##0") + "\n");

                RunLogAddMsg("Writing to DataBase Now" + "\n");

                imageFileErrorList = new List <string>();

                int numInserted = 0;

                for (int x = 0; (x < importedFileNames.Count) && (!cancelBackGround); x++)
                {
                    PicesDataBaseImageGroupEntry ige = new PicesDataBaseImageGroupEntry();
                    ige.ImageGroupId  = group.ImageGroupId;
                    ige.ImageFileName = importedFileNames[x];
                    threadConn.ImageGroupEntriesInsert(ige);
                    if (!threadConn.Valid())
                    {
                        imageFileErrorList.Add(importedFileNames[x]);
                        RunLogAddMsg("Image[" + importedFileNames[x] + "]  ***ERROR***");
                    }
                    else
                    {
                        numInserted++;
                    }

                    if ((x % 100) == 0)
                    {
                        RunLogAddMsg("Images Assigned[" + numInserted + "]  Failures[" + imageFileErrorList.Count + "]");
                    }
                }
            }

            threadConn.Close();
            threadConn = null;
            GC.Collect();
            PicesDataBase.ThreadEnd();

            backGroundRunning   = false;
            backGroundCompleted = true;
        } /* ImportAssignments */