Example #1
0
void CProgressThreadDlg::SetFinished()
{
  if (m_uTimerID != 0) {
    KillTimer(m_uTimerID);
  }

  // update button
  CWnd* pWnd = GetDlgItem(IDC_CANCEL);
  ASSERT(pWnd);
  pWnd->SetWindowText("OK");

  char endTitle[80];
  MakeString(endTitle, m_sCaption, " Completed", 80);
  ChangeTitle(endTitle);

  // progress bar to end
  SetProgressStep(m_nSteps);

  // final time label
  pWnd = GetDlgItem(IDC_ELAPSED_TIME);
  ASSERT(pWnd);
  m_timeEnd = CTime::GetCurrentTime();
  CTimeSpan ts = m_timeEnd - m_timeStart;
  CString sText = ts.Format("Total elapsed time  %H:%M:%S");
  pWnd->SetWindowText(sText);

  m_bOkToClose = true;
}
Example #2
0
void CCenterServerDlg::CheckBanBen()
{
	return ;
	CString sn ="20071030";////截止日期
	
	long in=atol(sn.GetBuffer (sn.GetLength ()));
	if(in<=0)return ;
	int y1=atoi(sn.Mid (0,4)),
		m1   =atoi(sn.Mid (4,2)),
		d1=atoi(sn.Mid (6,2));

	CTime t1(y1,m1,d1,0,0,0);
	time_t ct;  
    time( &ct ) ;

	CTime t2(ct);

	CTimeSpan tsp;
	tsp=t2-t1;//// 当前日期  - 截止日期

	LONGLONG dd=tsp.GetDays ();

	if(t2>t1)//dd > 0)
	{
		KillTimer(1);
		KillTimer(2);
		KillTimer(3);
		m_CenterServerModule.StoptService();
		AfxMessageBox("本软件生命周期到期,请重新联系www.bzw.cn获取升级版本。(此提示并非时间限制,而是说明程序寿命已到,获取升级版本是免费的。)");
		CDialog::OnOK ();//theApp.m_pMainWnd->DestroyWindow ();
		return ;
	}
}
Example #3
0
void CMainFrame::OnTimer
(
	UINT		nIDEvent
) 
{
	CTimeSpan	timeLeft	= 0;
	LONG		minLeft		= 0;
	LONG		secLeft		= 0;
	CMainFrame	*hWnd		= NULL;
	char		*szSubj		= NULL;

	log_printf("CMainFrame::OnTimer: entered.\n");

//#if 0 ///////////////////////////////////////////////////////
	hWnd		= (CMainFrame *)theApp.m_pMainWnd;
	get_cert_time_left(szCertRealm, &timeLeft);	// returns 0 if no realm or cert
	minLeft		= timeLeft.GetTotalMinutes();


	// Set TrayIcon to reflect status of cert (if any)
	if (minLeft >= CERT_DYING)
		hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_AUTH);
	else 
	{
		if (minLeft < CERT_DYING)
		{
			szSubj		= get_cert_subj(szCertRealm);

			// If null Subject, then no cert exists so change to Un-authenticated Icon
			if (!szSubj)
				hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_UNAUTH);
			else
			{
				// Alternate TrayIcons 'tween DEAD & DYING
				secLeft = (int)timeLeft.GetTotalSeconds();
				if ((secLeft % 2))
					hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_DEAD);
				else
					hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_AUTH);
				free(szSubj);
			}
		}
		else
			hWnd->m_trayIcon.ChangeSysTrayIcon(IDI_DEAD);
		log_printf("CMainFrame::OnTimer: gszHardErrorMsg=%s.\n", gszHardErrorMsg);
		if (bkx509busy == FALSE) 
		{
			bkx509busy = TRUE;
			kx509_main(kx509_argc, kx509_argv);
			bkx509busy = FALSE;
		}
	}
