CString CBCGPPlannerPrintMonth::GetPageHeaderText () const { CString strText; SYSTEMTIME st; CString str; COleDateTime dtStart (GetDateStart ()); COleDateTime dtEnd (GetDateEnd ()); if ((dtStart + COleDateTimeSpan (7, 0, 0, 0)).GetMonth () != dtStart.GetMonth ()) { dtStart += COleDateTimeSpan (7, 0, 0, 0); } if ((dtEnd - COleDateTimeSpan (7, 0, 0, 0)).GetMonth () != dtEnd.GetMonth ()) { dtEnd -= COleDateTimeSpan (7, 0, 0, 0); } dtStart.GetAsSystemTime (st); ::GetDateFormat ( LOCALE_USER_DEFAULT, 0, &st, _T("MMMM yyyy"), str.GetBuffer (100), 100 ); str.ReleaseBuffer (); strText = str; if (dtStart.GetMonth () != dtEnd.GetMonth ()) { dtEnd.GetAsSystemTime (st); ::GetDateFormat ( LOCALE_USER_DEFAULT, 0, &st, _T("MMMM yyyy"), str.GetBuffer (100), 100 ); str.ReleaseBuffer (); strText += _T(" -\r"); strText += str; } return strText; }
int GetSeconds(COleDateTime& time1, COleDateTime& time2) { SYSTEMTIME sm1, sm2; time1.GetAsSystemTime(sm1); time2.GetAsSystemTime(sm2); CTime tm1(sm1); CTime tm2(sm2); return (int)(tm1.GetTime() - tm2.GetTime()); }
int GetSeconds(COleDateTime& time1) { SYSTEMTIME sm1; time1.GetAsSystemTime(sm1); CTime tm1(sm1); return (int)(tm1.GetTime()); }
BOOL CallContextDayNote(SYSTEMTIME Time, HWND hCalendar) { CStringArray arr; arr.Add(_l("New reminder")); arr.Add(_l("Add date to clipboard")); int iSelection=SelectFromMenu(arr,0); if(iSelection<0){ return 0; } if(iSelection==0){ return -1; } CString s=""; COleDateTime tm;//=COleDateTime(Time); tm.SetDate(Time.wYear,Time.wMonth,Time.wDay); if(strlen(szDateFormat)==0){ s=DateFormat(tm,FALSE); }else{ SYSTEMTIME EventTime; tm.GetAsSystemTime(EventTime); char szTmp[1020]={0}; GetDateFormat(LOCALE_USER_DEFAULT,0,&EventTime,szDateFormat,szTmp,sizeof(szTmp)); s=szTmp; } BOOL bThroughGlobal=0; USES_CONVERSION; SetClipboardText(A2W(s),bThroughGlobal,0); return 0; };
ATL::CTime GlobeFuns::StringToTime(const ATL::CString &strTime) { COleDateTime tm; tm.ParseDateTime(strTime); SYSTEMTIME st; tm.GetAsSystemTime(st); return CTime(st); }
VOID CDataBaseAide::GetValue_SystemTime(LPCTSTR pszItem, SYSTEMTIME & SystemTime) { if (m_pIDataBase != NULL) { COleDateTime Time; ((CDataBase*)m_pIDataBase)->GetFieldValue(pszItem, Time); Time.GetAsSystemTime(SystemTime); } return; }
void XTPGetAsSystemTime(const COleDateTime& dateTime, SYSTEMTIME& st) { #if _MSC_VER < 1200 UNREFERENCED_PARAMETER(dateTime); UNREFERENCED_PARAMETER(st); DXASSERT(FALSE); #else dateTime.GetAsSystemTime(st); #endif }
CString TimeFormat(COleDateTime tm,BOOL bDef, BOOL bNoSecs) { SYSTEMTIME EventTime; tm.GetAsSystemTime(EventTime); char szTmp[128]={0}; GetTimeFormat(LOCALE_USER_DEFAULT,(bDef?0:TIME_FORCE24HOURFORMAT)|(bNoSecs?TIME_NOSECONDS:0),&EventTime,0,szTmp,sizeof(szTmp)); CString sRes=szTmp; /*if(sRes.GetLength()==3){ sRes=CString("0")+sRes; }*/ return sRes; }
//------------------------------------------------------------------------ //! DTN_USERSTRING notification handler to convert clipboard to datetime //! //! @param pNMHDR Pointer to NMDATETIMESTRING structure //! @param pResult Must be set to zero //------------------------------------------------------------------------ void CGridEditorDateTimeCtrl::OnUserString(NMHDR *pNMHDR, LRESULT *pResult) { NMDATETIMESTRINGW* pDateInfoW = reinterpret_cast<NMDATETIMESTRINGW*>(pNMHDR); NMDATETIMESTRINGA* pDateInfoA = reinterpret_cast<NMDATETIMESTRINGA*>(pNMHDR); CString userstr; if (pNMHDR->code == DTN_USERSTRINGA) userstr = pDateInfoA->pszUserString; else userstr = pDateInfoW->pszUserString; if (m_pColumnTrait) { COleDateTime dt; if (m_pColumnTrait->ParseDateTime(userstr, dt)) { if (pNMHDR->code == DTN_USERSTRINGA) { pDateInfoA->dwFlags = GDT_VALID; dt.GetAsSystemTime(pDateInfoA->st); } else { pDateInfoW->dwFlags = GDT_VALID; dt.GetAsSystemTime(pDateInfoW->st); } } else { if (pNMHDR->code == DTN_USERSTRINGA) pDateInfoA->dwFlags = GDT_NONE; else pDateInfoW->dwFlags = GDT_NONE; } } *pResult = 0; }
BOOL CMonthCalCtrl::SetSelRange(const COleDateTime& refMinRange, const COleDateTime& refMaxRange) { // control must have multiple select ASSERT((GetStyle() & MCS_MULTISELECT)); ASSERT(::IsWindow(m_hWnd)); SYSTEMTIME sysTimes[2]; BOOL bResult = FALSE; if (refMinRange.GetStatus() == COleDateTime::valid && refMaxRange.GetStatus() == COleDateTime::valid) { if (refMinRange.GetAsSystemTime(sysTimes[0]) && refMaxRange.GetAsSystemTime(sysTimes[1])) { bResult = (BOOL) ::SendMessage(m_hWnd, MCM_SETSELRANGE, 0, (LPARAM)sysTimes); } } return bResult; }
void CHostStatistic::Update() { CAutoLock lock(m_Lock); m_sStartLogonTime = ""; if (theApp.m_dtLogonTime != 0) { // convert to local time COleDateTime date = theApp.m_dtLogonTime; SYSTEMTIME sysTime; FILETIME fileTime; if(date.GetAsSystemTime(sysTime)) { if(SystemTimeToFileTime(&sysTime,&fileTime)) { if(FileTimeToLocalFileTime(&fileTime,&fileTime)) { if(FileTimeToSystemTime(&fileTime,&sysTime)) { date = sysTime; m_sStartLogonTime = date.Format(_T("%m/%d/%Y %H:%M:%S")); } } } } } unsigned long nSMN = theApp.m_ulSendMessNum; m_sSentMsg.Format(_T("%d"), nSMN); unsigned long nCMN = theApp.m_ulConfMessNum; m_sConfirmedMsg.Format(_T("%d"), nCMN); unsigned long nRMN = theApp.m_ulRecMessNum; m_sReceivedMsg.Format(_T("%d"),nRMN); unsigned long nUMN = theApp.m_ulUnsentMessNum; m_sUnsentMsg.Format(_T("%d"),nUMN); if(IsWindow(m_hWnd)) UpdateData(FALSE); }
BOOL CMonthCalCtrl::SetCurSel(const COleDateTime& refTime) { ASSERT(::IsWindow(m_hWnd)); SYSTEMTIME sysTime; BOOL bRetVal = FALSE; // if the passed time is null or out of range, // we'll set the control to NULL if (refTime.GetAsSystemTime(sysTime) && refTime.GetStatus() == COleDateTime::valid) { bRetVal = (BOOL) ::SendMessage(m_hWnd, MCM_SETCURSEL, 0, (LPARAM) &sysTime); } return bRetVal; }
BOOL CDateTimeCtrl::SetTime(const COleDateTime& timeNew) { BOOL bRetVal = FALSE; // make sure the time isn't invalid ASSERT(timeNew.GetStatus() != COleDateTime::invalid); ASSERT(::IsWindow(m_hWnd)); SYSTEMTIME sysTime; WPARAM wParam = GDT_NONE; if (timeNew.GetStatus() == COleDateTime::valid && timeNew.GetAsSystemTime(sysTime)) { wParam = GDT_VALID; } bRetVal = (BOOL) ::SendMessage(m_hWnd, DTM_SETSYSTEMTIME, wParam, (LPARAM) &sysTime); return bRetVal; }
///////////////////////////////////////////////////////////////////////////// // 获取组件的编译时间 ///////////////////////////////////////////////////////////////////////////// CTime CPlugIn::GetPlugInBuildTime() { typedef int (*FNGetInterfaceList)(TInterfaceInfo **pInfo); // 获取函数指针 FNGetInterfaceList fnGetInterfaceList = (FNGetInterfaceList)GetProcAddress(m_hVciHandle, "GetInterfaceList"); if(fnGetInterfaceList) { TInterfaceInfo *pInfo = NULL; int nInterfaceCount = fnGetInterfaceList(&pInfo); if(pInfo != NULL) { CString strBuildDate = pInfo->csDate; COleDateTime dtTime; dtTime.ParseDateTime(strBuildDate); SYSTEMTIME st; dtTime.GetAsSystemTime(st); CTime tTime(st); return tTime; } } return 0; }
void CMonthCalCtrl::SetToday(const COleDateTime& refTime) { ASSERT_VALID(this); // make sure the time isn't invalid ASSERT(refTime.GetStatus() != COleDateTime::invalid); ASSERT(::IsWindow(m_hWnd)); SYSTEMTIME sysTime; LPSYSTEMTIME pSysTime = NULL; WPARAM wParam = GDT_NONE; // if the passed time is null or out of range, // we'll set the control to NULL if (refTime.GetAsSystemTime(sysTime)) { pSysTime = &sysTime; wParam = GDT_VALID; } if (::IsWindow(m_hWnd)) ::SendMessage(m_hWnd, MCM_SETTODAY, wParam, (LPARAM) pSysTime); }
void CBCGPPlannerPrintMonth::OnDrawHeader (CDC* pDC, const CRect& rectHeader) { ASSERT_VALID (pDC); const int dxColumn = m_ViewRects [0].Width (); CRect rectDayCaption (rectHeader); DrawHeader (pDC, rectDayCaption, dxColumn); rectDayCaption.right = rectDayCaption.left + dxColumn; COleDateTime day ( GetFirstWeekDay2 (m_Date, CBCGPPlannerManagerCtrl::GetFirstDayOfWeek () + 1) ); const int nEnd = m_bCompressWeekend ? 6 : 7; CStringArray sa; sa.SetSize (nEnd); int iColumn = 0; for (iColumn = 0; iColumn < nEnd; iColumn++) { CString strDate; if (IsCompressWeekend () && day.GetDayOfWeek () == 7) { for (int i = 0; i < 2; i++) { CString strTemp; strTemp.GetBuffer (_MAX_PATH); SYSTEMTIME st; day.GetAsSystemTime (st); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, _T("ddd"), (LPTSTR)(LPCTSTR)strTemp, _MAX_PATH); strTemp.ReleaseBuffer (); strDate += strTemp; if (i == 0) { strDate += _T("/"); } day += COleDateTimeSpan (1, 0, 0, 0); } } else { strDate.GetBuffer (_MAX_PATH); SYSTEMTIME st; day.GetAsSystemTime (st); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, m_strCaptionFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); day += COleDateTimeSpan (1, 0, 0, 0); } sa.SetAt (iColumn, strDate); } for (iColumn = 0; iColumn < nEnd; iColumn++) { DrawCaption (pDC, rectDayCaption, sa[iColumn], TRUE, TRUE, m_brGray); rectDayCaption.OffsetRect (dxColumn + m_OnePoint.cx, 0); } }
void CBCGPPlannerPrintMonth::OnDrawClient (CDC* pDC) { ASSERT_VALID (pDC); CRect rectFill (m_rectApps); int nMonth = m_Date.GetMonth (); const int nRows = GetViewDuration () / 7; COleDateTime day (GetDateStart ()); int nIndex = 0; int iRow = 0; { CPen* pOldPen = pDC->SelectObject (&m_penBlack); const int nEnd = 7; int nCol = 0; int iColumn = 1; for (iColumn = 1; iColumn < 7; iColumn++) { if (m_ViewRects [iColumn - 1].right == m_ViewRects [iColumn].right) { nCol = iColumn - 1; break; } } for (iColumn = 1; iColumn < nEnd; iColumn++) { pDC->MoveTo (m_ViewRects [iColumn].left - m_OnePoint.cx, m_rectApps.top); pDC->LineTo (m_ViewRects [iColumn].left - m_OnePoint.cx, m_rectApps.bottom); } for (iRow = 0; iRow < nRows; iRow++) { int nIndex = iRow * 7 + 6; pDC->MoveTo (m_rectApps.left , m_ViewRects [nIndex].bottom); pDC->LineTo (m_rectApps.right, m_ViewRects [nIndex].bottom); if (m_bCompressWeekend) { nIndex -= (6 - nCol); pDC->MoveTo (m_ViewRects [nIndex].left, m_ViewRects [nIndex].bottom); pDC->LineTo (m_ViewRects [nIndex].right, m_ViewRects [nIndex].bottom); } } pDC->SelectObject (pOldPen); } DWORD dwFlags = GetDrawFlags (); BOOL bBold = (dwFlags & BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_BOLD) == BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_BOLD; BOOL bCompact = (dwFlags & BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_COMPACT) == BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_COMPACT; CFont* pOldFont = NULL; if (bBold) { pOldFont = pDC->SelectObject (&m_FontBold); } const BOOL bDateBeforeMonth = CBCGPPlannerView::IsDateBeforeMonth (); for (iRow = 0; iRow < nRows; iRow++) { for (int iDay = 0; iDay < 7; iDay++) { BOOL bAnotherMonth = nMonth != day.GetMonth (); int nDay = iRow * 7 + iDay; CRect rectDayCaption (m_ViewRects [nDay]); if (m_nRowHeight <= rectDayCaption.Height () + 2 * m_OnePoint.cy) { rectDayCaption.bottom = rectDayCaption.top + m_nRowHeight + m_OnePoint.cy; CString strFormat (_T("d")); CString strDate; BOOL bNewYear = FALSE; if (!bCompact) { if ((iRow == 0 && iDay == 0) || day.GetDay () == 1) { if (bDateBeforeMonth) { strFormat = _T("d MMMM"); } else { strFormat = _T("MMMM d"); } if (day.GetDay () == 1 && day.GetMonth () == 1) { bNewYear = TRUE; strFormat += _T(" yyyy"); } } if (!strFormat.IsEmpty ()) { strDate.GetBuffer (_MAX_PATH); SYSTEMTIME st; day.GetAsSystemTime (st); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); CSize szSize (pDC->GetTextExtent (strDate)); if (rectDayCaption.Width () - 4 < szSize.cx) { if (bDateBeforeMonth) { strFormat = _T("d MMM"); } else { strFormat = _T("MMM d"); } if (bNewYear) { strFormat += _T(" yy"); } strDate.GetBuffer (_MAX_PATH); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); } } } else { if ((iRow == 0 && iDay == 0) || day.GetDay () == 1) { if (bDateBeforeMonth) { strFormat = _T("d MMM"); } else { strFormat = _T("MMM d"); } if (day.GetDay () == 1 && day.GetMonth () == 1) { bNewYear = TRUE; strFormat += _T(" yy"); } } if (!strFormat.IsEmpty ()) { strDate.GetBuffer (_MAX_PATH); SYSTEMTIME st; day.GetAsSystemTime (st); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); CSize szSize (pDC->GetTextExtent (strDate)); if (rectDayCaption.Width () - 4 < szSize.cx) { strFormat = _T("d"); BOOL bNeedFormat = TRUE; if (bNewYear) { if (bDateBeforeMonth) { strFormat += _T(" MMM"); } else { strFormat = _T("MMM ") + strFormat; } bNeedFormat = FALSE; strDate.GetBuffer (_MAX_PATH); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); szSize = pDC->GetTextExtent (strDate); if (rectDayCaption.Width () - 4 < szSize.cx) { strFormat = _T("d"); bNeedFormat = TRUE; } } if (bNeedFormat) { strDate.GetBuffer (_MAX_PATH); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); } } } } DrawCaption (pDC, rectDayCaption, strDate, FALSE, TRUE, bAnotherMonth ? m_brDarkGray : m_brGray); } day += COleDateTimeSpan (1, 0, 0, 0); nIndex++; } } if (bBold && pOldFont != NULL) { pDC->SelectObject (pOldFont); } }
int WINAPI WKPluginShowEventX(char szEvent[128],HWND pParent,COleDateTime dt,BOOL bAskMenu) { static long l=0; if(l>0){ return 0; } SimpleTracker lc(l); CString sEventName=_l2("Scheduled event"); HINSTANCE hLLHookInst=GetModuleHandle("WP_KeyMaster.wkp"); _WKIHOTKEYS_GetHotkeyDscByID fpHk=(_WKIHOTKEYS_GetHotkeyDscByID)GetProcAddress(hLLHookInst,"WKIHOTKEYS_GetHotkeyDscByID"); BOOL bDef=(strcmp(szEvent,DEF_ID)==0); if(fpHk){ char szTitle[256]={0}; if((*fpHk)(szEvent,szTitle,sizeof(szTitle))){ sEventName=szTitle; }else{ sEventName=_l2("Attention! Time has come!"); } } _GetReminder fp=(_GetReminder)GetProcAddress(hRemin,"GetReminder"); _IsReminderFamilyPresent fpPr=(_IsReminderFamilyPresent)GetProcAddress(hRemin,"IsReminderFamilyPresent"); CString sRMKey=szEvent; // Возможно нужен выбор? CStringArray aTitles; CStringArray aKeys; if(bDef){ aTitles.SetAtGrow(0,_l2("Add new reminder")); aKeys.SetAtGrow(0,sRMKey); }else{ aTitles.SetAtGrow(0,_l2("Add new schedule")); aKeys.SetAtGrow(0,sRMKey); } CString sSelectedKey=""; if(bAskMenu){ int iMaxIndex=0; if(fpPr && (*fpPr)(sRMKey,&iMaxIndex)){ aKeys[0]=""; for(int i=0;i<=iMaxIndex;i++){ if(fp){ CWPReminder rem; strcpy(rem.szKey,GetNextPrefixedId(sRMKey,i)); if((*fp)(rem.szKey,rem)){ AddMapItems(aKeys,aTitles, rem.szKey, GetRemDsc(rem,TRUE)); } } } } if(aKeys.GetSize()==1){ sRMKey=aKeys[0]; }else{ CMenu menu; menu.CreatePopupMenu(); CPoint pt; GetCursorPos(&pt); for(int i=0;i<aKeys.GetSize();i++){ AddMenuString(&menu,WM_USER+i,aTitles[i]); } AddMenuString(&menu,WM_USER+aKeys.GetSize()+1,_l2("Close menu")); int iNum=::TrackPopupMenu(menu.GetSafeHmenu(), TPM_RETURNCMD|TPM_NONOTIFY|TPM_RIGHTBUTTON, pt.x, pt.y, 0, pParent, NULL); if(iNum==0 || iNum<WM_USER || iNum>=WM_USER+aKeys.GetSize()){ return 0; } sSelectedKey=aKeys[iNum-WM_USER]; if(sSelectedKey==""){ sSelectedKey=calcNextPrefixedId(sRMKey); } sRMKey=sSelectedKey; } } BOOL bNewReminder=0; CWPReminder rem; memset(&rem,0,sizeof(CWPReminder)); if(fp && sRMKey!=""){ strcpy(rem.szKey,sRMKey); if(!(*fp)(rem.szKey,rem)){ // Создаем новый! bNewReminder=1; //COleDateTime dt=COleDateTime::GetCurrentTime(); dt=dt+COleDateTimeSpan(0,0,1,0); dt.GetAsSystemTime(rem.EventTime); rem.bActPopup=bDef; rem.bActSound=bActSound; rem.bLoopSound=bLoopSound; strcpy(rem.szText,sEventName); strcpy(rem.szSoundPath,szWavFilePath); if(!bDef){ // Здесь именно оригинальный Id-Event!!! strcpy(rem.szReserved,szEvent); } _PutReminder fp2=(_PutReminder)GetProcAddress(hRemin,"PutReminder"); if(fp2){ (*fp2)(rem.szKey,rem); } } } #ifdef _DEBUG WKGetPluginContainer()->ShowAlert(rem.szKey,"opened reminder"); #endif _CallModifyReminder fp1=(_CallModifyReminder)GetProcAddress(hRemin,"CallModifyReminder"); if(fp1){ int iRes=(*fp1)(rem.szKey,pParent,0); if(iRes==IDCANCEL && bNewReminder){ _RemoveReminder fp3=(_RemoveReminder)GetProcAddress(hRemin,"RemoveReminder"); if(fp3){ (*fp3)(rem.szKey); } } } return 1; }
//This function was added to CGrandDataFile to recursively retrieve a list of *.BID files in //a directory. It reads the file header to populate the CList of tFileRecords that is converted to //a safe array used by ImportManager. This was flagrantly stolen from Kelly Michel and modified to //search for and read in *.BID files. hn 6/8/2005 // 5-Jul-2005 SFK Removed dead code for readability // 11-Jul-2005 SFK Copied from GRAND Import and modified for binary void CBinaryDataFile::GetCompleteFileList(short FacilityID, CList<tFileRecord, tFileRecord> *pFileList, const CString& Directory, bool IncludeSubdirs) { //USES_CONVERSION; CFileFind Finder; BOOL bWorking; CString FileName; tFileRecord FileRecord; CString DirWithFileMask; DirWithFileMask.Format("%s\\*.*", Directory); bWorking = Finder.FindFile(DirWithFileMask); //If this is an "archive" directory, then skip it completely, and everything that may be underneath it. int StartSubDirName = Directory.ReverseFind('\\'); if(StartSubDirName != -1) { CString SubDirName = Directory.Mid(StartSubDirName + 1); if(SubDirName.CompareNoCase("Archive")) //If SubDirName is not Archive... { do { bWorking = Finder.FindNextFile(); if(!Finder.IsDots()) { if(Finder.IsDirectory() && IncludeSubdirs) { //Recurse. GetCompleteFileList(FacilityID, pFileList, Finder.GetFilePath(), IncludeSubdirs); } else //if(Finder.IsNormal()) { FileName = Finder.GetFileName(); CString Ext = FileName.Mid(FileName.GetLength() - 3, 3); if(!Ext.CompareNoCase("BNY")) { FileRecord.File.bstrVal = (Finder.GetFilePath()).AllocSysString(); //**************************************************************** //Open the file and get info on the data in the file. Load that //file data into the FileRecord structure. //**************************************************************** CString err; //If we are not able to read the *.BNY header, we fail CString cs(FileRecord.File.bstrVal); if (!ReadHeader (cs,&err)) //if (!ReadHeader (W2T(FileRecord.File.bstrVal),&err)) { if (mpFile) CloseDataFile(); } else //Otherwise, save the file date and station ID read. { SYSTEMTIME sysTime; COleDateTime fileDate = GetFileDate (); fileDate.GetAsSystemTime (sysTime); SystemTimeToVariantTime (&sysTime,&FileRecord.Date.date); FileRecord.StationID.lVal = (long) GetStationID (); pFileList->AddTail (FileRecord); CloseDataFile (); } } } } } while(bWorking != 0); } } }
void CBCGPPlannerViewMonth::OnDrawClient (CDC* pDC, const CRect& rect) { ASSERT_VALID (pDC); CRect rectFill (rect); int nMonth = m_Date.GetMonth (); BOOL bIsWorking = nMonth % 2; const int nRows = GetViewDuration () / 7; COleDateTime day (GetDateStart ()); COleDateTime dayCurrent = COleDateTime::GetCurrentTime (); dayCurrent.SetDateTime (dayCurrent.GetYear (), dayCurrent.GetMonth (), dayCurrent.GetDay (), 0, 0, 0); int iRow = 0; int nStartColumn = 1; if (m_nWeekBarWidth != 0) { nStartColumn = 0; } { CPen penBlack (PS_SOLID, 0, visualManager->GetPlannerSeparatorColor (this)); CPen* pOldPen = pDC->SelectObject (&penBlack); const int nEnd = 7; int nCol = 0; int iColumn = 1; for (iColumn = 1; iColumn < 7; iColumn++) { if (m_ViewRects [iColumn - 1].right == m_ViewRects [iColumn].right) { nCol = iColumn - 1; break; } } for (iColumn = nStartColumn; iColumn < nEnd; iColumn++) { pDC->MoveTo (m_ViewRects [iColumn].left - 1, rect.top); pDC->LineTo (m_ViewRects [iColumn].left - 1, rect.bottom); } for (iRow = 0; iRow < nRows; iRow++) { int nIndex = iRow * 7 + 6; pDC->MoveTo (rect.left , m_ViewRects [nIndex].bottom); pDC->LineTo (rect.right, m_ViewRects [nIndex].bottom); if (m_bCompressWeekend) { nIndex -= (6 - nCol); pDC->MoveTo (m_ViewRects [nIndex].left, m_ViewRects [nIndex].bottom); pDC->LineTo (m_ViewRects [nIndex].right, m_ViewRects [nIndex].bottom); } } pDC->SelectObject (pOldPen); } DWORD dwFlags = GetPlanner ()->GetDrawFlags (); BOOL bBold = (dwFlags & BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_BOLD) == BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_BOLD; BOOL bCompact = (dwFlags & BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_COMPACT) == BCGP_PLANNER_DRAW_VIEW_CAPTION_DAY_COMPACT; HFONT hOldFont = NULL; if (bBold) { hOldFont = SetCurrFont (pDC, bBold); } const BOOL bDateBeforeMonth = CBCGPPlannerView::IsDateBeforeMonth (); for (iRow = 0; iRow < nRows; iRow++) { for (int iDay = 0; iDay < 7; iDay++) { int nDay = iRow * 7 + iDay; CRect rectDayCaption (m_ViewRects [nDay]); BOOL bToday = day == dayCurrent; BOOL bSelected = IsDateInSelection (day); bIsWorking = day.GetMonth () % 2; visualManager->PreparePlannerBackItem (bToday, bSelected); OnFillPlanner (pDC, rectDayCaption, bIsWorking); rectDayCaption.bottom = rectDayCaption.top + m_nRowHeight + 1; CString strFormat (_T("d")); CString strDate; BOOL bNewYear = FALSE; if (!bCompact) { if ((iRow == 0 && iDay == 0) || day.GetDay () == 1) { if (bDateBeforeMonth) { strFormat = _T("d MMMM"); } else { strFormat = _T("MMMM d"); } if (day.GetDay () == 1 && day.GetMonth () == 1) { bNewYear = TRUE; strFormat += _T(" yyyy"); } } if (!strFormat.IsEmpty ()) { strDate.GetBuffer (_MAX_PATH); SYSTEMTIME st; day.GetAsSystemTime (st); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); CSize szSize (pDC->GetTextExtent (strDate)); if (rectDayCaption.Width () - 4 < szSize.cx) { if (bDateBeforeMonth) { strFormat = _T("d MMM"); } else { strFormat = _T("MMM d"); } if (bNewYear) { strFormat += _T(" yy"); } strDate.GetBuffer (_MAX_PATH); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); } } } else { if ((iRow == 0 && iDay == 0) || day.GetDay () == 1) { if (bDateBeforeMonth) { strFormat = _T("d MMM"); } else { strFormat = _T("MMM d"); } if (day.GetDay () == 1 && day.GetMonth () == 1) { bNewYear = TRUE; strFormat += _T(" yy"); } } if (!strFormat.IsEmpty ()) { strDate.GetBuffer (_MAX_PATH); SYSTEMTIME st; day.GetAsSystemTime (st); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); CSize szSize (pDC->GetTextExtent (strDate)); if (rectDayCaption.Width () - 4 < szSize.cx) { strFormat = _T("d"); BOOL bNeedFormat = TRUE; if (bNewYear) { if (bDateBeforeMonth) { strFormat += _T(" MMM"); } else { strFormat = _T("MMM ") + strFormat; } bNeedFormat = FALSE; strDate.GetBuffer (_MAX_PATH); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); szSize = pDC->GetTextExtent (strDate); if (rectDayCaption.Width () - 4 < szSize.cx) { strFormat = _T("d"); bNeedFormat = TRUE; } } if (bNeedFormat) { strDate.GetBuffer (_MAX_PATH); ::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, strFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH); strDate.ReleaseBuffer (); } } } } if (bToday) { rectDayCaption.bottom--; } visualManager->PreparePlannerCaptionBackItem (FALSE); COLORREF clrText = OnFillPlannerCaption ( pDC, rectDayCaption, bToday, bSelected, FALSE); DrawCaptionText (pDC, rectDayCaption, strDate, clrText, bCompact ? DT_LEFT : DT_RIGHT, bToday && bSelected); day += COleDateTimeSpan (1, 0, 0, 0); } } if (hOldFont != NULL) { ::SelectObject (pDC->GetSafeHdc (), hOldFont); } }
BOOL GetAsSystemTime(const COleDateTime& dtTime, SYSTEMTIME& sysTime) { ::ZeroMemory(&sysTime, sizeof(sysTime)); return dtTime.GetAsSystemTime(sysTime); }
void CFtpManager::SyncServerFolder(CConnection * con, CRealFtpClient * ftpClient, CString &folder) { //TRACE2(" Synch folder %s %s \n", con->name, folder); // Download directory information CFtpManager ftp; bool r = ftp.GetFtpDirectory(con, folder, ftpClient); if(!r){return;} CLocalStore localStore; bool local_store = false; CFileContainer dir; dir.host = CString(con->host); dir.path = CString(folder); dir.name = CString(_T("")); local_store = localStore.IsFolderStored(dir); //TRACE2(" folder: %s l: %d \n ", folder, local_store); // Read directory information, process subfolders. std::vector<CFileContainer> files; ftp.ReadLocalDirectory(con, folder, files); int i = 0; for(i = 0; i < files.size(); i++) { CFileContainer f; f = (CFileContainer)files[i]; bool descend = true; bool download = false; bool upload = false; //TRACE1(" name %s \n", f.name); // If store local, sync.... TODO if(f.dir == 0 && local_store) // is file and local store { CFileStatus status; if(CFile::GetStatus(f.localPath + f.name, status) == 0) // not found, not local { download = true; } else { // File exists ULONGLONG local_size = status.m_size; // is local file stale? CString fileDate = f.remoteDate; // 2012/11/23 15:00 COleDateTime myDtTime; CTime sysTime; if(myDtTime.ParseDateTime(fileDate)) { SYSTEMTIME st_remote; if(myDtTime.GetAsSystemTime(st_remote)) { sysTime = st_remote; } CTime ct_local = status.m_mtime; SYSTEMTIME st_local; ct_local.GetAsSystemTime(st_local); //DWORD x = ft_remote-> _int64 d = Delta(st_local, st_remote); // d = d / 10000000; //TRACE1(" d: %ld \n", d); // -200859136 // 105568 1 day - if(d > 86400) // remote file was updated a day later than the local. { download = true; } //TRACE2(" size: %d : %d \n", f.size, local_size); if(d < 86400 && f.size != local_size) // local file updated a day after the remote file. { upload = true; } } } } if(download) { CWaitDialog wait; ftp.ReceiveFile(con, f, wait); } // if file is local but not remote send it if(upload) { CWaitDialog wait; //ftp.SendFile(con, f, wait); } // If older than a year skip, unless local store long age = f.GetAge(); //TRACE2(" date %s age: %d \n", f.remoteDate, age); if(age > 1000){ // this only applies if not local store directory descend = false; } if(f.path.Compare(_T("/proc/")) == 0){ descend = false; } if(f.path.Compare(_T("/sys/")) == 0){ descend = false; } if(f.dir && descend) { CString subFolder(CString(f.path + f.name + _T("/"))); SyncServerFolder(con, ftpClient, subFolder); if(f.path.Find(_T("newsletter-form")) != -1){ int i = 0; } } } }