public bool Delete(string DetectorName, string CounterType, ElementList sParams)
        {
            DataRow dr = null;

            string table = "CountingParams";
            if (CounterType.Equals("Multiplicity") || CounterType.Equals("Coincidence"))
                table = "LMMultiplicity";

            Detectors dets = new Detectors(db);
            long l = dets.PrimaryKey(DetectorName);
            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return false;
            }

            if (table.Equals("LMMultiplicity"))
                dr = HasRow(l, CounterType, table, sParams, sParams[faidx].Value); // the FA parameter
            else
                dr = HasRow(l, CounterType, table, sParams);
            if (dr != null)
            {
                string sSQL = "DELETE FROM " + table + " where counter_type=" + SQLSpecific.QVal(CounterType) + " AND detector_id=" + l.ToString();
                if (table.Equals("LMMultiplicity"))
                    sSQL += " AND " + sParams[faidx].Name + "=" + sParams[faidx].Value;
                return db.Execute(sSQL);
            }
            else
                return true;
        }
        private DataTable BasicSelect(string DetectorName, string CounterType, string table, string FA)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(DetectorName);

            return(GetTable(l, CounterType, table, FA));
        }
Exemplo n.º 3
0
        // delete all the stratum associations with a detector
        public bool Unassociate(string measDetId)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);
            string    sSQL = "DELETE FROM stratum_id_detector where " + "(stratum_id_detector.detector_id=" + l.ToString() + ")";

            return(db.Execute(sSQL));
        }
Exemplo n.º 4
0
 public DataTable Get(string measDetId)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL = "Select * FROM " + table + " where detector_id = " + l.ToString();
     DataTable dt = db.DT(sSQL);
     return dt;
 }
Exemplo n.º 5
0
        public bool Associate(string measDetId, string stratumID)
        {
            db.SetConnection();
            Detectors dets  = new Detectors(db);
            long      l     = dets.PrimaryKey(measDetId);
            long      m     = PrimaryKey(stratumID);
            string    saSQL = "insert into stratum_id_detector VALUES(" + l.ToString() + "," + m.ToString() + ")";

            return(db.Execute(saSQL));
        }
Exemplo n.º 6
0
        public DataTable Get(string measDetId)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);
            string    sSQL = "Select * FROM " + table + " where detector_id = " + l.ToString();
            DataTable dt   = db.DT(sSQL);

            return(dt);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
 public bool Create(string measDetId, ElementList sParams) 
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     sParams.Add(new Element("detector_id", l));
     string sSQL1 = "Insert into " + table + " ";
     string sSQL = sSQL1 + sParams.ColumnsValues;            
     return db.Execute(sSQL);
 }
Exemplo n.º 9
0
        public DataTable Get(string measDetId)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);
            string    sSQL = "Select * from LMNetComm, LMHWParams where (LMNetComm.detector_id=" + l.ToString() + " AND LMHWParams.detector_id=" + l.ToString() + ")";
            DataTable dt   = db.DT(sSQL);

            return(dt);
        }
Exemplo n.º 10
0
        public DataTable Get(DateTimeOffset measDatetime, string measDetId, string item_type)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);
            string    sSQL = "Select * FROM LMAcquireParams where detector_id = " + l.ToString() + " AND item_type=" + SQLSpecific.Value(item_type, true);
            DataTable dt   = db.DT(sSQL);

            return(dt);
        }
Exemplo n.º 11
0
 public bool Update(string measDetId, ElementList sParams)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL1 = "UPDATE " + table + " SET ";
     string sSQL1i = String.Empty;
     string wh = " where " + "detector_id = " + l.ToString();
     string sSQL = sSQL1 + sParams.ColumnEqValueList + wh;
     return db.Execute(sSQL);
 }
Exemplo n.º 12
0
        public bool Has(string DetectorName, string CounterType)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(DetectorName);
            string    sSQL = "Select * from INNER JOIN LMMultiplicity, CountingParams ON (LMMultiplicity.detector_id=CountingParams.detector_id) " +
                             "where detector_id=" + l.ToString() + " AND " + "counter_type=" + SQLSpecific.QVal(CounterType);
            DataTable dt = db.DT(sSQL);

            return(dt.Rows.Count > 0);
        }
Exemplo n.º 13
0
 // joins the matching LM if found
 public DataTable Get(string measDetId)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL = "select * from acquire_parms_rec left join LMAcquireParams on (LMAcquireParams.detector_id=" + l.ToString() + ") " +
         "where (acquire_parms_rec.meas_detector_id=" + SQLSpecific.Value(measDetId, true) + ")" +
          " order by acquire_parms_rec.MeasDate DESC";
     DataTable dt = db.DT(sSQL);
     return dt;
 }