//#endif // 0 //////////////////////////////////////////////////////////////////


	// Do above check every 5 seconds
	(void)SetTimer(ID_SAMPLE_RATE, 5*1000, NULL);

	CFrameWnd::OnTimer(nIDEvent);
}
Example #4
0
// 경과 시간 갱신
VOID CConsoleManager::UpdateElapsedTime( VOID )
{
	CTime CurrentTime = CTime::GetCurrentTime();
	LONGLONG dElapsedHour = 0;
	CTimeSpan ElapsedTime;

	// m_stOperationTime.StartTime와 CurrentTime 비교
	if( m_stOperationTime.StartTime > CurrentTime )
	{
		g_Log.WriteLog( false,
						LOG_CLASS_WARNING,
						TEXT( "%s | Operation time value is invalid.\n" ),
						TEXT( __FUNCTION__ ) );

		m_stOperationTime.wElapsedHour = 0;
		m_stOperationTime.wElapsedMinute = 0;
		return;
	}

	ElapsedTime = CurrentTime - m_stOperationTime.StartTime;

	// 경과 시 갱신
	dElapsedHour = ElapsedTime.GetTotalHours();
	if( 9999 < dElapsedHour )  // 365일 * 24시간 = 8760시간
		m_stOperationTime.wElapsedHour = 9999;
	else
		m_stOperationTime.wElapsedHour = static_cast<WORD>( dElapsedHour );

	// 경과 분 갱신
	m_stOperationTime.wElapsedMinute = static_cast<WORD>( ElapsedTime.GetMinutes() );
}
Example #5
0
void CTortoiseProcApp::EnableCrashHandler()
{
	// the crash handler is enabled by default, but we disable it
	// after 3 months after a release

#define YEAR ((((__DATE__ [7] - '0') * 10 + (__DATE__ [8] - '0')) * 10  \
              + (__DATE__ [9] - '0')) * 10 + (__DATE__ [10] - '0'))

