Пример #1
0
        private static int FindThis( Sample FindThis, ArrayList VarDesc)
        {
            bool WasFoundinDB = false;
            foreach (DATATBL_Vars Varible in VarDesc) {
                ModeLabel.Text = "Comparing Samples to DB Varibles.";
                Varible.NAME = Varible.NAME.Trim();
                foreach (Analyte Metal in FindThis.Metals) {
                    Metal.SampleNameForUpload = Metal.SampleNameForUpload.Trim();
                    if ((Varible.NAME) == (Metal.SampleNameForUpload)) {
                        Metal.WasFoundinDB = true;
                        Metal.FoundVarID = Varible.VARID;
                        WasFoundinDB = true;
                        if (WasFoundinDB) {
                            BuildUpLoadString(FindThis);
                        }
                    }
                }

            }
            if (WasFoundinDB) return 1;
            else return 0;
        }
Пример #2
0
 private static string LC_SampleDateTimeLookup( Sample Item)
 {
     ModeLabel.Text = "Looking up LabCal sample times.";
     Database myDB = new Database();
     SimplerAES myAES = new SimplerAES();
     string BaseCommand = "+CFENk6LKiNLKVKt+NZnQO1d4fqE6vLg1eHJuaCfBFjYxBPPH8K2Y4x6hwMOrzzN78bgkB0bfqdojXMvuzYoZA==";
     Item.SampleNameBackup = Item.SampleNameBackup.TrimStart("\"".ToArray());
     Item.SampleNameBackup = Item.SampleNameBackup.TrimEnd("\"".ToArray());
     myDB.CurrentCommand.SetCommand("GetLC_SampleDateTime");
     ArrayList Retrieved = myDB.RetrieveData(myAES.Decrypt(BaseCommand) + quoet + Item.SampleNameBackup + quoet, ref RTB, ref ErrorLog);
     if (Retrieved.Count != 0){
         DateTime Referance = (DateTime)Retrieved[0];
         Item.DateTimeInSQL = BuildDateTimeStamps(Referance.ToString());
         return Referance.ToString();
     }
     else return "";
 }
Пример #3
0
 private static void BuildUpLoadString( Sample Item)
 {
     Item.AuditTimeinSQL = Item.AuditTimeinSQL.TrimStart("\0".ToArray());
     Item.DateTimeInSQL = Item.DateTimeInSQL.TrimStart("\0".ToArray());
     ModeLabel.Text = "Building upload strings.";
     SimplerAES myAES = new SimplerAES();
     foreach (Analyte Metal in Item.Metals) {
         if (Metal.WasFoundinDB==false || Item.AuditTimeinSQL.Length == 0 || Item.DateTimeInSQL.Length == 0) {
             Metal.Ready2Upload = false;
         }
         else if(Metal.WasFoundinDB) {
             string Builder = "";
             Builder += myAES.Decrypt("I/ydFjDhNoT3OB8O9/qRFnNxo+9lwU5jsDsbF798e3nsB9sE9PmRDbnTeMLhFPobva+jFzLQf5YXoI/FAtiINMvk33WR175KYnWeJ9bg6bfj3/T9q8yY5vRL7QYOhbWkQ7EJzEyffaOosACmFycCBwNJ+bRLxVSL9fDFq1dU35Y=");
             Builder += Item.AuditTimeinSQL + "," + Item.DateTimeInSQL + "," +
                        Metal.ConcMean + ",'" + Metal.ConcMean + "'," + Metal.FoundVarID + ",0,0)";
             Metal.Ready2Upload = true;
             Builder = Builder.Trim();
             Metal.SQLUPLOADSTR = Builder;
         }
     }
 }
Пример #4
0
 private static string BuildDateTimeStamps( Sample Sample)
 {
     ModeLabel.Text = "Fixing QC Set timestamps.";
     DateTime SampleTime;
     string FullDate;
     try {
         SampleTime = DateTime.Parse(Sample.DateTimeInSQL);
         FullDate = quoet + SampleTime.Month.ToString() + dash + SampleTime.Day.ToString() + dash + SampleTime.Year.ToString() + spacezeros;
     }
     catch (Exception ex) {
         FullDate = "";
         ErrorLog += ex.Message.ToString() + "\r\n";
     }
     return FullDate;
 }