Exemplo n.º 14
0
        public bool Update(string measDetId, ElementList sParams)
        {
            db.SetConnection();
            Detectors dets   = new Detectors(db);
            long      l      = dets.PrimaryKey(measDetId);
            string    sSQL1  = "UPDATE " + table + " SET ";
            string    sSQL1i = String.Empty;
            string    wh     = " where " + "detector_id = " + l.ToString();
            string    sSQL   = sSQL1 + sParams.ColumnEqValueList + wh;

            return(db.Execute(sSQL));
        }
Exemplo n.º 15
0
        public bool Update(string measDetId, string item_type, ElementList sParams)
        {
            db.SetConnection();
            Detectors dets   = new Detectors(db);
            long      l      = dets.PrimaryKey(measDetId);
            string    sSQL1  = "UPDATE LMAcquireParams SET ";
            string    sSQL1i = String.Empty;
            string    wh     = " where " + "item_type = " + SQLSpecific.Value(item_type, true) + " AND detector_id = " + l.ToString();
            string    sSQL   = sSQL1 + sParams.ColumnEqValueList + wh;

            return(db.Execute(sSQL));
        }
Exemplo n.º 16
0
        public bool Create(DateTimeOffset measDatetime, string measDetId, ElementList sParams)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);

            sParams.Add(new Element("detector_id", l));
            string sSQL1 = "Insert into LMAcquireParams ";
            string sSQL  = sSQL1 + sParams.ColumnsValues;

            return(db.Execute(sSQL));
        }
Exemplo n.º 17
0
        public bool Delete(string measDetId)
        {
            db.SetConnection();
            Detectors dets   = new Detectors(db);
            long      l      = dets.PrimaryKey(measDetId);
            string    sSQL1  = "DELETE from " + table;
            string    sSQL1i = String.Empty;
            string    wh     = " where " + "detector_id = " + l.ToString();
            string    sSQL   = sSQL1 + wh;

            return(db.Execute(sSQL));
        }
Exemplo n.º 18
0
Arquivo: acq.cs Projeto: radtek/INCC6
        public DataTable Get(string measDetId) // joins the matching LM if found
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);
            string    sSQL = "select * from acquire_parms_rec left join LMAcquireParams on (LMAcquireParams.detector_id=" + l.ToString() + ") " +
                             "where (acquire_parms_rec.meas_detector_id=" + SQLSpecific.Value(measDetId, true) + ")" +
                             " order by acquire_parms_rec.MeasDate DESC";
            DataTable dt = db.DT(sSQL);

            return(dt);
        }
Exemplo n.º 19
0
        private DataTable AllWithKeyNames(string DetectorName)
        {
            db.SetConnection();
            Detectors dets  = new Detectors(db);
            long      l     = dets.PrimaryKey(DetectorName);
            string    sSQLa = "Select * from CountingParams where CountingParams.detector_id=" + l.ToString();
            string    sSQLb = "Select * from LMMultiplicity where LMMultiplicity.detector_id=" + l.ToString();
            DataTable dta   = db.DT(sSQLa);
            DataTable dtb   = db.DT(sSQLb);

            dta.Merge(dtb);
            return(dta);
        }
Exemplo n.º 20
0
        // return the named stratum associated with a detector
        public DataTable Get(string measDetId, string stratumId)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);
            long      m    = PrimaryKey(stratumId);
            string    sSQL = "Select * FROM stratum_ids INNER JOIN stratum_id_detector ON " +
                             "(stratum_id_detector.stratum_id=stratum_ids.stratum_id AND stratum_id_detector.detector_id=" + l.ToString()
                             + " AND stratum_id_detector.stratum_id=" + m.ToString() + ")";
            DataTable dt = db.DT(sSQL);

            return(dt);
        }
Exemplo n.º 21
0
        private string ResolvedKey(string val, IDB _db)
        {
            Detectors dets = new Detectors(_db);

            if (Id)
            {
                long l = dets.PrimaryKey(val);
                return(Field + "=" + l.ToString());
            }
            else
            {
                return(Field + "=" + SQLSpecific.Value(val, true));
            }
        }