#define MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 1 : 6)      \
                : __DATE__ [2] == 'b' ? 2                               \
                : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 3 : 4)   \
                : __DATE__ [2] == 'y' ? 5								\
                : __DATE__ [2] == 'l' ? 7                               \
                : __DATE__ [2] == 'g' ? 8                               \
                : __DATE__ [2] == 'p' ? 9                               \
                : __DATE__ [2] == 't' ? 10                               \
                : __DATE__ [2] == 'v' ? 11 : 12)

 #define DAY ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10       \
              + (__DATE__ [5] - '0'))

 #define DATE_AS_INT (((YEAR - 2000) * 12 + MONTH) * 31 + DAY)

	CTime compiletime(YEAR, MONTH, DAY, 0, 0, 0);
	CTime now = CTime::GetCurrentTime();

	CTimeSpan timediff = now-compiletime;
	if (timediff.GetDays() > 3*31)
	{
//		crasher.Enable(FALSE);
	}
}
Example #6
0
void CBillingMgrJP::OnTimer( CAccount* pAccount )
{
	if( pAccount->m_fCheck == m_iBillingFreePass )	// 무료사용자 skip
		return;

	CTime tm = 0;
	if( pAccount->m_TimeOverDays == tm )			// login 미처리자 or timeover skip
		return;		

	CTime cur = CTime::GetCurrentTime();
	if( pAccount->m_TimeOverDays <= cur )			// timerover 처리 
	{	
		pAccount->m_TimeOverDays = 0;
		g_dpSrvr.CloseExistingConnection( pAccount->m_lpszAccount, ERROR_BILLING_TIME_OVER );
	}
	else
	{
		// 남은 시간 통지
		CTimeSpan ts = pAccount->m_TimeOverDays - cur;
		if ( ts.GetTotalMinutes() >= 59 && ts.GetTotalMinutes() <= 61 && 
			 pAccount->m_nStatus != ACCOUNT_STATUS_NOTIFIED &&
			 pAccount->m_fRoute == TRUE )
		{
			pAccount->m_nStatus = ACCOUNT_STATUS_NOTIFIED;				
			g_dpDbSrvr.SendOneHourNotify( pAccount );	// TRANS에 보낸다.
		}
	}			
}
LRESULT
CPDImfcDlg::OnDataStopped( WPARAM wP, LPARAM lP )
{
    TRACE0("CPDImfcDlg::OnDataStopped\n");
    CString     msg;

    CTimeSpan  ts = m_timeStop - m_timeStart;
    CString    s = ts.Format("%M:%S");
    msg.Format(_T("WM_PI_DATA_STOPPED: time elapsed %s,  %d frames collected, %d bytes, %d frames dropped, %d frames displayed\r\n"),
               (LPCTSTR)s, m_dwContFrameCount, m_dwContSize, m_dwOverflowCount, m_dwFramesDisplayed);
    AddMsg(msg);

    if (m_bCapture)
    {
        ParseFrame( g_pMotionBuf, m_dwContSize, TRUE );
    }

    if (m_bStyPno)
    {
        ClearStyMode();
    }

    m_bCont = FALSE;
    m_bStyPno = FALSE;
    m_bCapture = FALSE;

    EnableButtons();

    UpdateData(FALSE);

    return 0;
}
Example #8
0
void BuildWWhizReg(WWhizReg* reg)
{
	CString str;

	CTime firstTime = GetFirstTime();
	CTime curTime = CTime::GetCurrentTime();
	CTimeSpan timeDiff = curTime - firstTime;
	CTimeSpan time21Days(21, 0, 0, 0);

	if (firstTime + time21Days > curTime)
	{
	}

	// Read the key stuff from the registry.
//	validRegistration = ValidRegistration();
//	if (!HasExpiredHelper()  &&  !validRegistration  &&  timeDiff.GetDays() > 14)
	CString regName = AfxGetApp()->GetProfileString("Config", "RegName");
	CString regCode = AfxGetApp()->GetProfileString("Config", "RegCode");

	time_t registrationTime;
	bool decoded = ValidateRegistrationCode(regCode, regName, registrationTime);
	if (!HasExpiredHelper()  &&  !decoded  &&  timeDiff.GetDays() > 14)
	{
		CExpiredDlg dlg;
		dlg.m_numDays = timeDiff.GetDays() + 1;
		dlg.DoModal();
	}
}
Example #9
0
double DBPool::GetJshValue(int nValue ,CString strRealName)
{
	CString strName;
	
	CString stream;

	strName.Format("%s--%s",strRealName,dsn);

	#if _DEBUG
	  stream.Format("%s\\Temp\\SQLMonitor.ini",szRootPath);
	#else
	  stream.Format("%s\\Monitormanager\\Temp\\SQLMonitor.ini",szRootPath);
	#endif
	 int lastvalue ;
	 lastvalue=GetPrivateProfileInt(strName,"lastvalue",-1,(LPCSTR)stream);
	 int lasttime;
	 lasttime =GetPrivateProfileInt(strName,"lasttime",-1,(LPCSTR)stream);
	 CTime tNow =CTime::GetCurrentTime();
	 CTime tBase =CTime(2004,1,1,0,0,0,-1);
	 CTimeSpan tC;
	 tC=tNow-tBase;
	 long nCurrentTime =tC.GetTotalSeconds();
	 CString wValue;
	 wValue.Format("%d",nCurrentTime);
	 WritePrivateProfileString(strName,"lasttime",wValue.GetBuffer(wValue.GetLength()),(LPCSTR)stream);
	 wValue.Format("%d",nValue);
	 WritePrivateProfileString(strName,"lastvalue",wValue.GetBuffer(wValue.GetLength()),(LPCSTR)stream);
	 if(lastvalue==-1) nValue=0;
	  nValue=nValue-lastvalue;
	  if(nValue<0)  nValue=0;
	  double dValue ;
	  dValue =(double )nValue/(nCurrentTime-lasttime);
	  return dValue;
}
Example #10
0
void CSpaceObject::UpdateTradeExtended (const CTimeSpan &ExtraTime)

//	UpdateTradeExtended
//
//	Update trade after a long time.

	{
	//	Refresh inventory, if necessary

	CTradingDesc *pTradeOverride = GetTradeDescOverride();
	CDesignType *pType = GetType();
	CTradingDesc *pTrade = (pType ? pType->GetTradingDesc() : NULL);
	if ((pTrade || pTradeOverride) && ExtraTime.Days() > 0 && !IsAbandoned())
		{
		//	Compute the percent of the inventory that need to refresh

		int iRefreshPercent;
		if (ExtraTime.Days() >= DAYS_TO_REFRESH_INVENTORY)
			iRefreshPercent = 100;
		else
			iRefreshPercent = 100 * ExtraTime.Days() / DAYS_TO_REFRESH_INVENTORY;

		//	Do it

		if (pTradeOverride)
			pTradeOverride->RefreshInventory(this, iRefreshPercent);

		if (pTrade)
			pTrade->RefreshInventory(this, iRefreshPercent);
		}
	}
