private void ReconcileImagesToDataBase_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (reconcilingRunning)
            {
                if (e.CloseReason == CloseReason.UserClosing)
                {
                    DialogResult dr = MessageBox.Show(this, "Reconciliation Process is still running!   Cancel Process Yes/No ?", "Cancel Reconciliation", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.No)
                    {
                        e.Cancel = true;
                        return;
                    }
                }

                formIsClosing = true;
                CancelRecondiliationThread();

                if (dbConn != null)
                {
                    dbConn.Close();
                    dbConn = null;
                    GC.Collect();
                }
            }
        }
Exemple #2
0
        } /* WriteTabDelToStream */

        private void ChartAbundanceByDeployment_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (buildPlotDataRunning)
            {
                if (e.CloseReason == CloseReason.WindowsShutDown)
                {
                    CancelBackGroundThread();
                    while (buildPlotDataRunning)
                    {
                        Thread.Sleep(100);
                    }
                }
                else
                {
                    MessageBox.Show(this, "Plot data is being collected; press \"Cancel Button\" to Stop before exiting.", "Form Closing", MessageBoxButtons.OK);
                    e.Cancel = true;
                    return;
                }
            }

            SaveConfiguration();

            mainWinConn.Close();
            mainWinConn = null;
            GC.Collect();
        }
Exemple #3
0
        } /* LoadImagesForOneSipperFile */

        private void  LoadImagesThread()
        {
            blocker.StartBlock();
            loaderThreadRuning = true;
            PicesDataBase.ThreadInit();
            blocker.EndBlock();

            dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            allSipperFiles = (String.IsNullOrEmpty(cruiseName) &&
                              String.IsNullOrEmpty(stationName) &&
                              String.IsNullOrEmpty(deploymentNum) &&
                              String.IsNullOrEmpty(sipperFileName)
                              );

            if (!String.IsNullOrEmpty(sipperFileName))
            {
                sipperFileNames    = new String[1];
                sipperFileNames[0] = sipperFileName;
            }
            else
            {
                sipperFileNames = dbConn.SipperFileGetList(cruiseName, stationName, deploymentNum);
            }

            if (selectedImageGroup != null)
            {
                LoadImagesForSelectedGroup();
            }
            else
            {
                if (sipperFileNames != null)
                {
                    for (curSipperFileIdx = 0; (curSipperFileIdx < sipperFileNames.Length) && (!cancelRequested); curSipperFileIdx++)
                    {
                        LoadImagesForOneSipperFile(sipperFileNames[curSipperFileIdx]);
                    }
                }
            }

            blocker.StartBlock();
            if (!cancelRequested)
            {
                doneLoading = true;
            }
            loaderThreadRuning = false;
            blocker.EndBlock();

            if (completionEvent != null)
            {
                completionEvent(this);
            }

            dbConn.Close();
            dbConn = null;
            GC.Collect();

            PicesDataBase.ThreadEnd();
        } /* LoadImagesTread */
Exemple #4
0
        } /* ImageEntry */



        private void  HarvestImages()
        {
            PicesDataBase.ThreadInit();
            harvestingRunning   = true;
            harvestingCompleted = false;

            PicesDataBase threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            List <ImageEntry> allImages = null;

            List <ImageEntry>[] imagesByDepth    = null;
            double[]            depthTimeProfile = null;
            double[]            fracPartByDepth  = null;
            List <ImageEntry>   randDistByDepth  = null;

            //if  (!cbOilDeployments.Checked)
            allImages = LoadAllImages(threadConn);
            //else
            //  allImages = LoadOilDeploymentImages();

            if (!cancelHarvesting)
            {
                if (weight)
                {
                    depthTimeProfile = LoadDepthTimeProfile(threadConn);
                    if (!cancelHarvesting)
                    {
                        imagesByDepth   = DeriveImagesByDepth(allImages, depthTimeProfile.Length);
                        fracPartByDepth = DeriveFracPartByDepth(depthTimeProfile, imagesByDepth);

                        randDistByDepth = DeriveRandomDistByDepth(imagesByDepth, fracPartByDepth);
                        harvestedImages = GetDatabaseImageRecords(threadConn, randDistByDepth);
                        UpdateImageGroupTables(threadConn, harvestedImages);

                        RunLogAddMsg("\n" + "Harvesting Completed Successfully." + "\n");
                    }
                }
                else
                {
                    harvestedImages = DeriveRandomDistribution(threadConn, allImages);
                    if (!cancelHarvesting)
                    {
                        UpdateImageGroupTables(threadConn, harvestedImages);
                    }
                }

                if (!cancelHarvesting)
                {
                    harvestingCompleted = true;
                }
            }

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

            PicesDataBase.ThreadEnd();
            harvestingRunning = false;
        } /* HarvestImages */
 private void  CloseMySQL()
 {
     if (mainWinConn != null)
     {
         mainWinConn.Close();
         mainWinConn = null;
         GC.Collect();
     }
 }
