コード例 #1
0
        public static List <DBInterface.RTDBInterface.SignalComm> ReadTagList(string filter)
        {
            List <DBInterface.RTDBInterface.SignalComm> results = new List <DBInterface.RTDBInterface.SignalComm>();

            DBInterface.RTDBInterface.LongPI.RTDbHelper   rtdbhelperpi   = null;
            DBInterface.RTDBInterface.LongPGIM.RTDbHelper rtdbhelperpgim = null;
            DBInterface.RTDBInterface.RTDbHelper          rtdbhelper     = null;

            try
            {
                string tagfilter = filter;              //这条语句经过测试可用。会返回所有标签

                if (APPConfig.rtdb_Type == "PI")        //PI数据库的情况下,使用PI长连接类
                {
                    rtdbhelperpi = new DBInterface.RTDBInterface.LongPI.RTDbHelper();
                    results      = rtdbhelperpi.GetTagList(tagfilter);
                }
                else if (APPConfig.rtdb_Type == "PGIM") //PGIM数据库的情况下,使用PI长连接类
                {
                    rtdbhelperpgim = new DBInterface.RTDBInterface.LongPGIM.RTDbHelper();
                    results        = rtdbhelperpgim.GetTagList(tagfilter);
                }
                else
                {
                    rtdbhelper = new DBInterface.RTDBInterface.RTDbHelper();
                    results    = rtdbhelper.GetTagList(tagfilter);
                }

                return(results);
            }
            catch (Exception ex)
            {
                ErrorFlag = true;
                //RTDBHelper在底层(pgimhelper、goldenhelper)对异常进行处理,将异常信息记录到rtdbhelper.Exception中,并将异常转发
                //在这里,如果Exception不为nulll,则说明底层捕捉到了异常信息,应该将底层捕捉到的Exception计入log
                //如果Exception为null,则说明底层没有捕捉到异常信息。这里应该记录ex内容
                string messageStr;
                messageStr = String.Format("DAO层ReadTagList()错误:---------->");
                logHelper.Error(messageStr);

                string exceptionStr = "";

                if (APPConfig.rtdb_Type == "PI")        //PI数据库的情况下,使用PI长连接类
                {
                    exceptionStr = rtdbhelperpi.Exception;
                }
                else if (APPConfig.rtdb_Type == "PGIM") //PGIM数据库的情况下,使用PI长连接类
                {
                    exceptionStr = rtdbhelperpgim.Exception;
                }
                else
                {
                    exceptionStr = rtdbhelper.Exception;
                }

                if (exceptionStr != null)
                {
                    messageStr = String.Format("错误信息:rtdbhelper.GetTagList()错误。{0}", rtdbhelper.Exception);
                }
                else
                {
                    messageStr = String.Format("错误信息:ReadTagList()未知错误。{0}", ex.ToString());
                }
                logHelper.Error(messageStr);
                return(null);
            }
        }