Exemple #1
0
 public bool Create(ElementList sParams)
 {
     db.SetConnection();
     string sSQL1 = "Insert into acquire_parms_rec ";
     string sSQL = sSQL1 + sParams.ColumnsValues;
     return db.Execute(sSQL);
 }
 public void ElementListCanRenderAsXml()
 {
     var list = new ElementList(new Element("input", "type=text"), new Element("img", "src=stoopid.gif"));
     var expected = "<input type=\"text\" /><img src=\"stoopid.gif\" />";
     var actual = list.Render(RendersTo.XmlTextWriter);
     Assert.AreEqual(expected, actual);
 }
        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;
        }
 public void NullElementsAreNotAddedToList()
 {
     Element nullel = null;
     Element el = new Element("b").Update("Anja");
     ElementList list = new ElementList(nullel, el);
     Assert.AreEqual(1, list.Count);
     Assert.AreEqual("<b>Anja</b>", list.ToString());
 }
Exemple #5
0
 public bool DefinitionExists(ElementList els)
 {
     db.SetConnection();
     string sSQL = "Select * FROM detectors where ";
     sSQL = sSQL + els.ColumnEqValueAndList;
     DataTable dt = db.DT(sSQL);
     return dt.Rows.Count > 0;
 }
Exemple #6
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);
 }
Exemple #7
0
 public long Create(long measid, ElementList sParams) 
 {
     db.SetConnection();
     ArrayList sqlList = new ArrayList();
     string sSQL1 = "Insert into results_rec ";
     sParams.Add(new Element("mid", measid));
     string sSQL = sSQL1 + sParams.ColumnsValues; sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID("results_rec"));
     return db.ExecuteTransactionID(sqlList);
 }
Exemple #8
0
 public long Create(long mid, ElementList resParams)
 {
     db.SetConnection();
     resParams.Add(new Element("mid", mid));
     ArrayList sqlList = new ArrayList();
     string sSQL1 = "Insert into " + table + "_m" + " ";
     string sSQL = sSQL1 + resParams.ColumnsValues;
     sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID(table + "_m" ));
     return db.ExecuteTransactionID(sqlList);
 }
Exemple #9
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);
 }
 public void CanRenderToXmlWriter()
 {
     ElementList list = new ElementList(
         new Element("b").Update("Chris"),
         new Element("i").Update("Emmitt"));
     string expected = "<b>Chris</b><i>Emmitt</i>";
     string actual;
     using (StringWriter text = new StringWriter())
     {
         XmlTextWriter xml = new XmlTextWriter(text);
         list.Render(xml);
         actual = text.ToString();
     }
     Assert.AreEqual(expected, actual);
 }
 public void CanRenderToStream()
 {
     ElementList list = new ElementList(
         new Element("b").Update("Chris"),
         new Element("i").Update("Emmitt"));
     string expected = "<b>Chris</b><i>Emmitt</i>";
     string actual;
     byte[] buffer = new byte[expected.Length];
     using (MemoryStream stream = new MemoryStream(buffer))
     {
         list.Render(stream);
         actual = System.Text.ASCIIEncoding.ASCII.GetString(buffer);
     }
     Assert.AreEqual(expected, actual);
 }
Exemple #12
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);
     }
 }
        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);
            }
        }
Exemple #14
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;
        }
Exemple #15
0
 public long Create(string detname, DateTime date, ElementList resParams)
 {
     db.SetConnection();
     Measurements ms = new Measurements(db);
     long mid = ms.PrimaryKey(detname, date);
     return Create(mid, resParams);
 }
 public void xtor()
 {
     Console.WriteLine("ElementCollection:xtor");
     _singles = new ElementList();
     _multiples = new System.LinkedList<ElementRef>();
 }
Exemple #17
0
 public bool Update(long rid, ElementList sParams) 
 {
     db.SetConnection();
     ArrayList sqlList = new ArrayList();
     string sSQL1 = "UPDATE  results_rec SET ";
     string wh = " where id=" + rid.ToString();
     string sSQL = sSQL1 + sParams.ColumnEqValueList + wh;
     return db.Execute(sSQL);
 }