Exemple #6
0
 private void CruiseMaintenance_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (weOwnDbConn)
     {
         dbConn.Close();
         dbConn = null;
         GC.Collect();
     }
 }
        } /* CreateFeatureDataFileThread */

        void  MakeSureDepthFieldIsIncluded(PicesFeatureVectorList data)
        {
            PicesDataBase dbConn = null;
            PicesRunLog   runLog = new PicesRunLog(dialogMsgQueue);

            data.SortByImageFileName();

            String curSipperFileName  = "";
            float  curSipperFileDepth = 0.0f;


            foreach (PicesFeatureVector fv in data)
            {
                if (fv.Depth == 0.0f)
                {
                    if (dbConn == null)
                    {
                        dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
                    }
                    uint   sacnLineNum        = 0;
                    uint   scanCol            = 0;
                    String nextSipperFileName = "";

                    PicesFeatureVector.ParseImageFileName(fv.ExampleFileName, ref nextSipperFileName, ref sacnLineNum, ref scanCol);

                    if (nextSipperFileName != curSipperFileName)
                    {
                        curSipperFileDepth = 0.0f;
                        curSipperFileName  = nextSipperFileName;

                        PicesSipperFile sf = dbConn.SipperFileRecLoad(curSipperFileName);
                        if (sf != null)
                        {
                            curSipperFileDepth = sf.Depth;
                        }
                    }

                    PicesInstrumentData id = dbConn.InstrumentDataGetByScanLine(curSipperFileName, sacnLineNum);
                    if ((id == null) || (id.Depth == 0.0))
                    {
                        fv.Depth = curSipperFileDepth;
                    }
                    else
                    {
                        fv.Depth = id.Depth;
                    }
                }
            }

            if (dbConn != null)
            {
                dbConn.Close();
                dbConn = null;
                GC.Collect();
            }
        } /* MakeSureDepthFieldIsIncluded */
        /// <summary>
        /// Using supplied 'Raster' data it will call each currently active model and return there predictions.
        /// </summary>
        /// <param name="raster">Raster of image to predict. .</param>
        /// <param name="instrumentData">Instrument data that was recorded with the 'raster' .</param>
        /// <param name="imageFileName">Name of the image file.</param>
        /// <param name="model1Predictions">The model1 predictions.</param>
        /// <param name="model2Predictions">The model2 predictions.</param>
        /// <param name="runLog">The run log.</param>
        public static void  MakePredictions(PicesRaster raster,
                                            InstrumentData instrumentData,
                                            String imageFileName,
                                            ref PicesPredictionList model1Predictions,
                                            ref PicesPredictionList model2Predictions,
                                            PicesRunLog runLog
                                            )
        {
            model1Predictions = null;
            model2Predictions = null;
            if (!ModelsAreAvailable())
            {
                return;
            }

            ParsedImageFileName pifn = PicesFeatureVector.ParseImageFileName(imageFileName);
            String sipperFileName    = pifn.sipperFileName;
            uint   scanLineNum       = pifn.scanLineNum;

            PicesFeatureVector fv = new PicesFeatureVector(raster, imageFileName, null, runLog);

            if (instrumentData != null)
            {
                fv.AddInstrumentData(instrumentData.Depth(),
                                     instrumentData.Salinity(),
                                     instrumentData.Oxygen(),
                                     instrumentData.Fluorescence()
                                     );
            }
            else
            {
                PicesDataBase       dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
                PicesInstrumentData pid    = dbConn.InstrumentDataGetByScanLine(sipperFileName, scanLineNum);
                if (pid != null)
                {
                    fv.AddInstrumentData(pid);
                }
                pid = null;
                dbConn.Close();
                dbConn = null;
            }

            if (model1 != null)
            {
                model1Predictions = model1.PredictProbabilities(fv);
            }

            if (model2 != null)
            {
                model2Predictions = model2.PredictProbabilities(fv);
            }

            fv = null;

            return;
        } /* MakePredictions */
