public SmcErr Load(XmlElement monitorConfigElement)
{
NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
logEx.Trace("Enter: TiandyVideoMonitor.Load().");
SmcErr err = new CgwError();
string userLevel = "";
//解析xml节点,获取所需参数
try
{
#region Tiandy视频监控平台(Easy7)连接信息
this.monitorId = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.ID_TAG);
userLevel = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PTZCONTROLLEVEL_TAG);
string httpUser = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PLATFORM_USER_TAG);
string httpPassword = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PLATFORM_PASSWORD_TAG);
string httpUrl = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.PLATFORM_URL_TAG);
string mediaServerId = CommonFunction.GetSingleNodeValue(monitorConfigElement, CgwConst.MEDIASERVER_SERVERID_TAG);
#endregion
this.httpClient = new TiandyHttpClient(httpUrl, httpUser, httpPassword);
//使用线程轮询加载监控平台
Thread loaderThread = new Thread(LoaderThread);
loaderThread.Start(mediaServerId);
}
catch (Exception e)
{
err.SetErrorNo(CgwError.MONITOR_CONFIG_FILE_INVALID);
logEx.Error("Load Tiandy monitor failed.Execption message:{0}.", e.Message);
return err;
}
this.sdkClient = new TiandySdkClient();
//如果控制级别配置错误,只记录错误日志,不向外报错
try
{
this.sdkClient.PtzControlLevel = int.Parse(userLevel);
}
catch (Exception e)
{
logEx.Error("Ptz Control Level is invalid.Execption message:{0}.", e.Message);
this.sdkClient.PtzControlLevel = CgwConst.PTZ_CONTROL_LEVEL;
}
logEx.Info("Load video monitor success.Monitor id:{0}.", this.monitorId);
return err;
}