Example #1
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));
            }
        }
Example #2
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));
        }
        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));
            }
        }
Example #4
0
        private DataTable GetRows(long DetectorId, string CounterType, string table, ElementList el, string FA)
        {
            db.SetConnection();
            string sSQL = "SELECT * FROM " + table + " where detector_id=" + DetectorId.ToString() +
                          " AND counter_type=" + SQLSpecific.QVal(CounterType) +
                          " AND gatewidth=" + SQLSpecific.QVal(el[gwidx].Value);

            if (!string.IsNullOrEmpty(FA))
            {
                sSQL += " AND " + el[faidx - 2].Name + "=" + el[faidx - 2].Value;
                sSQL += " AND " + el[faidx - 1].Name + "=" + el[faidx - 1].Value;
                sSQL += " AND " + el[faidx].Name + "=" + FA;
            }
            DataTable dt = db.DT(sSQL);

            return(dt);
        }
Example #5
0
        public bool Update(ElementList sParams)
        {
            DataRow dr    = null;
            string  table = "LMINCCAppContext";

            dr = Get();
            if (dr == null)
            {
                string sSQL = "Insert into " + table;
                sSQL += sParams.ColumnsValues;
                return(db.Execute(sSQL));
            }
            else
            {
                string sSQL1 = "UPDATE " + table + " SET ";
                string sSQL  = sSQL1 + sParams.ColumnEqValueList;
                return(db.Execute(sSQL));
            }
        }
        // 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);
            }
        }
Example #7
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);
            }
        }
Example #8
0
        public long Update(string Name, ElementList sParams)
        {
            db.SetConnection();
            DataTable dt = GetRows(Name); // must be unknown or at least one with same name because unique did not fire

            if (dt != null)
            {
                string wh   = " where item_name = " + SQLSpecific.QVal(Name);
                string sSQL = "UPDATE collar_data_entry SET ";
                sSQL += sParams.ColumnEqValueList + wh;
                return(db.Execute(sSQL) ? 0 : -1);
            }
            else  // totally new
            {
                ArrayList sqlList = new ArrayList();
                string    sSQL    = "Insert into collar_data_entry ";
                sSQL += sParams.ColumnsValues;
                sqlList.Add(sSQL);
                sqlList.Add(SQLSpecific.getLastID("collar_data_entry"));
                return(db.ExecuteTransactionID(sqlList));
            }
        }
Example #9
0
        public long Create(ElementList collar, ElementList collar_det, ElementList k5)
        {
            long success = 0;

            db.SetConnection();
            ArrayList sqlList = new ArrayList();
            // The collar is made of three records. One is in collar_rec, one in collar_detector, and one in collar_k5
            string sSQL = "Insert into collar_rec ";

            sSQL += collar.ColumnsValues;
            sqlList.Add(sSQL);
            sqlList.Add(SQLSpecific.getLastID("collar_rec"));
            success = db.ExecuteTransactionID(sqlList);

            sqlList = new ArrayList();
            // The collar is made of three records. One is in collar_rec, one in collar_detector, and one in collar_k5
            sSQL  = "Insert into collar_detector_rec ";
            sSQL += collar_det.ColumnsValues;
            sqlList.Add(sSQL);
            sqlList.Add(SQLSpecific.getLastID("collar_detector_rec"));
            if (success != -1) //Catch failure at each sql statement
            {
                success = db.ExecuteTransactionID(sqlList);
            }

            sqlList = new ArrayList();
            // The collar is made of three records. One is in collar_rec, one in collar_detector, and one in collar_k5
            sSQL  = "Insert into collar_k5_rec ";
            sSQL += k5.ColumnsValues;
            sqlList.Add(sSQL);
            sqlList.Add(SQLSpecific.getLastID("collar_k5_rec"));
            if (success != -1) //Catch failure at each sql statement
            {
                success = db.ExecuteTransactionID(sqlList);
            }

            return(success);
        }
Example #10
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);
        }