Пример #5
0
 private bool AddSmpXToList( ArrayList Samples)
 {
     int Count = 0;
     int SmpCounter = 0;
     ArrayList Nums = new ArrayList();
     ArrayList SmpsToAdd = new ArrayList();
     ModeLabel.Text = "Inserting SMP's into upload list.";
     this.Refresh();
     foreach (Sample Sample in Samples) {
         if (Sample.QCType == Sample.QCTYPES.Dup) {
             SmpCounter++; //= Sample.QCSet;
             int MetalCounter = 0;
             string SmpName = "QC " + ((Analyte)Sample.Metals[MetalCounter]).AtomName + " Smp " + (Sample.QCsetRv[SmpCounter]);
             Sample SmpX = new Sample(SmpName,
                             ((Sample)Samples[Count - 1]).SampleDateTimeFromFile,
                             ((Sample)Samples[Count - 1]).TimeRun,
                             ((Sample)Samples[Count - 1]).DateRun,
                             ((Sample)Samples[Count - 1]).DateTimeInSQL,
                             ((Sample)Samples[Count - 1]).AuditTimeinSQL);
             Nums.Add(Count);
             SmpX.SampleNameBackup = SmpName;
             SmpX.DayOfSample = Sample.DayOfSample;
             SmpX.MonthOfSample = Sample.MonthOfSample;
             SmpX.IsQc = true;
             SmpX.is_CCB_QCI = false;
             SmpX.IsQCSTD2 = false;
             SmpX.QCType = Sample.QCTYPES.Smp;
             foreach (Analyte Metal in Sample.Metals) {
                 string MetalSmpName = "QC " + ((Analyte)Sample.Metals[MetalCounter]).AtomName + " Smp " + (Sample.QCsetRv[SmpCounter]);
                 Analyte MetaltoAdd = new Analyte(MetalSmpName,
                                        Metal.AtomName,
                                        Metal.MeasIntensityMean,
                                        Metal.NetIntensityMean,
                                        Metal.ConcRSD,
                                        Metal.ConcMean,
                                        Metal.ReportUnits,
                                        Metal.YpercRec,
                                        Metal.QCStdPercRec,
                                        Metal.SpkPercRec,
                                        Metal.IntStdSymb,
                                        Metal.IntStdRec);
                 MetaltoAdd.FoundVarID = FindVardesc(MetalSmpName);
                 MetaltoAdd.SampleNameForUpload = MetalSmpName;
                 SmpX.Metals.Add(MetaltoAdd);
                 Metal.DO_NOT_UPLOAD = false;
                 Metal.WasFoundinDB = true;
                 Metal.Ready2Upload = true;
                 MetalCounter++;
             }
             SmpsToAdd.Add(SmpX);
         }
         Count++;
     }
     int Counter = 0;
     if (Nums.Count != 0) {
         foreach (int Index in Nums) {
             Sample Ref = (Sample)SmpsToAdd[Counter];
             Samples.Insert(Index + Counter, Ref );
             Counter++;
         }
     }
     if (Counter > 0) return true;
     else return false;
 }
Пример #6
0
        private bool AddQCSetToList( ArrayList Samples)
        {
            int Count = 0;
            int SmpCounter = 0;
            ArrayList Nums = new ArrayList();
            ArrayList SmpsToAdd = new ArrayList();
            ModeLabel.Text = "Inserting QCSet Linker into upload list.";
            this.Refresh();
            foreach (Sample Item in Samples) {
                if ((Item.IsQc == false) &&
                   ((Item.is_CCB_QCI == false)) &&
                   ((Item.SampleName != "Cal BLK")) &&
                   (!Item.SampleName.Contains("Repeated Run")) &&
                   (!Item.SampleName.Contains("Sample 0.1ppm")) &&
                   (!Item.SampleName.Contains("STD1 0.1ppm")) &&
                   (!Item.SampleName.Contains("STD2 5ppm")) &&
                   (!Item.SampleName.Contains("STD3 15ppm")) &&
                   (!Item.SampleName.Contains("QC-Std-Blk")) &&
                   (!Item.SampleName.Contains("QC-Std2")) &&
                   (!Item.SampleName.Contains("QC-Std-2")) &&
                   (!Item.SampleName.Contains("Method Blank")) &&
                    (Item.QCType != Sample.QCTYPES.QCI)) {
                    SmpCounter = (int)Item.QC_SET;
                    string SmpName = Item.SampleName + QCSetTypes[(int)Selection] + Sample.QCs[5];

                    Sample SmpX = new Sample(SmpName,
                                    ((Sample)Samples[Count]).SampleDateTimeFromFile,
                                    ((Sample)Samples[Count]).TimeRun,
                                    ((Sample)Samples[Count]).DateRun,
                                    ((Sample)Samples[Count]).DateTimeInSQL,
                                    ((Sample)Samples[Count]).AuditTimeinSQL);
                    Nums.Add(Count);
                    SmpX.SampleNameBackup = Item.SampleNameBackup;
                    SmpX.DateTimeInSQL = LC_SampleDateTimeLookup(((Sample)Samples[Count]));
                    SmpX.DateTimeInSQL = BuildDateTimeStamps(SmpX);
                    SmpX.DayOfSample = Item.DayOfSample;
                    SmpX.MonthOfSample = Item.MonthOfSample;
                    SmpX.IsQc = true;
                    SmpX.is_CCB_QCI = false;
                    SmpX.IsQCSTD2 = false;
                    SmpX.QCType = Sample.QCTYPES.QCSet;
                    SmpX.QC_SET = Item.QC_SET;
                    SmpX.WasFound = true;
                    SmpX.QCSetVARID = FindVardesc(SmpName);
                    SmpsToAdd.Add(SmpX);
                }
                Count++;
            }
            int Counter = 0;
            if (Nums.Count != 0) {
                foreach (int Index in Nums) {
                    Sample Ref = (Sample)SmpsToAdd[Counter];
                    Samples.Insert(Index + Counter, Ref);
                    Counter++;
                }
            }
            if (Counter > 0) return true;
            else return false;
        }