Exemplo n.º 22
0
        // return the stratums associated with a detector
        public DataTable GetAssociations(string measDetId)
        {
            if (String.IsNullOrEmpty(measDetId))
            {
                return(Get());
            }
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);
            string    sSQL = "Select * FROM stratum_ids INNER JOIN stratum_id_detector ON (stratum_id_detector.stratum_id=stratum_ids.stratum_id AND stratum_id_detector.detector_id=" + l.ToString() + ")";
            DataTable dt   = db.DT(sSQL);

            return(dt);
        }
Exemplo n.º 23
0
        public bool Update(string measDetId, string table, ElementList sParams)
        {
            db.SetConnection();
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(measDetId);

            if (table == "net")
            {
                return(UpdateNetComm(l, sParams, db));
            }
            else
            {
                return(UpdateCfg(l, sParams, db));
            }
        }
Exemplo n.º 24
0
        // create a stratum and detector stratum association
        public bool Create(string measDetId, ElementList sParams)
        {
            db.SetConnection();
            Detectors dets    = new Detectors(db);
            long      l       = dets.PrimaryKey(measDetId);
            string    sSQL    = InsertStratum(sParams);
            ArrayList sqlList = new ArrayList();

            sqlList.Add(sSQL);
            sqlList.Add(SQLSpecific.getLastID("stratum_ids"));
            long   newID = db.ExecuteTransactionID(sqlList);
            string saSQL = "insert into stratum_id_detector VALUES(" + l.ToString() + "," + newID.ToString() + ")";

            return(db.Execute(saSQL));
        }
Exemplo n.º 25
0
        public bool Update(string DetectorName, string CounterType, ElementList sParams)
        {
            DataRow dr = null;

            string table = "CountingParams";

            if (CounterType.Equals("Multiplicity") || CounterType.Equals("Coincidence"))
            {
                table = "LMMultiplicity";
            }

            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(DetectorName);

            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return(false);
            }

            if (table.Equals("LMMultiplicity"))
            {
                dr = HasRow(DetectorName, CounterType, table, sParams[faidx].Value); // the FA parameter
            }
            else
            {
                dr = HasRow(DetectorName, CounterType, table);
            }
            if (dr == null)
            {
                sParams.Add(new Element("detector_id", l));
                string sSQL = "Insert into " + table;
                sSQL += sParams.ColumnsValues;
                return(db.Execute(sSQL));
            }
            else
            {
                //NEXT: not tested(?)
                string sSQL = "UPDATE " + table + " SET ";
                sSQL += (sParams.ColumnEqValueList + " where counter_type=" + SQLSpecific.QVal(CounterType) + " AND detector_id=" + l.ToString());
                if (table.Equals("LMMultiplicity"))
                {
                    sSQL += " AND " + sParams[faidx].Name + "=" + sParams[faidx].Value;
                }
                return(db.Execute(sSQL));
            }
        }
Exemplo n.º 26
0
        public long DeleteAll(string DetectorName)
        {
            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(DetectorName);

            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return(-1);
            }
            string    table1  = "CountingParams";
            string    table2  = "LMMultiplicity";
            ArrayList sqlList = new ArrayList();

            sqlList.Add("DELETE FROM " + table1 + " where detector_id=" + l.ToString());
            sqlList.Add("DELETE FROM " + table2 + " where detector_id=" + l.ToString());
            return(db.Execute(sqlList));
        }
Exemplo n.º 27
0
        // fix this, need a blanket clear

        public bool DeleteAll(string DetectorName, string CounterType, ElementList sParams)
        {
            DataRow dr = null;

            string table = "CountingParams";

            if (CounterType.Equals("Multiplicity") || CounterType.Equals("Coincidence"))
            {
                table = "LMMultiplicity";
            }

            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(DetectorName);

            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return(false);
            }

            if (table.Equals("LMMultiplicity"))
            {
                dr = HasRow(DetectorName, CounterType, table, sParams[faidx].Value); // the FA parameter
            }
            else
            {
                dr = HasRow(DetectorName, CounterType, table);
            }
            if (dr != null)
            {
                //NEXT: not tested(?)
                string sSQL = "DELETE FROM " + table + " where counter_type=" + SQLSpecific.QVal(CounterType) + " AND detector_id=" + l.ToString();
                if (table.Equals("LMMultiplicity"))
                {
                    sSQL += " AND " + sParams[faidx].Name + "=" + sParams[faidx].Value;
                }
                return(db.Execute(sSQL));
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 28
0
        public bool Insert(string DetectorName, string CounterType, ElementList sParams)
        {
            DataRow dr = null;

            string table = "CountingParams";

            if (CounterType.Equals("Multiplicity") || CounterType.Equals("Coincidence"))
            {
                table = "LMMultiplicity";
            }

            Detectors dets = new Detectors(db);
            long      l    = dets.PrimaryKey(DetectorName);

            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return(false);
            }

            if (table.Equals("LMMultiplicity"))
            {
                dr = HasRow(l, CounterType, table, sParams, sParams[faidx].Value); // the FA parameter
            }
            else
            {
                dr = HasRow(l, CounterType, table, sParams);
            }
            if (dr == null)
            {
                sParams.Add(new Element("detector_id", l));
                string sSQL = "Insert into " + table;
                sSQL += sParams.ColumnsValues;
                return(db.Execute(sSQL));
            }
            else
            {
                // identical row found, skip it
                return(false);
            }
        }
