예제 #1
0
ATL::CString GlobeFuns::TimeToFriendlyString(const CTime &t)
{
	CTimeSpan tmSpan = CTime::GetCurrentTime() - t;
	CString strRet;
	if (tmSpan.GetTotalMinutes()<1)
	{
		return "现在";
	}
	//if (tmSpan.GetTotalMinutes()<10)
	//{
	//	strRet.Format("%d分钟前",tmSpan.GetTotalMinutes());
	//	return strRet;
	//}
	if (tmSpan.GetTotalMinutes()<60)
	{
		strRet.Format("%d分钟前",tmSpan.GetTotalMinutes());
		return strRet;
	}
	if (tmSpan.GetTotalHours()<24)
	{
		strRet.Format("%d小时前",tmSpan.GetTotalHours());
		return strRet;
	}

	strRet.Format("%d天前",tmSpan.GetTotalHours()/24);
	return strRet;
}
예제 #2
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에 보낸다.
		}
	}			
}
예제 #3
0
파일: MainFrm.cpp 프로젝트: DUNE/kx509
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);
}
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);
	}
}
예제 #5
0
long certLife(char *realm)
{
	CTimeSpan		timeLeft	= 0;
	long			lifeLeft	= 0;


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

	return lifeLeft;
}
예제 #6
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;
}
예제 #7
0
int CCashItemPeriodSystem::CalcItemUseLeftTime(LPSTR pchBuyDate)
{
	int iUsedTime = 0;
	CTime tCurrentTime = CTime::GetTickCount();
	CTime tBuyTime;
	CTimeSpan tTimeSpan;

	this->ConvertStringToTime(pchBuyDate, &tBuyTime);
	tCurrentTime - tBuyTime;
	tTimeSpan = tBuyTime - tCurrentTime;
	iUsedTime = tTimeSpan.GetTotalMinutes();

	return iUsedTime;
}
예제 #8
0
//006bbfb0
long CPeriodItemEx::ConvertStringToTime(char const* pchTime)	//OK
{
	int iYear = 0;
	int iMonth = 0;
	int iDay = 0;
	int iHour = 0;
	int iMinute = 0;
	int iDateLength = 0;

	CTime tCurrentTime(CTime::GetTickCount());
	CTime tExpireTime;
	CTimeSpan tSpanTime;

	long lReturnTime = 0;
	char chDate[20];

	char* Token;
	char seps[4] = "-: ";

	if( !pchTime )
		return 0;

	memcpy(chDate,pchTime,sizeof(chDate));
	iDateLength = strlen(chDate);

	if( iDateLength < 0 || iDateLength > 20 )
		return 0;

	Token = strtok(chDate,seps);
	iYear = atoi(Token);

	Token = strtok(0,seps);
	iMonth = atoi(Token);

	Token = strtok(0,seps);
	iDay = atoi(Token);

	Token = strtok(0,seps);
	iHour = atoi(Token);

	Token = strtok(0,seps);
	iMinute = atoi(Token);

	CTime tReturnTime(iYear,iMonth,iDay,iHour,iMinute,0,-1);
	tSpanTime = tReturnTime - tCurrentTime;
	lReturnTime = tSpanTime.GetTotalMinutes();
	return lReturnTime;
}
예제 #9
0
파일: MainFrm.cpp 프로젝트: DUNE/kx509
LONG CMainFrame::OnSysTrayMessage(
	WPARAM			uID, 
	LPARAM			lEvent
) 
{
	DWORD			nMenuItem	= -1;
	CTimeSpan		timeLeft	= 0;


	if (uID != IDI_UNAUTH) {
		return(0);
	}
	// You can select which way the Shell should behave by calling Shell_NotifyIcon with dwMessage set to NIM_SETVERSION. 
	// Set the uVersion member of the NOTIFYICONDATA structure to indicate whether you want version 5.0 or pre-version 5.0 behavior.

	switch (lEvent) {
		case (WM_CONTEXTMENU) :			// 
		case (WM_RBUTTONUP) : {
			// Do SysTray Menu stuff
			switch (this->SysTrayMenu())
			{
				case IDS_EXIT_APP:
					PostQuitMessage(0);
					return(1);
				case IDS_SILENT_SELECT:
					SetSilentSelectFlag((bSilentSelect==FALSE) ? TRUE : FALSE);
					break;
				default:
					break;
			}
		}
		case (WM_LBUTTONDBLCLK) : {
			// FORCE RE-FETCH OF CERT (USEFUL IF CHANGED KERB-IDENTITY PRIOR TO CERT EXPIRE)
			char	**argv = NULL;
			int		argc = 0;

			bPwdPrompt = TRUE;
			if (bkx509busy == FALSE) {
				bkx509busy = TRUE;
			    kx509_main(kx509_argc, kx509_argv);
				bkx509busy= FALSE;
			}
			bPwdPrompt = FALSE;

			return(1);
			break;
		}
		case (WM_MOUSEMOVE) : {
			// Show Current User Identity
			CString		sTimeLeft;
			char		*szTimeLeft = NULL;
			char		*szSubj		= NULL;
			char		tip[128]	= {0};
			char		*krbv		= KX509_CLIENT_KRB;


#ifdef USE_KRB5
#  ifdef USE_MSK5
			sprintf(tip, "%s %s: <Lock-Unlock screen or Double-Click Icon to get Certificate>\n\n", krbv, KX509_CLIENT_VERSION);
#  else // !USE_MSK5
			sprintf(tip, "%s %s: <Double-Click Icon to acquire tickets to get Certificate>\n\n", krbv, KX509_CLIENT_VERSION);
#  endif // !USE_MSK5
#else // !USE_KRB5
			sprintf(tip, "%s %s: <Double-Click Icon to acquire tickets to get Certificate>\n\n", krbv, KX509_CLIENT_VERSION);
#endif // !USE_KRB5

			if (strlen(gszHardErrorMsg))
			{
				sprintf(tip, "%s %s: ", krbv, KX509_CLIENT_VERSION);
				strncat(tip, gszHardErrorMsg, 63);
				strcat(tip, "\n\n");
			}
			else if (szStatusMsg)
			{
				sprintf(tip, "%s %s: ", krbv, KX509_CLIENT_VERSION);
				strncat(tip, szStatusMsg, 63);
				strcat(tip, "\n\n");
			}
			else
			{
				szSubj		= get_cert_subj(szCertRealm);
				if (szSubj)
				{
			log_printf("CMainFrame::OnSysTrayMessage: before get_cert_time_left.\n");
					get_cert_time_left(szCertRealm, &timeLeft);
					sTimeLeft	= timeLeft.Format(" %H hours, %M minutes");
					if (szTimeLeft = (char *)malloc(256))
					{
						if (strlen(szSubj) > 30)
							szSubj = szCertRealm;

						strcpy(szTimeLeft, sTimeLeft.GetBuffer(64));

						if (timeLeft.GetTotalMinutes() < 0)
							sprintf(tip, "%s %s: Cert for %s: EXPIRED\n\n", krbv, KX509_CLIENT_VERSION, szSubj);
						else
							sprintf(tip, "%s %s: Cert for %s: %s\n\n", krbv, KX509_CLIENT_VERSION, szSubj, szTimeLeft);
						free(szTimeLeft);
						szTimeLeft = NULL;
					}
			log_printf("CMainFrame::OnSysTrayMessage: before free.\n");
					free(szSubj);
					szSubj = NULL;
				}
			}
		log_printf("CMainFrame::OnSysTrayMessage: before ChangeSysTrayTip.\n");
			m_trayIcon.ChangeSysTrayTip(tip);

			// No "return(1)"  Let the system finish up for us.
			break;
		}
	}
	return(0);
}
예제 #10
0
파일: Fun.cpp 프로젝트: xfxf123444/japan
BOOL CheckPassword(char *szUserName,char *szPassword)
{
	WCHAR   szFile[MAX_PATH],*p;
	USERPASSSTRUCT   UserInfo[2] = {0};
	DWORD  dwWrited;
	HANDLE hFile;
	SYSTEMTIME  CurTime;
	CTimeSpan   TimeSpan;
	BOOL bResult = FALSE;

	if (stricmp(szUserName,"administrator") &&
		stricmp(szUserName,"comptroller")) return FALSE;

	GetModuleFileName(NULL,szFile,MAX_PATH);
	p = wcsrchr(szFile,L'\\');
	if (!p) return FALSE;
	wcscpy(p,L"\\AdminData.dat");

	hFile = CreateFile(szFile,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,
						NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);

	if( INVALID_HANDLE_VALUE == hFile) 
	{
		SavePassword("administrator","administrator",TRUE);
		SavePassword("comptroller","comptroller",FALSE);
		if (!stricmp(szUserName,"administrator"))
		{
			bResult = (!stricmp(szPassword,"administrator"));
		}
		else
		{
			bResult = (!stricmp(szPassword,"comptroller"));
		}
		return bResult;
	}

	ReadFile(hFile,&UserInfo,sizeof(USERPASSSTRUCT)*2,&dwWrited,NULL);
	if (!stricmp(szUserName,"administrator"))
	{
		if (UserInfo[0].ulTryTimes >= 3)
		{
			GetLocalTime(&CurTime);
			if (CTime(CurTime) > CTime(UserInfo[0].LastTryTime))
			{
				TimeSpan = CTime(CurTime) - CTime(UserInfo[0].LastTryTime);
				if (TimeSpan.GetTotalMinutes() >= 10)
					UserInfo[0].ulTryTimes = 0;
			}
		}

		if (UserInfo[0].ulTryTimes >= 3)
		{
			AfxMessageBox(IDS_TRY_LIMIT);
			bResult = FALSE;
		}
		else
		{
			GetLocalTime(&UserInfo[0].LastTryTime);
//			YGAESDecryptData((UCHAR *)szPassword,strlen(szPassword),(UCHAR *)UserInfo[0].szUserName,(UCHAR *)UserInfo[0].szUserName,64);
			bResult = (!stricmp(szUserName,UserInfo[0].szUserName) && 
						!stricmp(szPassword,UserInfo[0].szUserPass));
			if (bResult)
			{
				UserInfo[0].ulLastTryStatus = 0;
				UserInfo[0].ulTryTimes = 0;
			}
			else
			{
				UserInfo[0].ulLastTryStatus = -1;
				UserInfo[0].ulTryTimes ++;
			}
//			YGAESEncryptData((UCHAR *)szPassword,strlen(szPassword),(UCHAR *)UserInfo[0].szUserName,(UCHAR *)UserInfo[0].szUserName,64);
			SetFilePointer(hFile,0,NULL,FILE_BEGIN);
			WriteFile(hFile,&UserInfo,sizeof(USERPASSSTRUCT)*2,&dwWrited,NULL);
		}
	}
	else
	{
		if (UserInfo[0].ulTryTimes >= 3)
		{
			GetLocalTime(&CurTime);
			if (CTime(CurTime) > CTime(UserInfo[0].LastTryTime))
			{
				TimeSpan = CTime(CurTime) - CTime(UserInfo[0].LastTryTime);
				if (TimeSpan.GetTotalMinutes() >= 10)
					UserInfo[0].ulTryTimes = 0;
			}
		}

		if (UserInfo[1].ulTryTimes >= 3)
		{
			AfxMessageBox(IDS_TRY_LIMIT);
			bResult = FALSE;
		}
		if (UserInfo[1].ulTryTimes < 3)
		{
			GetLocalTime(&UserInfo[1].LastTryTime);
//			YGAESDecryptData((UCHAR *)szPassword,strlen(szPassword),(UCHAR *)UserInfo[1].szUserName,(UCHAR *)UserInfo[1].szUserName,64);
			bResult = (!stricmp(szUserName,UserInfo[1].szUserName) && 
						!stricmp(szPassword,UserInfo[1].szUserPass));
			if (bResult)
			{
				UserInfo[1].ulLastTryStatus = 0;
				UserInfo[1].ulTryTimes = 0;
			}
			else
			{
				UserInfo[1].ulLastTryStatus = -1;
				UserInfo[1].ulTryTimes ++;
			}
//			YGAESEncryptData((UCHAR *)szPassword,strlen(szPassword),(UCHAR *)UserInfo[1].szUserName,(UCHAR *)UserInfo[1].szUserName,64);
			SetFilePointer(hFile,0,NULL,FILE_BEGIN);
			WriteFile(hFile,&UserInfo,sizeof(USERPASSSTRUCT)*2,&dwWrited,NULL);
		}
	}
	CloseHandle(hFile);
	return bResult;
}
예제 #11
0
파일: Fun.cpp 프로젝트: xfxf123444/japan
BOOL CheckPassword( char *szUserName,char *szPassword )
{
	WCHAR   szFile[MAX_PATH],*p;
	USERPASSSTRUCT   UserInfo[2] = {0};
	DWORD  dwWrited;
	HANDLE hFile;
	SYSTEMTIME  CurTime;
	CTimeSpan   TimeSpan;
	BOOL bResult = FALSE;

	if (stricmp(szUserName,"administrator") &&
		stricmp(szUserName,"comptroller")) return FALSE;

	//GetModuleFileName(NULL,szFile,MAX_PATH);
	//p = wcsrchr(szFile,L'\\');
	//if (!p) return FALSE;
	//wcscpy(p,L"\\AdminData.dat");
	CString path;
	GetLocalDir(path);
	path += L"\\AdminData.dat";

	hFile = CreateFile(path,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,
						NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);

	if( INVALID_HANDLE_VALUE == hFile) 
	{
		SavePassword("administrator","administrator",TRUE);
		SavePassword("comptroller","comptroller",FALSE);
		if (!stricmp(szUserName,"administrator"))
		{
			bResult = (!stricmp(szPassword,"administrator"));
		}
		else
		{
			bResult = (!stricmp(szPassword,"comptroller"));
		}
		return bResult;
	}

	ReadFile(hFile,&UserInfo,sizeof(USERPASSSTRUCT)*2,&dwWrited,NULL);
	BOOL bAdmin = !stricmp(szUserName,"administrator");
	USERPASSSTRUCT* pTempUser = 0;
	if (bAdmin)
	{
		pTempUser = &UserInfo[0];
	}
	else
	{
		pTempUser = &UserInfo[1];
	}
	if (pTempUser->ulStructVer != CURRENT_FILE_VERSION)
	{
		CloseHandle(hFile);
		if (bAdmin)
		{
			SavePassword("administrator","administrator",TRUE);
			bResult = (!stricmp(szPassword,"administrator"));
		}
		else
		{
			SavePassword("comptroller","comptroller",FALSE);
			bResult = (!stricmp(szPassword,"comptroller"));
		}
		return bResult;
	}
	else
	{
		if (pTempUser->ulTryTimes >= 3)
		{
			GetLocalTime(&CurTime);
			if (CTime(CurTime) > CTime(pTempUser->LastTryTime))
			{
				TimeSpan = CTime(CurTime) - CTime(pTempUser->LastTryTime);
				if (TimeSpan.GetTotalMinutes() >= 10)
					pTempUser->ulTryTimes = 0;
			}
		}

		if (pTempUser->ulTryTimes >= 3)
		{
			AfxMessageBox(IDS_TRY_LIMIT);
			bResult = FALSE;
		}
		else
		{
			GetLocalTime(&pTempUser->LastTryTime);

			YGAESDecryptData((UCHAR *)pTempUser->szUserPass,strlen(pTempUser->szUserPass),\
				(UCHAR *)pTempUser->szUserName,(UCHAR *)pTempUser->szUserName,32);

			bResult = (!stricmp(szUserName,pTempUser->szUserName) && 
						!stricmp(szPassword,pTempUser->szUserPass));
			if (bResult)
			{
				pTempUser->ulLastTryStatus = 0;
				pTempUser->ulTryTimes = 0;
			}
			else
			{
				pTempUser->ulLastTryStatus = -1;
				pTempUser->ulTryTimes ++;
			}
			YGAESEncryptData((UCHAR *)pTempUser->szUserPass,strlen(pTempUser->szUserPass),(UCHAR *)pTempUser->szUserName,(UCHAR *)pTempUser->szUserName,32);
			SetFilePointer(hFile,0,NULL,FILE_BEGIN);
			WriteFile(hFile,&UserInfo,sizeof(USERPASSSTRUCT)*2,&dwWrited,NULL);
		}
	}
	
	CloseHandle(hFile);
	return bResult;
}
예제 #12
0
UINT CReportCameraWorker::OnThread(int ThreadNum)
{
	CRequest req;
	CRequest reqSend;
	COptionsMap map;

	CString strData;
	CTaskInfo task;

	CString folder;
	CString strFilename;
	
	while(!m_Thread.IsStopped())
	{
		//TRACE(_T("CReportCameraWorker::OnThread\n"));

		HANDLE hEvents[] = {m_hStartCaptureEvent, m_hStopCaptureEvent};
		DWORD res = WaitForMultipleObjects(2, hEvents, FALSE, 1000);

		switch (res)
		{
			// start capture
		case WAIT_OBJECT_0:
			StartCapture();
			break;
			// stop capture
		case WAIT_OBJECT_0 + 1:
			StopCapture();
			break;
		case WAIT_OBJECT_0 + 2:
			break;
		case WAIT_TIMEOUT:
			break;
		}

		if(m_Thread.WaitEvent(1000) == CThread::WAIT_STATUS_ON_EVENT)
		{
			TRACE(_T("CReportCameraWorker::OnThread Wake\n"));
		}
		if(m_Thread.WaitEvent(1000) == -1)
			break;
		//TRACE(_T("CReportCameraWorker::OnThread2\n"));

		if (m_bCaptureStarted)
		{
			CTime CurrentTime = CTime::GetCurrentTime();
			
			CTimeSpan ts = CurrentTime - m_LastStartedCaptureTime;

			//TRACE(_T("%ld, %ld\n"), ts.GetTotalMinutes(), ts.GetTotalSeconds());
			
			switch (m_ReportCameraConfig.m_Action)
			{
			case REPORT_CAMERA_RECORD_VIDEO:
				if (ts.GetTotalMinutes() >= REPORT_CAMERA_VIDEO_DURATION)
				//if (ts.GetTotalSeconds() > 10)
				{
					RestartCapture();
				}
				break;
			case REPORT_CAMERA_SHOOT_PHOTO:
				if (ts.GetTotalMinutes() >= m_ReportCameraConfig.m_iShootPhotoEvery)
				//if (ts.GetTotalSeconds() > 10)
				{
					MakeCapturePhoto();
				}
				break;
			}

		}

	}

	TRACE(_T("CReportCameraWorker::OnThread end\n"));

	return 0;
}
예제 #13
0
void Alarm::CheckAndTrigger()
{
    if (ValidFieldFlags == 0)
        return;

    BOOL Triggered = TRUE;

    CTime now = CTime::GetCurrentTime();

    if ((ValidFieldFlags & VF_TIMEOFDAY) != 0)
    {
        if ((now.GetHour() != TimeOfDayHour) ||
                (now.GetMinute() != TimeOfDayMinute))
        {
            Triggered = FALSE;
        }
    }

    if ((ValidFieldFlags & VF_DAYOFWEEK) != 0)
    {
        if (now.GetDayOfWeek() != DayOfWeek)
            Triggered = FALSE;
    }

    if ((ValidFieldFlags & VF_DAYOFMONTH) != 0)
    {
        if (now.GetDay() != DayOfMonth)
            Triggered = FALSE;
    }

    if ((ValidFieldFlags & VF_MONTHOFYEAR) != 0)
    {
        if (now.GetMonth() != MonthOfYear)
            Triggered = FALSE;
    }

    if (Triggered)
    {
        CTimeSpan timeSinceLastTrigger = now - TimeLastTriggered;

        if ((ValidFieldFlags & VF_TIMEOFDAY) != 0)
        {
            if (timeSinceLastTrigger.GetTotalMinutes() < 2)
                Triggered = FALSE;
        }
        else if (((ValidFieldFlags & VF_DAYOFWEEK) != 0) ||
                 ((ValidFieldFlags & VF_DAYOFMONTH) != 0))
        {
            if (timeSinceLastTrigger.GetTotalHours() < 26)
                Triggered = FALSE;
        }
        else
        {
            if (timeSinceLastTrigger.GetTotalHours() < (24*33))
                Triggered = FALSE;
        }
    }

    if (Triggered)
    {
        TimeLastTriggered = now;

        TRACE1("TRIGGER: %s\n", TextMessage);

        DAlarmNotify& dlg = *new DAlarmNotify;
        dlg.TextMessage = TextMessage;
        dlg.Create(IDD_ALARMNOTIFY);
        dlg.ShowWindow(SW_SHOW);

        sndPlaySound(((CAlarmsDlg*)theApp.m_pMainWnd)->alarmsSoundFile,SND_ASYNC);
    }
}