Exemple #9
0
 private void StationDialog_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (weOwnDbConn)
     {
         dbConn.Close();
         dbConn = null;
         GC.Collect();
         weOwnDbConn = false;
     }
 }
        private void GetRunTimeParameters_Load(object sender, EventArgs e)
        {
            LoadConfiguraionData();
            PicesDataBase dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            dbConn.SipperFileLoadOracle();

            dbConn.Close();
            dbConn = null;
        }
Exemple #11
0
        } /* PerformUpdate */

        private void  UpdateProcess()
        {
            PicesDataBase.ThreadInit();
            updateRunning = true;

            PicesRunLog   updRunLog = new PicesRunLog();
            PicesDataBase updDbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(updRunLog);

            sipperFilesTotal   = 0;
            sipperFilesUpdated = 0;

            if (addingNewClass || deletingExistingClass || (mergeClass != null))
            {
                sipperFiles = updDbConn.SipperFileLoad("", "", "");
                if (sipperFiles == null)
                {
                    RunLogAddMsg("Could not retrieve list of SIPPER files update failed." + "\n");
                    updateRunning = false;
                    return;
                }
                sipperFilesTotal = sipperFiles.Count;
            }

            if (addingNewClass)
            {
                UpdateProcessAdd(updDbConn);
            }

            else if (deletingExistingClass)
            {
                UpdateProcessDelete(updDbConn);
            }

            else if (mergeClass != null)
            {
                UpdateProcessMerge(updDbConn);
            }

            else if (nameChangeHasOccured)
            {
                UpdateProcessNameChange(updDbConn);
            }

            else
            {
                UpdateDataFields(updDbConn);
            }

            updDbConn.Close();
            updDbConn = null;
            GC.Collect();

            PicesDataBase.ThreadEnd();
            updateRunning = false;
        } /* UpdateProcess */
        public PredictionBreakDownDisplayDual(PicesDataBase _dbConn,
                                              String _fileName,
                                              TrainingModel2 _trainingModel,
                                              PicesInstrumentData _instrumentData, /**<  Instrument data that goes with image,  if null will read from dtabase. */
                                              PicesRunLog _runLog
                                              )
        {
            if (_runLog == null)
            {
                runLog = new PicesRunLog();
            }
            else
            {
                runLog = _runLog;
            }

            fileName       = _fileName;
            instrumentData = _instrumentData;
            trainingModel  = _trainingModel;

            PicesDataBase dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
            PicesRaster   raster = dbConn.ImageFullSizeFind(fileName);

            if (raster == null)
            {
                return;
            }

            if (_dbConn != null)
            {
                dbFeatureVector = _dbConn.FeatureDataRecLoad(_fileName);
                if (instrumentData == null)
                {
                    PicesDataBaseImage image = dbConn.ImageLoad(fileName);
                    if (image != null)
                    {
                        instrumentData = dbConn.InstrumentDataGetByScanLine(image.SipperFileName, image.TopLeftRow);
                    }
                }
            }

            featureVector = new PicesFeatureVector(raster, fileName, null, runLog);

            if (instrumentData != null)
            {
                featureVector.AddInstrumentData(instrumentData);
            }

            dbConn.Close();
            dbConn = null;
            GC.Collect();

            InitializeComponent();
        }
Exemple #13
0
        private void ClassMaintenance_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (updateRunning)
            {
                MessageBox.Show("We are in the middle of updating;  please wait until completed before closing window.");
                e.Cancel = true;
                return;
            }

            mainDbConn.Close();
            mainDbConn = null;
            GC.Collect();
        }