Exemplo n.º 29
0
        public bool Update(string DetectorName, string CounterType, ElementList sParams)
        {
            DataRow dr = null;

            string table = "CountingParams";
            if (CounterType.Equals("Multiplicity") || CounterType.Equals("Coincidence"))
                table = "LMMultiplicity";

            Detectors dets = new Detectors(db);
            long l = dets.PrimaryKey(DetectorName);
            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return false;
            }

            if (table.Equals("LMMultiplicity"))
                dr = HasRow(DetectorName, CounterType, table, sParams[faidx].Value); // the FA parameter
            else
                dr = HasRow(DetectorName, CounterType, table);
            if (dr == null)
            {
                sParams.Add(new Element("detector_id", l));
                string sSQL = "Insert into " + table;
                sSQL += sParams.ColumnsValues;
                return db.Execute(sSQL);
            }
            else
            {
                //NEXT: not tested(?)
                string sSQL = "UPDATE " + table + " SET ";
                sSQL += (sParams.ColumnEqValueList + " where counter_type=" + SQLSpecific.QVal(CounterType) + " AND detector_id=" + l.ToString());
                if (table.Equals("LMMultiplicity"))
                    sSQL += " AND " + sParams[faidx].Name + "=" + sParams[faidx].Value;
                return db.Execute(sSQL);
            }
        }
Exemplo n.º 30
0
        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);
        }
Exemplo n.º 31
0
        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;
        }
Exemplo n.º 32
0
 public bool Delete(string measDetId)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL1 = "DELETE from " + table;
     string sSQL1i = String.Empty;
     string wh = " where " + "detector_id = " + l.ToString();
     string sSQL = sSQL1 + wh;
     return db.Execute(sSQL);
 }
Exemplo n.º 33
0
 // return the stratums associated with a detector
 public DataTable GetAssociations(string measDetId)
 {
     if (String.IsNullOrEmpty(measDetId))
         return Get();
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL = "Select * FROM stratum_ids INNER JOIN stratum_id_detector ON (stratum_id_detector.stratum_id=stratum_ids.stratum_id AND stratum_id_detector.detector_id=" + l.ToString() + ")";
     DataTable dt = db.DT(sSQL);
     return dt;
 }
Exemplo n.º 34
0
 public bool Associate(string measDetId, string stratumID)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     long m = PrimaryKey(stratumID);
     string saSQL = "insert into stratum_id_detector VALUES(" + l.ToString() + "," + m.ToString() + ")";
     return db.Execute(saSQL);
 }
Exemplo n.º 35
0
 // create a stratum and detector stratum association
 public bool Create(string measDetId, ElementList sParams)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL = InsertStratum(sParams);
     ArrayList sqlList = new ArrayList();
     sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID("stratum_ids"));
     long newID = db.ExecuteTransactionID(sqlList);
     string saSQL = "insert into stratum_id_detector VALUES(" + l.ToString() + "," + newID.ToString() + ")";
     return db.Execute(saSQL);
 }
Exemplo n.º 36
0
 // delete all the stratum associations with a detector
 public bool Unassociate(string measDetId)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL = "DELETE FROM stratum_id_detector where " + "(stratum_id_detector.detector_id=" + l.ToString() + ")";
     return db.Execute(sSQL);
 }
Exemplo n.º 37
0
 // return the named stratum associated with a detector
 public DataTable Get(string measDetId, string stratumId) 
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     long m = PrimaryKey(stratumId);
     string sSQL = "Select * FROM stratum_ids INNER JOIN stratum_id_detector ON " + 
         "(stratum_id_detector.stratum_id=stratum_ids.stratum_id AND stratum_id_detector.detector_id=" + l.ToString() 
         + " AND stratum_id_detector.stratum_id=" + m.ToString() + ")";
     DataTable dt = db.DT(sSQL);
     return dt;
 }
