예제 #1
0
        private void BackupAllDataClick(object sender, RoutedEventArgs e)
        {
            string dest = UIIntegration.GetUsersFolder("Select Destination", "Select a path to backup data.");

            if (dest != String.Empty)
            {
                string source = System.IO.Path.GetDirectoryName(NC.App.Pest.GetDBFileFromConxString());
                string destFileName;
                destFileName = String.Format("\\INCC-{0}", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
                FileStream    fs = File.Create(dest + destFileName + ".gz");
                GZipStream    compressionStream = new GZipStream(fs, CompressionMode.Compress);
                DirectoryInfo selectedDir       = new DirectoryInfo(source);
                foreach (FileInfo fileToCompress in selectedDir.GetFiles())
                {
                    using (FileStream originalFileStream = new FileStream(fileToCompress.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        if ((File.GetAttributes(fileToCompress.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden & fileToCompress.Extension != ".gz")
                        {
                            originalFileStream.CopyTo(compressionStream);
                        }
                    }
                }
                fs.Close();
            }
            else
            {
                MessageBox.Show("The destination folder could not be created", "ERROR");
            }
        }
예제 #2
0
        public static DialogResult GetUsersFilesFolder(string title, string dir, string name, string ext, string ext2 = "")
        {
            FoldorFile.FileOrFolderChoice choice = ChooseFiles();
            if (choice == FoldorFile.FileOrFolderChoice.Cancel)
            {
                return(DialogResult.Cancel);
            }

            if (choice == FoldorFile.FileOrFolderChoice.Folder)
            {
                string xs = UIIntegration.GetUsersFolder("Select folder", dir);
                if (!String.IsNullOrEmpty(xs))
                {
                    NC.App.AppContext.FileInput     = xs;
                    NC.App.AppContext.FileInputList = null;  // no explicit file list
                    return(DialogResult.OK);
                }
                else
                {
                    return(DialogResult.Cancel);
                }
            }
            // choice == files
            System.Windows.Forms.OpenFileDialog RestoreFileDialog = new System.Windows.Forms.OpenFileDialog();
            List <string> paths = new List <string>();

            RestoreFileDialog.CheckFileExists = false;
            RestoreFileDialog.DefaultExt      = "ext";
            RestoreFileDialog.Filter          = name + " files (." + ext + ")|*." + ext;
            if (!String.IsNullOrEmpty(ext2))
            {
                RestoreFileDialog.Filter += "| (." + ext2 + ")|*." + ext2;
            }
            RestoreFileDialog.Filter          += "|All files (*.*)|*.*";
            RestoreFileDialog.InitialDirectory = NC.App.AppContext.FileInput;
            RestoreFileDialog.Title            = title;
            RestoreFileDialog.Multiselect      = true;
            RestoreFileDialog.RestoreDirectory = true;
            DialogResult r = DialogResult.No;

            r = RestoreFileDialog.ShowDialog();
            if (r == DialogResult.OK)
            {
                foreach (string s in RestoreFileDialog.FileNames)
                {
                    paths.Add(s);
                }
                FileSel fs = new FileSel(paths);
                r = fs.ShowDialog();
                if (r == DialogResult.OK)
                {
                    NC.App.AppContext.FileInputList = paths;
                    NC.App.AppContext.FileInput     = null; // no explicit folder System.IO.Path.GetDirectoryName(paths[0]);
                }
            }
            return(r);
        }
예제 #3
0
        private void TransferFileOutClick(object sender, RoutedEventArgs e)
        {
            String s = UIIntegration.GetUsersFolder("Select Transfer File Folder for Output", NC.App.AppContext.FileInput);

            if (!String.IsNullOrEmpty(s))
            {
                UIIntegration.Controller.file = true;
                // JFL todo: we do not have a way to export transfer files in this code, so this is a placeholder
            }
        }
예제 #4
0
        private void TransferFileInClick(object sender, RoutedEventArgs e)
        {
            String s = UIIntegration.GetUsersFolder("Select Input Transfer File Folder", NC.App.AppContext.FileInput);

            if (!String.IsNullOrEmpty(s))
            {
                NC.App.AppContext.FileInput     = s;
                NC.App.AppContext.FileInputList = null;                                            // no explicit file list
                UIIntegration.Controller.file   = true;
                UIIntegration.Controller.SetFileTransform();                                       // it is a file action
                NC.App.AppContext.MutuallyExclusiveFileActions(NCCConfig.NCCFlags.INCCXfer, true); //enable only xfer file processing
                UIIntegration.Controller.Perform();                                                // run the current specified operation
            }
        }
예제 #5
0
        private void incc5IniLoc_Click(object sender, EventArgs e)
        {
            string str = UIIntegration.GetUsersFolder("Data file folder location", (string)maybe[(NCCFlags)((Control)sender).Tag]);

            if (!string.IsNullOrEmpty(str))
            {
                maybe[(NCCFlags)((Control)sender).Tag] = str;
                DataFileLoc.Text = str;
                if (!string.IsNullOrEmpty(str))
                {
                    incc5IniLoc.Text = System.IO.Path.GetFullPath(str);
                }
            }
        }
예제 #6
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            NCCReporter.LMLoggers.LognLM applog = NC.App.Logger(NCCReporter.LMLoggers.AppSection.App);
            string dest = UIIntegration.GetUsersFolder("Select Destination", string.Empty);

            if (string.IsNullOrEmpty(dest))
            {
                return;
            }
            if (DetectorCurrentRadioButton.Checked)
            {
                List <Detector> l = new List <Detector>();
                l.Add(Integ.GetCurrentAcquireDetector());
                INCCInitialDataDetectorFile iddf = INCCKnew.FromDetectors(l);
                iddf.Save(dest);
            }
            else if (DetectorAllRadioButton.Checked)
            {
                List <Detector>             l    = NC.App.DB.Detectors;
                INCCInitialDataDetectorFile iddf = INCCKnew.FromDetectors(l);
                iddf.Save(dest);
            }
            else if (CalibrationCurrentRadioButton.Checked)
            {
                List <Detector> l = new List <Detector>();
                l.Add(Integ.GetCurrentAcquireDetector());
                List <INCCInitialDataCalibrationFile> lidcf = INCCKnew.CalibFromDetectors(l);
                if (lidcf.Count > 0)
                {
                    if (!lidcf[0].Save(dest))
                    {
                        applog.TraceEvent(NCCReporter.LogLevels.Warning, 33154, "No calibration parameters for " + lidcf[0].Name);
                    }
                }
            }
            else if (CalibrationAllRadioButton.Checked)
            {
                List <Detector> l = NC.App.DB.Detectors;
                List <INCCInitialDataCalibrationFile> lidcf = INCCKnew.CalibFromDetectors(l);
                foreach (INCCInitialDataCalibrationFile idcf in lidcf)
                {
                    if (!idcf.Save(dest))
                    {
                        applog.TraceEvent(NCCReporter.LogLevels.Warning, 33154, "No calibration parameters for " + idcf.Name);
                    }
                }
            }
            Close();
        }
예제 #7
0
        // possible to append daily path to the daily path, so do not do that.
        private void root_Click(object sender, EventArgs e)
        {
            string str = UIIntegration.GetUsersFolder("Working folder (the current directory) location", (string)maybe[(NCCFlags)((Control)sender).Tag]);

            //Adding date to this path is sticking.  Need to just display the root location. hn 10-2
            //Checking for extra date presence to skip it, to keep the daily path override of the overall root path in play, to fix  hn 10-2 bug,

            if (!String.IsNullOrEmpty(str))
            {
                maybe[(NCCFlags)((Control)sender).Tag] = str;
                if ((bool)maybe[NCCFlags.dailyRootPath])
                {
                    string part = DateTime.Now.ToString("yyyy-MMdd");
                    if (!str.EndsWith(part))  // it's not the current day
                    {
                        Match m = Regex.Match(str, "\\d{4}-\\d{4}$");
                        if (m.Success)  // it is a pattern match
                        {
                            // so strip and replace with current date
                            string s = str.Remove(m.Index);
                            s = System.IO.Path.Combine(s, part);
                            WorkingDirTextBox.Text = s;
                        }
                        else
                        {
                            WorkingDirTextBox.Text = System.IO.Path.Combine(str, part);
                        }
                    }
                    else
                    {
                        WorkingDirTextBox.Text = System.IO.Path.GetFullPath(str);
                    }
                }
                else
                {
                    WorkingDirTextBox.Text = System.IO.Path.GetFullPath(str);
                }
            }
        }
예제 #8
0
        private void BackupAllDataClick(object sender, RoutedEventArgs e)
        {
            string dest = UIIntegration.GetUsersFolder("Select Destination", string.Empty);

            if (!string.IsNullOrEmpty(dest))
            {
                //Path to sql or sqlite files
                string destFileName;
                destFileName = string.Format("INCC-{0}.zip", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
                using (FileStream zipToOpen = new FileStream(Path.Combine(dest, destFileName), FileMode.OpenOrCreate))
                {
                    using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update))
                    {
                        // Cannot archive connected DB or cfg, copy, archive, then delete.
                        // TODO: is this all that we want to save? HN 7/27/2016
                        string DBFolder   = Path.GetDirectoryName(NC.App.Pest.GetDBFileFromConxString());
                        string DBFile     = Path.GetFullPath(NC.App.Pest.GetDBFileFromConxString());
                        string DBFileName = Path.GetFileName(NC.App.Pest.GetDBFileFromConxString());
                        string CfgPath    = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

                        File.Copy(Path.Combine(DBFolder, DBFile), Path.Combine(dest, DBFileName), true);
                        File.Copy(CfgPath, Path.Combine(dest, Path.GetFileName(CfgPath)), true);

                        ZipArchiveEntry dbFile  = archive.CreateEntryFromFile(Path.Combine(dest, DBFileName), DBFileName);
                        ZipArchiveEntry cfgFile = archive.CreateEntryFromFile(Path.Combine(dest, Path.GetFileName(CfgPath)), Path.GetFileName(CfgPath));
                        NC.App.Loggers.AppLogger.TraceEvent(LogLevels.Info, 1111, String.Format("Zip file containing database and config created: {0}", Path.Combine(dest, destFileName)));
                        File.Delete(Path.Combine(dest, DBFileName));
                        File.Delete(Path.Combine(dest, Path.GetFileName(CfgPath)));
                    }
                }
            }
            else
            {
                MessageBox.Show("The destination folder could not be created", "ERROR");
            }
        }
예제 #9
0
 private void OKBtn_Click(object sender, EventArgs e)
 {
     if (CurrentDetectorRadioButton.Checked)
     {
         IDDSaveCampaignId f = new IDDSaveCampaignId();
         DialogResult      r = f.ShowDialog();
         if (r == DialogResult.OK)
         {
             string dest = UIIntegration.GetUsersFolder("Select Directory for Saving Measurement Data", string.Empty);
             if (string.IsNullOrEmpty(dest))
             {
                 return;
             }
             IDDMeasurementList measlist = new IDDMeasurementList();
             measlist.Init(f.FilteredList,
                           AssaySelector.MeasurementOption.unspecified,
                           lmonly: false, goal: IDDMeasurementList.EndGoal.Transfer, inspnum: f.inspnum, detector: f.det);
             DialogResult dr = DialogResult.None;
             if (measlist.bGood)
             {
                 measlist.ShowDialog();
             }
             dr = measlist.DialogResult;
             if (dr != DialogResult.OK)
             {
                 return;
             }
             List <Measurement> mlist = measlist.GetSelectedMeas();
             foreach (Measurement m in mlist)
             {
                 CycleList cl = NC.App.DB.GetCycles(f.det, m.MeasurementId, m.AcquireState.data_src);                         // APluralityOfMultiplicityAnalyzers: // URGENT: get all the cycles associated with each analyzer, restoring into the correct key->result pair
                 m.Cycles.AddRange(cl);
                 // NEXT: m.CFCyles for AAS not used for INCC6 created measurements, only INCC5 transfer measurements have them m.Add(c, i);
                 m.INCCAnalysisResults.TradResultsRec = NC.App.DB.ResultsRecFor(m.MeasurementId);
                 m.ReportRecalc();                         // dev note: not strictly from INCC5, but based on usage complaint from LANL
             }
             List <INCCTransferFile> itdl = INCCKnew.XFerFromMeasurements(mlist);
             foreach (INCCTransferFile itd in itdl)
             {
                 itd.Save(dest);
             }
         }
     }
     else if (AllDetectorsRadioButton.Checked)
     {
         string dest = UIIntegration.GetUsersFolder("Select Directory for Saving Measurement Data", string.Empty);
         if (string.IsNullOrEmpty(dest))
         {
             return;
         }
         List <Detector> l = NC.App.DB.Detectors;
         foreach (Detector det in l)
         {
             List <Measurement> mlist = NC.App.DB.MeasurementsFor(det.Id.DetectorId);
             foreach (Measurement m in mlist)
             {
                 CycleList cl = NC.App.DB.GetCycles(det, m.MeasurementId, m.AcquireState.data_src);                         // APluralityOfMultiplicityAnalyzers: // URGENT: get all the cycles associated with each analyzer, restoring into the correct key->result pair
                 m.Add(cl);
                 if (m.MeasOption == AssaySelector.MeasurementOption.rates)
                 {
                     return;
                 }
                 else
                 {
                     m.INCCAnalysisResults.TradResultsRec = NC.App.DB.ResultsRecFor(m.MeasurementId);
                 }
             }
             List <INCCTransferFile> itdl = INCCKnew.XFerFromMeasurements(mlist);
             foreach (INCCTransferFile itd in itdl)
             {
                 itd.Save(dest);
             }
         }
     }
 }
예제 #10
0
        ///////////////////
        //  MOUSER MENU  //
        ///////////////////

        private void AnalysisWizardClick(object sender, RoutedEventArgs e)
        {
            AcquireParameters acq = null;
            Detector          det = null;

            Integ.GetCurrentAcquireDetectorPair(ref acq, ref det);
            if (!det.ListMode)
            {
                MessageBox.Show("'" + det.ToString() + "' is not a List Mode detector,\r\ncreate or select a List Mode detector\r\n with Setup > Facility/Inspection...", "List Mode Acquire");
                return;
            }
            NewUI.AnalysisWizard f = new NewUI.AnalysisWizard(NewUI.AnalysisWizard.AWSteps.Step1, acq, det);
            System.Windows.Forms.DialogResult dr = f.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                if (acq.modified || acq.lm.modified)
                {
                    INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, acq.item_type, DateTime.Now);
                    acq.MeasDateTime = sel.TimeStamp; acq.lm.TimeStamp = sel.TimeStamp;
                    NC.App.DB.AcquireParametersMap().Add(sel, acq);  // it's a new one, not the existing one modified
                    NC.App.DB.UpdateAcquireParams(acq, det.ListMode);
                }

                switch (NC.App.Opstate.Measurement.AcquireState.data_src)  // global access to latest acq here, same as acq set in wizard
                {
                case ConstructedSource.Live:
                    UIIntegration.Controller.file = false;   // make sure to use the DAQ controller, not the file controller
                    NC.App.AppContext.FileInput   = null;    // reset the cmd line file input flag
                    if (NC.App.Opstate.Measurement.Detectors[0].ListMode)
                    {
                        //  NC.App.DB.UpdateAcquireParams(ap, det.ListMode); //update it again
                        //   NC.App.DB.UpdateDetector(det);
                        // if ok, the analyzers are set up, so can kick it off now.
                        if (NC.App.Opstate.Measurement.Detectors[0].Id.SRType == InstrType.PTR32)
                        {
                            Ptr32Instrument instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detectors[0]);
                            instrument.DAQState = DAQInstrState.Offline;
                            instrument.selected = true;
                            instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));

                            if (!Instruments.Active.Contains(instrument))
                            {
                                Instruments.Active.Add(instrument);
                            }
                        }
                        else
                        {
                            LMInstrument lm = new LMInstrument(NC.App.Opstate.Measurement.Detectors[0]);
                            lm.DAQState = DAQInstrState.Offline; // these are manually initiated as opposed to auto-pickup
                            lm.selected = false;                 //must broadcast first to get it selected
                            if (!Instruments.All.Contains(lm))
                            {
                                Instruments.All.Add(lm);     // add to global runtime list
                            }
                        }
                    }
                    else
                    {
                        SRInstrument sri = new SRInstrument(NC.App.Opstate.Measurement.Detectors[0]);
                        sri.selected = true;
                        sri.Init(NC.App.Loggers.Logger(LMLoggers.AppSection.Data), NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis));
                        if (!Instruments.All.Contains(sri))
                        {
                            Instruments.All.Add(sri);     // add to global runtime list
                        }
                    }
                    break;

                case ConstructedSource.DB:
                    UIIntegration.Controller.file = true;
                    return;

                //break;
                case ConstructedSource.Manual:
                    UIIntegration.Controller.file = true;
                    return;

                //break;
                case ConstructedSource.CycleFile:
                case ConstructedSource.ReviewFile:
                    UIIntegration.Controller.file = true;
                    string xs = UIIntegration.GetUsersFolder("Select Input Folder", NC.App.AppContext.FileInput);
                    if (!String.IsNullOrEmpty(xs))
                    {
                        NC.App.AppContext.FileInput     = xs;
                        NC.App.AppContext.FileInputList = null;      // no explicit file list
                    }
                    SRInstrument sri2 = new SRInstrument(NC.App.Opstate.Measurement.Detectors[0]);
                    sri2.selected = true;
                    sri2.Init(NC.App.Loggers.Logger(LMLoggers.AppSection.Data), NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis));
                    if (!Instruments.All.Contains(sri2))
                    {
                        Instruments.All.Add(sri2);     // add to global runtime list
                    }
                    break;

                case ConstructedSource.NCDFile:
                    NC.App.AppContext.NCDFileAssay = true;     // suntoucher, this is right here how we're flowing now
                    UIIntegration.Controller.file  = true;
                    break;

                case ConstructedSource.SortedPulseTextFile:
                    NC.App.AppContext.PulseFileAssay = true;
                    UIIntegration.Controller.file    = true;
                    break;

                case ConstructedSource.PTRFile:
                    NC.App.AppContext.PTRFileAssay = true;
                    UIIntegration.Controller.file  = true;
                    break;

                default:
                    break;
                }
                NC.App.Opstate.Measurement.Detectors[0].Id.source = NC.App.Opstate.Measurement.AcquireState.data_src; // set the detector overall data source value here
                UIIntegration.Controller.SetAssay();                                                                  // tell the controller to do an assay operation using the current measurement state
                UIIntegration.Controller.Perform();                                                                   // start the measurement file or DAQ thread
            }
        }