Exemple #14
0
        private void ImageViewer_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (image.SizeCoordinates.NotEqual(sizeCoordinates))
            {
                image.SizeCoordinates = sizeCoordinates;
                image.ImageSize       = imageSize;
                dbConn.ImagesUpdateImageSize(image.ImageFileName, sizeCoordinates, imageSize);
            }

            dbConn.Close();
            dbConn = null;
            GC.Collect();
        }
        } /* CreateTuningFeatureFiles */

        void  MakeSureDepthFieldIsIncluded(PicesFeatureVectorList data)
        {
            PicesDataBase dbConn = null;
            PicesRunLog   runLog = new PicesRunLog();

            data.SortByImageFileName();

            String curSipperFileName  = "";
            float  curSipperFileDepth = 0.0f;


            foreach (PicesFeatureVector fv in data)
            {
                if (fv.Depth == 0.0f)
                {
                    String nextSipperFileName = PicesMethods.SipperFileNameFromImageFileName(fv.ExampleFileName);

                    if (nextSipperFileName != curSipperFileName)
                    {
                        curSipperFileDepth = 0.0f;
                        curSipperFileName  = nextSipperFileName;

                        if (dbConn == null)
                        {
                            dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
                        }

                        PicesSipperFile sf = dbConn.SipperFileRecLoad(curSipperFileName);
                        if (sf != null)
                        {
                            curSipperFileDepth = sf.Depth;
                        }
                    }

                    if (fv.Depth == 0.0f)
                    {
                        fv.Depth = curSipperFileDepth;
                    }
                }
            }

            if (dbConn != null)
            {
                dbConn.Close();
                dbConn = null;
                GC.Collect();
            }
        } /* MakeSureDepthFieldIsIncluded */
Exemple #16
0
        } /* AddCruiseToSeries */

        /// <summary>
        /// This next method will be ran as a separate thread; it is responsible for collecting all the data needed to generate the plot.
        /// </summary>
        private void  BuildPlotData()
        {
            if (buildPlotDataRunning)
            {
                return;
            }

            PicesDataBase.ThreadInit();

            threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            buildPlotDataRunning = true;

            timeInterval = (int)TimeInterval.Value;

            series = new List <DataSeriesToPlot> ();
            foreach (PlotRequest pr in plotRequests)
            {
                if (cancelRequested)
                {
                    break;
                }
                AddDeploymentToSeries(pr.deployment, pr.color);
            }

            if (plotCruise && (!cancelRequested))
            {
                AddCruiseToSeries();
            }

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

            if (cancelRequested)
            {
                statusMsgs.AddMsg("Plotting of data CANCELLED!!!");
            }
            else
            {
                statusMsgs.AddMsg("Building of plot data completed !!!");
            }

            buildPlotDataRunning = false;
            buildPlotDataDone    = true;
        } /* BuildPlotData */
Exemple #17
0
        private void Harvester_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (harvestingRunning)
            {
                MessageBox.Show(this, "Harvesting is still running; need to cancel.", "Harvesting");
                e.Cancel = true;
                return;
            }

            if (mainWinConn != null)
            {
                mainWinConn.Close();
                mainWinConn = null;
                GC.Collect();
            }

            return;
        }
        } /* AddDeploymentToSeries */

        /// <summary>
        /// This method will be ran as a separate thread; it is responsible for collecting all the data needed to generate the plot.
        /// </summary>
        private void  BuildPlotData()
        {
            if (buildPlotDataRunning)
            {
                return;
            }

            PicesDataBase.ThreadInit();

            threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            buildPlotDataRunning = true;

            depthIncrement = (int)DepthIncr.Value;
            classToPlot    = PicesClassList.GetUniqueClass(ClassToPlot.Text, "");

            series = new List <DataSeriesToPlot> ();

            foreach (PlotRequest pr in plotRequests)
            {
                if (cancelRequested)
                {
                    break;
                }
                AddDeploymentToSeries(pr.deployment);
            }

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

            if (cancelRequested)
            {
                statusMsgs.AddMsg("Plotting of data CANCELLED!!!");
            }
            else
            {
                statusMsgs.AddMsg("Building of plot data completed !!!");
            }

            buildPlotDataRunning = false;
            buildPlotDataDone    = true;
        } /* BuildPlotData */
Exemple #19
0
        private void CruiseDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (ChangesMade() && (!deletingCruise))
            {
                DialogResult dr = MessageBox.Show(this, "You have made change;  are you sure you want to exit ?", "You have made changes", MessageBoxButtons.YesNo);
                if (dr == DialogResult.No)
                {
                    e.Cancel = true;
                }
            }

            if (weOwnDbConn)
            {
                dbConn.Close();
                dbConn = null;
                GC.Collect();
                weOwnDbConn = false;
            }
        }
