中间件标准版5.1git,去除基础模块

ACDDlg.cpp 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. // ACDDlg.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "ACD.h"
  5. #include "ACDDlg.h"
  6. #include "afxdialogex.h"
  7. #include "AcdCore.h"
  8. #include "Config.h"
  9. #include "SoftAuther.h"
  10. #include "SoftAuth.h"
  11. #include "resource.h"
  12. #include "Resource.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #endif
  16. HWND m_MyHwnd;
  17. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
  18. class CAboutDlg : public CDialogEx
  19. {
  20. public:
  21. CAboutDlg();
  22. // 对话框数据
  23. enum { IDD = IDD_ABOUTBOX };
  24. protected:
  25. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  26. virtual BOOL OnInitDialog();
  27. // 实现
  28. protected:
  29. DECLARE_MESSAGE_MAP()
  30. };
  31. CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
  32. {
  33. }
  34. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialogEx::DoDataExchange(pDX);
  37. }
  38. BOOL CAboutDlg::OnInitDialog()
  39. {
  40. CDialogEx::OnInitDialog();
  41. // TODO: 在此添加额外的初始化
  42. CStatic* pLogoCtrl = (CStatic*)GetDlgItem(IDC_STATIC_LOGO);
  43. #ifdef _VERSION_EHANG
  44. HBITMAP bm = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BMP_LOGO_EHANG));
  45. if(bm != NULL)
  46. pLogoCtrl->SetBitmap(bm);
  47. SetDlgItemText(IDC_STATIC_ABOUT_VERSION, _T("毅航Ehangcom_ACD子系统V4.0"));
  48. SetDlgItemText(IDC_STATIC_ABOUT_RIGHT, _T("Copyright (C) 2015 广州市毅航互联通信股份有限公司"));
  49. #else
  50. pLogoCtrl->ModifyStyle(SS_BITMAP, SS_ICON);
  51. HICON Icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME));
  52. if(Icon != NULL)
  53. pLogoCtrl->SetIcon(Icon);
  54. SetDlgItemText(IDC_STATIC_ABOUT_VERSION, _T("河南华谊中间件_ACD子系统V4.0"));
  55. SetDlgItemText(IDC_STATIC_ABOUT_RIGHT, _T("Copyright (C) 2015 河南华谊网络科技有限公司"));
  56. #endif
  57. return TRUE; // return TRUE unless you set the focus to a control
  58. // 异常: OCX 属性页应返回 FALSE
  59. }
  60. BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
  61. END_MESSAGE_MAP()
  62. // CACDDlg 对话框
  63. CACDDlg::CACDDlg(CWnd* pParent /*=NULL*/)
  64. : CDialogEx(CACDDlg::IDD, pParent)
  65. {
  66. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  67. }
  68. void CACDDlg::DoDataExchange(CDataExchange* pDX)
  69. {
  70. CDialogEx::DoDataExchange(pDX);
  71. DDX_Control(pDX, IDC_LIST_LOG, m_LogList);
  72. DDX_Control(pDX, IDC_TAB, m_TabItem);
  73. DDX_Control(pDX, IDC_STATIC_AUTH, m_StaticAuthMsg);
  74. }
  75. BEGIN_MESSAGE_MAP(CACDDlg, CDialogEx)
  76. ON_WM_SYSCOMMAND()
  77. ON_WM_PAINT()
  78. ON_WM_QUERYDRAGICON()
  79. ON_WM_CLOSE()
  80. ON_BN_CLICKED(IDC_BUTTON1, &CACDDlg::OnBnClickedReloadAuth)
  81. END_MESSAGE_MAP()
  82. // CACDDlg 消息处理程序
  83. BOOL CACDDlg::OnInitDialog()
  84. {
  85. CDialogEx::OnInitDialog();
  86. // 将“关于...”菜单项添加到系统菜单中。
  87. // IDM_ABOUTBOX 必须在系统命令范围内。
  88. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  89. ASSERT(IDM_ABOUTBOX < 0xF000);
  90. CMenu* pSysMenu = GetSystemMenu(FALSE);
  91. if (pSysMenu != NULL)
  92. {
  93. BOOL bNameValid;
  94. CString strAboutMenu;
  95. bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
  96. ASSERT(bNameValid);
  97. if (!strAboutMenu.IsEmpty())
  98. {
  99. pSysMenu->AppendMenu(MF_SEPARATOR);
  100. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  101. }
  102. }
  103. // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
  104. // 执行此操作
  105. SetIcon(m_hIcon, TRUE); // 设置大图标
  106. SetIcon(m_hIcon, FALSE); // 设置小图标
  107. // TODO: 在此添加额外的初始化代码
  108. // 设置主窗口标记
  109. ::SetProp(m_hWnd, AfxGetApp()->m_pszAppName, (HANDLE)1);
  110. if(!CAcdCore::GetInstance().stage1Start())
  111. return FALSE;
  112. //init Tab item
  113. m_TabItem.addItem(&m_AgentPage, IDD_PAGE_AGENT);
  114. m_TabItem.addItem(&m_CallPage, IDD_PAGE_CALL);
  115. m_MyHwnd=m_hWnd;
  116. __SoftAuth();
  117. return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
  118. }
  119. void CACDDlg::OnSysCommand(UINT nID, LPARAM lParam)
  120. {
  121. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  122. {
  123. CAboutDlg dlgAbout;
  124. dlgAbout.DoModal();
  125. }
  126. else
  127. {
  128. if(nID == SC_CLOSE)
  129. {
  130. if(MessageBox(_T("确定要退出ACD系统吗?"), _T("提示"), MB_OKCANCEL) != IDOK)
  131. return;
  132. }
  133. CDialogEx::OnSysCommand(nID, lParam);
  134. }
  135. }
  136. // 如果向对话框添加最小化按钮,则需要下面的代码
  137. // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
  138. // 这将由框架自动完成。
  139. void CACDDlg::OnPaint()
  140. {
  141. if (IsIconic())
  142. {
  143. CPaintDC dc(this); // 用于绘制的设备上下文
  144. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  145. // 使图标在工作区矩形中居中
  146. int cxIcon = GetSystemMetrics(SM_CXICON);
  147. int cyIcon = GetSystemMetrics(SM_CYICON);
  148. CRect rect;
  149. GetClientRect(&rect);
  150. int x = (rect.Width() - cxIcon + 1) / 2;
  151. int y = (rect.Height() - cyIcon + 1) / 2;
  152. // 绘制图标
  153. dc.DrawIcon(x, y, m_hIcon);
  154. }
  155. else
  156. {
  157. CDialogEx::OnPaint();
  158. }
  159. }
  160. //当用户拖动最小化窗口时系统调用此函数取得光标
  161. //显示。
  162. HCURSOR CACDDlg::OnQueryDragIcon()
  163. {
  164. return static_cast<HCURSOR>(m_hIcon);
  165. }
  166. void CACDDlg::OnClose()
  167. {
  168. // TODO: 在此添加消息处理程序代码和/或调用默认值
  169. CAcdCore::GetInstance().exit();
  170. ILogger::getInstance().close();
  171. CDialogEx::OnClose();
  172. }
  173. // void CACDDlg::__SoftAuth()
  174. // {
  175. //
  176. // SoftAuther ts;
  177. // char* CpuID=ts.GetCpuID();
  178. // char* Passw= ts.GetKeyByNumber(CpuID);
  179. //
  180. // char psdRead[50]={0};
  181. // ts.ReadssFile("mshy.dll",psdRead);
  182. //
  183. // CString Allstr = psdRead;
  184. //
  185. // CString cpuPsd = Allstr.Mid(0,16);
  186. //
  187. //
  188. // CTime time = CTime::GetCurrentTime(); ///构造CTime对象
  189. // int m_nYear = time.GetYear(); ///年
  190. // m_nYear=m_nYear-2000;
  191. // int m_nMonth = time.GetMonth(); ///月
  192. // int m_nDay = time.GetDay(); ///日
  193. // int SysTime=m_nYear*10000+m_nMonth*100+m_nDay;
  194. //
  195. //
  196. // CString DateCodeRead = Allstr.Mid(16,22);
  197. // char* DateRead = ts.TransCodeToDate(DateCodeRead.GetBuffer(0));
  198. // int DateinText = atoi(DateRead);
  199. //
  200. // if (strcmp(Passw,cpuPsd)!=0||ts.CompareDate(SysTime,DateinText))
  201. // {
  202. // SoftAuth dlg;
  203. // dlg.InitDlg(CpuID);
  204. // dlg.DoModal();
  205. // if (!isReg)
  206. // {
  207. // this->SendMessage(WM_CLOSE);
  208. // }
  209. // else
  210. // {
  211. // ts.WritessFile("mshy.dll",Inputchar);
  212. //
  213. // ts.ReadssDateFile("mshy.dll",psdRead);
  214. //
  215. // }
  216. // }
  217. //
  218. //
  219. // CString Datestr= DateRead;
  220. // CString year="20"+Datestr.Mid(0,2);
  221. // CString month = Datestr.Mid(2,2);
  222. // CString day = Datestr.Mid(4,2);
  223. //
  224. // ILogger::getInstance().init(&m_LogList, LOG_DEV_ACD, CConfig::logFilePath());
  225. // ILogger::getInstance().start();
  226. // CAcdCore::GetInstance().stage2Start();
  227. // ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("授权截至日期%s年%s月%s日"), year, month,day);
  228. //
  229. // }
  230. void CACDDlg::__SoftAuth()
  231. {
  232. m_Auther.InitAutherData("C://Windows//mshy.dll");
  233. char* CpuID=m_Auther.GetCpuID();
  234. char* Passw= m_Auther.GetKeyByNumber(CpuID);
  235. CString strAuth = m_Auther.GetCpuCodeAuth();
  236. CTime time = CTime::GetCurrentTime(); ///构造CTime对象
  237. int m_nYear = time.GetYear(); ///年
  238. m_nYear=m_nYear-2000;
  239. int m_nMonth = time.GetMonth(); ///月
  240. int m_nDay = time.GetDay(); ///日
  241. int SysTime=m_nYear*10000+m_nMonth*100+m_nDay;
  242. int DateinText = m_Auther.GetDateCode();
  243. if (0!=strcmp(Passw,strAuth)||false==m_Auther.CompareDate(SysTime,DateinText))
  244. {
  245. SoftAuth dlg;
  246. dlg.InitDlg(CpuID);
  247. dlg.DoModal();
  248. if (!isReg)
  249. {
  250. this->SendMessage(WM_CLOSE);
  251. }
  252. else
  253. {
  254. m_Auther.WritessFile("C://Windows//mshy.dll",Inputchar);
  255. Sleep(1000);
  256. m_Auther.InitAutherData("C://Windows//mshy.dll");
  257. }
  258. }
  259. char chDate[50]={0};
  260. _itoa_s(m_Auther.GetDateCode(),chDate,10);
  261. CString Datestr= chDate;
  262. CString year="20"+Datestr.Mid(0,2);
  263. CString month = Datestr.Mid(2,2);
  264. CString day = Datestr.Mid(4,2);
  265. ILogger::getInstance().init(&m_LogList, LOG_DEV_ACD, CConfig::logFilePath());
  266. ILogger::getInstance().start();
  267. CAcdCore::GetInstance().stage2Start();
  268. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("授权截至日期%s年%s月%s日"), year, month,day);
  269. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("座席授权数量%d"),m_Auther.GetAgentCount());
  270. CString AuthMsg;
  271. AuthMsg.Format("授权截止日期%s年%s月%s日 授权数量%d",year,month,day,m_Auther.GetAgentCount());
  272. m_StaticAuthMsg.SetWindowText(AuthMsg);
  273. }
  274. void CACDDlg::OnBnClickedReloadAuth()
  275. {
  276. CAcdCore::GetInstance().reloadAuther();
  277. m_Auther.InitAutherData("C://Windows//mshy.dll");
  278. char chDate[50]={0};
  279. _itoa_s(m_Auther.GetDateCode(),chDate,10);
  280. CString Datestr= chDate;
  281. CString year="20"+Datestr.Mid(0,2);
  282. CString month = Datestr.Mid(2,2);
  283. CString day = Datestr.Mid(4,2);
  284. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("授权截至日期%s年%s月%s日"), year, month,day);
  285. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("座席授权数量%d"),m_Auther.GetAgentCount());
  286. CString AuthMsg;
  287. AuthMsg.Format("授权截止日期%s年%s月%s日 授权数量%d",year,month,day,m_Auther.GetAgentCount());
  288. m_StaticAuthMsg.SetWindowText(AuthMsg);
  289. }