BOOL CDlgHistoryLogUser::InitControl() { // 查询结果列表中需要显示的列包括了:开始时间、结束时间、摄像头名称、 DWORD dwStyle; dwStyle = m_ListCtrl_UserLog.GetStyle(); dwStyle = LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT; m_ListCtrl_UserLog.SetExtendedStyle(dwStyle); InitControlList(); m_strNodeName = "全部用户"; // m_ComboType.InsertString(0, "所有类型"); m_ComboType.InsertString(0,"管理端操作"); m_ComboType.InsertString(1,"客户端操作"); m_ComboType.InsertString(2,"辅助管理端操作"); m_ComboType.SetCurSel(0); m_ComboSubType.InsertString(0, "所有分类型"); m_ComboSubType.SetCurSel(0); CTime nowtime = CTime::GetCurrentTime(); CTime StartTime(nowtime.GetYear(), nowtime.GetMonth(),nowtime.GetDay(), 0, 0, 0); CTime StopTime(nowtime.GetYear(), nowtime.GetMonth(), nowtime.GetDay(), 23, 59, 59); //开始时间初始化 m_StartDay = StartTime; m_StartTime = StartTime; m_StopDay = StopTime; m_StopTime = StopTime; UpdateData(FALSE); return TRUE; }
BOOL CDlgHistoryLogUser::SearchAndSetHistoryListInfo(char *szStartTime,char *szStopTime,char *szSelectUserName) { if (szStartTime == NULL||szStopTime == NULL) return FALSE; InitControlList(); char sql_buf[512] = {0}; bool result=false; char szYear[8] = {0}; int nYear = 2013; MYSQL_RES * res = NULL ; MYSQL_ROW row ; char szUserName[256] = {0}; char szIpAddress[64] = {0}; char szDateTime[64] = {0}; char szOperateType[64] = {0}; char szDbTableName[256] = {0}; char szNotes[512] = {0}; int nOperateType = 0; COLORREF BKColor; COLORREF TextColor; BKColor = RGB(207,235,250); TextColor = RGB(168,0,0); szYear[0] = szStartTime[0]; szYear[1] = szStartTime[1]; szYear[2] = szStartTime[2]; szYear[3] = szStartTime[3]; szYear[4] = 0; nYear = atoi(szYear); int nCount = 0; int nLoginType = g_userpower.logintype; int nUserType = g_userpower.usertype; int nUserID = g_userpower.userID; if (strcmp(szSelectUserName,"全部用户") == 0) { //读用户操作历史日志 if (nLoginType == VM_USER_TYPE_SD_LOGIN) { if(nUserType == VM_USER_TYPE_SD_SJ_LEADER||nUserType == VM_USER_TYPE_SD_SJ_ADMIN) { sprintf_s(sql_buf, sizeof(sql_buf),"SELECT t1.user_name, t1.ip_addr, t1.time, t1.operate_type, t1.db_name, t1.notes " "FROM history_manager_operate_log_%04d AS t1,ct_user AS t2 WHERE t2.login_type=0 AND t1.user_name=t2.user_name AND t1.time >= '%s' AND t1.time <= '%s' ORDER BY t1.time desc",nYear,szStartTime,szStopTime); } else { sprintf_s(sql_buf, sizeof(sql_buf),"SELECT user_name, ip_addr, time, operate_type, db_name, notes " "FROM history_manager_operate_log_%04d where time >= '%s' AND time <= '%s' AND user_name='%s' ORDER BY time desc",nYear,szStartTime,szStopTime,g_userpower.username); } } else if (nLoginType == VM_USER_TYPE_SJ_LOGIN) { if(nUserType == VM_USER_TYPE_SD_SJ_LEADER||nUserType == VM_USER_TYPE_SD_SJ_ADMIN) { sprintf_s(sql_buf, sizeof(sql_buf),"SELECT t1.user_name, t1.ip_addr, t1.time, t1.operate_type, t1.db_name, t1.notes " "FROM history_manager_operate_log_%04d AS t1,ct_user AS t2 WHERE t2.login_type=1 AND t1.user_name=t2.user_name AND t1.time >= '%s' AND t1.time <= '%s' ORDER BY t1.time desc",nYear,szStartTime,szStopTime); } else { sprintf_s(sql_buf, sizeof(sql_buf),"SELECT user_name, ip_addr, time, operate_type, db_name, notes " "FROM history_manager_operate_log_%04d where time >= '%s' AND time <= '%s' AND user_name='%s' ORDER BY time desc",nYear,szStartTime,szStopTime,g_userpower.username); } } else if (nLoginType == VM_USER_TYPE_ADMIN_LOGIN) { sprintf_s(sql_buf, sizeof(sql_buf),"SELECT t1.user_name, t1.ip_addr, t1.time, t1.operate_type, t1.db_name, t1.notes " "FROM history_manager_operate_log_%04d AS t1,ct_user AS t2 WHERE t1.user_name=t2.user_name AND t1.time >= '%s' AND t1.time <= '%s' ORDER BY t1.time desc",nYear,szStartTime,szStopTime); } else { return FALSE; } } else { //读用户操作历史日志 sprintf_s(sql_buf, sizeof(sql_buf),"SELECT user_name, ip_addr, time, operate_type, db_name, notes " "FROM history_manager_operate_log_%04d where time >= '%s' AND time <= '%s' AND user_name='%s' ORDER BY time desc",nYear,szStartTime,szStopTime,szSelectUserName); } if (!mysql_query(g_mySqlData, sql_buf)) { res = mysql_store_result(g_mySqlData); while ( row = mysql_fetch_row( res ) ) { if (nCount >= 1000) { MessageBox("用户操作日志超过1000条,超出部分无法显示。\r\n请缩小查询范围。","热点视频监视"); break; } sprintf_s(szUserName,"%s", row[0]); sprintf_s(szIpAddress, "%s", row[1]); sprintf_s(szDateTime, "%s", row[2]); nOperateType = atoi(row[3]); sprintf_s(szDbTableName,"%s",row[4]); sprintf_s(szNotes,"%s",row[5]); switch (nOperateType) { case 1: { sprintf_s(szOperateType,"%s","添加"); } break; case 2: { sprintf_s(szOperateType,"%s","修改"); } break; case 3: { sprintf_s(szOperateType,"%s","删除"); } break; default: { sprintf_s(szOperateType,"%s","未知"); } break; } m_ListCtrl_UserLog.InsertItem(nCount,szUserName); m_ListCtrl_UserLog.SetItemText(nCount,1,szIpAddress); m_ListCtrl_UserLog.SetItemText(nCount,2,szDateTime); m_ListCtrl_UserLog.SetItemText(nCount,3,szOperateType); m_ListCtrl_UserLog.SetItemText(nCount,4,szDbTableName); m_ListCtrl_UserLog.SetItemText(nCount,5,szNotes); m_ListCtrl_UserLog.SetRowColor(nCount,BKColor); m_ListCtrl_UserLog.SetRowTextColor(nCount,TextColor); nCount++; } mysql_free_result( res ) ; } if (m_ListCtrl_UserLog.GetItemCount() == 0) { m_ListCtrl_UserLog.InsertItem(nCount,"无"); m_ListCtrl_UserLog.SetItemText(nCount,1,"无"); m_ListCtrl_UserLog.SetItemText(nCount,2,"无"); m_ListCtrl_UserLog.SetItemText(nCount,3,"无"); m_ListCtrl_UserLog.SetItemText(nCount,4,"无"); m_ListCtrl_UserLog.SetItemText(nCount,5,"无"); } return TRUE; }
// Build the screen LTBOOL CScreenConfigure::Build() { CreateTitle(IDS_TITLE_CONFIGURE); m_nActionWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"ActionWidth"); m_nEqualsWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"EqualsWidth"); m_nCommandWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"CommandWidth"); m_ListRect = g_pLayoutMgr->GetScreenCustomRect(SCREEN_ID_CONFIGURE,"ListRect"); m_nListFontSize = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_CONFIGURE,"ListFontSize"); int nWidth = GetPageRight() - GetPageLeft(); LTIntPt topPos = g_pLayoutMgr->GetScreenCustomPoint(SCREEN_ID_CONFIGURE,"MoveControlPos"); CLTGUITextCtrl *pCtrl = AddTextItem(IDS_MOVE_CONTROLS,CMD_MOVE_COM,LTNULL,topPos); pCtrl->SetFixedWidth(nWidth); pCtrl = AddTextItem(IDS_INV_CONTROLS,CMD_INV_COM,LTNULL); pCtrl->SetFixedWidth(nWidth); pCtrl = AddTextItem(IDS_VIEW_CONTROLS,CMD_VIEW_COM,LTNULL); pCtrl->SetFixedWidth(nWidth); pCtrl = AddTextItem(IDS_MISC_CONTROLS,CMD_MISC_COM,LTNULL); pCtrl->SetFixedWidth(nWidth); LTIntPt pos(m_ListRect.left,m_ListRect.top); int nHt = m_ListRect.bottom - m_ListRect.top; int nWd = m_nActionWidth + m_nEqualsWidth + m_nCommandWidth; char szFrame[128]; g_pLayoutMgr->GetScreenCustomString(SCREEN_ID_CONFIGURE,"FrameTexture",szFrame,sizeof(szFrame)); HTEXTURE hFrame = g_pInterfaceResMgr->GetTexture(szFrame); m_pFrame = debug_new(CLTGUIFrame); m_pFrame->Create(hFrame,nWd,nHt+8,LTTRUE); m_pFrame->SetBasePos(pos); AddControl(m_pFrame); for (int nType = 0; nType < kNumCommandTypes; nType++) { m_pList[nType] = AddList(pos,nHt); m_pList[nType]->SetFrameWidth(2); m_pList[nType]->SetIndent(LTIntPt(4,4)); m_pList[nType]->Show(LTFALSE); pCtrl = LTNULL; switch (nType) { case COM_MOVE: pCtrl = CreateTextItem(IDS_MOVE_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE); break; case COM_INV: pCtrl = CreateTextItem(IDS_INV_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE); break; case COM_VIEW: pCtrl = CreateTextItem(IDS_VIEW_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE); break; case COM_MISC: pCtrl = CreateTextItem(IDS_MISC_CONTROLS,LTNULL,LTNULL,kDefaultPos,LTTRUE); break; } if (pCtrl) m_pList[nType]->AddControl(pCtrl); } InitControlList(); // Make sure to call the base class if (! CBaseScreen::Build()) return LTFALSE; UseBack(LTTRUE,LTTRUE); return LTTRUE; }