Exemple #20
0
        } /* GetNextFeatureVector*/

        private void  ThreadProcess()
        {
            threadRunning = true;
            PicesDataBase.ThreadInit();


            if ((classifier == null) && (!String.IsNullOrEmpty(classifierName)))
            {
                PicesRunLog log = new PicesRunLog();
                classifier = new TrainingModel2(log, classifierName);
                classifier.LoadExistingModelOtherwiseBuild(null);
                classifierWeOwnIt = true;
            }

            while (!cancelFlag)
            {
                PicesFeatureVector fv = GetNextFeatureVector();
                if (fv != null)
                {
                    ProcessOneFeatureVector(fv);
                }
                else
                {
                    if (threadTerminate)
                    {
                        break;
                    }
                    Thread.Sleep(10);
                }
            }

            if (dbConn != null)
            {
                dbConn.Close();
                dbConn = null;
                GC.Collect();
            }

            PicesDataBase.ThreadEnd();

            threadRunning = false;
            threadDone    = true;
        } /* ThreadProcess */
Exemple #21
0
        private void SipperFileDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!userRequestedToCancel)
            {
                if (ChangesMade())
                {
                    DialogResult dr = MessageBox.Show(this, "Changes have been made;  are you sure you want to exit ?", "Exiting Sipper File Dialog", MessageBoxButtons.YesNo);
                    if (dr == DialogResult.No)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }

            if (weOwnDbConn)
            {
                dbConn.Close();
                dbConn = null;
                GC.Collect();
                weOwnDbConn = false;
            }
        }
        } /* ToCmdLine */

        private void  ImportValidatedClassAssignments()
        {
            importingRunning   = true;
            importingCompleted = false;

            PicesDataBase.ThreadInit();

            PicesRunLog   runLog     = new PicesRunLog();
            PicesDataBase threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            extractionLogEntryId = threadConn.LogEntriesProcessStart("IV",
                                                                     "ImportValidatedClass",
                                                                     ExecutableDateTimeStamp(),
                                                                     ToCmdLine(),
                                                                     OSservices.GetRootName(sipperFileName)
                                                                     );
            totalImagesUpdated = 0;

            ImportValidatedClassAssignmentsDir(threadConn, sourceDirectory);
            if (cancelImporting)
            {
                RunLogAddMsg("\n" + "Importing Assignments has been Canceled." + "\n\n");
            }
            else
            {
                RunLogAddMsg("\n\n" + "Total Images[" + totalImagesUpdated.ToString("###,##0") + "\n\n");
            }

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

            PicesDataBase.ThreadEnd();

            importingRunning   = false;
            importingCompleted = true;
        } /* ImportValidatedClassAssignments */
        } /* MakePredictions */

        public static void  MakePredictions(PicesRaster raster,
                                            ref PicesPrediction model1Prediction1,
                                            ref PicesPrediction model1Prediction2,
                                            ref PicesPrediction model2Prediction1,
                                            ref PicesPrediction model2Prediction2,
                                            PicesRunLog runLog
                                            )
        {
            String imageFileName = raster.FileName;

            ParsedImageFileName pifn = PicesFeatureVector.ParseImageFileName(imageFileName);
            String sipperFileName    = pifn.sipperFileName;
            uint   scanLineNum       = pifn.scanLineNum;

            PicesFeatureVector fv = new PicesFeatureVector(raster, imageFileName, null, runLog);

            {
                PicesDataBase       dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
                PicesInstrumentData pid    = dbConn.InstrumentDataGetByScanLine(sipperFileName, scanLineNum);
                if (pid != null)
                {
                    fv.AddInstrumentData(pid);
                }
                pid = null;
                dbConn.Close();
                dbConn = null;
            }

            MakePredictions(fv,
                            ref model1Prediction1,
                            ref model1Prediction2,
                            ref model2Prediction1,
                            ref model2Prediction2,
                            runLog
                            );
            fv = null;
        }
        } /* ToCmdLine */

        private void  ImportImagesIntoDeploymentProcess()
        {
            importingRunning   = true;
            importingCompleted = false;

            PicesDataBase.ThreadInit();

            PicesRunLog   runLog     = new PicesRunLog();
            PicesDataBase threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            extractionLogEntryId = threadConn.LogEntriesProcessStart("II",
                                                                     "ImportImagesIntoDeployment",
                                                                     ExecutableDateTimeStamp(),
                                                                     ToCmdLine(),
                                                                     ""
                                                                     );
            totalImagesUpdated = 0;

            ImportImagesFromDirectoryStructure(threadConn, sourceDirectory);
            if (cancelImporting)
            {
                runLog.Writeln("\n" + "Importing Images has been Canceled." + "\n\n");
            }
            else
            {
                runLog.Writeln("\n\n" + "Total Images[" + totalImagesUpdated.ToString("###,##0") + "\n\n");
            }

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

            PicesDataBase.ThreadEnd();

            importingRunning   = false;
            importingCompleted = true;
        } /* ImportImagesIntoDeploymentProcess */
        } /* SizeDistributionForAClass */

        /// <summary>
        /// This method will be ran as a separate thread; it is responsible for collecting all the data needed to generate the plot.
        /// </summary>
        private void  BuildPlotData()
        {
            if (buildPlotDataRunning)
            {
                return;
            }

            PicesDataBase.ThreadInit();

            threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);

            buildPlotDataRunning = true;

            classToPlot = PicesClassList.GetUniqueClass(ClassToPlot.Text, "");

            sbyte ch = (sbyte)statistic;

            downCast = null;
            upCast   = null;

            goalie.StartBlock();

            SizeDistributionForAClass(classToPlot,
                                      IncludeSubClasses.Checked,
                                      ref downCast,
                                      ref upCast
                                      );

            if (cast == "Down")
            {
                bucketsDisplayed = downCast;
            }

            else if (cast == "Up")
            {
                bucketsDisplayed = upCast;
            }

            else
            {
                bucketsDisplayed = new PicesImageSizeDistribution(downCast);
                bucketsDisplayed.AddIn(upCast, runLog);
            }

            integratedDensityDistribution = bucketsDisplayed.IntegratedDensityDistribution();

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

            goalie.EndBlock();

            if (cancelRequested)
            {
                statusMsgs.AddMsg("Plotting of data CANCELLED!!!");
            }
            else
            {
                statusMsgs.AddMsg("Building of plot data completed !!!");
            }

            buildPlotDataRunning = false;
            buildPlotDataDone    = true;
        } /* BuildPlotData */
        } /* WriteTabDelToStream */

        private void ChartSizeDepthDistribution_FormClosing(object sender, FormClosingEventArgs e)
        {
            mainWinConn.Close();
            mainWinConn = null;
            GC.Collect();
        }
        } /* 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 */
