//实时数据库logoff public static void disconnect() { ErrorFlag = false; ErrorInfo = ""; //——实时数据库使用长连接的情况下,需要logoff DBInterface.RTDBInterface.LongPI.RTDbHelper rtdbhelperpi = null; DBInterface.RTDBInterface.LongPGIM.RTDbHelper rtdbhelperpgim = null; DBInterface.RTDBInterface.LongXIANDB.RTDbHelper rtdbhelperxiandb = null; try { //每次执行,都是在新的线程中,这个方式,PGIM会不会有问题,要测试 //关于异常处理方式的说明: //——总体原则1:不在helper层处理异常,将异常放到DAO层处理。 if (APPConfig.rtdb_Type == "PI") //PI数据库的情况下,使用PI长连接类 { rtdbhelperpi = new DBInterface.RTDBInterface.LongPI.RTDbHelper(); rtdbhelperpi.Logoff(); } else if (APPConfig.rtdb_Type == "PGIM") //PGIM数据库的情况下,使用PI长连接类 { rtdbhelperpgim = new DBInterface.RTDBInterface.LongPGIM.RTDbHelper(); rtdbhelperpgim.Logoff(); } else if (APPConfig.rtdb_Type == "PI") //PGIM数据库的情况下,使用PI长连接类 { rtdbhelperpi = new DBInterface.RTDBInterface.LongPI.RTDbHelper(); rtdbhelperpi.Logoff(); } else if (APPConfig.rtdb_Type == "XIANDB") //PGIM数据库的情况下,使用PI长连接类 { rtdbhelperxiandb = new DBInterface.RTDBInterface.LongXIANDB.RTDbHelper(); rtdbhelperxiandb.Logoff(); } else { } } catch (Exception ex) { ErrorFlag = true; //RTDBHelper在底层(pgimhelper、goldenhelper)对异常进行处理,将异常信息记录到rtdbhelper.Exception中,并将异常转发 //在这里,如果Exception不为nulll,则说明底层捕捉到了异常信息,应该将底层捕捉到的Exception计入log //如果Exception为null,则说明底层没有捕捉到异常信息。这里应该记录ex内容 string messageStr; messageStr = String.Format("DAO层readRTDBData()错误:---------->"); 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 { } if (exceptionStr != null) { } else { messageStr = String.Format("错误信息:disconnect()未知错误。{0}", ex.ToString()); } logHelper.Error(messageStr); } }