// ACDDlg.cpp : 实现文件 // #include "stdafx.h" #include "ACD.h" #include "ACDDlg.h" #include "afxdialogex.h" #include "AcdCore.h" #include "Config.h" #include "SoftAuther.h" #include "SoftAuth.h" #include "resource.h" #include "Resource.h" #ifdef _DEBUG #define new DEBUG_NEW #endif HWND m_MyHwnd; // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 class CAboutDlg : public CDialogEx { public: CAboutDlg(); // 对话框数据 enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 virtual BOOL OnInitDialog(); // 实现 protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BOOL CAboutDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 CStatic* pLogoCtrl = (CStatic*)GetDlgItem(IDC_STATIC_LOGO); #ifdef _VERSION_EHANG HBITMAP bm = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BMP_LOGO_EHANG)); if(bm != NULL) pLogoCtrl->SetBitmap(bm); SetDlgItemText(IDC_STATIC_ABOUT_VERSION, _T("毅航Ehangcom_ACD子系统V4.0")); SetDlgItemText(IDC_STATIC_ABOUT_RIGHT, _T("Copyright (C) 2015 广州市毅航互联通信股份有限公司")); #else pLogoCtrl->ModifyStyle(SS_BITMAP, SS_ICON); HICON Icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME)); if(Icon != NULL) pLogoCtrl->SetIcon(Icon); SetDlgItemText(IDC_STATIC_ABOUT_VERSION, _T("河南华谊中间件_ACD子系统V4.0")); SetDlgItemText(IDC_STATIC_ABOUT_RIGHT, _T("Copyright (C) 2015 河南华谊网络科技有限公司")); #endif return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // CACDDlg 对话框 CACDDlg::CACDDlg(CWnd* pParent /*=NULL*/) : CDialogEx(CACDDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CACDDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST_LOG, m_LogList); DDX_Control(pDX, IDC_TAB, m_TabItem); DDX_Control(pDX, IDC_STATIC_AUTH, m_StaticAuthMsg); } BEGIN_MESSAGE_MAP(CACDDlg, CDialogEx) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_CLOSE() ON_BN_CLICKED(IDC_BUTTON1, &CACDDlg::OnBnClickedReloadAuth) END_MESSAGE_MAP() // CACDDlg 消息处理程序 BOOL CACDDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // 将“关于...”菜单项添加到系统菜单中。 // IDM_ABOUTBOX 必须在系统命令范围内。 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 // 设置主窗口标记 ::SetProp(m_hWnd, AfxGetApp()->m_pszAppName, (HANDLE)1); if(!CAcdCore::GetInstance().stage1Start()) return FALSE; //init Tab item m_TabItem.addItem(&m_AgentPage, IDD_PAGE_AGENT); m_TabItem.addItem(&m_CallPage, IDD_PAGE_CALL); m_MyHwnd=m_hWnd; __SoftAuth(); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE } void CACDDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { if(nID == SC_CLOSE) { if(MessageBox(_T("确定要退出ACD系统吗?"), _T("提示"), MB_OKCANCEL) != IDOK) return; } CDialogEx::OnSysCommand(nID, lParam); } } // 如果向对话框添加最小化按钮,则需要下面的代码 // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序, // 这将由框架自动完成。 void CACDDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // 用于绘制的设备上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); // 使图标在工作区矩形中居中 int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // 绘制图标 dc.DrawIcon(x, y, m_hIcon); } else { CDialogEx::OnPaint(); } } //当用户拖动最小化窗口时系统调用此函数取得光标 //显示。 HCURSOR CACDDlg::OnQueryDragIcon() { return static_cast(m_hIcon); } void CACDDlg::OnClose() { // TODO: 在此添加消息处理程序代码和/或调用默认值 CAcdCore::GetInstance().exit(); ILogger::getInstance().close(); CDialogEx::OnClose(); } // void CACDDlg::__SoftAuth() // { // // SoftAuther ts; // char* CpuID=ts.GetCpuID(); // char* Passw= ts.GetKeyByNumber(CpuID); // // char psdRead[50]={0}; // ts.ReadssFile("mshy.dll",psdRead); // // CString Allstr = psdRead; // // CString cpuPsd = Allstr.Mid(0,16); // // // CTime time = CTime::GetCurrentTime(); ///构造CTime对象 // int m_nYear = time.GetYear(); ///年 // m_nYear=m_nYear-2000; // int m_nMonth = time.GetMonth(); ///月 // int m_nDay = time.GetDay(); ///日 // int SysTime=m_nYear*10000+m_nMonth*100+m_nDay; // // // CString DateCodeRead = Allstr.Mid(16,22); // char* DateRead = ts.TransCodeToDate(DateCodeRead.GetBuffer(0)); // int DateinText = atoi(DateRead); // // if (strcmp(Passw,cpuPsd)!=0||ts.CompareDate(SysTime,DateinText)) // { // SoftAuth dlg; // dlg.InitDlg(CpuID); // dlg.DoModal(); // if (!isReg) // { // this->SendMessage(WM_CLOSE); // } // else // { // ts.WritessFile("mshy.dll",Inputchar); // // ts.ReadssDateFile("mshy.dll",psdRead); // // } // } // // // CString Datestr= DateRead; // CString year="20"+Datestr.Mid(0,2); // CString month = Datestr.Mid(2,2); // CString day = Datestr.Mid(4,2); // // ILogger::getInstance().init(&m_LogList, LOG_DEV_ACD, CConfig::logFilePath()); // ILogger::getInstance().start(); // CAcdCore::GetInstance().stage2Start(); // ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("授权截至日期%s年%s月%s日"), year, month,day); // // } void CACDDlg::__SoftAuth() { m_Auther.InitAutherData("C://Windows//mshy.dll"); char* CpuID=m_Auther.GetCpuID(); char* Passw= m_Auther.GetKeyByNumber(CpuID); CString strAuth = m_Auther.GetCpuCodeAuth(); CTime time = CTime::GetCurrentTime(); ///构造CTime对象 int m_nYear = time.GetYear(); ///年 m_nYear=m_nYear-2000; int m_nMonth = time.GetMonth(); ///月 int m_nDay = time.GetDay(); ///日 int SysTime=m_nYear*10000+m_nMonth*100+m_nDay; int DateinText = m_Auther.GetDateCode(); if (0!=strcmp(Passw,strAuth)||false==m_Auther.CompareDate(SysTime,DateinText)) { SoftAuth dlg; dlg.InitDlg(CpuID); dlg.DoModal(); if (!isReg) { this->SendMessage(WM_CLOSE); } else { m_Auther.WritessFile("C://Windows//mshy.dll",Inputchar); Sleep(1000); m_Auther.InitAutherData("C://Windows//mshy.dll"); } } char chDate[50]={0}; _itoa_s(m_Auther.GetDateCode(),chDate,10); CString Datestr= chDate; CString year="20"+Datestr.Mid(0,2); CString month = Datestr.Mid(2,2); CString day = Datestr.Mid(4,2); ILogger::getInstance().init(&m_LogList, LOG_DEV_ACD, CConfig::logFilePath()); ILogger::getInstance().start(); CAcdCore::GetInstance().stage2Start(); ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("授权截至日期%s年%s月%s日"), year, month,day); ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("座席授权数量%d"),m_Auther.GetAgentCount()); CString AuthMsg; AuthMsg.Format("授权截止日期%s年%s月%s日 授权数量%d",year,month,day,m_Auther.GetAgentCount()); m_StaticAuthMsg.SetWindowText(AuthMsg); } void CACDDlg::OnBnClickedReloadAuth() { CAcdCore::GetInstance().reloadAuther(); m_Auther.InitAutherData("C://Windows//mshy.dll"); char chDate[50]={0}; _itoa_s(m_Auther.GetDateCode(),chDate,10); CString Datestr= chDate; CString year="20"+Datestr.Mid(0,2); CString month = Datestr.Mid(2,2); CString day = Datestr.Mid(4,2); ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("授权截至日期%s年%s月%s日"), year, month,day); ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("座席授权数量%d"),m_Auther.GetAgentCount()); CString AuthMsg; AuthMsg.Format("授权截止日期%s年%s月%s日 授权数量%d",year,month,day,m_Auther.GetAgentCount()); m_StaticAuthMsg.SetWindowText(AuthMsg); }