void ShowError() { LPVOID lpMsgBuf; FILE* fp; CHAR szDate[7]; if ((fp = fopen(LOGFILE, "a+t")) == NULL) return; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL); // display the string. printf(lpMsgBuf); // write string to log file GetCurrentDate(szDate); fprintf(fp, "%s - %s", szDate, lpMsgBuf); // Free the buffer. LocalFree(lpMsgBuf); // close file _flushall(); fclose(fp); }
void LogSave(uint8_t type) { FRESULT f_result; FIL file; uint32_t cnt, tmp; struct Date date; f_result = f_open(&file, "system/log.f", FA_OPEN_EXISTING | FA_WRITE | FA_READ); if (f_result != FR_OK) { f_open(&file, "system/log.f", FA_CREATE_NEW | FA_WRITE); cnt = 1; } else { f_read(&file, (void *) &cnt, 4, &tmp); cnt++; } f_lseek(&file, 0); // save log file size f_write(&file, (void *) &cnt, 4, &tmp); vTaskDelay(100); // go to end of file f_lseek(&file, f_size(&file)); // save log data GetCurrentDate(&date); f_write(&file, (void *) (void *) (&date), sizeof(struct Date), &tmp); vTaskDelay(100); // save log type f_write(&file, (void *) (void *) (&type), 1, &tmp); vTaskDelay(100); f_close(&file); }
int GetFileWithWGET(AGPS_CONFIG_T DataFileInfo) { char cmd[SMALL_BUFF]; char DataFilePath[SMALL_BUFF]; char LogPath[SMALL_BUFF]; char LogPostfix[SMALL_BUFF]; char TimeStamp[TIMESTAMP_SIZE]; int len; memset(cmd, 0, SMALL_BUFF); memset(LogPath, 0, SMALL_BUFF); memset(LogPostfix, 0, SMALL_BUFF); memset(DataFilePath, 0, SMALL_BUFF); memset(TimeStamp, 0, TIMESTAMP_SIZE); GetCurrentDate(TimeStamp); sprintf(LogPath, "%s", Config.SERVICE_LOG_PATH); sprintf(LogPostfix, "%s.LOG", TimeStamp); len = strlen(LogPath) - 3; memcpy(LogPath + len, LogPostfix, strlen(LogPostfix)); printLog(HEAD, "LogPath(%s)\n", LogPath); sprintf(cmd, "cd %s;/usr/bin/wget %s -a %s", Config.WORKING_DIR, DataFileInfo.FileURL, LogPath); system(cmd); printLog(HEAD, "cmd(%s)\n", cmd); sprintf(DataFilePath, Config.WORKING_DIR, DataFileInfo.DataFile); if(FileExist(DataFilePath) > 0) return SUCCESS; else return 0; }
/** * @brief Logging::Logging The overload constructor * @param FileName The prefix of the actural file name * * @author sheng * @date 2014-08-21 * @version 0.1 * * @history * <author> <date> <version> <description> * sheng 2014-08-21 0.1 build the function * */ Logging::Logging(const std::string &FileName) : ActualFile(NULL) { // consturct a fstream ActualFile = new std::fstream; // Acturall file name std::string ActuralFileName = FileName + GetCurrentDate(); // open the output file ActualFile->open(ActuralFileName.c_str(), std::ios_base::out); }
/** * @brief Logging::Logging The default constructor * * @author sheng * @date 2014-08-21 * @version 0.1 * * @history * <author> <date> <version> <description> * sheng 2014-08-21 0.1 build the function * */ Logging::Logging() : ActualFile(NULL) { // get the current date std::string FileName = GetCurrentDate(); // construct a fstream ActualFile = new std::fstream; // open the output file ActualFile->open(FileName.c_str(), std::ios_base::out); }
void COXTreeCal::OnKillFocusEdit() { COleDateTime dt = GetCurrentDate(); COXCalendar::OnKillFocusEdit(); CWnd *pFocusWnd = GetFocus(); HWND hFocus = pFocusWnd->GetSafeHwnd(); if( hFocus != GetSafeHwnd() && hFocus != m_wndDatePicker.GetSafeHwnd()) FinishEdit(dt.GetStatus() == COleDateTime::valid || dt.GetStatus() == COleDateTime::null); }
// ------------------------------------------------------------------------------------------------------------------------------------------------------- void LogClass::LogAddStr(COLORREF colorText, LPCCH pText) { GetCurrentDate(&m_SysTime); // ----- m_iTextLength = sprintf(m_LogBuff, "[%02d:%02d:%02d] %s\0", m_SysTime.wHour, m_SysTime.wMinute, m_SysTime.wSecond, pText); // ----- LogTextAdd(colorText, m_LogBuff, m_iTextLength); // ----- if ( CheckDate(&m_SysTime, &m_Prev_SysTime) == false ) { sprintf(m_szFilePath, "LOG_%02d.%02d.%04d[%s].log\0", m_SysTime.wDay, m_SysTime.wMonth, m_SysTime.wYear, SOFT_NAME); // ----- GetCurrentDate(&m_Prev_SysTime); // ----- WriteDataInFile(m_LogBuffFile, m_iTextLengthKeep); // ----- memset(m_LogBuffFile, 0, sizeof(m_LogBuffFile)); m_iTextLengthKeep = 0; } else { if( m_iTextLengthKeep + m_iTextLength >= LOG_TEXT_FILE_LENGTH ) { sprintf(m_szFilePath, "LOG_%02d.%02d.%04d[%s].log\0", m_Prev_SysTime.wDay, m_Prev_SysTime.wMonth, m_Prev_SysTime.wYear, SOFT_NAME); // ----- WriteDataInFile(m_LogBuffFile, m_iTextLengthKeep); // ----- memset(m_LogBuffFile, 0, sizeof(m_LogBuffFile)); m_iTextLengthKeep = 0; } } // ---- memcpy(& m_LogBuffFile[m_iTextLengthKeep], m_LogBuff, m_iTextLength); // ---- m_iTextLengthKeep += m_iTextLength; // ---- sprintf(& m_LogBuffFile[m_iTextLengthKeep], "\n"); // ---- m_iTextLengthKeep += 1; }
void Box::SetProgramRecorded() { string name; int aux=-1; int i = 0; cout << "Insert a Program's name: "; cin.clear(); cin.ignore(); getline(cin, name); cout << endl << endl << endl; int existInRecord = false; for (int j = 0; j < recordList.size(); j++) { if (string_to_upper(name) == string_to_upper(recordList[j].getName())) { existInRecord = true; cout << "The program \"" << name << "\", is in the list of recorded programs." << endl << endl << endl << endl; break; } } if (!existInRecord) { for (i; i < channels.size(); i++) { aux = searchProgram(string_to_upper(name), channels[i]); if (aux >= 0) { break; } } if (aux >= 0) { if (compDates(GetCurrentDate(), channels[i].getPrograms()[aux].getDate())) { cout << "The program \"" << channels[i].getPrograms()[aux].getName(); cout << "\", from the channel \"" << channels[i].getName() << "\", was sucefully\n"; cout << "set to be recorded." << endl << endl << endl << endl; recordList.push_back(channels[i].getPrograms()[aux]); } else { cout << "The program \"" << channels[i].getPrograms()[aux].getName(); cout << "\", from the channel \"" << channels[i].getName() << "\", has been reproduced." << endl << endl << endl << endl; } } else cout << "The program \"" << name << "\" doesn't exist." << endl << endl << endl << endl; } }
// ------------------------------------------------------------------------------------------------------------------------------------------------------- void LogClass::PrepareClass() { GetCurrentDate(&m_Start_SysTime); GetCurrentDate(&m_Prev_SysTime); // ----- m_LogFont.Width = 6; m_LogFont.Height = 15; // ----- sprintf(m_szFolderPath, "LOG\0"); sprintf(m_szFilePath, "LOG_%02d.%02d.%04d[%s].log\0", m_Start_SysTime.wDay, m_Start_SysTime.wMonth, m_Start_SysTime.wYear, SOFT_NAME); // ----- // ----- m_iTextLengthKeep = 0; m_iCurrentLine = 0; m_xPos = 5; // ----- memset(m_LogBuffFile, 0, sizeof(m_LogBuffFile)); memset(m_Log, 0, sizeof(m_Log)); // ----- SetFolderPath("LOG"); // ----- CreateDirectory(m_szFolderPath, NULL); }
void TTimeView::Update() { fLocale = *BLocale::Default(); GetCurrentTime(); GetCurrentDate(); SetToolTip(fCurrentDateStr); CalculateTextPlacement(); ResizeToPreferred(); if (fParent != NULL) fParent->Invalidate(); }
int CalculateExpireDateNAuthTime(B2B_AUTH_INFO_T *AuthInfo) { char CurrentDate[B2B_DATE_SIZE+1]; char NewDate[B2B_DATE_SIZE+1]; char CurrentTime[B2B_DATE_SIZE+1]; GetCurrentDate(CurrentDate); GetCurrentTime(CurrentTime); GetNDayDiff(CurrentDate, NewDate, B2B_EXPIREDATE_GAP); AuthInfo->ExpireDate = atoi(NewDate); AuthInfo->AuthTime = atoi(CurrentTime); return NO_ERROR; }
void cLogger::print(SupportedTypes type_variant, int severity) { std::string severity_str; //init severirity types if(LOG_SEV_INFO == severity) { severity_str = "INFO"; } else { severity_str = (LOG_SEV_ERROR == severity) ? "ERROR" : "WARNING"; } std::string message; cVariantVisitor variant_visitor(&message); boost::apply_visitor(variant_visitor, type_variant); std::string final_message = severity_str + " : " + GetCurrentDate() + " -- " + message + "\n"; pushLogMessage(std::move(final_message)); }
void TTimeView::Pulse() { time_t curTime = time(NULL); tm* ct = localtime(&curTime); if (ct == NULL) return; fCurrentTime = curTime; GetCurrentTime(); GetCurrentDate(); if (strcmp(fCurrentTimeStr, fLastTimeStr) != 0) { // Update bounds when the size of the strings has changed // For dates, Update() could be called two times in a row, // but that should only happen very rarely if ((fLastTimeStr[1] != fCurrentTimeStr[1] && (fLastTimeStr[1] == ':' || fCurrentTimeStr[1] == ':')) || !fLastTimeStr[0]) Update(); strlcpy(fLastTimeStr, fCurrentTimeStr, sizeof(fLastTimeStr)); fNeedToUpdate = true; } // Update the tooltip if the date has changed if (strcmp(fCurrentDateStr, fLastDateStr) != 0) { strlcpy(fLastDateStr, fCurrentDateStr, sizeof(fLastDateStr)); SetToolTip(fCurrentDateStr); } if (fNeedToUpdate) { fSeconds = ct->tm_sec; fMinute = ct->tm_min; fHour = ct->tm_hour; Draw(Bounds()); fNeedToUpdate = false; } }
void Box::updateProgramState(string &programn) { system("CLS"); cout << " _ _ _ " << endl; cout << " / \\ __| |_ ____ _ _ __ ___ ___ __| |" << endl; cout << " / _ \\ / _` \\ \\ / / _` | '_ \\ / __/ _ \\/ _` |" << endl; cout << " / ___ \\ (_| |\\ V / (_| | | | | (_| __/ (_| |" << endl; cout << " /_/ \\_\\__,_| \\_/ \\__,_|_| |_|\\___\\___|\\__,_|" << endl << endl; cout << "\t \t Update a program" << endl << endl << endl; int channel_position = 0; int program_position = 0; for (channel_position; channel_position < channels.size(); channel_position++) { program_position = searchProgram(programn, channels[channel_position]); if (program_position != -1) break; } if (compDates(GetCurrentDate(), channels[channel_position].getPrograms()[program_position].getDate())) { cout << "The program \"" << channels[channel_position].getPrograms()[program_position].getName() << "\""; cout << " wasn't reproduced yet"; Sleep(3000); } else { cout << endl << endl << "The record state of the program \"" << channels[channel_position].getPrograms()[program_position].getName() << "\""; cout << " was change to \""; if (channels[channel_position].getPrograms()[program_position].getState()) cout << "true"; else cout << "false"; cout << "\""; Sleep(3000); channels[channel_position].setProgramState(program_position); } }
BOOL CDetailGridCtrl::GetCell(CGridCell* pGridCell,int nRow, int nCol) const { if (nRow < 0 || nRow >= m_nRows || nCol < 0 || nCol >= m_nCols) return FALSE; if(nRow==0) { pGridCell->state=0; pGridCell->nFormat =DT_CENTER|DT_VCENTER|DT_SINGLELINE; pGridCell->szText=m_pColData[nCol].szText; pGridCell->iImage=-1; pGridCell->crBkClr=m_pDoc->m_colorArray[18]; pGridCell->crFgClr=m_pDoc->m_colorArray[14]; pGridCell->lParam=0; pGridCell->lfFont=m_Logfont; return TRUE; } CCellID cell; if((m_SortColumn==nCol||m_idCurrentCell.row==nRow)) { pGridCell->state=GVIS_SELECTED; } else { pGridCell->state=0; } pGridCell->iImage=-1; pGridCell->lParam=0; pGridCell->lfFont=m_Logfont; pGridCell->crBkClr=CLR_DEFAULT; pGridCell->nFormat=m_pColData[nCol].nFormat; if(nRow >= m_nRealRow) { pGridCell->szText=""; return TRUE; } CReportData *pCdat; char str[50]; if(!m_pDoc->m_sharesInformation.Lookup(m_pDoc->m_sharesSymbol.GetBuffer(0),pCdat,m_pDoc->m_stkKind)) return TRUE; Rsdn1 **Nidx2,*tempNidx; m_pDoc->m_sharesInformation.GetIndexRsdn(Nidx2); int which_stk; if(pCdat->kind==SHZS) which_stk=0; else if(pCdat->kind==SZZS) which_stk=1; else if(pCdat->kind==EBZS) which_stk=2; tempNidx=Nidx2[which_stk]; int CurrRow; int PreRow; if(this->m_bIsF1) { if(nRow-1<=m_pDoc->m_nANT[which_stk]) CurrRow=nRow-1; else CurrRow=m_pDoc->m_nANT[which_stk]; PreRow= CurrRow -1; if(PreRow<0) PreRow=0; } else { if((nRow-1)*5<m_pDoc->m_nANT[which_stk]) { if(nRow-1==0) { CurrRow=0; PreRow=0; } else { CurrRow=5*(nRow-1); PreRow=5*(nRow-2); if(PreRow<0) PreRow=0; } } else { if(nRow-1==0) { CurrRow=0; PreRow=0; } else { CurrRow=m_pDoc->m_nANT[which_stk]; PreRow=5*(nRow-2); } } } switch(m_pColData[nCol].nID) { case 0: GetCurrentDate(CurrRow,pGridCell->szText); pGridCell->crFgClr =m_pDoc->m_colorArray[14]; break; case 1: if(pCdat->m_Kdata1[CurrRow].Price==0&&CurrRow!=0) { sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow-1].Price); if(pCdat->m_Kdata1[CurrRow-1].Price>pCdat->ystc ) pGridCell->crFgClr =m_pDoc->m_colorArray[13]; else if(pCdat->m_Kdata1[CurrRow-1].Price < pCdat->ystc) pGridCell->crFgClr =m_pDoc->m_colorArray[15]; else pGridCell->crFgClr =m_pDoc->m_colorArray[14]; } else { sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow].Price); if(pCdat->m_Kdata1[CurrRow].Price>pCdat->ystc ) pGridCell->crFgClr =m_pDoc->m_colorArray[13]; else if(pCdat->m_Kdata1[CurrRow].Price < pCdat->ystc) pGridCell->crFgClr =m_pDoc->m_colorArray[15]; else pGridCell->crFgClr =m_pDoc->m_colorArray[14]; } pGridCell->szText =str; break; case 2: if(pCdat->m_Kdata1[CurrRow].Price==0&&CurrRow!=0) { sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow-1].Price - pCdat->ystc); if(pCdat->m_Kdata1[CurrRow-1].Price>pCdat->ystc ) pGridCell->crFgClr =m_pDoc->m_colorArray[13]; else if(pCdat->m_Kdata1[CurrRow-1].Price < pCdat->ystc) pGridCell->crFgClr =m_pDoc->m_colorArray[15]; else pGridCell->crFgClr =m_pDoc->m_colorArray[14]; } else { sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow].Price - pCdat->ystc); if(pCdat->m_Kdata1[CurrRow].Price>pCdat->ystc ) pGridCell->crFgClr =m_pDoc->m_colorArray[13]; else if(pCdat->m_Kdata1[CurrRow].Price < pCdat->ystc) pGridCell->crFgClr =m_pDoc->m_colorArray[15]; else pGridCell->crFgClr =m_pDoc->m_colorArray[14]; } pGridCell->szText =str; break; case 3: if(pCdat->ystc !=0) { if(pCdat->m_Kdata1[CurrRow].Price==0&&CurrRow>0) { sprintf(str,"%6.2f%s",(pCdat->m_Kdata1[CurrRow-1].Price - pCdat->ystc)/pCdat->ystc*100,"%"); if(pCdat->m_Kdata1[CurrRow-1].Price>pCdat->ystc ) pGridCell->crFgClr =m_pDoc->m_colorArray[13]; else if(pCdat->m_Kdata1[CurrRow-1].Price < pCdat->ystc) pGridCell->crFgClr =m_pDoc->m_colorArray[15]; else pGridCell->crFgClr =m_pDoc->m_colorArray[14]; } else { sprintf(str,"%6.2f%s",100*(pCdat->m_Kdata1[CurrRow].Price - pCdat->ystc)/pCdat->ystc,"%"); if(pCdat->m_Kdata1[CurrRow].Price>pCdat->ystc ) pGridCell->crFgClr =m_pDoc->m_colorArray[13]; else if(pCdat->m_Kdata1[CurrRow].Price < pCdat->ystc) pGridCell->crFgClr =m_pDoc->m_colorArray[15]; else pGridCell->crFgClr =m_pDoc->m_colorArray[14]; } pGridCell->szText =str; } else sprintf(str,"%6.2f",0.0f); break; case 4: if(tempNidx[CurrRow].rsn!=0) sprintf(str,"%d",tempNidx[CurrRow].rsn); else sprintf(str,"%d",tempNidx[CurrRow-1].rsn); pGridCell->crFgClr =m_pDoc->m_colorArray[13]; pGridCell->szText =str; break; case 5: if(tempNidx[CurrRow].dnn!=0) sprintf(str,"%d",tempNidx[CurrRow].dnn); else sprintf(str,"%d",tempNidx[CurrRow-1].dnn); pGridCell->crFgClr =m_pDoc->m_colorArray[15]; pGridCell->szText =str; break; case 6: if(pCdat->m_Kdata1[CurrRow].Amount==0&&CurrRow>0) sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow-1].Amount /10000 ); else sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow].Amount /10000 ); pGridCell->szText =str; pGridCell->crFgClr =m_pDoc->m_colorArray[14]; break; case 7: if(pCdat->m_Kdata1[CurrRow].Amount==0&&CurrRow>0) sprintf(str,"%6.2f",0 ); else { if(CurrRow==0) sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow].Amount ); else sprintf(str,"%6.2f",(pCdat->m_Kdata1[CurrRow].Amount - pCdat->m_Kdata1[PreRow].Amount) /10000 ); } pGridCell->szText =str; pGridCell->crFgClr =m_pDoc->m_colorArray[14]; break; case 8: if(pCdat->m_Kdata1[CurrRow].Volume==0&&CurrRow>0) sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow-1].Volume); else sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow].Volume); pGridCell->szText =str; pGridCell->crFgClr =m_pDoc->m_colorArray[14]; break; case 9: if(pCdat->m_Kdata1[CurrRow].Volume==0&&CurrRow>0) sprintf(str,"%6.2f",0); else { if(CurrRow==0) sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow].Volume); else sprintf(str,"%6.2f",pCdat->m_Kdata1[CurrRow].Volume - pCdat->m_Kdata1[PreRow].Volume); } pGridCell->szText =str; pGridCell->crFgClr =m_pDoc->m_colorArray[14]; break; } return TRUE; }
void CCedtView::ActionReplayMacro(INT nMacro, INT nTimes) { POSITION posAction, posParam, posFlags, posString; INT nAction; UINT nParam, nFlags, nOptions; CString szString, szReplace; CMacroBuffer & rBuffer = m_clsMacroBuffer[nMacro]; while( nTimes-- ) { posAction = rBuffer.m_lstAction.GetHeadPosition(); posParam = rBuffer.m_lstParam.GetHeadPosition(); posFlags = rBuffer.m_lstFlags.GetHeadPosition(); posString = rBuffer.m_lstString.GetHeadPosition(); while( posAction ) { nAction = rBuffer.m_lstAction.GetNext( posAction ); switch( nAction ) { case MACRO_MOVE: nParam = rBuffer.m_lstParam.GetNext( posParam ); nFlags = rBuffer.m_lstFlags.GetNext( posFlags ); EventMoveCaret(nParam, nFlags, TRUE); break; case MACRO_CHAR: nParam = rBuffer.m_lstParam.GetNext( posParam ); EventInsertChar(nParam, TRUE); break; case MACRO_STRING: szString = rBuffer.m_lstString.GetNext( posString ); EventInsertString(szString, TRUE); break; case MACRO_FILE: szString = rBuffer.m_lstString.GetNext( posString ); EventInsertFile(szString, TRUE); break; case MACRO_FIND: szString = rBuffer.m_lstString.GetNext( posString ); nOptions = rBuffer.m_lstParam.GetNext( posParam ); EventFindString(szString, nOptions, TRUE); break; case MACRO_REPLACE: szString = rBuffer.m_lstString.GetNext( posString ); szReplace = rBuffer.m_lstString.GetNext( posString ); nOptions = rBuffer.m_lstParam.GetNext( posParam ); EventReplaceString(szString, szReplace, nOptions, TRUE); break; case MACRO_GOTO: nParam = rBuffer.m_lstParam.GetNext( posParam ); EventGoToLine(nParam, TRUE); break; case MACRO_COMMAND: nParam = rBuffer.m_lstParam.GetNext( posParam ); switch( nParam ) { case ID_EDIT_ESCAPE: EventCommandEscape(TRUE); break; case ID_EDIT_RETURN: EventCommandReturn(TRUE); break; case ID_EDIT_BACK: EventCommandBack(TRUE); break; case ID_EDIT_DELETE: EventCommandDelete(TRUE); break; case ID_EDIT_TAB: EventCommandTab(TRUE); break; case ID_EDIT_DETAB: EventCommandDetab(TRUE); break; case ID_EDIT_INCREASE_INDENT: EventIncreaseIndent(TRUE); break; case ID_EDIT_DECREASE_INDENT: EventDecreaseIndent(TRUE); break; case ID_EDIT_MAKE_COMMENT: EventMakeComment(TRUE); break; case ID_EDIT_RELEASE_COMMENT: EventReleaseComment(TRUE); break; case ID_EDIT_JOIN_LINES: EventJoinLines(TRUE); break; case ID_EDIT_SPLIT_LINE: EventSplitLine(TRUE); break; case ID_EDIT_DELETE_WORD: EventDeleteWord(TRUE); break; case ID_EDIT_DELETE_PREV_WORD: EventDeletePrevWord(TRUE); break; case ID_EDIT_DELETE_TO_END_OF_LINE: EventDeleteToEndOfLine(TRUE); break; case ID_EDIT_DELETE_TO_BEGIN_OF_LINE: EventDeleteToBeginOfLine(TRUE); break; case ID_EDIT_DELETE_LINE: EventDeleteLine(TRUE); break; case ID_EDIT_DUPLICATE_LINE: EventDuplicateLine(TRUE); break; case ID_EDIT_CUT: EventCommandCut(TRUE); break; case ID_EDIT_COPY: EventCommandCopy(TRUE); break; case ID_EDIT_COPY_FILE_PATH: EventCommandCopyFilePath(TRUE); break; case ID_EDIT_CUT_APPEND: EventCommandCutAppend(TRUE); break; case ID_EDIT_COPY_APPEND: EventCommandCopyAppend(TRUE); break; case ID_EDIT_PASTE: EventCommandPaste(TRUE); break; case ID_EDIT_INSERT_DATE: EventInsertString(GetCurrentDate() + CString(" "), TRUE); break; case ID_EDIT_INSERT_TIME: EventInsertString(GetCurrentTime() + CString(" "), TRUE); break; case ID_EDIT_SELECT_ALL: EventSelectAll(TRUE); break; case ID_EDIT_SELECT_LINE: EventSelectLine(TRUE); break; case ID_EDIT_SELECT_WORD: EventSelectWord(TRUE); break; case ID_EDIT_SELECT_BLOCK: EventSelectBlock(TRUE); break; case ID_EDIT_UPPER_CASE: EventUpperCase(TRUE); break; case ID_EDIT_LOWER_CASE: EventLowerCase(TRUE); break; case ID_EDIT_CAPITALIZE: EventCapitalize(TRUE); break; case ID_EDIT_INVERT_CASE: EventInvertCase(TRUE); break; case ID_EDIT_CONVERT_TABS_TO_SPACES: EventConvertTabsToSpaces(TRUE); break; case ID_EDIT_CONVERT_SPACES_TO_TABS: EventConvertSpacesToTabs(TRUE); break; case ID_EDIT_LEADING_SPACES_TO_TABS: EventLeadingSpacesToTabs(TRUE); break; case ID_EDIT_REMOVE_TRAILING_SPACES: EventRemoveTrailingSpaces(TRUE); break; case ID_EDIT_UNDO: /* cannot be included in a macro */ break; case ID_EDIT_REDO: /* cannot be included in a macro */ break; case ID_TOOL_EVALUATE_LINE: EventEvaluateLine(TRUE); break; case ID_MACRO_REPLAY: /* cannot be included in a macro */ break; case ID_SEARCH_NEXT_WORD: EventFindCurrentString(TRUE); break; case ID_SEARCH_PREV_WORD: EventFindCurrentString(TRUE); break; case ID_SEARCH_FIND_NEXT: EventFindSelectedString(TRUE); break; case ID_SEARCH_FIND_PREV: EventFindSelectedString(TRUE); break; case ID_SEARCH_NEXT_OCCURRENCE: EventSearchNextOccurrence(TRUE); break; case ID_SEARCH_PREV_OCCURRENCE: EventSearchPrevOccurrence(TRUE); break; case ID_SEARCH_REPLACE_THIS: EventReplaceThisOccurrence(TRUE); break; case ID_SEARCH_REPALL_IN_SELECTION: EventReplaceAllInSelection(TRUE); break; case ID_SEARCH_REPALL_IN_FILE: EventReplaceAllInFile(TRUE); break; case ID_SEARCH_REPALL_IN_OPEN_FILES: /* cannot be included in a macro */ break; case ID_SEARCH_TOGGLE_BOOKMARK: EventToggleBookmark(TRUE); break; case ID_SEARCH_NEXT_BOOKMARK: EventNextBookmark(TRUE); break; case ID_SEARCH_PREV_BOOKMARK: EventPrevBookmark(TRUE); break; case ID_SEARCH_PREV_EDIT: EventPrevEditingPosition(TRUE); break; case ID_SEARCH_PAIRS_BEGIN: EventPairsBeginPosition(TRUE); break; case ID_SEARCH_PAIRS_END: EventPairsEndPosition(TRUE); break; } break; } if( m_bPairHighlighted[0] || m_bPairHighlighted[1] ) UnhighlightPairs(); if( ! m_bSelected && m_bEnablePairsMatching ) HighlightMatchingPairs(); } } }
void BudgetWindow::GenerateBudget(const bool &zero) { // Generate a budget based on the last year's transactions ReportGrid income(1,0), spending(1,0); gDatabase.DBCommand("delete from budgetlist", "BudgetWindow::GenerateBudget:empty budget"); CppSQLite3Query query; query = gDatabase.DBQuery("select * from categorylist order by name", "BudgetWindow::GenerateBudget:get categories"); if(query.eof()) return; float maxwidth=fCategoryList->StringWidth(TRANSLATE("Category")); while(!query.eof()) { BString catname = DeescapeIllegalCharacters(query.getStringField(0)); if(catname.ICompare(TRANSLATE("Transfer"))==0) { query.nextRow(); continue; } bool isexpense = !query.getIntField(1); if(isexpense) { spending.AddItem(); spending.SetRowTitle(spending.CountItems()-1,catname.String()); } else { income.AddItem(); income.SetRowTitle(income.CountItems()-1,catname.String()); } float tempwidth = fCategoryList->StringWidth(catname.String()); maxwidth = MAX(maxwidth,tempwidth); query.nextRow(); } query.finalize(); // Now that we have the list of categories, query for transactions for each // account from each category BString querystring; Fixed cattotal; for(int32 i=0; i<income.CountItems(); i++) { querystring = ""; cattotal = 0; if(!zero) { for(int32 j=0; j<gDatabase.CountAccounts(); j++) { Account *acc = gDatabase.AccountAt(j); querystring = "select sum(amount) from account_" ; querystring << acc->GetID() << " where category = '" << EscapeIllegalCharacters(income.RowTitle(i)) << "' and date > " << DecrementDateByYear(GetCurrentDate()) << ";"; query = gDatabase.DBQuery(querystring.String(), "BudgetWindow::GenerateBudget:get category"); cattotal.AddPremultiplied(query.getInt64Field(0)); query.finalize(); } cattotal /= 12; cattotal.Round(); } income.SetValue(0,i,cattotal); gDatabase.AddBudgetEntry(BudgetEntry(income.RowTitle(i),cattotal,BUDGET_MONTHLY,false)); } for(int32 i=0; i<spending.CountItems(); i++) { querystring = ""; cattotal = 0; if(!zero) { for(int32 j=0; j<gDatabase.CountAccounts(); j++) { Account *acc = gDatabase.AccountAt(j); querystring = "select sum(amount) from account_" ; querystring << acc->GetID() << " where category = '" << EscapeIllegalCharacters(spending.RowTitle(i)) << "';"; query = gDatabase.DBQuery(querystring.String(), "BudgetWindow::GenerateBudget:get category"); cattotal.AddPremultiplied(query.getInt64Field(0)); query.finalize(); } cattotal /= 12; cattotal.Round(); } spending.SetValue(0,i,cattotal); gDatabase.AddBudgetEntry(BudgetEntry(spending.RowTitle(i),cattotal,BUDGET_MONTHLY,true)); } }
/** * @constructor * * Calls GetCurrentDate method. */ NxsDate::NxsDate() { GetCurrentDate(); }
void main() { HANDLE hEventLog; EVENTLOGRECORD* pEventLogRecord = 0; EVENTRECORD* pER = 0; CHAR szFilePath[_MAX_PATH]; CHAR szDate[9]; DWORD dwBytesRead, dwBytesNeeded; DWORD dwEventLogRecords, dwTemp; FILE* fp; // get current date GetCurrentDate(szDate); // get file path if (!(GetFilePath(szFilePath))) strcpy(szFilePath, ""); // format file name sprintf(szFileName, "%s%s%s", szFilePath, szDate, ".LOG"); // open security event log on local machine printf("Opening Security Event Log for Reading...\n"); if (!(hEventLog = OpenEventLog(NULL, "Security"))) { printf("Error Opening Event Log.\n"); return; } // open event file printf("Opening Event File %s for Writing...\n", szFileName); if ((fp = fopen(szFileName, "w+t")) == NULL) { printf("Error Opening Event File.\n"); return; } // find the number of event log records GetNumberOfEventLogRecords(hEventLog, &dwEventLogRecords); // read data and output to file printf("Writing Data To File...\n"); for (dwTemp = 1; dwTemp <= dwEventLogRecords; dwTemp++) { if (!(pEventLogRecord = (EVENTLOGRECORD*)malloc(16384))) return; // read records from event log if (!(ReadEventLog(hEventLog, // event log handle EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ, // get specified record dwTemp, pEventLogRecord, // buffer address 16384, // max size &dwBytesRead, // number of bytes read &dwBytesNeeded))) // number of bytes needed ShowError(); // read record information if (dwBytesRead) { if (ShouldWriteRecord(pEventLogRecord->TimeWritten)) { // allocate memory for event record if (!(pER = (EVENTRECORD*)malloc(sizeof(EVENTRECORD)))) { printf("Error allocating memory for record.\n"); if (pEventLogRecord) free (pEventLogRecord); return; } // set event record into structure SetEventRecord(pEventLogRecord, pER); // write data to file fprintf(fp, "%d\t%s\t%s\t%s\t%s\n%s\n", pER->EventID, pER->szEventDate, pER->szEventType, pER->szSourceName, pER->szComputerName, pER->pMessage); // free allocated memory if (pER) free(pER); } } // free allocated buffer if (pEventLogRecord) free (pEventLogRecord); } printf("Closing Files...\n"); // release event log handle CloseEventLog(hEventLog); // close event file _flushall(); fclose(fp); // send message printf("Sending messages...\n"); SendMail(); }