Exemplo n.º 38
0
 public bool Has(string DetectorName, string CounterType)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(DetectorName);
     string sSQL = "Select * from INNER JOIN LMMultiplicity, CountingParams ON (LMMultiplicity.detector_id=CountingParams.detector_id) " +
         "where detector_id=" + l.ToString() + " AND " + "counter_type=" + SQLSpecific.QVal(CounterType);
     DataTable dt = db.DT(sSQL);
     return (dt.Rows.Count > 0);
 }
Exemplo n.º 39
0
 private DataTable AllWithKeyNames(string DetectorName)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(DetectorName);
     string sSQLa = "Select * from CountingParams where CountingParams.detector_id=" + l.ToString();
     string sSQLb = "Select * from LMMultiplicity where LMMultiplicity.detector_id=" + l.ToString();
     DataTable dta = db.DT(sSQLa);
     DataTable dtb = db.DT(sSQLb);
     dta.Merge(dtb);
     return dta;
 }
Exemplo n.º 40
0
 private DataTable BasicSelect(string DetectorName, string CounterType, string table, string FA)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(DetectorName);
     return GetTable(l, CounterType, table, FA);
 }
Exemplo n.º 41
0
        public bool Insert(string DetectorName, string CounterType, ElementList sParams)
        {
            DataRow dr = null;

            string table = "CountingParams";
            if (CounterType.Equals("Multiplicity") || CounterType.Equals("Coincidence"))
                table = "LMMultiplicity";

            Detectors dets = new Detectors(db);
            long l = dets.PrimaryKey(DetectorName);
            if (l == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
                return false;
            }

            if (table.Equals("LMMultiplicity"))
                dr = HasRow(l, CounterType, table, sParams, sParams[faidx].Value); // the FA parameter
            else
                dr = HasRow(l, CounterType, table, sParams);
            if (dr == null)
            {
                sParams.Add(new Element("detector_id", l));
                string sSQL = "Insert into " + table;
                sSQL += sParams.ColumnsValues;
                return db.Execute(sSQL);
            }
            else
            {
                // identical row found, skip it
                return false;
            }
        }
Exemplo n.º 42
0
 private string ResolvedKey(string val, IDB _db)
 {
     Detectors dets = new Detectors(_db);
     if (Id)
     {
         long l = dets.PrimaryKey(val);
         return Field + "=" + l.ToString();
     }
     else
     {
         return Field + "=" + SQLSpecific.Value(val, true);   
     }
 }
Exemplo n.º 43
0
 public bool Update(string measDetId, string item_type, ElementList sParams)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL1 = "UPDATE LMAcquireParams SET ";
     string sSQL1i = String.Empty;
     string wh = " where " + "item_type = " + SQLSpecific.Value(item_type, true) + " AND detector_id = " + l.ToString();
     string sSQL = sSQL1 + sParams.ColumnEqValueList + wh;
     return db.Execute(sSQL);
 }
Exemplo n.º 44
0
 public DataTable Get(DateTimeOffset measDatetime, string measDetId, string item_type)
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL = "Select * FROM LMAcquireParams where detector_id = " + l.ToString() + " AND item_type=" + SQLSpecific.Value(item_type, true);
     DataTable dt = db.DT(sSQL);
     return dt;
 }
Exemplo n.º 45
0
 public bool Update(string measDetId, string table, ElementList sParams) 
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     if (table == "net")
         return UpdateNetComm(l, sParams, db);
     else
         return UpdateCfg(l, sParams, db);
 }
Exemplo n.º 46
0
 public DataTable Get(string measDetId) 
 {
     db.SetConnection();
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(measDetId);
     string sSQL = "Select * from LMNetComm, LMHWParams where (LMNetComm.detector_id=" + l.ToString() + " AND LMHWParams.detector_id=" + l.ToString() +")";
     DataTable dt = db.DT(sSQL);
     return dt;
 }
Exemplo n.º 47
0
 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);
 }
Exemplo n.º 48
0
 public long DeleteAll(string DetectorName)
 {
     Detectors dets = new Detectors(db);
     long l = dets.PrimaryKey(DetectorName);
     if (l == -1)
     {
         DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det key ({0}) selecting CountingParams", l);
         return -1;
     }
     string table1 = "CountingParams";
     string table2 = "LMMultiplicity";
     ArrayList sqlList = new ArrayList();
     sqlList.Add("DELETE FROM " + table1 + " where detector_id=" + l.ToString());
     sqlList.Add("DELETE FROM " + table2 + " where detector_id=" + l.ToString());
     return db.Execute(sqlList);
 }