Exemple #28
0
        } /* StartTheBackGroundProcedure */

        private void  BackGroundProcess()
        {
            backGroundRunning = true;

            PicesDataBase.ThreadInit();


            OSservices.CreateDirectoryPath(reportFileDir);

            DateTime n           = DateTime.Now;
            String   logFileName = OSservices.AddSlash(PicesSipperVariables.TempDirectory()) + "InstrumentDataByDeployment_Log_" +
                                   n.Year.ToString("0000") + "-" + n.Month.ToString("00") + "-" + n.Day.ToString("00") + "_" +
                                   n.Hour.ToString("00") + "-" + n.Minute.ToString("00") + "-" + n.Hour.ToString("00") +
                                   ".txt";

            backGroundLog = new PicesRunLog(logFileName);
            PicesDataBase threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(backGroundLog);

            RunLogAddMsg("Cruise           [" + cruiseName + "]" + "\n");
            RunLogAddMsg("Station          [" + stationName + "]" + "\n");
            RunLogAddMsg("Deployment       [" + deploymentNum + "]" + "\n");
            RunLogAddMsg("Start Date/Time  [" + DateTime.Now.ToString("yyyy-MMM-dd HH:mm:ss") + "]" + "\n");
            RunLogAddMsg("Active DataBase  [" + threadConn.Server.Description + "]" + "\n");

            PicesSipperDeploymentList deployments = null;

            if (!String.IsNullOrEmpty(deploymentNum))
            {
                PicesSipperDeployment d = threadConn.SipperDeploymentLoad(cruiseName, stationName, deploymentNum);
                if (d != null)
                {
                    deployments = new PicesSipperDeploymentList();
                    deployments.Add(d);
                }
            }
            else
            {
                deployments = threadConn.SipperDeploymentLoad(cruiseName, stationName);
            }

            if (deployments == null)
            {
                RunLogAddMsg("\n\nNo Deployments for Specified Criteria!\n\n");
                return;
            }

            int reportNum = 0;

            foreach (PicesSipperDeployment d in deployments)
            {
                if (cancelBackGround)
                {
                    break;
                }

                reportNum++;

                RunLogAddMsg("Generating Report " + reportNum.ToString() + " of " + deployments.Count.ToString());

                SummarizeInstrumentDataForADeployment(threadConn, d.CruiseName, d.StationName, d.DeploymentNum);
            }

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

            PicesDataBase.ThreadEnd();

            backGroundRunning = false;
        } /* BackGroundProcess */