/// <summary>
/// 消息队列
/// </summary>
public MessageHandlerQueue _msgHdl;
public MessageHandlerQueue MsgHandle
{
get
{
if (_msgHdl == null)
{
_msgHdl = new MessageHandlerQueue(ThreadFun);
_msgHdl.Start();
return _msgHdl;
}
else
return _msgHdl;
}
private set
{
_msgHdl = value;
}
}
#region 消息队列函数
private void ThreadFun(object msg)
{
try
{
var dev = msg as CfgObjectDevice;
if (dev != null)
{
if (devDao != null)
{
//devDao.SaveOrUpdate(dev);
int isOnline = dev.IsOnline ? 1 : 0;
var sqlStr = string.Format("UPDATE cfg_object_device SET is_online = {0} WHERE object_id = {1}", isOnline, dev.ObjectId);
devDao.ExecSQL(sqlStr);
}
return;
}
var mod = msg as CfgObjectModule;
if (mod != null)
{
if (moduleDao != null)
{
//moduleDao.SaveOrUpdate(mod);
int isOnline = mod.IsOnline ? 1 : 0;
var sqlStr = string.Format("UPDATE cfg_object_module SET is_online = {0} WHERE object_id = {1}", isOnline, mod.ObjectId);
moduleDao.ExecSQL(sqlStr);
}
return;
}
var sys = msg as CfgObjectSubsystem;
if (sys != null)
{
if (subsysDao != null)
{
//subsysDao.SaveOrUpdate(sys);
int link_status = 0;
if (sys.LinkStatus == "1")
link_status = 1;
else if (sys.LinkStatus == "0")
link_status = 0;
var sqlStr = string.Format("UPDATE cfg_object_subsystem SET link_status = {0} WHERE object_id = {1}", link_status, sys.ObjectId);
subsysDao.ExecSQL(sqlStr);
}
return;
}
var entity = msg as HisAlarm;
if (entity != null)
{
if (alarmDao != null)
{
alarmDao.SaveOrUpdate(entity);
}
return;
}
var cfgTypeAlarm = msg as CfgTypeAlarm;
if (cfgTypeAlarm != null)
{
if (cfgTypeAlarmDao != null)
{
cfgTypeAlarmDao.SaveOrUpdate(cfgTypeAlarm);
}
return;
}
LogHelper.GetLog("Server").ErrorFormat("{0} 类型没有处理", msg.GetType());
}
catch (Exception ex)
{
LogHelper.GetLog("Server").Error(ExceptionHelper.GetExceptionDesc(ex));
}
}