Beispiel #1
0
CString CTradeStatistic2::CalculateElapseTime()
{
	CString strElapsedTime;
	CTime tmNow = CTime::GetCurrentTime();
	CTimeSpan tElapsed = tmNow - m_tmBegin;
	strElapsedTime.Format("%d小时 %d分钟 %d秒", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds());
	return strElapsedTime;
}
Beispiel #2
0
/*********************************************************
函数名称:CheckSocketStatus
功能描述:检查每个Socket 将其中空的和超时的删除掉
创建时间:2016-08-19
参数说明:
返 回 值:
*********************************************************/
int CSocketServerDlg::CheckSocketStatus(void)
{
	POSITION pos = m_listSocketChat.GetHeadPosition();
	while(pos != NULL)
	{
		CChatSocket* p = m_listSocketChat.GetNext(pos);
		// 删除空Socket
		if(p == NULL)
		{
			if(pos == NULL)
			{// 空Socket位于链表末尾
				m_listSocketChat.RemoveTail();
				break;
			}
			else
			{
				POSITION posTemp = pos;
				m_listSocketChat.GetPrev(posTemp);
				m_listSocketChat.RemoveAt(posTemp);
			}
			continue;
		}
		
		// 删除超过时间没有通信的Socket
		int nMaxSec = 30; // 等待的最大时间
		CTimeSpan tmsp;
		tmsp = CTime::GetCurrentTime() - p->m_tmLastMsg;
		TRACE("%d\n", tmsp.GetTotalSeconds());
		
		if(tmsp.GetTotalSeconds() >= nMaxSec || tmsp.GetSeconds() < 0)
		{
			CString csOutMsg;
			CString csID;
			csID = p->m_userID;
			csOutMsg.Format(_T("用户%s连接超时"), csID);
			OutputInfo(csOutMsg);
			
			m_data.SetUserStatus(p->m_userID, IDS_STATUS_OFFLINE);
			
			p->Close(); // 关闭连接
			delete p; // 释放内存
			// 删除元素
			if(pos == NULL)
			{// 空Socket位于链表末尾				
				m_listSocketChat.RemoveTail();
				break;
			}
			else
			{
				POSITION posTemp = pos;
				m_listSocketChat.GetPrev(posTemp);
				m_listSocketChat.RemoveAt(posTemp);
			}
			continue;
		}
	}
	return 0;
}
string VirtualListCtrlFT::FormatElapsed(CTimeSpan &span)
{
	string ret;
	char buf[4096];

	if(span.GetTotalHours()==0)	// < hour
	{
		sprintf(buf,"%u:%02u",span.GetMinutes(),span.GetSeconds());
	}
	else	//	> hour
	{
		sprintf(buf,"%u:%02u:%02u",span.GetHours(),span.GetMinutes(),span.GetSeconds());
	}
			
	ret=buf;

	return ret;
}
void CDialogToDoHistory::UpdateItem( int iItem )
{
	DWORD dwId;
	m_listTodoHistory.GetItemData(iItem,dwId);
	ToDoTask todo = g_todoSet.GetToDo(dwId);
	ATLASSERT(todo.id!=ToDoTask::ERROR_TASKID);

	//改变的文字颜色
	COLORREF clrBgn,clrText;
	m_listTodoHistory.GetItemColours(iItem,m_iColCreateTime,clrBgn,clrText);
	m_listTodoHistory.SetItemColours(iItem,m_iColCreateTime,clrBgn,RGB(0X66,0X66,0X66));
	m_listTodoHistory.SetSubItemData(iItem,m_iColCreateTime,GlobeFuns::TimeToInt(todo.tmCreateTime));

	m_listTodoHistory.SetItemText(iItem,m_iColTitle,todo.strTask.c_str());

	m_listTodoHistory.SetItemText(iItem,m_iColPriority,ToDoTask::PriorityText(todo.priority));
	m_listTodoHistory.SetItemColours(iItem,m_iColPriority,RGB(10,170-todo.priority*25,10),RGB(0,0,0));
	m_listTodoHistory.SetSubItemData(iItem,m_iColPriority,todo.priority);

	CString strTime;
	if (todo.tmPlanFinshTime>=todo.tmCreateTime)
	{
		CTimeSpan ts = todo.tmPlanFinshTime-todo.tmCreateTime;

		CString strTmp;
		if (ts.GetDays()>0)
		{
			strTmp.Format("%d天",ts.GetDays());
			strTime += strTmp;
		}
		if (ts.GetHours()>0)
		{
			strTmp.Format("%d时",ts.GetHours());
			strTime += strTmp;
		}
		if (ts.GetDays()==0		//任务持续一天以上的,就不要精确到分钟了。
			&& ts.GetMinutes()>0)
		{
			strTmp.Format("%d分",ts.GetMinutes());
			strTime += strTmp;
		}
		if (strTime.IsEmpty())
		{
			strTmp.Format("%d秒",ts.GetSeconds());
			strTime += strTmp;
		}
		m_listTodoHistory.SetSubItemData(iItem,m_iColTotleHours,GlobeFuns::TimeToInt(CTime(0)+ts));
	}
	else
	{
		strTime = "(无数据)";
	}
	m_listTodoHistory.SetItemText(iItem,m_iColTotleHours,strTime);

	m_listTodoHistory.SetItemText(iItem,m_iColRemark,todo.strRemark.c_str());
}
Beispiel #5
0
void test_ServerThread(IUnitTest* _ts)
{
	TEST_SUITE(_ts,_T("Pipe"),_T("Pipe Server thread"));
	
	//TRACE(_T("Test server thread ------------------------------------\n"));
	CServer1* pserver = trace_alloc(new CServer1(_T("test_pipe")));
	pserver->start();
	Sleep(100);
	CTime t1 = CTime::GetCurrentTime();
	delete trace_free(pserver);
	CTime t2 = CTime::GetCurrentTime();
	CTimeSpan dif = t2 - t1;
	ok(dif.GetSeconds()<5,_T("closing pipe server to long"));
}
void PageProgress::CompleteSuccess(const DFUEngine::Status &status)
{
	bool ok = true;

	// Start the next operation
	CTimeSpan timeSpan = timeEnd - timeStart;
	switch (status.state)
	{
	case DFUEngine::reconfigure:
		if (fileUpload.IsEmpty()) ok = dfu.StartDownload(fileDownload);
		else ok = dfu.StartUpload(fileUpload);
		break;

	case DFUEngine::upload:
		if (status.result) GetSheet()->pageResults.valueSaved = true;
		timeTakenUpload.Format(IDS_RESULTS_MSG_TIME, (int)timeSpan.GetTotalMinutes(), (int)timeSpan.GetSeconds());
		ok = dfu.StartDownload(fileDownload);
		break;

	case DFUEngine::download:
		timeTakenDownload.Format(IDS_RESULTS_MSG_TIME, (int)timeSpan.GetTotalMinutes(), (int)timeSpan.GetSeconds());
		ok = dfu.StartManifest();
		break;

	default:
		// Otherwise successfully completed
		CompleteSuccessLast(status);
		break;
	}

	// Handle failure to start the next operation
	if (!ok)
	{
		// Display the results page
		GetSheet()->pageResults.valueTitle.Format(IDS_RESULTS_TITLE_FAIL);
		CString &results = GetSheet()->pageResults.valueResults;
		results.Format(IDS_RESULTS_MSG_FAIL_INTERNAL);
		CString recover;
		recover.Format(IDS_RESULTS_MSG_RECOVER_FAIL);
		if (!recover.IsEmpty()) results += "\n\n" + recover;
		GetSheet()->pageResults.valueAnimation = false;
		GetSheet()->pageResults.valueDetails.Empty();
		GetSheet()->SetActivePage(&GetSheet()->pageResults);
	}
}
Beispiel #7
0
void CPMotion::SWait(short Seconds)				//waits n seconds
{
    //OK
    CTime WaitUntilTime = CTime::GetCurrentTime();
    WaitUntilTime += CTimeSpan(0, 0, 0, Seconds);
    bool done = false;

    while (!done)
    {
        m_Robot->DoWindowMessages();
        CTime StartTime = CTime::GetCurrentTime();
        CTimeSpan TimeDiff = WaitUntilTime - StartTime;

        if ((TimeDiff.GetHours() == 0) && (TimeDiff.GetMinutes() == 0) &&
                (TimeDiff.GetSeconds() <= 0))
        {
            done = true;
        }
    }
}
Beispiel #8
0
bool CPMotion::RWait(short Seconds)				//waits n seconds or exit on nudge
{
    //OK
    CTime WaitUntilTime = CTime::GetCurrentTime();
    WaitUntilTime += CTimeSpan(0, 0, 0, Seconds);
    bool done = false;

    while ((!done) && (!(m_Robot->m_Nudged)))
    {
        m_Robot->DoWindowMessages();
        CTime StartTime = CTime::GetCurrentTime();
        CTimeSpan TimeDiff = WaitUntilTime - StartTime;

        if ((TimeDiff.GetHours() == 0) && (TimeDiff.GetMinutes() == 0) &&
                (TimeDiff.GetSeconds() <= 0))
        {
            done = true;
        }
    }

    return (done || (m_Robot->m_Nudged));	// ||boolean
}
void SaveBinaryNoParsingDlg::ShowDuration(CTimeSpan ts, UINT id)
{
  char buf[128];
  //CTimeSpan ts = CTime::GetCurrentTime() - startTime;
  if(ts.GetDays() > 0)
  {
    sprintf_s(buf, 128, "%d day(s) and %02d:%02d:%02d", (int)ts.GetDays(), (int)ts.GetHours(), (int)ts.GetMinutes(), (int)ts.GetSeconds());
  }
  else
  {
    sprintf_s(buf, 128, "%02d:%02d:%02d", (int)ts.GetHours(), (int)ts.GetMinutes(), (int)ts.GetSeconds());
  }
  GetDlgItem(id)->SetWindowText(buf);
}
Beispiel #10
0
void DLLBuildDone()
{
  g_hToolThread = NULL;
  CTime tEnd = CTime::GetCurrentTime();
  CTimeSpan tElapsed = tEnd - g_tBegin;
  CString strElapsed;
  strElapsed.Format("Run time was %i hours, %i minutes and %i seconds", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds());
	Sys_Printf(strElapsed.GetBuffer(0));
	Pointfile_Check();

  if (g_PrefsDlg.m_bRunQuake == TRUE)
  {
    char cCurDir[1024];
    GetCurrentDirectory(1024, cCurDir);
    CString strExePath = g_PrefsDlg.m_strQuake2;
    CString strOrgPath;
    CString strOrgFile;
    ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);
    if (g_PrefsDlg.m_bSetGame == TRUE) // run in place with set game.. don't copy map
    {
	    CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
      strExePath += " +set game ";
      strExePath += strBasePath;
      WinExec(strExePath, SW_SHOW);
    }
    else
    {
      CString strCopyPath = strExePath;
      char* pBuffer = strCopyPath.GetBufferSetLength(_MAX_PATH + 1);
      pBuffer[strCopyPath.ReverseFind('\\') + 1] = '\0';
      strCopyPath.ReleaseBuffer();
      SetCurrentDirectory(strCopyPath);
      CString strOrgPath;
      CString strOrgFile;
      ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);
      AddSlash(strCopyPath);
      FindReplace(strOrgFile, ".map", ".bsp");
      strCopyPath += "\\baseq2\\maps\\";
      strCopyPath += strOrgFile;
      AddSlash(strOrgPath);
      strOrgPath += strOrgFile;
      bool bRun = (strOrgPath.CompareNoCase(strCopyPath) == 0);
      if (!bRun)
        bRun = (CopyFile(strOrgPath, strCopyPath, FALSE) == TRUE);
      if (bRun)
      {
        FindReplace(strOrgFile, ".bsp", "");
        strExePath += " +map ";
        strExePath += strOrgFile;
        WinExec(strExePath, SW_SHOW);
      }
    }
    SetCurrentDirectory(cCurDir);
  }

}
Beispiel #11
0
void CheckBspProcess( void )
{
	char    outputpath[1024];
	char    temppath[512];
	DWORD   exitcode;
	char*   out;
	BOOL    ret;
	
	if ( !bsp_process )
		return;
		
	ret = GetExitCodeProcess( bsp_process, &exitcode );
	if ( !ret )
		Error( "GetExitCodeProcess failed" );
	if ( exitcode == STILL_ACTIVE )
		return;
		
	bsp_process = 0;
	
	GetTempPath( 512, temppath );
	sprintf( outputpath, "%sjunk.txt", temppath );
	
	LoadFile( outputpath, ( void** )&out );
	Sys_Printf( "%s", out );
	Sys_Printf( "\ncompleted.\n" );
	free( out );
	
	CTime tEnd = CTime::GetCurrentTime();
	CTimeSpan tElapsed = tEnd - g_tBegin;
	CString strElapsed;
	strElapsed.Format( "Run time was %i hours, %i minutes and %i seconds", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds() );
	Sys_Printf( strElapsed.GetBuffer( 0 ) );
	
	
	Sys_Beep();
	Pointfile_Check();
	// run game if no PointFile and pref is set
	//++timo needs to stop after BSP if leaked .. does run through vis and light instead ..
	if ( g_PrefsDlg.m_bRunQuake == TRUE  && !g_qeglobals.d_pointfile_display_list )
	{
		char cCurDir[1024];
		GetCurrentDirectory( 1024, cCurDir );
		CString strExePath = "../../qio.exe";
		//= g_PrefsDlg.m_strQuake2;
		CString strOrgPath;
		CString strOrgFile;
		ExtractPath_and_Filename( currentmap, strOrgPath, strOrgFile );
		if ( g_PrefsDlg.m_bSetGame == TRUE )  // run in place with set game.. don't copy map
		{
			CString strBasePath = ValueForKey( g_qeglobals.d_project_entity, "basepath" );
			strExePath += " +set game ";
			strExePath += strBasePath;
			WinExec( strExePath, SW_SHOW );
		}
		else
		{
			CString strCopyPath = strExePath;
			char* pBuffer = strCopyPath.GetBufferSetLength( _MAX_PATH + 1 );
			pBuffer[strCopyPath.ReverseFind( '\\' ) + 1] = '\0';
			strCopyPath.ReleaseBuffer();
			SetCurrentDirectory( strCopyPath );
			CString strOrgPath;
			CString strOrgFile;
			ExtractPath_and_Filename( currentmap, strOrgPath, strOrgFile );
			AddSlash( strCopyPath );
			FindReplace( strOrgFile, ".map", ".bsp" );
			//++timo modified for Quake3 !!
			strCopyPath += "baseq3\\maps\\";
			strCopyPath += strOrgFile;
			AddSlash( strOrgPath );
			strOrgPath += strOrgFile;
			bool bRun = ( strOrgPath.CompareNoCase( strCopyPath ) == 0 );
			if ( !bRun )
				bRun = ( CopyFile( strOrgPath, strCopyPath, FALSE ) == TRUE );
			if ( bRun )
			{
				FindReplace( strOrgFile, ".bsp", "" );
				strExePath += " +map ";
				strExePath += strOrgFile;
				WinExec( strExePath, SW_SHOW );
			}
		}
		SetCurrentDirectory( cCurDir );
	}
}
Beispiel #12
0
void COscillogram::DrawGrid(CDC *dc)
{
	//_DrawGrid(dc);

	CString tempStr;
	CSize	tempSzie;
	int		tempPos;
	CFont	m_cFont, *oldFont;
	CPen	pen(PS_SOLID,6,m_GridColor);

	m_cFont.CreatePointFont(260,"宋体");//"Arial");
	oldFont = dc->SelectObject(&m_cFont);
	dc->SelectObject(&pen);
	dc->SetTextColor(m_xyTextColor);

	float m_xTemp = (float)m_GridRect.Width() / (m_xShowCount-1);
	float m_yTemp = (float)m_GridRect.Height() / (m_yShowCount-1);
	CTimeSpan m_xTimeSpan = 0;

	if(m_showTime)
	{
		CTimeSpan sc    = m_endTime - m_beginTime;

		double secCount = (sc.GetDays()*86400) + (sc.GetHours()*3600) + 
						  (sc.GetMinutes()*60) + sc.GetSeconds();
		secCount = secCount / (m_xShowCount-1);

		int day    = (int)secCount/86400;	//天
		secCount  -= day*86400;
		int hour   = (int)secCount/3600;	//小时
		secCount  -= hour*3600;
		int minute = (int)secCount/60;		//分钟
		secCount  -= minute*60;
		int second = (int)secCount;			//秒

		m_xTimeSpan = CTimeSpan(day,hour,minute,second);
	}
	
	for(int i=0;i<m_xShowCount;i++)
	{
		tempPos =   m_GridRect.left + (int)(m_xTemp*i);
		
		DotLine(dc, tempPos, 
			        m_GridRect.top ,
				    tempPos , 
				    m_GridRect.bottom ,
				    m_GridColor );
		
		if(!m_showTime)
			tempStr.Format("%.2f", 
					(m_xMaxVal-m_xMinVal)/(m_xShowCount-1) 
					* i	+ m_xMinVal );
		else
		{
			CTime cnTime = m_beginTime;;

			for(int j=0;j<i;j++)
				cnTime += m_xTimeSpan;

			tempStr = cnTime.Format("%H:%M:%S");//%Y/%m/%d 
		}

		tempSzie =  dc->GetTextExtent(tempStr);
		dc->TextOut(tempPos - tempSzie.cx/2 , 
					m_GridRect.bottom - 15 ,
					tempStr );
	}

	for(int j=0;j<m_yShowCount;j++)
	{
		tempPos = m_GridRect.top + (int)(m_yTemp*j);

		DotLine(dc, m_GridRect.left , 
			        tempPos ,
				    m_GridRect.right ,
				    tempPos ,
				    m_GridColor );
	
		tempStr.Format("%.2f",
					(m_yMaxVal-m_yMinVal)/(m_yShowCount-1)
					* (m_yShowCount-1-j) + m_yMinVal );

		tempSzie =  dc->GetTextExtent(tempStr);

		dc->TextOut(m_GridRect.left - tempSzie.cx-15 , 
					tempPos + tempSzie.cy/2 ,
					tempStr );
	}
	
	//X轴文本
	tempSzie = dc->GetTextExtent(m_xText);
	dc->TextOut(m_GridRect.right + 15,m_GridRect.bottom + tempSzie.cy/2,m_xText);
	//Y轴文本
	tempSzie = dc->GetTextExtent(m_yText);
	dc->TextOut(m_GridRect.left - tempSzie.cx/2,m_GridRect.top + tempSzie.cy + 15,m_yText);

	//XY轴线
	dc->MoveTo(m_GridRect.left,m_GridRect.top);
	dc->LineTo(m_GridRect.left,m_GridRect.bottom);
	dc->MoveTo(m_GridRect.left,m_GridRect.bottom);
	dc->LineTo(m_GridRect.right,m_GridRect.bottom);
	//上面小三角
	int i;
	for(i=1;i<12;i++)
	{
		dc->MoveTo(m_GridRect.left-i-3,m_GridRect.top-i);
		dc->LineTo(m_GridRect.left+i-3,m_GridRect.top-i);
	}
	//上面小三角
	for(i=1;i<12;i++)
	{
		dc->MoveTo(m_GridRect.right-i,m_GridRect.bottom-i);
		dc->LineTo(m_GridRect.right-i,m_GridRect.bottom+i);
	}
	
	dc->SelectObject(oldFont);
}
Beispiel #13
0
void COscillogram::OnMouseMove(UINT nFlags, CPoint point) 
{
	CStringArray valArray;
	CDWordArray colArray;
	CString     strVal;
	CRect		mRect;
	CClientDC	dc(this);
	float		length;		//鼠标位置绝对象素数
	float		gValue;
	int			oldMode;
	int			curCell;	//所在单元格
	CPen pen(PS_SOLID,0,RGB(0,0,0));
	BOOL		PtState = FALSE;

	//(整个函数过程的功能)计算所有线所在单元格的数值
	oldMode = dc.SetMapMode(MM_LOMETRIC);
	SetOscillogramRect(&dc);
	dc.SelectObject(&pen);
	dc.SetROP2(R2_NOTXORPEN);
	dc.DPtoLP(&point);

	//如果 鼠标不在波形图内 或者 没有曲线 不做处理返回
	if(!(point.x >= m_GridRect.left  && point.x <= m_GridRect.right+3
		&& point.y <= m_GridRect.top && point.y >= m_GridRect.bottom)
		|| GetCurveCount() < 1 || m_showTitle == FALSE)
	{
		if(m_bPt.x != -1)
		{
			DrawMouseLine(&dc,m_bPt);
			m_bPt =-1;
		}
		m_TitleTip.ShowWindow(SW_HIDE);
		return;
	}
	
	//绘画跟随鼠标的十字线
	if(m_bPt.x == -1)
	{
		m_bPt = point;
		DrawMouseLine(&dc,point);
	}
	else
	{	
		DrawMouseLine(&dc,m_bPt);
		m_bPt = point;
		DrawMouseLine(&dc,point);
	}

	//计算个单元格数值
	length  = (float)( point.x - m_GridRect.left );
	curCell = (int)( length / m_xSpan );
	
	if(!m_showTime)
	{
		float n1 = (m_xMaxVal - m_xMinVal)/(m_xCount-1);
		float n2 = m_xMinVal + curCell*n1;
		strVal.Format("%s: %.2f",m_xText,n2);
	}
	else
	{
		CTimeSpan m_xTimeSpan = 0;
		CTimeSpan sc    = m_endTime - m_beginTime;
		CTime	cnTime  = m_beginTime;
		
		double secCount = (sc.GetDays()*86400) + (sc.GetHours()*3600) + 
			(sc.GetMinutes()*60) + sc.GetSeconds();
		secCount = secCount / (m_xCount-1);
		
		int day    = (int)secCount/86400;	//天
		secCount  -= day*86400;
		int hour   = (int)secCount/3600;	//小时
		secCount  -= hour*3600;
		int minute = (int)secCount/60;		//分钟
		secCount  -= minute*60;
		int second = (int)secCount;			//秒
		m_xTimeSpan = CTimeSpan(day,hour,minute,second);

		for(int j=0;j<curCell;j++)
			cnTime += m_xTimeSpan;
		strVal.Format("%s: %s",m_xText,cnTime.Format("%Y/%m/%d  %H:%M:%S"));
	}
	colArray.Add(RGB(0,0,0));
	valArray.Add(strVal);

	for(int i=0;i<GetCurveCount();i++)
	{
		gValue = GetCurve(i)->ptVal.GetPointValue(curCell,PtState);
		
		if(PtState)
			strVal.Format("%s: %.2f",GetCurveName(i),gValue);
		else
			strVal.Format("%s: ",GetCurveName(i));
		colArray.Add(GetCurve(i)->lColor);
		valArray.Add(strVal);
	}

	//显示浮动窗体
	dc.LPtoDP(&point);
	dc.SetMapMode(oldMode);

	//窗口跟随鼠标位置移动
	GetClientRect(mRect);
	mRect.left   += CS_LMARGIN;
	mRect.top    += CS_LMARGIN;
	mRect.right  -= CS_LMARGIN;
	mRect.bottom -= CS_LMARGIN;
	ClientToScreen(&point);
	ClientToScreen(&mRect);

	m_TitleTip.SetParentRect(mRect);
	m_TitleTip.SetStrArray(valArray,colArray);
	m_TitleTip.SetPos(&point);
	ScreenToClient(&point);
	
	CWnd::OnMouseMove(nFlags, point);
}
Beispiel #14
0
void CMirrorDlg::DispathNotification()
{
	NBSYNC_REPORT report;
	report.nSize = sizeof(NBSYNC_REPORT);
	CMultithreadedObserver::GerReport( static_cast<NDAS_SYNC_REPORT*>(&report) );

	if ( m_nCurrentPhase != report.nPhase )
	{
		m_nCurrentPhase = report.nPhase;
		switch( report.nPhase )
		{
		case NBSYNC_PHASE_CONNECT:
			m_strPhase = _T("Connecting to disks..."); // TODO : String resource
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_REBIND:
			m_strPhase = _T("Updating disk information...");
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_BIND:
			m_strPhase = _T("Writing disk information required for mirroring...");
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_RETRIVE_BITMAP:
			m_strPhase = _T("Retrieving synchronization information..."); // TODO : String resource
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_SYNCHRONIZE:
			m_strPhase = _T("Synchronizing..."); // TODO : String resource
			DoDataExchange(FALSE);
			break;
		case NBSYNC_PHASE_FINISHED:
			m_strPhase = _T("Synchronization has finished."); // TODO : String resource
			DoDataExchange(FALSE);
			m_bFinished = TRUE;
			break;
		case NBSYNC_PHASE_FAILED:
		default:
			if ( report.nErrorCode == NBSYNC_ERRORCODE_STOPPED )
			{
				m_strPhase = _T("Synchronization has been stopped.");
				DoDataExchange(FALSE);
			}
			else
			{
				m_strPhase = _T("Synchronization has failed.");
				DoDataExchange(FALSE);
			}
			break;
		}

		if ( report.bRebound && !m_bRebound )
		{
			boost::dynamic_pointer_cast<CDiskObjectComposite>
				(m_pDest->GetParent())->DeleteChild(m_pDest);
			if ( m_pMirDisks->front()->IsUsable() )
			{
				m_pMirDisks->DeleteChild( m_pMirDisks->back() );
			}
			else
			{
				m_pMirDisks->DeleteChild( m_pMirDisks->front() );
			}
			m_pMirDisks->AddChild(m_pMirDisks, m_pDest);
			m_bRebound = TRUE;
		}
	}

	// Display process
	if ( (m_nCurrentPhase == NBSYNC_PHASE_SYNCHRONIZE 
		  || m_nCurrentPhase == NBSYNC_PHASE_FINISHED
		  || m_nCurrentPhase == NBSYNC_PHASE_FAILED )
		&& report.nTotalSize != 0 )
	{
		// Step in progress bar
		UINT nNewStep = 
			static_cast<UINT>(
			   (report.nProcessedSize*m_progBar.GetRangeLimit(FALSE)) 
			 / report.nTotalSize
			);
		while ( m_progBar.GetPos() < nNewStep )
		{
			m_progBar.StepIt();
		}

		// Display progressbar message
		/*
		WTL::CString strProgBarMsg;

		strProgBarMsg.Format(
			"%d / %d KBs", 
			static_cast<int>(report.nProcessedSize/2),
			static_cast<int>(report.nTotalSize/2));
		m_progBar.SetWindowText( strProgBarMsg );
		*/

		// Display time left
		CTime timeNow = CTime::GetCurrentTime();
		CTimeSpan timeElapsed = timeNow - m_timeBegin;
		CTimeSpan timeLeft;
		if ( timeElapsed.GetTotalSeconds() != 0 
			&& m_timePrev != timeNow	// To prevent too frequent update
			)
		{
			m_timePrev = timeNow;
			// Calculate transfer rate
			double fMBPerSecond = 
				(report.nProcessedDirtySize) / 2.0 / 1024
				/ timeElapsed.GetTotalSeconds();
			

			WTL::CString strMBPerSecond;
			strMBPerSecond.Format( _T("%.01f"),fMBPerSecond);
			::SetWindowText( GetDlgItem(IDC_TEXT_RATE), strMBPerSecond );

			WTL::CString strTimeLeft;
			timeLeft = 
				static_cast<UINT>(
					(report.nTotalDirtySize-report.nProcessedDirtySize) 
					/ ( fMBPerSecond * 2 * 1024 )
				);
			int nHour, nMin, nSec;
			nSec = timeLeft.GetSeconds();
			nMin = timeLeft.GetMinutes();
			nHour = static_cast<int>(timeLeft.GetTotalHours());
			strTimeLeft.Format( _T("%02d:%02d:%02d"), nHour, nMin, nSec );
			//strTimeLeft = timeLeft.Format(TIME_FORMAT);
			::SetWindowText( GetDlgItem(IDC_TEXT_LEFTTIME), strTimeLeft );
		}
	}
	return;
}
Beispiel #15
0
void CuDlgIpmDetailNetTrafic::UpdatePerSecondTrafic(CaNetTraficInfo& infoNetTrafic)
{
	CTimeSpan t;
	int dt = 0;
	double dRate = 0.0;

	if (m_nCounter < 2)
	{
		//
		// Current:
		m_strCurrentPacketIn = _T("n/a");
		m_strCurrentDataIn = _T("n/a");
		m_strCurrentPacketOut = _T("n/a");
		m_strCurrentDataOut = _T("n/a");
	}
	else
	{
		t = infoNetTrafic.GetTimeStamp() - m_TraficInfo.GetTimeStamp();
		dt = t.GetSeconds();
		if (dt == 0)
			dt = 1;

		//
		// Current:
		dRate = (double)(abs(infoNetTrafic.GetPacketIn() - m_TraficInfo.GetPacketIn()));
		dRate = dRate / (double)dt;
		m_strCurrentPacketIn.Format(_T("%0.2f"), dRate);

		dRate = (double)(abs(infoNetTrafic.GetDataIn() - m_TraficInfo.GetDataIn()));
		dRate = dRate / (double)dt;
		m_strCurrentDataIn.Format(_T("%0.2f"), dRate);

		dRate = (double)(abs(infoNetTrafic.GetPacketOut() - m_TraficInfo.GetPacketOut()));
		dRate = dRate / (double)dt;
		m_strCurrentPacketOut.Format(_T("%0.2f"), dRate);

		dRate = (double)(abs(infoNetTrafic.GetDataOut() - m_TraficInfo.GetDataOut()));
		dRate = dRate / (double)dt;
		m_strCurrentDataOut.Format(_T("%0.2f"), dRate);
	}

	if (m_bStartup)
	{
		//
		// Average:
		m_strAveragePacketIn = _T("n/a");
		m_strAverageDataIn = _T("n/a");
		m_strAveragePacketOut = _T("n/a");
		m_strAverageDataOut = _T("n/a");
		//
		// Peek:
		m_strPeekPacketIn = _T("n/a");
		m_strPeekDataIn = _T("n/a");
		m_strPeekPacketOut = _T("n/a");
		m_strPeekDataOut = _T("n/a");
		//
		// Date/Time (reached between and):
		m_strDate1PacketIn = _T("n/a");
		m_strDate2PacketIn = _T("n/a");
		m_strDate1DataIn = _T("n/a");
		m_strDate2DataIn = _T("n/a");
		m_strDate1PacketOut = _T("n/a");
		m_strDate2PacketOut = _T("n/a");
		m_strDate1DataOut = _T("n/a");
		m_strDate2DataOut = _T("n/a");
	}
	else
	{
		if (m_nCounter < 2)
		{
			//
			// Average:
			m_strAveragePacketIn = _T("n/a");
			m_strAverageDataIn = _T("n/a");
			m_strAveragePacketOut = _T("n/a");
			m_strAverageDataOut = _T("n/a");
			//
			// Peek:
			m_strPeekPacketIn = _T("n/a");
			m_strPeekDataIn = _T("n/a");
			m_strPeekPacketOut = _T("n/a");
			m_strPeekDataOut = _T("n/a");
			//
			// Date/Time (reached between and):
			m_strDate1PacketIn = _T("n/a");
			m_strDate2PacketIn = _T("n/a");
			m_strDate1DataIn = _T("n/a");
			m_strDate2DataIn = _T("n/a");
			m_strDate1PacketOut = _T("n/a");
			m_strDate2PacketOut = _T("n/a");
			m_strDate1DataOut = _T("n/a");
			m_strDate2DataOut = _T("n/a");
		}
		else
		{
			t = infoNetTrafic.GetTimeStamp() - m_TraficInfo.GetTimeStamp();
			dt = t.GetSeconds();
			if (dt == 0)
				dt = 1;
			//
			// Average:
			t = infoNetTrafic.GetTimeStamp() - m_TraficInfo_0.GetTimeStamp();
			dt = t.GetSeconds();
			if (dt == 0)
				dt = 1;

			dRate = (double)(abs(infoNetTrafic.GetPacketIn() - m_TraficInfo_0.GetPacketIn()));
			dRate = dRate / (double)dt;
			m_strAveragePacketIn.Format(_T("%0.2f"), dRate);

			dRate = (double)(abs(infoNetTrafic.GetDataIn() - m_TraficInfo_0.GetDataIn()));
			dRate = dRate / (double)dt;
			m_strAverageDataIn.Format(_T("%0.2f"), dRate);

			dRate = (double)(abs(infoNetTrafic.GetPacketOut() - m_TraficInfo_0.GetPacketOut()));
			dRate = dRate / (double)dt;
			m_strAveragePacketOut.Format(_T("%0.2f"), dRate);

			dRate = (double)(abs(infoNetTrafic.GetDataOut() - m_TraficInfo_0.GetDataOut()));
			dRate = dRate / (double)dt;
			m_strAverageDataOut.Format(_T("%0.2f"), dRate);
			//
			// Peek:
			if (atof (m_strPeekPacketIn) < atof(m_strCurrentPacketIn))
			{
				m_strPeekPacketIn = m_strCurrentPacketIn;
				m_strDate1PacketIn = m_TraficInfo.GetTimeStamp().Format(_T("%c"));
				m_strDate2PacketIn = infoNetTrafic.GetTimeStamp().Format(_T("%c"));
			}
			if (atof (m_strPeekDataIn) < atof(m_strCurrentDataIn))
			{
				m_strPeekDataIn = m_strCurrentDataIn;
				m_strDate1DataIn = m_TraficInfo.GetTimeStamp().Format(_T("%c"));
				m_strDate2DataIn = infoNetTrafic.GetTimeStamp().Format(_T("%c"));
			}
			if (atof (m_strPeekPacketOut) < atof(m_strCurrentPacketOut))
			{
				m_strPeekPacketOut = m_strCurrentPacketOut;
				m_strDate1PacketOut = m_TraficInfo.GetTimeStamp().Format(_T("%c"));
				m_strDate2PacketOut = infoNetTrafic.GetTimeStamp().Format(_T("%c"));
			}
			if (atof (m_strPeekDataOut) < atof(m_strCurrentDataOut))
			{
				m_strPeekDataOut = m_strCurrentDataOut;
				m_strDate1DataOut = m_TraficInfo.GetTimeStamp().Format(_T("%c"));
				m_strDate2DataOut = infoNetTrafic.GetTimeStamp().Format(_T("%c"));
			}
		}
	}
}
Beispiel #16
0
BOOL CDlgBankPass::OnInitDialog()
{
	__super::OnInitDialog();

	SetWindowText(TEXT("保险箱密码"));

	if(m_tmLogin == NULL) 
		m_tmLogin = CTime::GetCurrentTime();

	switch(g_GlobalOption.m_BankCloseMode)
	{
	case enBankRule_LK:
		break;
	case enBankRule_ZD:
		{
			CTimeSpan ts = CTime::GetCurrentTime() - m_tmLogin;
			int ipass=ts.GetSeconds();
			if( ipass <= g_GlobalOption.m_BankCloseTime)
			{
				m_tmLogin = CTime::GetCurrentTime();
				__super::OnOK();
				return TRUE;
			}
			break;
		}	
		
	case enBankRule_LEAVE:		//离开大厅时注销
		CGameFrame* pFrame = (CGameFrame*)AfxGetMainWnd();
		if(pFrame->m_bIsLogBank == true)
		{
			__super::OnOK();
			return TRUE;
		}
		break;
	}
	
	//设置变量
	m_strPassword=TEXT("");

	//更新变量
	UpdateData(FALSE);
    
	//设置焦点
	GetDlgItem(IDC_PASSWORD)->SetFocus();

	if(!m_ImageKuang.IsNull())
		m_ImageKuang.Destroy();
	m_ImageKuang.LoadFromResource(AfxGetInstanceHandle(),IDB_LOCK_KUANG);
	CRect rcFrame;
	GetWindowRect(&rcFrame);
	MoveWindow(&rcFrame,FALSE);
    
  //  m_btCancel.SetButtonImage(IDB_FACE_CLOSE,AfxGetInstanceHandle(),false);
	//m_btCancel.load
	SetWindowPos(NULL,0,0,290,200,SWP_NOMOVE|SWP_NOZORDER|SWP_NOCOPYBITS);
	m_ImageBuffer.Destroy();
    m_ImageBuffer.Create(290,200,16);

	//
	//m_btCancel2.LoadStdImage((L"skin/bt_close.png"));
    
	HDWP hDwp=BeginDeferWindowPos(0);
    
//	DeferWindowPos(hDwp,m_btCancel2,NULL,249,1,0,0,SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCOPYBITS|SWP_NOSIZE);
    
	EndDeferWindowPos(hDwp);

	return TRUE;
}
// 处理键盘捕捉的数字按键信息
LRESULT CIncrementSystemBFDlg::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
		// lParam&0x800000,如果结果是1,表示是被释放的,也就是抬起的。 

	if ( !(lParam & 0X80000000)) {

		if ((wParam >= 0x30 && wParam <= 0x39)
		||(wParam >= 0x60 && wParam <= 0x69)){
			timeNow = CTime::GetCurrentTime();
			CTimeSpan t = timeNow - timeStart;
			if (t.GetSeconds() >= cSystem.PressTimeout){
				CString logTime;
				logTime.Format(_T("输入间隔超过%d秒,此次按键为号码首位!"), cSystem.PressTimeout);
				CLogFile::WriteLog(logTime);
				telPos = 0;
				timeStart = CTime::GetCurrentTime();
			}
			
			if (telPos == 0){
				memset(&telPhone, 1, sizeof(telPhone) );
			}
			CString tempCode;
			tempCode.Format("%c", wParam);
			memcpy(&telPhone[telPos], tempCode, 1);
			
			CString logStr;
			logStr.Format("%d %c -- [%s]%p", telPos, wParam, telPhone, telPhone);
			CLogFile::WriteLog(logStr);
			telPos++;
		}

		if (wParam == 0x8){
			CLogFile::WriteLog("Enter Back");

			CString logStr;
			if (telPos <= 1){
				telPos = 1;
			}
			telPhone[telPos-1] = '\0';  
			logStr.Format("当前号码串为: [%s]", telPhone);
			CLogFile::WriteLog(logStr);
				
			telPos--;
			if (telPos < 0){
				telPos = 0;
			}
		}
		if (wParam == 0x1B){
			CLogFile::WriteLog(_T("接收ESC按键 重置输入信息, 下个数字为号码首位!"));
			telPos = 0;
		}
		
	}	



	if (telPos >= 11){
		telPos = 0;
		telPhone[12] = '\0';
			
		log.Format("Server Phone Number : [%s]",  telPhone);
		CLogFile::WriteLog(log); 

		if (!checkPhoneIsUnicom(telPhone)){
			return 0;	
		}
		//szCharUrl.Format("http://www.baidu.com/s?wd=%s", telPhone); 
		szCharUrl.Format("%s%s", cUrls.QueryPhone, telPhone);
		
		m_MyIE.Navigate(szCharUrl, NULL, NULL, NULL, NULL);
		PostMessage(WM_SIZE,0,0);
		ShowWindow(SW_RESTORE);
		
		timeStart = CTime::GetCurrentTime();
		//m_MyIE.Navigate(szCharUrl, NULL, NULL, NULL, NULL);
	}
	return 1;
}
Beispiel #18
0
void CDLGPlaywin::GetCurWndRecordTime(char *rtime)
{
	CTime nowtime=CTime::GetTickCount();
	CTimeSpan ts = nowtime - m_video.record[m_curScreen].starttime;
	sprintf(rtime,"%02d:%02d:%02d",ts.GetHours(),ts.GetMinutes(),ts.GetSeconds());
}
Beispiel #19
0
void CWorldSocket::OnClose(int nErrorCode)
  {

bool bWasClosed = m_pDoc->m_iConnectPhase == eConnectNotConnected;

  TRACE1 ("CWorldSocket::OnClose, error code %i\n", nErrorCode);

  m_pDoc->m_iConnectPhase = eConnectDisconnecting;

  m_pDoc->UpdateAllViews (NULL);

  m_pDoc->MXP_Off (true);   // turn off MXP now

  // update button bar - make button red
  if (m_pDoc->m_view_number >= 1 &&
      m_pDoc->m_view_number <= 10)
    Frame.OnUpdateBtnWorlds (m_pDoc->m_view_number, NULL);

  // execute "disconnect" script
  if (m_pDoc->m_ScriptEngine)
    {
    if (m_pDoc->SeeIfHandlerCanExecute (m_pDoc->m_strWorldDisconnect))
      {
      DISPPARAMS params = { NULL, NULL, 0, 0 };
      long nInvocationCount = 0;

      m_pDoc->ExecuteScript (m_pDoc->m_dispidWorldDisconnect,  
                             m_pDoc->m_strWorldDisconnect,
                             eWorldAction,
                             "world disconnect", 
                             "disconnecting from world",
                             params, 
                             nInvocationCount); 
      }
    } // end of executing disconnect script

  m_pDoc->SendToAllPluginCallbacks (ON_PLUGIN_DISCONNECT);

  // close log file if we auto-opened it
  if (!m_pDoc->m_strAutoLogFileName.IsEmpty ())
    m_pDoc->CloseLog ();

  if (m_pDoc->m_bShowConnectDisconnect && !bWasClosed)
    {
    CTime theTime;
    theTime = CTime::GetCurrentTime();

    CString strConnected;
    strConnected = theTime.Format (TranslateTime ("--- Disconnected on %A, %B %d, %Y, %#I:%M %p ---"));

    m_pDoc->Note (strConnected);  

    // find time spent connected
    CTimeSpan ts = CTime::GetCurrentTime() - m_pDoc->m_tConnectTime;
      
    CString strDuration = TFormat ("--- Connected for %i day%s, %i hour%s, %i minute%s, %i second%s. ---",
                  PLURAL ((long) ts.GetDays()),
                  PLURAL ((long) ts.GetHours()),
                  PLURAL ((long) ts.GetMinutes()),
                  PLURAL ((long) ts.GetSeconds()));

    m_pDoc->Note (strDuration);  

    // and a horizontal rule

    m_pDoc->m_pCurrentLine->flags = HORIZ_RULE;  
    m_pDoc->StartNewLine (true, 0); 
    }  // end of message in world window wanted

  CString strInfo = TFormat ("--- Received %i line%s, sent %i line%s.",
                PLURAL (m_pDoc->m_nTotalLinesReceived),
                PLURAL (m_pDoc->m_nTotalLinesSent)
                );
  
  m_pDoc->Note (strInfo);  

  strInfo = TFormat ("--- Output buffer has %i/%i line%s in it (%.1f%% full).",
                m_pDoc->m_LineList.GetCount (),
                m_pDoc->m_maxlines,
                (m_pDoc->m_LineList.GetCount ()) == 1 ? "" : "s",
                (double) m_pDoc->m_LineList.GetCount () / (double) m_pDoc->m_maxlines * 100.0
                );

  m_pDoc->Note (strInfo);  

  strInfo = TFormat ("--- Matched %i trigger%s, %i alias%s, and %i timer%s fired.",
                PLURAL (m_pDoc->m_iTriggersMatchedThisSessionCount),   
                PLURALES (m_pDoc->m_iAliasesMatchedThisSessionCount),    
                PLURAL (m_pDoc->m_iTimersFiredThisSessionCount)       
                );

  m_pDoc->Note (strInfo);  

CString str;

  str = TFormat ("The \"%s\" server has closed the connection", 
              (const char *) m_pDoc->m_mush_name);

  if (App.m_bNotifyOnDisconnect && !m_pDoc->m_bDisconnectOK)
    {
    if (App.m_bErrorNotificationToOutputWindow)
      m_pDoc->Note (str);
    else
      ::UMessageBox (str, MB_ICONEXCLAMATION);
    }
  else
    Frame.SetStatusMessage (str);
  m_pDoc->m_iConnectPhase = eConnectNotConnected;

  m_pDoc->UpdateAllViews  (NULL);     // force window title to be redrawn

  } // end of OnClose