Example #11
0
 public bool UpdateNetComm(long id, ElementList sParams, IDB db)
 {
     return(UpdateTbl(id, "LMNetComm", sParams, db));
 }
Example #12
0
 public bool UpdateCfg(long id, ElementList sParams, IDB db)
 {
     return(UpdateTbl(id, "LMHWParams", sParams, db));
 }
Example #13
0
        // TODO: update results and method results in same step
        public bool unraeadyUpdate(string detname, DateTime date, ElementList resParams, ElementList methodParams)
        {
            db.SetConnection();
            Measurements ms      = new Measurements(db);
            ArrayList    sqlList = new ArrayList(); //.......

            long   l     = ms.PrimaryKey(detname, date);
            string sSQL1 = "UPDATE " + table + " SET ";
            string wh    = " where mid=" + l.ToString();
            string sSQL  = sSQL1 + resParams.ColumnEqValueList + wh;

            return(db.Execute(sSQL));
        }
Example #14
0
 public long CreateNetComm(long id, ElementList sParams, IDB db)
 {
     return(CreateTbl(id, "LMNetComm", sParams, db));
 }
Example #15
0
 public long CreateCfg(long id, ElementList sParams, IDB db)
 {
     return(CreateTbl(id, "LMHWParams", sParams, db));
 }
Example #16
0
        ///////////////////////

        public bool UpdateCalib(string DetectorName, string ItemType, string calib_table, ElementList sParams)
        {
            //NEXT: this duo-lookup part takes too long, so get the values once in a wrapper call, then cache them, then reuse them
            long l, m;

            GetKeys(DetectorName, ItemType, out l, out m);
            DataRow dr = HasRow(l, m); // sets the connection

            if (l == -1 || m == -1)
            {
                DBMain.AltLog(LogLevels.Warning, 70137, "Missing Det/Mat keys ({0},{1}) selecting method calibration params", l, m);
                return(false);
            }
            string wh    = " where item_type_id= " + m.ToString() + " AND detector_id=" + l.ToString();
            string exsql = "select item_type_id from " + calib_table + wh; // 1 column is sufficient to show existence

            DataTable dt = db.DT(exsql);

            if (dt.Rows.Count < 1)
            {
                string sSQL = "insert into " + calib_table + " ";
                sParams.Add(new Element("item_type_id", m));
                sParams.Add(new Element("detector_id", l));
                sSQL += sParams.ColumnsValues;
                return(db.Execute(sSQL));
            }
            else
            {
                string sSQL1 = "UPDATE " + calib_table + " SET ";
                string sSQL  = sSQL1 + sParams.ColumnEqValueList + wh;
                return(db.Execute(sSQL));
            }
        }
Example #17
0
 protected string CycleInsertStatement(long Measurement_ID, ElementList sParams)
 {
     sParams.Add(new Element("mid", Measurement_ID));
     return("Insert into cycles " + sParams.ColumnsValues);
 }
Example #18
0
 protected string HVPRunInsertStatement(long HVPId, ElementList sParams)
 {
     sParams.Add(new Element("hvp_id", HVPId));
     return("Insert into HVStatus " + sParams.ColumnsValues);
 }
Example #19
0
        public bool Update(DateTimeOffset measDatetime, string measDetId, string itemId, ElementList sParams)
        {
            db.SetConnection();
            string wh    = " where item_type = " + SQLSpecific.Value(itemId, true) + " AND meas_detector_id = " + SQLSpecific.Value(measDetId, true);
            string sSQL1 = "UPDATE acquire_parms_rec SET ";
            string sSQL  = sSQL1 + sParams.ColumnEqValueList + wh;

            return(db.Execute(sSQL));
        }
Example #20
0
 protected string CIInsertStatement(long cid, ElementList sParams)
 {
     sParams.Add(new Element("cid", cid));
     return("Insert into composite_isotopic_rec " + sParams.ColumnsValues);
 }
Example #21
0
        private string InsertStratum(ElementList sParams)
        {
            string sSQL1 = "Insert into stratum_ids " + sParams.ColumnsValues;

            return(sSQL1);
        }