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; }
private static Double Fixit( Analyte Item) { double Value = 999.99; try { Value = Convert.ToDouble(Item.QCStdPercRec); } catch (Exception e) { Value = 999.99; string DebugMemoryString = e.Message.ToString(); } return Value; }
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; }