private void GetKeys(string DetectorName, string ItemType, out long l, out long m) { db.SetConnection(); Detectors dets = new Detectors(db); l = dets.PrimaryKey(DetectorName); Descriptors mats = new Descriptors("material_types", db); m = mats.PrimaryKey(ItemType); }
public bool Update(string DetectorName, string ItemType, ElementList sParams) { bool res = false; db.SetConnection(); //NEXT: this duo-lookup part takes too long, so get the values once in a wrapper call, then cache them, then reuse them DataRow dr = HasRow(DetectorName, ItemType); // sets the connection Detectors dets = new Detectors(db); long l = dets.PrimaryKey(DetectorName); Descriptors mats = new Descriptors("material_types", db); long m = mats.PrimaryKey(ItemType); if (l == -1 || m == -1) { DBMain.AltLog(LogLevels.Warning, 70130, "Missing Det/Mat keys ({0},{1}) selecting AnalysisMethods", l, m); return(false); } if (dr == null) // a new entry! { string sSQL = "insert into analysis_method_rec "; sParams.Add(new Element("item_type_id", m)); sParams.Add(new Element("analysis_method_detector_id", l)); sSQL = sSQL + sParams.ColumnsValues; res = db.Execute(sSQL); } else { string wh = " where item_type_id= " + m.ToString() + " AND analysis_method_detector_id=" + l.ToString(); string sSQL1 = "UPDATE analysis_method_rec SET "; string sSQL = sSQL1 + sParams.ColumnEqValueList + wh; res = db.Execute(sSQL); } return(res); }
public bool Update(string DetectorName, string ItemType, ElementList sParams) { bool res = false; db.SetConnection(); //NEXT: this duo-lookup part takes too long, so get the values once in a wrapper call, then cache them, then reuse them DataRow dr = HasRow(DetectorName, ItemType); // sets the connection Detectors dets = new Detectors(db); long l = dets.PrimaryKey(DetectorName); Descriptors mats = new Descriptors("material_types", db); long m = mats.PrimaryKey(ItemType); if (l == -1 || m == -1) { DBMain.AltLog(LogLevels.Warning, 70130, "Missing Det/Mat keys ({0},{1}) selecting AnalysisMethods", l, m); return false; } if (dr == null) // a new entry! { string sSQL = "insert into analysis_method_rec "; sParams.Add(new Element("item_type_id", m)); sParams.Add(new Element("analysis_method_detector_id", l)); sSQL = sSQL + sParams.ColumnsValues; res = db.Execute(sSQL); } else { string wh = " where item_type_id= " + m.ToString() + " AND analysis_method_detector_id=" + l.ToString(); string sSQL1 = "UPDATE analysis_method_rec SET "; string sSQL = sSQL1 + sParams.ColumnEqValueList + wh; res = db.Execute(sSQL); } return res; }
// can use IList interface on this public DataTable GetACollection(Pieces p, String did = null) { DataTable dt = new DataTable(); try { switch (p) { default: break; case Pieces.HVParams: HVParams hv = new HVParams(); dt = hv.Get(did); break; case Pieces.HVResults: HVPlateauResults hvr = new HVPlateauResults(); dt = hvr.AllHVPlateauResults(did); break; case Pieces.Measurements: Measurements ms = new Measurements(); dt = ms.AllMeasurements(did); break; case Pieces.CountingAnalyzers: CountingAnalysisParameters cap = new CountingAnalysisParameters(); dt = cap.AnalyzerParamsForDetector(did); break; case Pieces.AnalysisMethodSpecifiers: using(AnalysisMethodSpecifiers am = new AnalysisMethodSpecifiers()) { dt = am.MethodsForDetector(did); } break; case Pieces.Detectors: Detectors clsD = new Detectors(); dt = clsD.getDetectors(true); break; case Pieces.LMParams: LMNetCommParams blue = new LMNetCommParams(); dt = blue.Get(did); break; case Pieces.LMMultParams: LMMultiplicityParams purple = new LMMultiplicityParams(); dt = purple.Get(did); break; case Pieces.DetectorTypes: Descriptors clsDT = new Descriptors("detector_types"); dt = clsDT.getDescs(); break; case Pieces.Materials: Descriptors clsMtl = new Descriptors("material_types"); dt = clsMtl.getDescs(); break; case Pieces.TestParams: TestParams tp = new TestParams(); dt = tp.Get(); break; case Pieces.NormParams: NormParams np = new NormParams(); dt = np.Get(did); break; case Pieces.AASSetupParams: AASSetupParams aass = new AASSetupParams(); dt = aass.Get(did); break; case Pieces.BackgroundParams: BackgroundParams clsB = new BackgroundParams(); TruncatedBackgroundParams clsTB = new TruncatedBackgroundParams(); dt = clsB.Get(did); DataTable dt2 = clsTB.Get(did); dt.Merge(dt2); break; // next: caution, should use select/join case Pieces.Facilities: Descriptors clsF = new Descriptors("facility_names"); dt = clsF.getDescs(); break; case Pieces.MBAs: Descriptors MBA = new Descriptors(p.ToString()); dt = MBA.getDescs(); break; case Pieces.Items: Items clsI = new Items(); dt = clsI.getItems(); break; case Pieces.CollarItems: CollarItems clsCI = new CollarItems(); dt = clsCI.getItems(); break; case Pieces.Isotopics: Isotopics clsIs = new Isotopics(); dt = clsIs.getIsotopics(); break; case Pieces.Strata: Strata s = new Strata(); dt = s.Get(); break; case Pieces.StrataWithAssoc: Strata ss = new Strata(); dt = ss.GetAssociations(did); break; case Pieces.AcquireParams: AcquireParams aq = new AcquireParams(); dt = aq.Get(did); break; case Pieces.IOCodes: Descriptors ioc = new Descriptors("io_code"); dt = ioc.getDescs(); break; case Pieces.InvChangeCodes: Descriptors icc = new Descriptors("inventory_change_code"); dt = icc.getDescs(); break; case Pieces.UnattendedParams: UnattendParams u = new UnattendParams(); dt = u.Get(did); break; case Pieces.CmPuRatioParams: cm_pu_ratio_rec cpu = new cm_pu_ratio_rec(); dt = cpu.Get(); break; case Pieces.Results: Results rr = new Results(); dt = rr.AllResults(did); break; } } catch (Exception caught) { DBMain.AltLog(LogLevels.Warning, 70191, "Get Collection '" + caught.Message + "' "); } return dt; }
// can use IList interface on this public DataTable GetACollection(Pieces p, String did = null) { DataTable dt = new DataTable(); try { switch (p) { default: break; case Pieces.HVParams: HVParams hv = new HVParams(); dt = hv.Get(did); break; case Pieces.HVResults: HVPlateauResults hvr = new HVPlateauResults(); dt = hvr.AllHVPlateauResults(did); break; case Pieces.Measurements: Measurements ms = new Measurements(); dt = ms.AllMeasurements(did); break; case Pieces.CountingAnalyzers: CountingAnalysisParameters cap = new CountingAnalysisParameters(); dt = cap.AnalyzerParamsForDetector(did); break; case Pieces.AnalysisMethodSpecifiers: using (AnalysisMethodSpecifiers am = new AnalysisMethodSpecifiers()) { dt = am.MethodsForDetector(did); } break; case Pieces.Detectors: Detectors clsD = new Detectors(); dt = clsD.getDetectors(true); break; case Pieces.LMParams: LMNetCommParams blue = new LMNetCommParams(); dt = blue.Get(did); break; case Pieces.LMMultParams: LMMultiplicityParams purple = new LMMultiplicityParams(); dt = purple.Get(did); break; case Pieces.DetectorTypes: Descriptors clsDT = new Descriptors("detector_types"); dt = clsDT.getDescs(); break; case Pieces.Materials: Descriptors clsMtl = new Descriptors("material_types"); dt = clsMtl.getDescs(); break; case Pieces.TestParams: TestParams tp = new TestParams(); dt = tp.Get(); break; case Pieces.NormParams: NormParams np = new NormParams(); dt = np.Get(did); break; case Pieces.AASSetupParams: AASSetupParams aass = new AASSetupParams(); dt = aass.Get(did); break; case Pieces.BackgroundParams: BackgroundParams clsB = new BackgroundParams(); TruncatedBackgroundParams clsTB = new TruncatedBackgroundParams(); dt = clsB.Get(did); DataTable dt2 = clsTB.Get(did); dt.Merge(dt2); break; // next: caution, should use select/join case Pieces.Facilities: Descriptors clsF = new Descriptors("facility_names"); dt = clsF.getDescs(); break; case Pieces.MBAs: Descriptors MBA = new Descriptors(p.ToString()); dt = MBA.getDescs(); break; case Pieces.Items: Items clsI = new Items(); dt = clsI.getItems(); break; case Pieces.CollarItems: CollarItems clsCI = new CollarItems(); dt = clsCI.getItems(); break; case Pieces.Isotopics: Isotopics clsIs = new Isotopics(); dt = clsIs.getIsotopics(); break; case Pieces.Strata: Strata s = new Strata(); dt = s.Get(); break; case Pieces.StrataWithAssoc: Strata ss = new Strata(); dt = ss.GetAssociations(did); break; case Pieces.AcquireParams: AcquireParams aq = new AcquireParams(); dt = aq.Get(did); break; case Pieces.IOCodes: Descriptors ioc = new Descriptors("io_code"); dt = ioc.getDescs(); break; case Pieces.InvChangeCodes: Descriptors icc = new Descriptors("inventory_change_code"); dt = icc.getDescs(); break; case Pieces.UnattendedParams: UnattendParams u = new UnattendParams(); dt = u.Get(did); break; case Pieces.CmPuRatioParams: cm_pu_ratio_rec cpu = new cm_pu_ratio_rec(); dt = cpu.Get(); break; case Pieces.Results: Results rr = new Results(); dt = rr.AllResults(did); break; } } catch (Exception caught) { DBMain.AltLog(LogLevels.Warning, 70191, "Get Collection '" + caught.Message + "' "); } return(dt); }