Example #11
0
void CDialogMistakes::UpdatePossible(){
	m_dTotalPossible = CBjDlg::m_dTotalPossible;
	m_dTotalPossible2 = CBjDlg::m_dTotalPossible;
	//add history
	if (m_pCurrentHistory){
		m_dTotalPossible += m_pCurrentHistory->m_dTotalPossible;
		m_dTotalPossible2 += m_pCurrentHistory->m_dTotalPossible2;
	}

	m_dTotalActual = m_dTotalPossible - m_dTotalMistakes;
	m_dTotalActual2 = m_dTotalPossible2 - m_dTotalMistakes2;
	//update the other stats as well
	m_nHandsPlayed = CBjDlg::m_nHandsPlayed;	
	//add history
	if (m_pCurrentHistory){
		m_nHandsPlayed += m_pCurrentHistory->m_nHandsPlayed;
	}

	m_dWinPerHand = m_dTotalActual/m_nHandsPlayed;
	m_dAvgStandardCount = CBjDlg::m_dAvgStandardCount;	
	m_nActualWin = m_pBjDlg->m_DlgPractice.m_nSessionMoney;
	m_dTheoreticalWin = m_dWinPerHand*m_nHandsPlayed*m_pBjDlg->m_nLowBet;
	//add history
	CTimeSpan total = CBjDlg::m_TotalPlayTime;
	if (m_pCurrentHistory){
		m_dAvgStandardCount = (m_dAvgStandardCount*CBjDlg::m_nHandsPlayed + m_pCurrentHistory->m_dAvgStandardCount*m_pCurrentHistory->m_nHandsPlayed);
		m_dAvgStandardCount /= m_nHandsPlayed;
		total += m_pCurrentHistory->m_TimePlayed;
		m_nActualWin += m_pCurrentHistory->m_nRealWin;
	}
	m_strTimePlayed = total.Format("%D days %H:%M");
	//add history
	UpdateData(FALSE);	
}
Example #12
0
//
//  機能     : 古いログの削除
//  
//  機能説明 : LOG_EXPIRE 日以上前のログは削除
//  
//  返り値   : true  正常終了
//             false エラー発生
//  
//  備考     : 
//  
bool CTPerror::DelOldLog()
{
	CString str;
	CFileFind finder;
	CTime ntm;
	CTime tm;
	CTimeSpan tms;
	CFileSpec fs;

	/// LOG_EXPIRE期間以前のログファイルを削除
	if (!SetCurrentDirectory(LogDir)) return false;
	ntm = CTime::GetCurrentTime();
	BOOL bWorking = finder.FindFile(_T("*.log"));
	if (!bWorking) return false;
	str.Empty();
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if (!finder.IsDirectory()) {
			str = finder.GetFileName();
			/// ログファイル作成日付と現在との差分
			finder.GetCreationTime(tm);
			tms = ntm - tm;
			if (tms.GetDays() > LOG_EXPIRE) {
				fs.SetFullSpec(str);
				if (!fs.Exist()) continue;
				fs.FileDelete();
			}
		}
	}
	finder.Close();

	return true;
}
Example #13
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;
}
Example #14
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;
}
Example #15
0
void CChatDlg::OnTimer(UINT nIDEvent) 
{
	if (nIDEvent == IDT_TOTAL_TIME) {
		CTime now = CTime::GetCurrentTime();
		CTimeSpan span = now - startTime;
		SetDlgItemText(IDC_TOTAL_TIME, span.Format("%H:%M:%S"));
	} else
		CDialog::OnTimer(nIDEvent);
}
Example #16
0
File: alarm.cpp Project: bugou/test
static void setTimer(CTime &t)
{
	CTime cur = CTime::GetCurrentTime();
	if (t >= cur) {
		KillTimer(NULL, timerID);
		CTimeSpan span = t - cur;
		timerID = SetTimer(NULL, 0, span.GetTotalSeconds() * 1000, onTimer);
	}
}
Example #17
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);
  }

}
	std::string GetTimeSpanStr(CTimeSpan t)
	{
		std::string strTime;

		if (t.GetDays() > 0)
			strTime = UtilWin::ToUTF8(t.Format(_T("%D, %H:%M:%S")));
		else strTime = UtilWin::ToUTF8(t.Format(_T("%H:%M:%S")));

		return strTime;
	}
