Esempio n. 1
0
        public static List <L1tag> GetTagList()
        {
            if (listTag == null)
            {
                listTag = new List <L1tag>();
                //string sql = "select id,type from  L1OPC_TAG where used=1  order by id ";
                //var dt = new sqlDbHelp().Query(sql);

                string sql = "select xuhao as id,type  L1OPC_TAG where used=1  order by id ";
                //DbMySql.GetDataTable(sql);
                //var dt = new sqlDbHelp().Query(sql);
                var dt = DbMySql.GetDataTable(sql);

                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        L1tag tag = new L1tag();
                        tag.id = Convert.ToInt16(item["id"]);
                        //tag.name = item["name"].ToString();
                        //tag.scanrate = Convert.ToInt16(item["scanrate"]);
                        //tag.datatype = Convert.ToInt16(item["datatype"]);
                        tag.type = Convert.ToInt16(item["type"]);
                        //tag.lasttime = DateTime.Now.AddHours(-2);
                        listTag.Add(tag);
                    }
                }
            }
            return(listTag);
        }
Esempio n. 2
0
 /// <summary>
 /// 加载变量表
 /// </summary>
 public void loadValList()
 {
     try
     {
         string sql = "select xuhao as id,L1name as name,scanrate,datatype from  L1OPC_TAG where used=1 and type=" + type + " order by id ";
         //DbMySql.GetDataTable(sql);
         //var dt = new sqlDbHelp().Query(sql);
         var dt = DbMySql.GetDataTable(sql);
         listTag = dt_to_list(dt);
     }
     catch (Exception ex)
     {
         SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "--loadValList方法加载变量列表时出错" + ex.ToString());
         throw new Exception("加载变量列表时出错:" + ex.ToString());
     }
 }