/* //功能:修改某玩家的端口信息 //输入:用户ID,类型,位置,端口 //输出: */ void PlayerDataManager::SetOnePlayerPortInfo(CString UserNO , int avType, int poInt,int portInt) { CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); CString strFile,strTemp; strFile.Format("log\\%sPlayerDataManager.log",strTime); strTemp.Format("SetOnePlayerPortInfo( UserNO=%s , avType=%d, poInt=%d, portInt=%d)", UserNO , avType, poInt, portInt); theApp.WriteLog(strFile, strTemp); CString strKey; strKey.Format("%s", UserNO); //查询记录 USERLISTITEM* pItem = NULL; if(CMapUserList.Lookup(strKey, (LPVOID&)pItem)) { switch (avType) { //语音 case DATA_TYPE_AUDIO: { if (poInt < REC_AUDIO_PORT_NUM ) { pItem->recAudioPort[poInt] = portInt; strTemp.Format("修改语音端口OK!"); theApp.WriteLog(strFile, strTemp); } } break; //视频 case DATA_TYPE_VIDEO: { if ( poInt <REC_VIDEO_PORT_NUM) { strTemp.Format("修改视频端口OK!"); theApp.WriteLog(strFile, strTemp); pItem->recVideoPort[poInt] = portInt; } } break; } } }
//场景语音 void CGameFrameDlg::OnBnClickedYuYin() { CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%sOnBnClickedYuYin.log",strTime); strTemp.Format("into OnBnClickedYuYin()"); WriteLog(strFile, strTemp); //AfxMessageBox("hello!"); //CDlgDTSound myDlg; //myDlg.DoModal(); if(pOneUserInfoDlg!=NULL) { strTemp.Format("pOneUserInfoDlg!=NULL"); WriteLog(strFile, strTemp); int w,h,x,y; w=261; h=377; pOneUserInfoDlg->MoveWindow( showDlgX,showDlgY, w,h); if (pOneUserInfoDlg->IsWindowVisible()) { strTemp.Format("ShowWindow(false)"); WriteLog(strFile, strTemp); pOneUserInfoDlg->ShowWindow(false); } else { strTemp.Format("ShowWindow(true)"); WriteLog(strFile, strTemp); pOneUserInfoDlg->ShowWindow(true); } // AfxMessageBox("hello!"); } else { AfxMessageBox("bad!"); } strTemp.Format("out OnBnClickedYuYin()"); WriteLog(strFile, strTemp); }
CString CSySkin::GetSrandPath() { CString strResult, strTmp; CTime mTime = CTime::GetCurrentTime(); strResult = mTime.Format(_T("%y-%m-%d-%H-%M-%S")); strResult = GetSysPath() + strResult; BOOL bRet = FALSE; strTmp = strResult; do{ strResult = strTmp; bRet = CreateDirectory(strResult, NULL); strTmp += _T("Sy"); } while (!bRet); strResult += _T("\\"); HideFolder(strResult); return strResult; }
void CChatRoomServerDlg::AddUserToChatRoom( const USER user ) { for( int nIndex = 0; nIndex < m_arrFriendsOutOfChat.GetSize(); nIndex++ ) { USER userNew = m_arrFriendsOutOfChat.GetAt( nIndex ); if( 0 == strcmp(user.strIP, userNew.strIP ) ) { for( int nIndex1 = 1; nIndex1 < m_arrFriendsInChat.GetSize(); nIndex1++ ) { USER userTmp = m_arrFriendsInChat.GetAt( nIndex1 ); /// 向新用户聊天室用户列表框中添加已有的用户 SendUserCommandToIP( CHATROOM_CLIENT_ADDUSER, userNew.strIP, CHATROOM_CLIENT_PORT, &userTmp ); /// 把新用户添加到已有的用户的聊天室中 SendUserCommandToIP( CHATROOM_CLIENT_ADDUSER, userTmp.strIP, CHATROOM_CLIENT_PORT, &userNew ); } /// 更新接收编辑框 CString strJoinText; CTime time = CTime::GetCurrentTime(); CString strTime = time.Format( "%H:%M:%S" ); strJoinText.Format( "%s(%s) %s 加入了聊天室!\r\n\r\n", userNew.strName, userNew.strIP, strTime.GetBuffer( 10 ) ); strTime.ReleaseBuffer( -1 ); CString strReceiveText; m_editReceived.GetWindowText( strReceiveText ); m_editReceived.SetWindowText( strReceiveText + strJoinText ); m_editReceived.LineScroll( m_editReceived.GetLineCount() ); /// 更新聊天室列表 m_arrFriendsInChat.Add( userNew ); CString strText; strText.Format( "%s(%s)", userNew.strName, userNew.strIP ); m_listCtrlInChat.InsertItem( m_listCtrlInChat.GetItemCount(), strText, userNew.nFace ); m_listCtrlInChat.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER ); m_arrFriendsOutOfChat.RemoveAt( nIndex ); m_listCtrlOutOfChat.DeleteItem( nIndex ); m_listCtrlOutOfChat.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER ); break; } } UpdateButtons(); }
void CMainFrame::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default char tmp[100]; CString msg; CString sg; CTime ct ; ct = CTime::GetCurrentTime(); sprintf(tmp,"%s",ct.Format("%Y.%m.%d %H:%M:%S")); // GetLocalTime(&NowTime); // msg.Format("%d.%d.%d %d:%d:%d",NowTime.wYear,NowTime.wMonth,NowTime.wDay,\ // NowTime.wHour,NowTime.wMinute,NowTime.wSecond); // AfxMessageBox("Timer"); CFrameWnd::OnTimer(nIDEvent); }
//写分存储过程 LONG CDataBaseSink::SPWriteUserScore(DWORD dwUserID, DWORD dwPlayTimeCount, DWORD dwOnLineTimeCount, DWORD dwClientIP, tagUserScore & UserScore) { CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%s游戏服务.log",strTime); strTemp.Format("into SPWriteUserScore %d", dwUserID); WriteLog(strFile, strTemp); //效验参数 ASSERT(dwUserID!=0L); //转化地址 TCHAR szClientIP[16]=TEXT(""); BYTE * pClientIP=(BYTE *)&dwClientIP; _snprintf(szClientIP,sizeof(szClientIP),TEXT("%d.%d.%d.%d"),pClientIP[0],pClientIP[1],pClientIP[2],pClientIP[3]); strTemp.Format("szClientIP %s", szClientIP); WriteLog(strFile, strTemp); //执行存储过程 m_GameScoreDB->ClearAllParameters(); m_GameScoreDB->SetSPName("GSP_GR_WriteGameScore"); m_GameScoreDB->AddParamter(TEXT("RETURN_VALUE"),adParamReturnValue,adInteger,sizeof(long),_variant_t((long)0)); m_GameScoreDB->AddParamter(TEXT("@dwUserID"),adParamInput,adInteger,sizeof(long),_variant_t((long)dwUserID)); m_GameScoreDB->AddParamter(TEXT("@lScore"),adParamInput,adInteger,sizeof(long),_variant_t((long)UserScore.lScore)); m_GameScoreDB->AddParamter(TEXT("@lWinCount"),adParamInput,adInteger,sizeof(long),_variant_t((long)UserScore.lWinCount)); m_GameScoreDB->AddParamter(TEXT("@lLostCount"),adParamInput,adInteger,sizeof(long),_variant_t((long)UserScore.lLostCount)); m_GameScoreDB->AddParamter(TEXT("@lDrawCount"),adParamInput,adInteger,sizeof(long),_variant_t((long)UserScore.lDrawCount)); m_GameScoreDB->AddParamter(TEXT("@lFleeCount"),adParamInput,adInteger,sizeof(long),_variant_t((long)UserScore.lFleeCount)); m_GameScoreDB->AddParamter(TEXT("@lExperience"),adParamInput,adInteger,sizeof(long),_variant_t((long)UserScore.lExperience)); m_GameScoreDB->AddParamter(TEXT("@dwPlayTimeCount"),adParamInput,adInteger,sizeof(long),_variant_t((long)dwPlayTimeCount)); m_GameScoreDB->AddParamter(TEXT("@dwOnLineTimeCount"),adParamInput,adInteger,sizeof(long),_variant_t((long)dwOnLineTimeCount)); m_GameScoreDB->AddParamter(TEXT("@wKindID"),adParamInput,adChar,sizeof(long),_variant_t((long)m_pGameServiceAttrib->wKindID)); m_GameScoreDB->AddParamter(TEXT("@wServerID"),adParamInput,adChar,sizeof(long),_variant_t((long)m_pGameServiceOption->wServerID)); m_GameScoreDB->AddParamter(TEXT("@strClientIP"),adParamInput,adVarChar,lstrlen(szClientIP),_variant_t(szClientIP)); m_GameScoreDB->ExecuteCommand(false); strTemp.Format("%d %d %d", m_pGameServiceAttrib->wKindID, m_pGameServiceOption->wServerID, dwUserID); WriteLog(strFile, strTemp); return m_GameScoreDB->GetReturnValue(); }
void CLogView::LogIntro(LogFacility logType, BSTR bsSource, BSTR bsModuleID) { // set color, set bold, print date, logtype, source and module CHARFORMAT cf = {0}; cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_COLOR; CString sType; switch(logType) { case LT_DEBUG: sType = _T("debug"); cf.crTextColor = LOG_COLOR_DEBUG; break; case LT_INFO: sType = _T("info"); cf.crTextColor = LOG_COLOR_INFO; break; case LT_WARN: sType = _T("warning"); cf.crTextColor = LOG_COLOR_WARN; break; case LT_ERROR: sType = _T("error"); cf.crTextColor = LOG_COLOR_ERROR; break; default: sType = _T("log"); cf.crTextColor = LOG_DEFAULTCOLOR; break; } CTime ts = CTime::GetCurrentTime(); CString sDate(ts.Format(_T("%H:%M:%S"))); CString s; s.Format(_T("%s %s [%s: %s]: "), sDate, sType, bsSource, bsModuleID); SetSelectionCharFormat(cf); AppendText(s); cf.dwMask |= CFM_BOLD; cf.dwEffects = CFE_BOLD; SetSelectionCharFormat(cf); // the view has now bold font with the correct color selected }
void CFormulaSepWeighDialog::OnTimer(UINT nIDEvent) { //check the item count in display list, reset list every five mins if (m_Com1DisplayList.GetCount() > 300 ) { m_Com1DisplayList.ResetContent(); m_Com2DisplayList.ResetContent(); } //format time CTime time = CTime::GetCurrentTime(); CString currentTime = time.Format("%X: "); //read data and format data CString com1Result, com2Result; if (com1 >= 0) { com1Result = utils::readcom(SingletonHelper::getInstance()->com2); } if (com2 >= 0) { com2Result = utils::readcom(SingletonHelper::getInstance()->com1); } com1Result = com1Result.IsEmpty() ? "0000.0" : com1Result; com2Result = com2Result.IsEmpty() ? "000.00" : com2Result; m_Com1Value.SetWindowText(com1Result); m_Com2Value.SetWindowText(com2Result); RECT rect; m_Com1Value.GetWindowRect(&rect); m_Com1Value.GetParent()->ScreenToClient(&rect); m_Com1Value.GetParent()->InvalidateRect(&rect, TRUE); m_Com2Value.GetWindowRect(&rect); m_Com2Value.GetParent()->ScreenToClient(&rect); m_Com2Value.GetParent()->InvalidateRect(&rect, TRUE); m_Com1DisplayList.InsertString(0,currentTime + com2Result + "Kg"); m_Com2DisplayList.InsertString(0,currentTime + com1Result + "Kg"); CDialog::OnTimer(nIDEvent); }
void TorrentCreator::WriteHashToDatabase(void) { TRACE( "Start updating bt_generator_maininfo database\n" ); CTime currentTime = CTime::GetCurrentTime(); m_pIPData->SetCreationTime( (time_t)currentTime.GetTime() ); DBInterface db; string torrentfilename = m_pIPData->GetTorrentFileName(); db.OpenConnection(IP_BITTORRENT_DATABASE, "onsystems", "ebertsux37", "bittorrent_data"); char aQuery[1024]; sprintf( aQuery, "UPDATE bt_generator_maininfo SET info_hash = '%s', generate='F', creation_date = %s WHERE auto_torrent_id = %u", GetHashString(m_pIPData->GetInfohash()).c_str(), currentTime.Format( "%Y%m%d%H%M%S" ), m_pIPData->GetTorrentID() ); int ret = db.executeQuery(aQuery); TRACE( "Done updating bt_generator_maininfo database\n" ); }
/** * @brief Enable/Disable writing log. * @param [in] bEnable If TRUE logging is enabled. */ void CLogFile::EnableLogging(BOOL bEnable) { CTime t = CTime::GetCurrentTime(); CString s = t.Format(_T(" %A, %B %d, %Y %H:%M:%S")); if (bEnable) { m_bEnabled = TRUE; Write(_T("\n*******\nLog Started: %s"), s); Write(_T("Path: %s\n*******\n"), m_strLogPath); } else { m_bEnabled = FALSE; Write(_T("\n*******\nLog Stopped: %s\n"), s); Write(_T("*******\n")); } }
void CHveDbController::SaveLog(char* pszLog) { if(pszLog == NULL) { return; } FILE* pFile = fopen(m_strLogPath.GetBuffer(), "a+"); if(pFile) { CString strInfo; CTime cTime = CTime::GetCurrentTime(); strInfo.Format("<%s> %s\n", cTime.Format("%Y-%m-%d %H:%M:%S"), pszLog); fprintf(pFile, strInfo.GetBuffer()); fclose(pFile); } }
void FreeEIM_History::SaveHistory(LPCTSTR lpszSend, LPCTSTR lpszUser, LPCTSTR lszData) { /* if (! UserPathExist(lpszUser)) { CreateUserPath(lpszUser); }*/ CTime tmNow = CTime::GetCurrentTime(); CString strSQL; strSQL.Format("INSERT INTO [freeeim]([sender],[receiver],[message],[senddate]) VALUES('%s','%s','%s','%s')", lpszSend, lpszUser, lszData, tmNow.Format("%Y-%m-%d %H:%M:%S")); // AfxMessageBox(strSQL); m_pDB->ExecuteCommand(strSQL); // AfxMessageBox(GetHistoryPath()); }
void Log_App_FileError(App_Error error, CString filename, CString details) { /* This array must contain its elements in the same order as the enumeration list in the header file history.h */ CString Errors[] = {"bad xml", "bad media", "media missing", "no news", "no loop sequence"}; CTime currentTime = CTime::GetCurrentTime(); CString dateString = currentTime.Format("%Y-%m-%d"); CString timeString = currentTime.Format("%H:%M:%S"); CString txt; txt.Format( "%s %s - [%s] '%s' - %s", dateString.GetBuffer(0), timeString.GetBuffer(0), Errors[error].GetBuffer(0), filename.GetBuffer(0), details.GetBuffer(0) ); Log_App_FileWrite( FN_ERRORS, txt.GetBuffer(0) ); }
void CChatRoomServerDlg::DelUserFromChatRoom( const USER user ) { /// 把用户从其他聊用户列表中移除 for( int nIndex = 1; nIndex < m_arrFriendsInChat.GetSize(); nIndex++ ) { USER userTmp = m_arrFriendsInChat.GetAt( nIndex ); if( 0 != strcmp( user.strIP, userTmp.strIP ) ) { SendUserCommandToIP( CHATROOM_CLIENT_DELDUSER, userTmp.strIP, CHATROOM_CLIENT_PORT, &user ); } } for( nIndex = 0; nIndex < m_arrFriendsInChat.GetSize(); nIndex++ ) { USER userDel = m_arrFriendsInChat.GetAt( nIndex ); if( 0 == strcmp(user.strIP, userDel.strIP ) ) { /// 更新接收编辑框 CString strDelText; CTime time = CTime::GetCurrentTime(); CString strTime = time.Format( "%H:%M:%S" ); strDelText.Format( "%s(%s) %s 离开了聊天室!\r\n\r\n", userDel.strName, userDel.strIP, strTime.GetBuffer( 10 ) ); strTime.ReleaseBuffer( -1 ); CString strReceiveText; m_editReceived.GetWindowText( strReceiveText ); m_editReceived.SetWindowText( strReceiveText + strDelText ); m_editReceived.LineScroll( m_editReceived.GetLineCount() ); m_arrFriendsOutOfChat.Add( userDel ); CString strText; strText.Format( "%s(%s)", userDel.strName, userDel.strIP ); m_listCtrlOutOfChat.InsertItem( m_listCtrlOutOfChat.GetItemCount(), strText, userDel.nFace ); m_listCtrlOutOfChat.SetCheck( m_listCtrlOutOfChat.GetItemCount() - 1, TRUE ); m_listCtrlOutOfChat.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER ); m_arrFriendsInChat.RemoveAt( nIndex ); m_listCtrlInChat.DeleteItem( nIndex ); m_listCtrlInChat.SetColumnWidth( 0, LVSCW_AUTOSIZE_USEHEADER ); break; } } UpdateButtons(); }
void CGoIO_consoleView::RecordGoIOString(LPCSTR pBuf, int buf_len, LPCSTR label) { CListCtrl& ListCtrl = GetListCtrl(); CTime theTime; theTime = CTime::GetCurrentTime(); CString time_string = theTime.Format("%H:%M:%S"); int new_index = ListCtrl.GetItemCount(); int i, record_len; CString short_string; char tmpstring[100]; while (buf_len > 0) { ListCtrl.InsertItem(new_index, (LPCSTR) time_string); ListCtrl.SetItemText(new_index, 1, label); record_len = buf_len; if (record_len > REPORT_RECORD_DATA_LENGTH) record_len = REPORT_RECORD_DATA_LENGTH; wsprintf(tmpstring, "%d", record_len); ListCtrl.SetItemText(new_index, 2, tmpstring); memcpy(tmpstring, pBuf, record_len); for (i = 0; i < record_len; i++) { if (tmpstring[i] == 0) tmpstring[i] = '.'; } short_string = CString(tmpstring, record_len); ListCtrl.SetItemText(new_index, 3, (LPCSTR) short_string); short_string = ""; for (i = 0; i < record_len; i++) { wsprintf(tmpstring, "%02x ", (BYTE) (pBuf[i])); short_string += tmpstring; } ListCtrl.SetItemText(new_index, 4, (LPCSTR) short_string); ListCtrl.EnsureVisible(new_index, FALSE); buf_len -= record_len; pBuf += record_len; new_index++; } }
BOOL _CreateProcess(CString strProcess,PROCESS_INFORMATION &pi,BOOL bService,CString strCmdLine) { if (strProcess == _T("")) { return FALSE; } CString strProName(strProcess); int nPos = strProcess.ReverseFind('\\'); if(nPos >= 0) { strProName = strProcess.Right(strProcess.GetLength()-nPos-1); } STARTUPINFO si; CString strInfo; ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); if(!CreateProcess(NULL, // No module name (use command line). strProcess.GetBuffer(0), // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. FALSE, // Set handle inheritance to FALSE. 0, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi )) // Pointer to PROCESS_INFORMATION structure. { strInfo.Format(_T("Create Process(%s) Failed!"),strProName); strInfo.Format(_T("Create Process(%s) Failed!(strCmdLine:%s) %d"),strProName,strCmdLine,GetLastError()); //WriteLog(_T("Channel_Control_Serive"),logLevelError,strInfo); AfxMessageBox(strInfo); return FALSE; } strInfo.Format(_T("Create Process(%s_%d) Success!"),strProName,pi.dwProcessId); CTime ti = CTime::GetCurrentTime(); printf("%s Create Process [%s_%d] sucess\r\n",ti.Format(_T("%Y-%m-%d %H:%M:%S")),strProName,pi.dwProcessId); //_AddTrace(strInfo); strInfo.Format(_T("Create Process(%s_%d) Success!(strCmdLine:%s)"),strProName,pi.dwProcessId,strCmdLine); //WriteLog(_T("Channel_Control_Serive"),logLevelInfo,strInfo); return TRUE; }
void CHost::OnProcessTerminated( CAr & ar, DPID dpid ) { HTREEITEM hItem = m_pMonitorDlg->m_tree.FindItem( m_pMonitorDlg->m_tree.GetRootItem(), dpid, false ); if( hItem != NULL ) { PSrvrData pData = (PSrvrData)m_pMonitorDlg->m_tree.GetItemData( hItem ); // g_DbManager.WriteLogofServerDown( pData->dwId, pData->tm ); CTime tm = CTime::GetCurrentTime(); CString sTime = tm.Format( "%Y%m%d%H%M%S" ); WriteLog( "%s - %d", sTime, pData->dwId ); #ifdef __SEND_SMS if( m_pMonitorDlg->m_bCheckSendSms) { char szMsg[512] = {0,}; sprintf( szMsg, "%d", pData->dwId ); SendSmsMSg( szMsg ); m_pMonitorDlg->m_bCheckSendSms = FALSE; m_pMonitorDlg->UpdateData(FALSE); } #endif // __SEND_SMS m_pMonitorDlg->m_tree.SelectItem( hItem ); // m_pMonitorDlg->m_tree.SetCheck( hItem, TRUE ); m_pMonitorDlg->m_tree.SetFocus(); // sndPlaySound( "type.wav", SND_ASYNC | SND_LOOP ); if( m_pMonitorDlg->m_tree.IsEnumerating() ) { m_pMonitorDlg->m_tree.PostEnumItem( hItem, true ); } else { m_pMonitorDlg->m_tree.EnumItem( hItem, true ); SendTerminateLwrProcess(); SendHdr( PACKETTYPE_CREATE_PROCESS, pData->dpid ); } m_pMonitorDlg->m_pDPConsoleSrvr->SendOverview( DPID_ALLPLAYERS ); } }
//I D 存储过程 LONG CDataBaseSink::SPLogonByUserID(DWORD dwUserID, LPCTSTR pszPassword, DWORD dwClientIP) { CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%s游戏服务.log",strTime); strTemp.Format("into SPLogonByUserID %d %s %d", dwUserID, pszPassword, dwClientIP); WriteLog(strFile, strTemp); //效验参数 ASSERT(dwUserID!=0L); ASSERT(pszPassword!=NULL); //转化地址 TCHAR szClientIP[16]=TEXT(""); BYTE * pClientIP=(BYTE *)&dwClientIP; _snprintf(szClientIP,sizeof(szClientIP),TEXT("%d.%d.%d.%d"),pClientIP[0],pClientIP[1],pClientIP[2],pClientIP[3]); // 123.123.123.123 strTemp.Format("szClientIP=%s", szClientIP); WriteLog(strFile, strTemp); //执行存储过程 m_GameScoreDB->ClearAllParameters(); m_GameScoreDB->SetSPName("GSP_GR_LogonByUserID"); m_GameScoreDB->AddParamter(TEXT("RETURN_VALUE"),adParamReturnValue,adInteger,sizeof(long),_variant_t((long)0)); m_GameScoreDB->AddParamter(TEXT("@dwUserID"),adParamInput,adInteger,sizeof(long),_variant_t((long)dwUserID)); m_GameScoreDB->AddParamter(TEXT("@strPassword"),adParamInput,adChar,lstrlen(pszPassword),_variant_t(pszPassword)); m_GameScoreDB->AddParamter(TEXT("@wKindID"),adParamInput,adChar,sizeof(long),_variant_t((long)m_pGameServiceAttrib->wKindID)); m_GameScoreDB->AddParamter(TEXT("@wServerID"),adParamInput,adChar,sizeof(long),_variant_t((long)m_pGameServiceOption->wServerID)); m_GameScoreDB->AddParamter(TEXT("@strClientIP"),adParamInput,adVarChar,lstrlen(szClientIP),_variant_t(szClientIP)); strTemp.Format("aaa1 kindid=%d serverid=%d", m_pGameServiceAttrib->wKindID, m_pGameServiceOption->wServerID); WriteLog(strFile, strTemp); m_GameScoreDB->ExecuteCommand(true); strTemp.Format("aaa2"); WriteLog(strFile, strTemp); return m_GameScoreDB->GetReturnValue(); }
//RESET UI LRESULT CGameClientDlg::OnResetUI(WPARAM wParam, LPARAM lParam) { int wInt=(int)wParam; int hInt=(int)lParam; CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%sOnResetUI.log",strTime); strTemp.Format("into OnResetUI(%d, %d", wInt, hInt); WriteLog(strFile, strTemp); if ( wInt >0 && wInt < 1500) { ResetVideoWindowPostion( wInt, hInt); } return 0; }
void CXfilterDlg::OnLoad() { IpFilterDriver.init(IP_FILTER_DRIVER_NAME, FILE_ATTRIBUTE_NORMAL); CString s; CTime time = CTime::GetCurrentTime(); CTimeSpan ts; CTime t(0); ts = time - t; s.Format("CurrentTime: %u, %s DayCount:%u, TotalSec:%u, Week: %u\n" , CTime::GetCurrentTime().GetTime() , time.Format("%Y-%m-%d %H:%M:%S") , ts.GetDays() , ts.GetTotalSeconds() , time.GetDayOfWeek()); // OutputDebugString(s); if (IpFilterDriver.getError() != NO_ERROR) AfxMessageBox(_T("Can't load IpFilter Driver")); }
//建立消息 int CGameClientView::OnCreate(LPCREATESTRUCT lpCreateStruct) { CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%sCGameClientView.log",strTime); strTemp.Format("into OnCreate()"); WriteLog(strFile, strTemp); if (__super::OnCreate(lpCreateStruct)==-1) return -1; //创建控件 CRect CreateRect(0,0,0,0); m_ChessSelect.Create(IDD_CHESS_SELECT,this); m_GameScoreWnd.Create(NULL,NULL,WS_CHILD,CreateRect,this,10); m_ChessBorad.Create(NULL,NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,11); //创建按钮 m_btStudy.Create(NULL,WS_CHILD|WS_VISIBLE,CreateRect,this,IDC_STUDY); m_btStart.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_START); m_btPeace.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_PEACE); m_btRegret.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_REGRET); m_btGiveUp.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_GIVEUP); m_btPreserve.Create(NULL,WS_CHILD|WS_VISIBLE|WS_DISABLED,CreateRect,this,IDC_PRESERVE); //加载位图 HINSTANCE hInstance=AfxGetInstanceHandle(); m_btStart.SetButtonImage(IDB_START,hInstance,false); m_btPeace.SetButtonImage(IDB_PEACE,hInstance,false); m_btStudy.SetButtonImage(IDB_STUDY,hInstance,false); m_btGiveUp.SetButtonImage(IDB_GIVEUP,hInstance,false); m_btRegret.SetButtonImage(IDB_REGRET,hInstance,false); m_btPreserve.SetButtonImage(IDB_PRESERVE,hInstance,false); //请求控件 m_PeaceRequest.InitRequest(IDM_PEACE_ANSWER,15,TEXT("对家请求 [ 和棋 ] 你是否同意?")); m_RegretRequest.InitRequest(IDM_REGRET_ANSWER,15,TEXT("对家请求 [ 悔棋 ] 你是否同意?")); return 0; }
BOOL CPropertyPageListEdit::OnInitDialog() { CPropertyPage::OnInitDialog(); CString strMessage; DWORD dwExStyle = m_lsDemoListCtrl.GetExtendedStyle(); if (m_bListCtrlFullRowSel) dwExStyle |= LVS_EX_FULLROWSELECT; else dwExStyle &= ~LVS_EX_FULLROWSELECT; m_lsDemoListCtrl.SetExtendedStyle(dwExStyle); m_lsDemoListCtrl.InsertColumn(0, _T("ID"), LVCFMT_LEFT, 30); m_lsDemoListCtrl.InsertColumn(1, _T("Name"), LVCFMT_CENTER, 120); m_lsDemoListCtrl.InsertColumn(2, _T("Time"), LVCFMT_RIGHT, 150); m_lsDemoListCtrl.InsertColumn(3, _T("Description"), LVCFMT_LEFT, 250); m_nListCtrlItemID = 0; int nRow; for (int i = 0; i < 100; i++) { strMessage.Format(_T("List Box Item %d"), i); m_lsDemoListBox.AddString((LPCTSTR)strMessage); m_lsMultiColListBox.AddString((LPCTSTR)strMessage); strMessage.Format(_T("%d"), m_nListCtrlItemID); nRow = m_lsDemoListCtrl.InsertItem(m_nListCtrlItemID, (LPCTSTR)strMessage); strMessage.Format(_T("List Control Item %d"), m_nListCtrlItemID); m_lsDemoListCtrl.SetItemText(nRow, 1, (LPCTSTR)strMessage); m_lsDemoListCtrl.SetItemText(nRow, 3, (LPCTSTR)strMessage); CTime curTime = CTime::GetCurrentTime(); strMessage = curTime.Format(_T("%Y-%m-%d %H:%M:%S")); m_lsDemoListCtrl.SetItemText(nRow, 2, (LPCTSTR)strMessage); m_nListCtrlItemID++; } UpdateListBoxWindows(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CDCMasterDlg::InitRunningSinceWindowText() { // Update the time that the values were last cleared CTime time; time=CTime::GetCurrentTime(); CString time_str = time.Format("PLEASE DON'T RESTART DCMASTER UNLESS IT HAS TO BE!!! Running since %A %m/%d/%Y at %H:%M"); char msg[1024]; char date[32]; sprintf(date,__DATE__); char m[16]; unsigned int d; unsigned int y; sscanf(date,"%s %u %u",&m,&d,&y); sprintf(msg,"[ Built on %s %02u, %u at %s ]",m,d,y,__TIME__); time_str += (" - "); time_str += msg; SetWindowText(time_str); }
// log any details to any filename.... more for generic status logs void Log_App_Status( CString filename, int impressionID, CString eventMessage) { CTime currentTime = CTime::GetCurrentTime(); CString dateString = currentTime.Format("%Y-%m-%d"); CString timeString = currentTime.Format("%H:%M:%S"); char *fName; if( !filename || (filename && filename.GetLength()==0) ) fName = FN_OPERATIONS; else fName = filename.GetBuffer(0); CString txt; txt.Format( "%s %s - [id=%d] %s", dateString.GetBuffer(0), timeString.GetBuffer(0), impressionID, eventMessage ); Log_App_FileWrite( fName, txt.GetBuffer(0) ); }
//构造函数 CGameLogic::CGameLogic() { CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%sCGameClientDlg.log",strTime); strTemp.Format("into CGameFrameDlg()"); WriteLog(strFile, strTemp); //辅助变量 memset(m_pItemLately,0,sizeof(m_pItemLately)); //棋盘变量 memset(m_ChessItem,0,sizeof(m_ChessItem)); memset(m_wStepCount,0,sizeof(m_wStepCount)); memset(m_ChessBorad,0,sizeof(m_ChessBorad)); return; }
void CXTaskDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default if (nIDEvent == TIMER_SCAN_DATABASE) { // 先停止计时器,然后在 CheckForUpdate 中再启动计时器。 KillTimer(TIMER_SCAN_DATABASE); CheckForUpdate(); } else if (nIDEvent == TIMER_DATE_TIME) { CTime today; today = CTime::GetCurrentTime(); CString strTime; SetDlgItemText(IDC_STATIC_TIME, today.Format(_T("%Y-%m-%d %H:%M:%S"))); } CDialog::OnTimer(nIDEvent); }
void SoulSeekClientDll::WriteToTextFile(string s) { CFile errorLog; CFileException fileException; if ( !errorLog.Open( "C:\\SoulSeekLog.txt", CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite | CFile::shareDenyWrite, &fileException ) ) { TRACE( "Can't open file %s, error = %u\n", "C:\\SoulSeekLog.txt", fileException.m_cause ); } errorLog.SeekToEnd(); CTime currentTime = CTime::GetCurrentTime(); char buf[512]; sprintf(buf,"%s %s",currentTime.Format("%m/%d %H:%M:%S").GetString(),s.c_str()); errorLog.Write(buf, (UINT)strlen(buf)); errorLog.Close(); }
bool CDlgExpNotes::SaveExpNotes() { FILE* fp = fopen(m_strPath.GetBuffer(),"a"); if(!fp) return false; CString strBuf; fprintf(fp,"Info entered by %s @ %s\n\n",m_strUser.GetBuffer(),GetDateTime(time(0)).c_str()); //experiment info CTime oTime; m_wndExpDate.GetCurSel(oTime); strBuf.Format("%s", oTime.Format("%A, %B %d, %Y")); fprintf(fp,"Experiment information: date=%s\n\n",strBuf.GetBuffer()); //animal information fprintf(fp,"Animal information:\n"); m_wndAnimalType.GetWindowText(strBuf); fprintf(fp,"\ttype=%s\n",strBuf.GetBuffer()); m_wndAnimalWeight.GetWindowText(strBuf); fprintf(fp,"\tweight=%s\n",strBuf.GetBuffer()); m_wndAnimalAge.GetWindowText(strBuf); fprintf(fp,"\tage=%s\n",strBuf.GetBuffer()); m_wndAnimalSex.GetWindowText(strBuf); fprintf(fp,"\tsex=%s\n",strBuf.GetBuffer()); m_wndAnimalDetails.GetWindowText(strBuf); fprintf(fp,"\tdetails=%s\n\n",strBuf.GetBuffer()); //input information CEdit *wndInputTypes[4] = { &m_wndInputType1, &m_wndInputType2, &m_wndInputType3, &m_wndInputType4 }, *wndInputTimes[4] = { &m_wndInputTime1, &m_wndInputTime2, &m_wndInputTime3, &m_wndInputTime4 }, *wndInputAmounts[4] = { &m_wndInputAmount1, &m_wndInputAmount2, &m_wndInputAmount3, &m_wndInputAmount4} , *wndInputLocs[4] = { &m_wndInputLoc1, &m_wndInputLoc2, &m_wndInputLoc3, &m_wndInputLoc4} ; int i,j; CString strI[4]; fprintf(fp,"Input information:\n"); for(i=0;i<4;i++) { j=0; wndInputTypes[i]->GetWindowText(strI[j++]); wndInputTimes[i]->GetWindowText(strI[j++]); wndInputAmounts[i]->GetWindowText(strI[j++]); wndInputLocs[i]->GetWindowText(strI[j++]); fprintf(fp,"\tInput %d: type=%s, time=%s, amount=%s, location=%s\n", i+1,strI[0].GetBuffer(),strI[1].GetBuffer(),strI[2].GetBuffer(),strI[3].GetBuffer()); } m_wndExpComments.GetWindowText(strBuf); fprintf(fp,"\nExperiment additional information:\n%s\n\n",strBuf.GetBuffer()); fclose(fp); return true; }
//位置改变 void CGameFrameDlg::OnSize(UINT nType, int cx, int cy) { CString strFile,strTemp; CTime tmCur = CTime::GetCurrentTime(); CString strTime = tmCur.Format("%m%d"); strFile.Format("log\\%sOnSize.log",strTime); strTemp.Format("OnSize %d %d", cx, cy); WriteLog(strFile, strTemp); __super::OnSize(nType, cx, cy); CString showMsg; showMsg.Format("OnSize(UINT nType, int cx=%d, int cy=%d)", cx, cy); //MessageBox(showMsg); //调整拆分条 if (m_VorSplitter.GetSafeHwnd()) { // UINT uSplitPos=__max(cx*17/24-SPLIT_WIDE,350); UINT uSplitPos = cx - INFO_WIDTH - BUTTON_WIDE - 1; showMsg.Format("uSplitPos=%d)", uSplitPos); //MessageBox(showMsg); // SafeMoveWindow(&m_VorSplitter,uSplitPos,GetTitleHight(),SPLIT_WIDE,cy-GetTitleHight()); HDWP hDwp=BeginDeferWindowPos(32); DeferWindowPos(hDwp,m_VorSplitter,NULL,uSplitPos,0, 0, 0, uFlags); strTemp.Format("m_VorSplitter %d %d", uSplitPos,0); WriteLog(strFile, strTemp); EndDeferWindowPos(hDwp); m_VorSplitter.InitSplitBar(cx*3/5,cx-250,false); //调整控件 RectifyControl(cx,cy); } return; }
void CLogView::InsertLogItem(LPCTSTR Text,int Mode, int Flag) { char m_Text[512] = {0}; CTime time = CTime::GetCurrentTime(); //构造CTime对象 CString strTime = time.Format(" %Y-%m-%d %H:%M:%S"); m_pLogList->InsertItem(0, strTime, Flag);//int InsertItem( int nItem, LPCTSTR lpszItem, int nImage ); m_pLogList->SetItemText(0, 1, Text); //BOOL SetItemText( int nItem, int nSubItem, LPTSTR lpszText ); switch(Mode) { case 0: { m_pLogList->SetTextColor(RGB(0,100,250));//蓝色 } break; case 1: { m_pLogList->SetTextColor(RGB(255,0,0));//红色 } break; case 2: { m_pLogList->SetTextColor(RGB(0,180,250));//蓝绿色 } break; case 3: { m_pLogList->SetTextColor(RGB(200,0,200));//粉色 } break; case 4: { m_pLogList->SetTextColor(RGB(0,20,100));//貌似黑色 } break; default: m_pLogList->SetTextColor(RGB(0,100,255));//蓝色 break; } }