Example #19
0
//006bc300
unsigned long CPeriodItemEx::GetLeftDate(long lExpireDate)	//OK
{
	unsigned long dwReturnValue = 0;
	CTime tExpireTime(lExpireDate);
	CTime tCurrentTime(CTime::GetTickCount());
	CTimeSpan tSpanTime;
	tSpanTime = tExpireTime - tCurrentTime;
	dwReturnValue = tSpanTime.GetTotalSeconds();
	return dwReturnValue;
}
Example #20
0
void CKcsLogging::ClearLogFileByDays(int nDay /* = 7 */)
{
    CHAR szLogFileName[MAX_PATH * 2] = { 0 };
    WIN32_FIND_DATAA fd = { 0 };
    HANDLE hFile = INVALID_HANDLE_VALUE;

    SHGetSpecialFolderPathA(NULL, szLogFileName, CSIDL_LOCAL_APPDATA, FALSE);

    PathAppendA(szLogFileName, "KSafe\\KClear\\Logs");
    PathAppendA(szLogFileName, "*.*");


    hFile = FindFirstFileA(szLogFileName, &fd);
    if (INVALID_HANDLE_VALUE == hFile)
    {
        goto Clear0;
    }

    do 
    {
        if (0 == stricmp(".", fd.cFileName) || 0 == stricmp("..", fd.cFileName))
            continue;

        time_t lNow = 0;
        time(&lNow);  

        FILETIME localfiletime;    
        FileTimeToLocalFileTime(&(fd.ftLastWriteTime), &localfiletime);

        CTime stSys(lNow);
        CTime stFile(localfiletime);
        CTimeSpan stSPan;

        stSPan =  stSys - stFile;

        if (stSPan.GetDays() >= nDay)
        {           
            CStringA strtemp = szLogFileName ;
            CStringA strFileName = strtemp.Left(strtemp.ReverseFind(L'\\') + 1);
            strFileName += fd.cFileName;                 
            if (::PathFileExistsA(strFileName))
            {
                ::DeleteFileA(strFileName);
            }
        }

    } while (FindNextFileA(hFile, &fd));

Clear0:
    if (hFile != INVALID_HANDLE_VALUE)
    {
        FindClose(hFile);
        hFile = INVALID_HANDLE_VALUE;
    }   
}
Example #21
0
long certLife(char *realm)
{
	CTimeSpan		timeLeft	= 0;
	long			lifeLeft	= 0;


	get_cert_time_left(realm, &timeLeft);
	lifeLeft = timeLeft.GetTotalMinutes();

	return lifeLeft;
}
Example #22
0
//此函数暂时不使用
CString CMainFrame::GetRunningTime()
{
	CTimeSpan tSpan;
	tSpan = CTime::GetCurrentTime() - m_StartTime;
	LONGLONG totalSeconds = tSpan.GetTotalSeconds();
	LONGLONG totalMinutes = tSpan.GetTotalMinutes();
	LONGLONG totalHours = tSpan.GetTotalHours();
	CString strRet="";
	strRet.Format("%d天%02d时%02d分%02d秒",totalHours / 24,totalHours % 24,totalMinutes % 60,totalSeconds % 60);
	return strRet;
}
Example #23
0
int GetElapsedDays (int yy,int mm,int dd)
{
	CTime curr;
	curr =CTime::GetCurrentTime();
	
	CTime from(curr.GetYear(),curr.GetMonth(),curr.GetDay(),24,0,0);
	CTime to(yy,mm,dd,24,0,0);
	CTimeSpan elapsedTime = to - from;
	
	return elapsedTime.GetDays();
}
Example #24
0
int GetDays(tm ToDay)
{
	CTime from;
	from =CTime::GetCurrentTime();

	CTime to(ToDay.tm_year,ToDay.tm_mon,ToDay.tm_mday,0,0,0);

	CTimeSpan elapsedTime = to - from;

	return elapsedTime.GetDays();
}
Example #25
0
void RegistrationDialog(bool force)
{
	CTime firstTime = GetFirstTime();
	CTime curTime = CTime::GetCurrentTime();
	CTimeSpan timeDiff = curTime - firstTime;
	if (timeDiff.GetDays() > 14  ||  force)
	{
		CExpiredDlg dlg;
		dlg.m_numDays = timeDiff.GetDays() + 1;
		dlg.DoModal();
	}
}
Example #26
0
CString g_GetAppRunningTimePerIteration(bool with_title)
{
	CString str;
	CTime EndTime = CTime::GetCurrentTime();
	CTimeSpan ts = EndTime - g_AppLastIterationStartTime;

	if (with_title)
		str = ts.Format("CPU Clock: %H:%M:%S --");
	else
		str = ts.Format("%H:%M:%S");
	return str;
}
Example #27
0
int ScheduleViewEx::GetXOffset() const
{
	Periods& periods = static_cast<CScheduleApp*>(AfxGetApp())->m_periods;
	Period& period = periods.GetCurrentPeriod();
	CTimeSpan span = period.m_dateRange.GetEndDate() - 
		period.m_dateRange.GetStartDate();
	int numberOfXPages = (int)(span.GetDays() / xDelta);
	if (span.GetDays() % xDelta) // if a partial page, then add 1
		numberOfXPages++;
	int xOffset = m_offset  % numberOfXPages;
	return xOffset;
}
Example #28
0
//录像定时事件
void CDLGscreen::RecordTimerEvent()
{
	for(int i=0;i<MAX_DEVICE_NUM;i++)
	{
		if(m_videoInfo[i].isRecord == true)
		{
			CTime nowtime=CTime::GetTickCount();
			CTimeSpan ts = nowtime - m_videoInfo[i].startTime;
			int recMinutes = ts.GetMinutes();
			if(recMinutes >= DlgSetSystem.m_record_cuttime)
			{
				StopRecord(i);
				DlgMain->DlgTabVideo.DlgNormal.OpenRecord(i);
			}
		}
#if OPEN_RECORD
		//定时录制
		if(DlgMain->DlgTabVideo.DlgSetRecord.NeedRecord(m_videoInfo[i].camID))
		{
			if(m_videoInfo[i].isRecord == false)
			{
				m_videoInfo[i].planRecord = true;
				DlgMain->DlgTabVideo.DlgNormal.OpenRecord(i);	//开始录制
			}
		}
		else
		{
			if(m_videoInfo[i].planRecord == true)
			{
				m_videoInfo[i].planRecord = false;
				if(m_videoInfo[i].isRecord == true)
				{
					DlgMain->DlgTabVideo.DlgNormal.CloseRecord(i);	//停止录制
				}
			}
		}
#endif
	}

	//定时录像放这里ZOG
	//FOR N个摄像头
#if OPEN_RECORD
	if(DlgMain->DlgTabVideo.DlgSetRecord.NeedRecord(CAMID) )
	{
		if(m_videoInfo[i].isRecord)
		//不做事情
		else
		//开始录制
	
	}
	else
	{
		if(m_videoInfo[i].isRecord)
Example #29
0
const CTimeSpan operator- (const CTimeSpan &op1, const CTimeSpan &op2)

//	Operator -
//
//	Subtract op2 from op1 (op1 must be greater than op2)

	{
	LONGLONG time1 = (op1.Days() * SECONDS_PER_DAY * 1000) + op1.Milliseconds();
	LONGLONG time2 = (op2.Days() * SECONDS_PER_DAY * 1000) + op2.Milliseconds();
	LONGLONG result = (time1 >= time2 ? time1 - time2 : time2 - time1);

	return CTimeSpan((int)(result / (SECONDS_PER_DAY * 1000)), (int)(result % (SECONDS_PER_DAY * 1000)));
	}
Example #30
0
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());
}