Exemple #18
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);
 }
        /**
         * Parses an HTML string and a string containing CSS into a list of Element objects.
         * The FontProvider will be obtained from iText's FontFactory object.
         * 
         * @param   html    a String containing an XHTML snippet
         * @param   css     a String containing CSS
         * @return  an ElementList instance
         */
        public static ElementList ParseToElementList(String html, String css) {
            // CSS
            ICSSResolver cssResolver = new StyleAttrCSSResolver();
            if (css != null) {
                ICssFile cssFile = XMLWorkerHelper.GetCSS(new MemoryStream(Encoding.Default.GetBytes(css)));
                cssResolver.AddCss(cssFile);
            }

            // HTML
            CssAppliers cssAppliers = new CssAppliersImpl(FontFactory.FontImp);
            HtmlPipelineContext htmlContext = new HtmlPipelineContext(cssAppliers);
            htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
            htmlContext.AutoBookmark(false);

            // Pipelines
            ElementList elements = new ElementList();
            ElementHandlerPipeline end = new ElementHandlerPipeline(elements, null);
            HtmlPipeline htmlPipeline = new HtmlPipeline(htmlContext, end);
            CssResolverPipeline cssPipeline = new CssResolverPipeline(cssResolver, htmlPipeline);

            // XML Worker
            XMLWorker worker = new XMLWorker(cssPipeline, true);
            XMLParser p = new XMLParser(worker);
            p.Parse(new MemoryStream(Encoding.Default.GetBytes(html)));

            return elements;
        }
Exemple #20
0
 // create a stratum 
 public long Create(ElementList sParams)
 {
     db.SetConnection();
     ArrayList sqlList = new ArrayList();
     string sSQL = InsertStratum(sParams);
     sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID("stratum_ids"));
     return db.ExecuteTransactionID(sqlList);
 }
Exemple #21
0
 public bool Update(string name, ElementList sParams)
 {
     db.SetConnection();
     long m = PrimaryKey(name);
     string sSQL1 = "UPDATE stratum_ids SET ";
     string wh = " where stratum_id = " + m.ToString();
     string sSQL = sSQL1 + sParams.ColumnEqValueList + wh;
     return db.Execute(sSQL);
 }
Exemple #22
0
 public long CreateNetComm(long id, ElementList sParams, IDB db) 
 {
     return CreateTbl(id, "LMNetComm", sParams, db);
 }
Exemple #23
0
 private string InsertStratum(ElementList sParams)
 {
     string sSQL1 = "Insert into stratum_ids " + sParams.ColumnsValues;
     return sSQL1;
 }
Exemple #24
0
 public long CreateTbl(long id, string table, ElementList sParams, IDB db) 
 {
     sParams.Add(new Element("detector_id", id));
     string sSQL1 = "Insert into " + table + " ";
     string sSQL = sSQL1 + sParams.ColumnsValues;
     
     ArrayList sqlList = new ArrayList(); 
     sqlList.Add(sSQL);
     sqlList.Add(SQLSpecific.getLastID(table));
     return db.ExecuteTransactionID(sqlList);
 }
Exemple #25
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);
        }
Exemple #26
0
 public bool UpdateTbl(long id, string table, ElementList sParams, IDB db) 
 {
     db.SetConnection();
     string sSQL1 = "UPDATE " + table + " SET ";
     string sSQL1i = String.Empty;
     string wh = " where detector_id = " + id.ToString();
     string sSQL = sSQL1 + sParams.ColumnEqValueList + wh;
     return db.Execute(sSQL);
 }
Exemple #27
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);
 }
Exemple #28
0
 public bool UpdateCfg(long id, ElementList sParams, IDB db) 
 {
     return UpdateTbl(id, "LMHWParams", sParams, db);
 }
Exemple #29
0
 public bool UpdateNetComm(long id, ElementList sParams, IDB db) 
 {
     return UpdateTbl(id, "LMNetComm", sParams, db);
 }
Exemple #30
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);
            }
        }