Exemple #1
0
        /**
         * Hendelse for å printe tekst
         */
        private void btnPrint_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();

            pd.PrinterSettings = new PrinterSettings();
            MultipadPrintDocument printDoc = new MultipadPrintDocument();

            printDoc.PrinterSettings = pd.PrinterSettings;
            printDoc.Font            = new Font("Courier New", 9, FontStyle.Regular);
            printDoc.Text            = tbContent.Text;
            printDoc.Print();

            //string cout;
            //Utils.RunCommand("DATAPLOT", cnfFile + " /SCALE=" + SysPar.ReportScaleY + " /XSCALE=" + SysPar.ReportScaleX + " /ENHPLOT", out cout, false);
        }
Exemple #2
0
        /**
         * Hendelse for arkivering av jobb
         */
        private void btnStore_Click(object sender, EventArgs e)
        {
            if (hasError)
            {
                DialogResult dialogresult = MessageBox.Show("NB! Denne analysen ble fullført med feilmelding fra Genie-2000!" + Environment.NewLine + "Vil du lagre allikevel?", "Advarsel", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dialogresult != DialogResult.Yes)
                {
                    return;
                }
            }

            string rptFile = BaseName + ".RPT";
            string cnfFile = BaseName + ".CNF";
            string parFile = BaseName + ".PAR";
            string outFile = BaseName + ".OUT";
            string batFile = BaseName + ".BAT";

            if (File.Exists(rptFile) && File.Exists(cnfFile) && File.Exists(parFile))
            {
                if (IsReanal)
                {
                    string year = "20" + jp.SpecRef.Substring(2, 2);

                    string newRpt = Config.ArchiveDir + jp.DetectorName + Path.DirectorySeparatorChar + year + Path.DirectorySeparatorChar + jp.SpecRef + "-" + jp.SampleID + "-" + jp.Operation + "-" + jp.CollectorName + ".RPT";
                    string newPar = Config.ArchiveDir + jp.DetectorName + Path.DirectorySeparatorChar + year + Path.DirectorySeparatorChar + jp.SpecRef + "-" + jp.SampleID + "-" + jp.Operation + "-" + jp.CollectorName + ".PAR";
                    string newCnf = Config.ArchiveDir + jp.DetectorName + Path.DirectorySeparatorChar + year + Path.DirectorySeparatorChar + jp.SpecRef + "-" + jp.SampleID + "-" + jp.Operation + "-" + jp.CollectorName + ".CNF";

                    string oldRpt = ArchiveName + ".RPT";
                    string oldPar = ArchiveName + ".PAR";
                    string oldCnf = ArchiveName + ".CNF";

                    File.Copy(rptFile, newRpt, true);
                    File.Copy(cnfFile, newCnf, true);
                    File.Copy(parFile, newPar, true);

                    if (newRpt != oldRpt)
                    {
                        File.Delete(oldRpt);
                    }
                    if (newPar != oldPar)
                    {
                        File.Delete(oldPar);
                    }
                    if (newCnf != oldCnf)
                    {
                        File.Delete(oldCnf);
                    }

                    if (cbExportLIMS.Checked)
                    {
                        File.Copy(rptFile, SysPar.LimsImport + jp.SampleID + ".NAI.RES", true);
                    }

                    File.Delete(batFile);
                    File.Delete(outFile);
                    lblStatus.Text = "Reanalyse av spekter " + jp.SpecRef + " ble lagret";

                    if (cbPrint.Checked)
                    {
                        PrintDialog pd = new PrintDialog();
                        pd.PrinterSettings = new PrinterSettings();
                        MultipadPrintDocument printDoc = new MultipadPrintDocument();
                        printDoc.PrinterSettings = pd.PrinterSettings;
                        printDoc.Font            = new Font("Courier New", 9, FontStyle.Regular);
                        printDoc.Text            = File.ReadAllText(rptFile, Encoding.GetEncoding(1252));
                        printDoc.Print();

                        string cout;
                        Utils.RunCommand("DATAPLOT", cnfFile + " /SCALE=" + SysPar.ReportScaleY + " /XSCALE=" + SysPar.ReportScaleX + " /ENHPLOT", out cout, true);
                    }

                    File.Delete(rptFile);
                    File.Delete(cnfFile);
                    File.Delete(parFile);

                    // Logg aktivitet
                    Config.LogMessage("Reanalysering av spekref " + jp.SpecRef);
                }
                else
                {
                    string year        = "20" + jp.SpecRef.Substring(2, 2);
                    string archiveDir  = Config.ArchiveDir + Detector.Name + Path.DirectorySeparatorChar + year + Path.DirectorySeparatorChar;
                    string baseName    = jp.SpecRef + "-" + jp.SampleID + "-" + jp.Operation + "-" + jp.CollectorName;
                    string cnfFileDest = archiveDir + baseName + ".CNF";
                    string rptFileDest = archiveDir + baseName + ".RPT";

                    if (!Directory.Exists(Config.ArchiveDir + Detector.Name))
                    {
                        Directory.CreateDirectory(Config.ArchiveDir + Detector.Name);
                    }
                    if (!Directory.Exists(Config.ArchiveDir + Detector.Name + Path.DirectorySeparatorChar + year))
                    {
                        Directory.CreateDirectory(Config.ArchiveDir + Detector.Name + Path.DirectorySeparatorChar + year);
                    }

                    Detector.SpectrumCounter++;
                    UpdateDetectors = true;

                    if (Directory.GetFiles(Config.ArchiveDir + Detector.Name + Path.DirectorySeparatorChar + year, Detector.Name + "*.CNF").Length == 0)
                    {
                        Detector.SpectrumCounter = 0;
                    }

                    if (cbExportLIMS.Checked)
                    {
                        File.Copy(rptFile, SysPar.LimsImport + jp.SampleID + ".NAI.RES", true);
                    }

                    File.Move(rptFile, rptFileDest);
                    File.Move(cnfFile, cnfFileDest);
                    File.Move(parFile, archiveDir + baseName + ".PAR");

                    File.Delete(batFile);
                    File.Delete(outFile);

                    lblStatus.Text = "Jobb for detektor " + Detector.Name + " ble arkivert som " + baseName;

                    if (cbPrint.Checked)
                    {
                        PrintDialog pd = new PrintDialog();
                        pd.PrinterSettings = new PrinterSettings();
                        MultipadPrintDocument printDoc = new MultipadPrintDocument();

                        printDoc.PrinterSettings = pd.PrinterSettings;
                        printDoc.Font            = new Font("Courier New", 9, FontStyle.Regular);
                        printDoc.Text            = File.ReadAllText(rptFileDest, Encoding.GetEncoding(1252));
                        printDoc.Print();

                        string cout;
                        Utils.RunCommand("DATAPLOT", cnfFileDest + " /SCALE=" + SysPar.ReportScaleY + " /XSCALE=" + SysPar.ReportScaleX + " /ENHPLOT", out cout, true);
                    }

                    // Logg aktivitet
                    Config.LogMessage("Analysering av spekref " + jp.SpecRef);
                }
            }
            else
            {
                MessageBox.Show("En eller flere filer ble ikke funnet");
            }

            Close();
        }