void SDateEdit::SetDateTime( CTime tm ) { TCHAR szBuf[256]; struct tm ttm; _tcsftime(szBuf,256,_T("%Y/%m/%d"),tm.GetLocalTm(&ttm)); SetDateTime(szBuf); }
/* MORPH START leuk_he: Remove 2nd apply in scheduler void CPPgScheduler::OnBnClickedApply() { int index=m_list.GetSelectionMark(); */ BOOL CPPgScheduler::OnApply(){ int index=miActiveSelection ; // MORPH END leuk_he: Remove 2nd apply in scheduler if (index>-1) { Schedule_Struct* schedule=theApp.scheduler->GetSchedule(index); //title GetDlgItem(IDC_S_TITLE)->GetWindowText(schedule->title); //time CTime myTime; DWORD result=m_time.GetTime(myTime); if (result == GDT_VALID){ struct tm tmTemp; schedule->time=safe_mktime(myTime.GetLocalTm(&tmTemp)); } CTime myTime2; DWORD result2=m_timeTo.GetTime(myTime2); if (result2 == GDT_VALID){ struct tm tmTemp; schedule->time2=safe_mktime(myTime2.GetLocalTm(&tmTemp)); } if (IsDlgButtonChecked(IDC_CHECKNOENDTIME)) schedule->time2=0; //time kindof (days) schedule->day=m_timesel.GetCurSel(); schedule->enabled=IsDlgButtonChecked(IDC_S_ENABLE)!=0; schedule->ResetActions(); for (uint8 i=0;i<m_actions.GetItemCount();i++) { schedule->actions[i]=m_actions.GetItemData(i); //MORPH START - Changed by Stulle, Show cat name for scheduler cat actions if(schedule->actions[i]==ACTION_CATSTOP || schedule->actions[i]==ACTION_CATRESUME) { CString strCat = m_actions.GetItemText(i,1); schedule->values[i]=strCat.Left(strCat.Find(L"(")-1); } else //MORPH END - Changed by Stulle, Show cat name for scheduler cat actions schedule->values[i]=m_actions.GetItemText(i,1); } m_list.SetItemText(index, 0, schedule->title); m_list.SetItemText(index, 1, GetDayLabel(schedule->day)); CTime time(theApp.scheduler->GetSchedule(index)->time); CString timeS; timeS.Format(_T("%s"),time.Format(_T("%H:%M"))); m_list.SetItemText(index, 2, timeS); } RecheckSchedules(); // MORPH START leuk_he: Remove 2nd apply in scheduler SetModified(false); return CPropertyPage::OnApply(); // MORPH END leuk_he: Remove 2nd apply in scheduler }
BOOL COXMonthCalCtrl::GetAsSystemTime(const CTime& rTime, SYSTEMTIME& timeDest) { struct tm* ptm = rTime.GetLocalTm(NULL); if (ptm == NULL) return FALSE; timeDest.wYear = (WORD) (1900 + ptm->tm_year); timeDest.wMonth = (WORD) (1 + ptm->tm_mon); timeDest.wDay = (WORD) ptm->tm_mday; timeDest.wHour = (WORD) ptm->tm_hour; timeDest.wMinute = (WORD) ptm->tm_min; timeDest.wSecond = (WORD) ptm->tm_sec; timeDest.wMilliseconds = 0; return TRUE; }
void CImageView::DrawTimeStampAndRuleType(LONG width, LONG height, __int64 i64TimeStamp, int iruleType) { char Text[128]; SIZE size = {width, height}; POINT pt = {0, 0}; CTime cTime = CTime( (time_t) i64TimeStamp ); struct tm osTime; cTime.GetLocalTm( &osTime ); sprintf_s(Text, _countof(Text), "%4d/%02d/%02d %02d:%02d:%02d : RuleType [%s]", osTime.tm_year+1900, osTime.tm_mon+1, osTime.tm_mday, osTime.tm_hour, osTime.tm_min, osTime.tm_sec, g_strFilterItem[iruleType-1]); m_pD3d->DrawText(m_ClientRect, size, pt, &Text[0], 128, RGB(0, 255, 0)); }
void CPPgScheduler::OnBnClickedApply() { int index=m_list.GetSelectionMark(); if (index>-1) { Schedule_Struct* schedule=theApp.scheduler->GetSchedule(index); //title GetDlgItem(IDC_S_TITLE)->GetWindowText(schedule->title); //time CTime myTime; DWORD result=m_time.GetTime(myTime); if (result == GDT_VALID){ struct tm tmTemp; schedule->time=safe_mktime(myTime.GetLocalTm(&tmTemp)); } CTime myTime2; DWORD result2=m_timeTo.GetTime(myTime2); if (result2 == GDT_VALID){ struct tm tmTemp; schedule->time2=safe_mktime(myTime2.GetLocalTm(&tmTemp)); } if (IsDlgButtonChecked(IDC_CHECKNOENDTIME)) schedule->time2=0; //time kindof (days) schedule->day=m_timesel.GetCurSel(); schedule->enabled=IsDlgButtonChecked(IDC_S_ENABLE)!=0; schedule->ResetActions(); for (uint8 i=0;i<m_actions.GetItemCount();i++) { schedule->actions[i]=m_actions.GetItemData(i); schedule->values[i]=m_actions.GetItemText(i,1); } m_list.SetItemText(index, 0, schedule->title); m_list.SetItemText(index, 1, GetDayLabel(schedule->day)); CTime time(theApp.scheduler->GetSchedule(index)->time); CString timeS; timeS.Format(_T("%s"),time.Format(_T("%H:%M"))); m_list.SetItemText(index, 2, timeS); } RecheckSchedules(); }
void CCardView::OnCardServer() { // Some configurations do not support online greetings ("card server"). if (!GetConfiguration()->SupportsCardServer()) { return; } // Get our document. CPmwDoc* pDoc = GetDocument(); if(GetGlobalContentManager()->CheckAccountStatus()) { CString strID = GetGlobalContentManager()->GetAccountID(); if(strID != "") { // Put up the card server dialog. CCardServerDialog Dialog(this); Dialog.m_ctTime = CTime::GetCurrentTime(); if (Dialog.DoModal() == IDOK) { // Put up the disclaimer dialog. CCardServerDisclaimer Disclaimer(this); if (Disclaimer.DoModal() == IDOK) { // Create the directory we want to use as our FTP source. CString csDir = pDoc->GetPathManager()->ExpandPath("[[U]]\\NETCARD"); if (!Util::MakeDirectory(csDir)) { // Not able to make the directory. // LPCSTR pFormat = "Can't create the directory\n%s"; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateDirectory); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csDir); AfxMessageBox(csMessage); return; } // Construct the text file. CString csTextFile; Util::ConstructPath(csTextFile, csDir, "INFO.INI"); CFile cfText; CString csVersion; CString csPPN; TRY { CFileException e; //if (!cfText.Open(csTextFile, // CFile::modeCreate // | CFile::modeWrite, // &e)) //{ // AfxThrowFileException(e.m_cause, e.m_lOsError); //} //do the time stuff //time zone difference from PST struct _timeb tstruct; _ftime( &tstruct ); int timecorrection = PacificTimeCorrection(tstruct.timezone); //get date of delivery - include current time struct tm when; CString strDate; CTime testtime = CTime::GetCurrentTime(); when = *testtime.GetLocalTm(NULL); SYSTEMTIME sysTime = *Dialog.GetTime(); if((when.tm_mday != sysTime.wDay) || (when.tm_mon != (sysTime.wMonth - 1))) { when.tm_mday = sysTime.wDay; when.tm_mon = sysTime.wMonth - 1; ConvertToPST(&when, timecorrection); CString str_ampm = "AM"; if( when.tm_hour > 12 ) /* Set up extension. */ str_ampm = "PM"; if( when.tm_hour > 12 ) /* Convert from 24-hour */ when.tm_hour -= 12; /* to 12-hour clock. */ if( when.tm_hour == 0 ) /*Set hour to 12 if midnight. */ when.tm_hour = 12; strDate.Format("%d/%d/%d %d:%d:%d%s", (int)((int)when.tm_mon + 1),when.tm_mday,when.tm_year,when.tm_hour,when.tm_min,when.tm_sec,str_ampm); } else { strDate = ""; } CString strPSTCorrection; strPSTCorrection.Format("%d", timecorrection); // Construct the version string. CString csEol = "\r\n"; csVersion = GetConfiguration()->ReplacementText('T'); csVersion += ' '; csVersion += GET_PMWAPP()->GetVersion(); csPPN = GET_PMWAPP()->GetParentPartNumber(); WritePrivateProfileString( "UserData", "UserId", GetGlobalContentManager()->GetAccountID(), csTextFile); WritePrivateProfileString( "UserData", "Description", csVersion, csTextFile); WritePrivateProfileString( "UserData", "SenderEmail", Dialog.m_csFrom, csTextFile); WritePrivateProfileString( "UserData", "RecipientEmail", Dialog.m_csTo, csTextFile); WritePrivateProfileString( "UserData", "sku", csPPN, csTextFile); WritePrivateProfileString( "CardData", "Title", Dialog.m_csTitle, csTextFile); WritePrivateProfileString( "CardData", "Date", strDate, csTextFile); WritePrivateProfileString( "CardData", "Offset", strPSTCorrection, csTextFile); #if 0 // Write version cfText.Write(csVersion, csVersion.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write "from" email address cfText.Write(Dialog.m_csFrom, Dialog.m_csFrom.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write "to" email address cfText.Write(Dialog.m_csTo, Dialog.m_csTo.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write Parent Part Number cfText.Write(csPPN, csPPN.GetLength()); cfText.Write(csEol, csEol.GetLength()); #endif //cfText.Close(); } CATCH_ALL(e) { // Could not write the text file. Complain. // LPCSTR pFormat = "Can't create the file\n%s"; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateFile); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csTextFile); AfxMessageBox(csMessage); return; } END_CATCH_ALL // Figure out how big we want the panels to be. CPoint cpFrontDims; CPoint cpInsideDims; PBOX World; pDoc->get_panel_world(&World, CARD_PANEL_Front); // Fit the front panel into a 425x425 square. PPNT FrontDims; FrontDims.x = World.x1 - World.x0; FrontDims.y = World.y1 - World.y0; double dScale = 425.0/(double)FrontDims.x; double dYScale = 425.0/(double)FrontDims.y; if (dScale > dYScale) dScale = dYScale; cpFrontDims.x = (int)((double)FrontDims.x*dScale); cpFrontDims.y = (int)((double)FrontDims.y*dScale); pDoc->get_panel_world(&World, CARD_PANEL_Inside); cpInsideDims.x = (int)((double)(World.x1-World.x0)*dScale); cpInsideDims.y = (int)((double)(World.y1-World.y0)*dScale); TRACE("Front: %d, %d; Inside: %d, %d\n", cpFrontDims.x, cpFrontDims.y, cpInsideDims.x, cpInsideDims.y); BOOL fSuccess = FALSE; CCardServerProgressDialog ProgressDialog(AfxGetMainWnd()); CString csName; Util::ConstructPath(csName, csDir, "front.gif"); ProgressDialog.SetStatus(IDS_BuildingFront); if (DumpPanel(CARD_PANEL_Front, csName, cpFrontDims)) { ProgressDialog.SetStatus(IDS_BuildingInside); Util::ConstructPath(csName, csDir, "inside.gif"); if(DumpPanel(CARD_PANEL_Inside, csName, cpInsideDims)) fSuccess = TRUE; } if (!fSuccess) { // "Can't create card pictures." AfxMessageBox(GET_PMWAPP()->GetResourceStringPointer(IDS_ErrWriteCardPictures)); return; } // Now, invoke the DLL to write the data. CCardServerDLL DLL; #ifdef WIN32 CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP32.DLL"); #else CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP16.DLL"); #endif // Startup the dialog. if (DLL.Startup(csDLLName)) { if(CheckForValidConnection()){ // Put up our progress dialog. // Send the files. int nResult = DLL.SendFiles(csDir, ProgressDialog); // Take down the progress dialog now. ProgressDialog.DestroyWindow(); // Shut down the DLL. DLL.Shutdown(); CPmwDialog Dialog(nResult == 0 ? IDD_CARD_SERVER_SUCCESS : IDD_CARD_SERVER_FAILURE); Dialog.DoModal(); } } else { // Not able to load the DLL. Complain. // LPCSTR pFormat = "The file\n%s\nis missing or bad."; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrMissingDLL); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csDLLName); AfxMessageBox(csMessage); } }