BOOL CCapDownload::checkOcsAgentSetupResult() { CString csFile, csCode = ERR_DONE_FAILED, csID; CStdioFile myFile; csFile.Format(_T("%s\\%s"), getDownloadFolder(), OCS_AGENT_SETUP_DONE); if (!fileExists(csFile)) // No OCS Agent Setup done file return TRUE; m_pLogger->log(LOG_PRIORITY_DEBUG, _T("DOWNLOAD => Found OCS Inventory Agent Setup result file <%s>"), csFile); // Open OCS Agent Setup done file to read exit code and package ID try { if (!myFile.Open(csFile, CFile::modeRead | CFile::typeText | CFile::shareDenyNone)) return FALSE; // First line contains result code and seconf line contains package ID myFile.ReadString(csCode); myFile.ReadString(csID); myFile.Close(); } catch (CException *pEx) { pEx->Delete(); myFile.Abort(); m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Failed reading OCS Inventory Agent Setup result file <%s>"), csFile); return FALSE; } if (csID.IsEmpty()) { // Upgrading from agent 1.X or previous to 2.0.0.22 ? m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Found result code <%s> for OCS Inventory Agent Setup package but no package ID specified, so remove all packages to avoid running Agent setup in loop !"), csCode); COptDownloadPackage::cleanAll(); return FALSE; } // All information available => copy result file to Package directory csFile.Format(_T("%s\\%s\\%s"), getDownloadFolder(), csID, OCS_DOWNLOAD_DONE); if (!CopyFile(myFile.GetFilePath(), csFile, FALSE)) { m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Failed to copy result code for OCS Inventory Agent Setup package to file <%s>"), csFile); return FALSE; } DeleteFile(myFile.GetFilePath()); m_pLogger->log(LOG_PRIORITY_NOTICE, _T("DOWNLOAD => Validated result code <%s> for OCS Inventory Agent Setup package <%s>"), csCode, csID); return TRUE; }
void CXunJianDlg::OnBnClickedOpenfile() { // TODO: 在此添加控件通知处理程序代码 CStdioFile listfile; if( opened == true || listfile.Open(xj_ipListFileName,CFile::modeRead,0) == false) { //listfile.Close(); m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); CFileDialog FileDlg(true, _T("txt"),NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY, "文本文件(*.TXT)|*.TXT|All Files(*.*)|*.*||"); if( FileDlg.DoModal() == IDOK ) { xj_ipListFileName = FileDlg.GetFileName(); listfile.Open(xj_ipListFileName,CFile::modeRead,0); } else return; } xj_ipListFileName = listfile.GetFileName();//FileDlg.GetFileName(); xj_FilePath = listfile.GetFilePath();//FileDlg.GetPathName(); xj_FilePath.Replace(xj_ipListFileName,""); xj_FilePath.Replace("\\","\\\\"); pList= (CListBox *)GetDlgItem(IDC_HOSTLIST); pList->ResetContent(); CString str; while(listfile.ReadString(str)) { if(str.Find("\'") == -1) //空行不加入 ,有 '符号不加入,相当于注释掉此行 { str.Replace(" ",""); //去除所有空格 pList->AddString(str); } } opened = true; listfile.Close(); UpdateData(false); }
//-------------------------------------------------------------------------------- int main(int argc, char* argv[]) { ::SetConsoleTitle("SecurityServer TokenCompiler Version 1.4"); char sPass[32]; GetPasswordFromConsole(sPass, 32, 2); #ifndef _DEBUG if(strncmp(sPass, PASSWORD, strlen(PASSWORD)) != 0) { printf("Password Failed\n"); return -1; } #endif if(argc < 2) { printf("TokenCompiler by Rich Schonthal\n"); printf("Copyright (c) 2000 MarkCare Medical Systems, Inc.\n"); printf("usage:\n"); printf("tokencompiler <input filename> [output filename]\n"); printf("tokencompiler -dongle <starting serial number> <count>\n"); printf("default output filename mcmssecserv.dat\n"); return -1; } // generate dongle files only if(stricmp("-dongle", argv[1]) == 0) { if(argc < 4) { printf("TokenCompiler by Rich Schonthal\n"); printf("Copyright (c) 2000 MarkCare Medical Systems, Inc.\n"); printf("usage:\n"); printf("tokencompiler -dongle <starting serial number> <count>\n"); return -1; } int nStart = atoi(argv[2]); int nCount = atoi(argv[3]); for(int i = nStart; i < nStart + (nCount * 10); i += 10) { CFile file; CString sName; sName.Format("%d.sec", i); // now write the dongle file if(! file.Open(sName, CFile::modeWrite|CFile::modeCreate|CFile::shareExclusive)) { printf("error creating dongle file\n"); return -1; } else { char cTemp[128]; memset(cTemp, 0, 128); sprintf(cTemp, "MarkCareMedicalSystemsSecurityServerDongle-%d", i); file.Write(cTemp, 128); } } } CStdioFile fIn; if(! fIn.Open(argv[1], CFile::modeRead|CFile::shareExclusive)) { printf("error opening %s for input\n", argv[1]); return -1; } LPCTSTR pOutname = argc == 2 ? "mcmssecserv.dat" : argv[2]; CFile fOut; if(! fOut.Open(pOutname, CFile::modeWrite|CFile::modeCreate|CFile::shareExclusive)) { printf("error opening %s for output\n", pOutname); return -1; } char* pBkupName = new char[strlen(pOutname) + 96]; MakeBackupFilename(pOutname, pBkupName); CFile fOutBkup; if(! fOutBkup.Open(pBkupName, CFile::modeWrite|CFile::modeCreate|CFile::shareExclusive)) { printf("error opening %s for output\n", pBkupName); ::DeleteFile(pOutname); return -1; } int nRv = Parse(fIn, fOut, fOutBkup); CString sPath(fIn.GetFilePath()); int nIndex = sPath.ReverseFind('\\'); if(nIndex > -1) { sPath.GetBufferSetLength(nIndex + 1); sPath.ReleaseBuffer(); } else sPath = ".\\"; fIn.Close(); fOut.Close(); fOutBkup.Close(); if(nRv != 0) { printf("error in output - file not created\n"); ::DeleteFile(pOutname); ::DeleteFile(pBkupName); } // now create the dongle filename char* pBackslash = strrchr(pBkupName, '\\'); char cDongleName[64]; sprintf(cDongleName, "%08lx.sec", time(NULL)); if(pBackslash == NULL) strcpy(pBkupName, cDongleName); else strcpy(pBackslash+1, cDongleName); { // remove old dongle files WIN32_FIND_DATA find; HANDLE hand = ::FindFirstFile(sPath + "*.sec", &find); if(hand != INVALID_HANDLE_VALUE) for(;;) { ::DeleteFile(sPath + find.cFileName); if(! ::FindNextFile(hand, &find)) break; } } // now write the dongle file if(! fOutBkup.Open(pBkupName, CFile::modeWrite|CFile::modeCreate|CFile::shareExclusive)) { printf("error creating dongle file\n"); nRv = false; } else { char cTemp[128]; memset(cTemp, 0, 128); sprintf(cTemp, "MarkCareMedicalSystemsSecurityServerDongle-%s", g_pDongle); fOutBkup.Write(cTemp, 128); } delete[] pBkupName; return nRv; }
CFieldValuePair::DumpARX(CARSConnection &arsConnect, CString Form, CStdioFile &File, CString &strAttachDir, unsigned int *p_uiAttachNum, CEntryId &EntryId, CString &strBuffer) { // Insert a space before the value // File.Write(" ", 1); strBuffer += " "; CString cleanValue(Value); // dump the value to the file switch(uiType) { case AR_DATA_TYPE_NULL: //File.Write("\"\"", 2); strBuffer += "\"\""; break; // basically an value exported via this case will not have any double // quotes exported case AR_DATA_TYPE_INTEGER: case AR_DATA_TYPE_REAL: case AR_DATA_TYPE_ENUM: case AR_DATA_TYPE_TIME: case AR_DATA_TYPE_DECIMAL: //File.Write(LPCSTR(Value), Value.GetLength()); // write the value strBuffer += Value; break; // any value exported via this case will have double quotes // inserted before and after the Value. case AR_DATA_TYPE_CHAR: case AR_DATA_TYPE_DIARY: case AR_DATA_TYPE_CURRENCY: // treat currency like a char because we need to double quotes cleanValue.Replace("\"", "\\\""); // insert a \ before each double quote cleanValue.Replace("\n", "\\r\\n"); // replace carriage returns with \r\n text //File.Write("\"", 1); // write double quote before value strBuffer += "\""; //File.Write(LPCSTR(cleanValue), cleanValue.GetLength()); // write the text value strBuffer += cleanValue; //File.Write("\"", 1); // write double quote after value strBuffer += "\""; break; case AR_DATA_TYPE_ATTACH: CString strExt; // working extenstion of the attachment CString strFile; // working file name with no extension CString strAttachNum; // working string for attachment number CString strFinishedAttach; // working completed attachment name to use when calling GetEntryBLOB() CString strFilePath; // the full path the the filename for saving the BLOB file // Save the file extension strExt = Value; strExt.MakeReverse(); strExt = strExt.Left(4); strExt.MakeReverse(); // Save the file name with out extenstion strFile = Value.Left(Value.GetLength() - 4); // convert the Attachment number to a string and increment it strAttachNum.Format("%d", *p_uiAttachNum); *p_uiAttachNum = *p_uiAttachNum + 1; // build the completed attachment name to save // strBuffer += "\"" + strAttachDir + "\\" + strFile + "_" + \ // strAttachNum + strExt + "\""; strFinishedAttach = strAttachDir + "\\" + strFile + "_" + strAttachNum + strExt; strBuffer += "\"" + strFinishedAttach + "\""; // Lastly, save the attachment file BLOB // This function call needs the full path\filename to save the BLOB // this should be specified in strAttachFileName strFilePath = File.GetFilePath(); strFilePath.Replace(File.GetFileName(), LPCSTR(strFinishedAttach)); // replace the filename with the relative attachment name DumpAttachment(arsConnect, Form, EntryId, uiFieldId, strFilePath); break; } // end switch }