Пример #7
0
        private static bool ParseElanFile( string myFile, ArrayList FileData, ArrayList Samples)
        {
            Form1.FileData = ReadPerkinElmerFile(myFile);
            try { Samples.Clear(); }
            catch (Exception ex) { ErrorLog += ex.Message.ToString() + " : Prior null assignment to Samples \n"; Samples = new ArrayList(); }
            ModeLabel.Text = "Parsing now.";
            int LineNum = 0;
            int SampleCounter = 0;
            bool MetalsHit = false;
            if (FileData.Count > 0) {
                string[] SplitMe;
                while (LineNum < FileData.Count-1) {
                    Sample Group = new Sample();
                    MetalsHit = false;
                    do
                    {
                        SplitMe = FileData[LineNum].ToString().Split(",".ToArray());
                        SplitMe = RemoveSlashs(SplitMe);
                        if (SplitMe[0] == "Method 200.8-Summary Report") { goto nextline; }
                        if (SplitMe[0] == "Sample ID:") {
                            Group.SampleName = SplitMe[1];
                            Group.SampleNameBackup = SplitMe[1];
                        }
                        if (SplitMe[0] == "Sample Date/Time:") {
                            if(SplitMe.Count()>3) {
                                string FullDateTime = SplitMe[1] + SplitMe[2] + SplitMe[3];
                                DateTime Parsed = DateTime.Parse(FullDateTime);
                                Group.SampleDateTimeFromFile = Parsed.ToString();//SplitMe[1];
                                Group.TimeRun = Parsed.ToShortTimeString();
                            }
                        }
                        if (SplitMe[0] == "Sample Description:") {
                            if (SplitMe.Count() > 1) {
                                Group.SampleDescription = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Number of Replicates:") {
                            if (SplitMe.Count() > 1) {
                                Group.NumberReplicates = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Method File:") {
                            if (SplitMe.Count() > 1){
                                Group.MethodFile = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Dataset File:") {
                            if (SplitMe.Count() > 1) {
                                Group.DatasetFile = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Optimization File:") {
                            if (SplitMe.Count() > 1) {
                                Group.OptimusFile = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Tuning File:") {
                            if (SplitMe.Count() > 1) {
                                Group.TuneFile = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Sample Prep Volume (mL):") {
                            if (SplitMe.Count() > 1) {
                                Group.SamplePrepVolume = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Initial Sample Quantity (mg):") {
                            if (SplitMe.Count() > 1) {
                                Group.InitalSampleQuanity = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Aliquot Volume (mL):") {
                            if (SplitMe.Count() > 1) {
                                Group.AliquotVolume = SplitMe[1];
                            }
                        }
                        if (SplitMe[0] == "Diluted to Volume (mL):") {
                            if (SplitMe.Count() > 1) {
                                Group.DilutedtoVolume = SplitMe[1];
                            }
                        }

                        if (SplitMe[0] == "Concentration Results") {
                            LineNum++;
                            int NumAnalytes = 0;
                            SplitMe = FileData[LineNum].ToString().Split(",".ToArray());
                            SplitMe = RemoveSlashs(SplitMe);
                            Establish_AnalyteFields(SplitMe);
                            if ((SplitMe[0] == "Analyte") && (SplitMe[1] == "Mass") && (SplitMe[ReturnAnalyteEnumeration(AnalyteFields.MeasIntensMean)] == "Meas. Intens. Mean")) {
                                while ((SplitMe[0] != "Method 200.8-Summary Report") && (SplitMe[2] != "QC Calculated Values") && (LineNum < FileData.Count - 1)) {
                                    Analyte NewAnalyte = new Analyte();
                                    MetalsHit = true;
                                    LineNum++;
                                    SplitMe = FileData[LineNum].ToString().Split(",".ToArray());
                                    SplitMe = RemoveSlashs(SplitMe);
                                    if (SplitMe[0] == "QC Calculated Values") { goto Nextsection; }
                                    if (SplitMe[0] == "Method 200.8-Summary Report") { goto endsample; }
                                    if (SplitMe.Count() > 1) {
                                        NewAnalyte.AtomName = SplitMe[ReturnAnalyteEnumeration(AnalyteFields.Name)];
                                        NewAnalyte.AtomName = NewAnalyte.AtomName.TrimStart("\"".ToArray());
                                        NewAnalyte.AtomName = NewAnalyte.AtomName.TrimEnd("\"".ToArray());
                                        NewAnalyte.Mass = SplitMe[ReturnAnalyteEnumeration(AnalyteFields.Mass)];
                                        NewAnalyte.Mass = NewAnalyte.Mass.Trim();
                                        NewAnalyte.MeasIntensityMean = SplitMe[ReturnAnalyteEnumeration(AnalyteFields.MeasIntensMean)];
                                        NewAnalyte.MeasIntensityMean = NewAnalyte.MeasIntensityMean.Trim();
                                        NewAnalyte.NetIntensityMean = SplitMe[ReturnAnalyteEnumeration(AnalyteFields.NetIntensMean)];
                                        NewAnalyte.NetIntensityMean = NewAnalyte.NetIntensityMean.Trim();
                                        //NewAnalyte.ConcRSD = SplitMe[(int)AnalyteFields.ConcRSD];
                                        //NewAnalyte.ConcRSD = NewAnalyte.ConcRSD.Trim();
                                        NewAnalyte.ConcMean = SplitMe[ReturnAnalyteEnumeration(AnalyteFields.ConcMean)];
                                        NewAnalyte.ConcMean = NewAnalyte.ConcMean.Trim();
                                        NewAnalyte.ReportUnits = SplitMe[ReturnAnalyteEnumeration(AnalyteFields.ReportUnit)];
                                        NewAnalyte.ReportUnits = NewAnalyte.ReportUnits.Trim();
                                    }

                                    if (SplitMe[0] != "Method 200.8-Summary Report") {
                                        NumAnalytes++;
                                        Group.Metals.Add(NewAnalyte);
                                    }
                                }
                                if (SplitMe[0] == "Method 200.8-Summary Report") { goto endsample; }
                            Nextsection: ;
                                if (LineNum < FileData.Count-1) LineNum++;
                                else return false;
                                int Counter = 0;
                                for (; Counter < NumAnalytes; Counter++) {
                                    if ((Counter <= NumAnalytes) && (LineNum < FileData.Count-1)) {
                                        SplitMe = FileData[LineNum].ToString().Split(",".ToArray());
                                        SplitMe = RemoveSlashs(SplitMe);
                                        Establish_QCPercFields(SplitMe);
                                        if (SplitMe[0] == "Method 200.8-Summary Report") { goto endsample; }
                                        if (SplitMe.Count() > 1) {
                                            if (((Analyte)Group.Metals[Counter]).AtomName == SplitMe[0]) {
                                                ((Analyte)Group.Metals[Counter]).QCStdPercRec = SplitMe[ReturnQCEnumeration(QCPercFields.QCStdPercRecovery)];
                                                ((Analyte)Group.Metals[Counter]).QCStdPercRec = ((Analyte)Group.Metals[Counter]).QCStdPercRec.TrimStart("\0".ToArray());
                                                ((Analyte)Group.Metals[Counter]).SpkPercRec = SplitMe[ReturnQCEnumeration(QCPercFields.SpikePercRecovery)];
                                                //((Analyte)Group.Metals[Counter]).IntStdSymb = SplitMe[(int)QCPercFields.InternalStandardSymbol];
                                                if (SplitMe.Count() == 7)
                                                {
                                                    ((Analyte)Group.Metals[Counter]).IntStdRec = SplitMe[ReturnQCEnumeration(QCPercFields.IntStdPercRecovery)];
                                                }
                                            }
                                            else Counter--;
                                        }
                                        if(Counter<NumAnalytes)LineNum++;
                                    }
                                }
                            }
                        }
                    nextline: ;
                        if(!MetalsHit)LineNum++;
                        if (LineNum < (FileData.Count - 1)) {
                            SplitMe = FileData[LineNum].ToString().Split(",".ToArray());
                            SplitMe = RemoveSlashs(SplitMe);
                        }
                    endsample: ;
                        if(LineNum>FileData.Count-1){ goto breakout;}
                    } while ((SplitMe[0] != "Method 200.8-Summary Report") && (LineNum<FileData.Count-1));
             breakout:  Samples.Add(Group);
                    SampleCounter++;
                }
                return true;
            }
            else return false;
        }