⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manager.cpp

📁 电信机房MDF、电源柜监控源码,主要用在通信机房配线设备监控、电源柜监控
💻 CPP
字号:
// Manager.cpp: implementation of the CManager class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "mdf.h"
#include "Manager.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
extern CMDFApp theApp ;
//##ModelId=44B6F885039B
CManager::CManager()
{

}

//##ModelId=44B6F885039C
CManager::~CManager()
{

}

//##ModelId=44B6F885039A
int CManager::InitMan()
{
	CString strTable1,strSQL ;
	CString strStep ;
	CString strTip ;
	int nResult=0 ;
	int nState ;
	sPerson f_Person ;

	_variant_t var;
	_RecordsetPtr pRsPtr1 ;

	try
	{
		pRsPtr1.CreateInstance(__uuidof(Recordset));

		strTable1 = "CMTSysUser" ; //监测模块表

		strSQL.Format("SELECT * FROM %s",strTable1) ;

		strStep = "异常:初始化 管理员 " ;

		strTip = strStep + "读表 CMTSysUser 出错:" ;

		if( theApp.m_pAdoDB->ReadDB(strSQL, pRsPtr1,strTip) != 0 )//读监测模块表
			return -1 ;

		if( pRsPtr1->adoEOF ) //监测设备
		{
			strTip = strStep + "读表 CMTSysUser 中无任何管理人员数据,请先录入" ; 
			theApp.OutPut(strTip) ;
			return -1 ;
		}

		while( ! pRsPtr1->adoEOF )
		{
			//获取告警通讯标志 AlarmFlag
			strTip = strStep + "读表 CMTSysUser 的 告警通讯标志 出错:" ;

			if( theApp.m_pAdoDB->GetRdData( "AlarmFlag", pRsPtr1,var,strTip ) != 0 )
			{
					nResult++ ;
					pRsPtr1->MoveNext() ;
					continue ;
			}
			else
			{
				strTip = (LPCSTR)_bstr_t(var) ;

				if( strTip.Find("1") >= 0 )//短信
					f_Person.bFMsg = TRUE ;
				else
					f_Person.bFMsg = FALSE ;

				if( strTip.Find("2") >= 0 )//电话
					f_Person.bFPhone = TRUE ;
				else
					f_Person.bFPhone = FALSE ;

				if( strTip.Find("3") >= 0 )//手机
					f_Person.bFMobile = TRUE ;
				else
					f_Person.bFMobile = FALSE ;

				if( !f_Person.bFMsg && !f_Person.bFMobile && !f_Person.bFPhone )
				{
					//不需通讯的人员将跳过
					pRsPtr1->MoveNext() ;
					continue ;
				}
			}

			//获得管理员ID
			strTip = strStep + "读表 CMTSysUser 的 管理人员ID号 出错:" ;

			if( theApp.m_pAdoDB->GetRdData( "UserID", pRsPtr1,var,strTip ) != 0 )
			{
					nResult++ ;
					nState = 1 ;
					f_Person.nID = -1 ;
			}
			else
				theApp.m_pAdoDB->GetIntVar(var,f_Person.nID,strTip) ;

			//获取管理员真实姓名
			if( theApp.m_pAdoDB->GetRdData( "TrueName", pRsPtr1,var,strTip ) != 0 )
			{
					strTip = strStep + "读表 CMTSysUser 的 真实姓名 出错:" + theApp.m_pAdoDB->m_strError ; 
					theApp.OutPut(strTip) ;
					nResult++ ;
					nState = 1 ;
					f_Person.strName = "未知" ;
			}
			else
				theApp.m_pAdoDB->GetStrVar(var,f_Person.strName,strTip) ;

			strStep.Format("异常:初始化 管理员 %s ",f_Person.strName) ;
			//获取管理员的电话号码
			if( theApp.m_pAdoDB->GetRdData( "Phone", pRsPtr1,var,strTip ) != 0 )
			{
					strTip = strStep + "读表 CMTSysUser 的 电话号码 出错:" + theApp.m_pAdoDB->m_strError ; 
					theApp.OutPut(strTip) ;
					nResult++ ;
					nState = 1 ;
					f_Person.strPhone = "未知" ;
			}
			else
			{
				theApp.m_pAdoDB->GetStrVar(var,f_Person.strPhone,strTip) ;
				if( f_Person.strPhone.IsEmpty() )
					f_Person.strPhone = "未知" ;
			}
			
			//获取管理员的手机号码
			strTip = strStep + "读表 CMTSysUser 的 手机号码 出错:" ;
			if( theApp.m_pAdoDB->GetRdData( "Mobile", pRsPtr1,var,strTip ) != 0 )
			{
				nResult++ ;
				nState = 1 ;
				f_Person.strMobile = "未知" ;
			}
			else
			{
				theApp.m_pAdoDB->GetStrVar(var,f_Person.strMobile,strTip) ;
				if(f_Person.strMobile.IsEmpty())
					f_Person.strMobile = "未知" ;
			}
			
			if( f_Person.bFMsg && f_Person.strMobile == "未知" )
			{
				strTip = strStep + "未能取得 表 CMTSysUser 中的 手机号码 将无法进行\"手机短信\"告警通知! " ;
				theApp.OutPut(strTip) ;
				f_Person.bFMsg = FALSE ;
			}

			if( f_Person.bFPhone && f_Person.strPhone == "未知" )
			{
				strTip = strStep + "未能取得 表 CMTSysUser 中的 电话号码 将无法进行\"电话语音\"告警通知! " ;
				theApp.OutPut(strTip) ;
				f_Person.bFPhone = FALSE ;
			}

			if( f_Person.bFMobile && f_Person.strMobile == "未知" )
			{
				strTip = strStep + "未能取得 表 CMTSysUser 中的 手机号码 将无法进行\"手机语音\"告警通知! " ;
				theApp.OutPut(strTip) ;
				f_Person.bFMobile = FALSE ;
			}

			if( !f_Person.bFMsg && !f_Person.bFMobile && !f_Person.bFPhone)
			{
				//不需通讯的人员将跳过
				pRsPtr1->MoveNext() ;
				continue ;
			}
			else
			{
				
				m_sManager.AddTail(f_Person) ;
				strTip.Format("* 系统:管理员 %s 手机 %s 加载成功",f_Person.strName,f_Person.strMobile) ;
				theApp.DebugShow(strTip) ;

				strTip.Format("系统:加载管理员 %s ",f_Person.strName) ;

				if(!f_Person.strPhone.IsEmpty())
					strTip += "固话:" + f_Person.strPhone + " " ;
				if(!f_Person.strMobile.IsEmpty())
					strTip += "手机:" + f_Person.strMobile + " " ;

				strTip += "接受告警:" ;

				if(f_Person.bFMsg)
					strTip += "短信|" ;
				if(f_Person.bFPhone)
					strTip += "固话语音|" ;
				if(f_Person.bFMobile)
					strTip += "手机语音|" ;

				theApp.OutPut(strTip) ;
				pRsPtr1->MoveNext() ;
			}
		}
		pRsPtr1->Close() ;
		return 0 ;
	}
	catch(_com_error e)
	{
		strTip.Format( "%s 产生未知异常系统将无法正常运行:%s ",strStep,(LPCSTR)e.Description() ) ;
		theApp.OutPut(strTip);
		theApp.Show( strTip ) ;
		return -1 ;
	}	
}

//##ModelId=44B6F8850399
int CManager::FreeMan()
{
	CString strTip ;
	strTip.Format("系统:清除所有管理人员") ;

	theApp.OutPut(strTip) ;
	theApp.Show(strTip) ;
	if( m_sManager.GetCount() >0 )
	{
		m_sManager.RemoveAll() ;
		return 0 ;
	}
	else
		return -1 ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -