📄 recordfile.cpp
字号:
// RecordFile.cpp: implementation of the CRecordFile class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "bxt.h"
#include "RecordFile.h"
#include "direct.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRecordFile::CRecordFile()
{
m_sFileName = _T("");
m_sSavePath = _T("E:\\我的文档\\TEMP\\");
#ifdef _DEBUG
m_sReadPath = _T("E:\\我的文档\\TEMP\\");
#else
GetCDReadPath();
#endif // #ifdef _DEBUG
m_sFileMatch = _T(m_sReadPath + "*.dat");
m_bIsNew = TRUE;
m_hFindFile = INVALID_HANDLE_VALUE;
}
CRecordFile::~CRecordFile()
{
CloseFile();
}
BOOL
CRecordFile::OpenFile(INT iDirection)
{
CHAR sBuffer[68000];
FILE* fp = NULL;
INT iBytesRead;
// -> FindFile
if (RF_FIRST_FILE == iDirection)
{
CloseFile();
m_hFindFile = ::FindFirstFile(TO_CHAR(m_sFileMatch), &m_FindFileData);
if (INVALID_HANDLE_VALUE == m_hFindFile) return (FALSE);
}
else if (RF_NEXT_FILE == iDirection)
{
if (INVALID_HANDLE_VALUE == m_hFindFile) return (FALSE);
if (!::FindNextFile(m_hFindFile, &m_FindFileData)) return (FALSE);
}
else return (FALSE);
// <- FindFile
// -> ReadFile
m_sFileName = m_sReadPath + m_FindFileData.cFileName;
fp = fopen(m_sFileName, "rb");
if (NULL == fp) return (FALSE);
fread(&(m_Record.m_Record), sizeof(RECORD_STRUCT), 1, fp);
iBytesRead = fread(sBuffer, 68000, 1, fp);
fclose(fp);
sBuffer[iBytesRead] = '\0';
m_Record.m_sReport = sBuffer;
// <- ReadFile
return (TRUE);
}
BOOL
CRecordFile::SaveFile(CHAR *sFileName)
{
BOOL bSaveSuccess = FALSE;
CString sDir;
FILE* fp = NULL;
sDir.Format("%s%s\\", TO_CHAR(m_sSavePath), m_Record.m_Record.m_sID);
m_sFileName = m_sSavePath + sFileName;
::CreateDirectory(sDir, NULL);
// -> Save File
fp = fopen(m_sFileName, "wb");
if (NULL == fp)
{
::remove(sDir);
return (FALSE);
}
fwrite(&m_Record, sizeof(RECORD_STRUCT), 1, fp);
fwrite(TO_CHAR(m_Record.m_sReport), m_Record.m_sReport.GetLength(), 1, fp);
fclose(fp);
// <- Save File
// -> Copy Files
CopyFileSet(TO_CHAR(m_sImagePath), TO_CHAR(sDir), "*.jpg");
CopyFileSet(TO_CHAR(m_sImagePath), TO_CHAR(sDir), "*.avi");
CopyFileSet(TO_CHAR(m_sImagePath), TO_CHAR(sDir), "*.mes");
CopyFileSet(TO_CHAR(m_sImagePath), TO_CHAR(sDir), "*.mrk");
// <- Copy Files
return (TRUE);
}
CRecordClass::CRecordClass()
{
m_sReport = _T("");
m_Record.m_iAge = 0;
m_Record.m_iPostCode = 0;
strcpy(m_Record.m_sAddress, "");
strcpy(m_Record.m_sBedID, "");
strcpy(m_Record.m_sCheck, "");
strcpy(m_Record.m_sCheckDate, "");
strcpy(m_Record.m_sCheckPos, "");
strcpy(m_Record.m_sCheckStyle, "");
strcpy(m_Record.m_sClass, "");
strcpy(m_Record.m_sDevice, "");
strcpy(m_Record.m_sDoctor, "");
strcpy(m_Record.m_sHospID, "");
strcpy(m_Record.m_sHospital, "");
strcpy(m_Record.m_sID, "");
strcpy(m_Record.m_sIllName, "");
strcpy(m_Record.m_sName, "");
strcpy(m_Record.m_sSex, "");
strcpy(m_Record.m_sTelephone, "");
strcpy(m_Record.m_sResult, "");
}
BOOL
CRecordFile::IsMatch()
{
if (m_Restrict.m_bResAddress &&
strcmp(m_Restrict.m_Record.m_sAddress, m_Record.m_Record.m_sAddress))
return (FALSE);
if (m_Restrict.m_bResName &&
strcmp(m_Restrict.m_Record.m_sName, m_Record.m_Record.m_sName))
return (FALSE);
if (m_Restrict.m_bResSex &&
strcmp(m_Restrict.m_Record.m_sSex, m_Record.m_Record.m_sSex))
return (FALSE);
if (m_Restrict.m_bResID &&
strcmp(m_Restrict.m_Record.m_sID, m_Record.m_Record.m_sID))
return (FALSE);
if (m_Restrict.m_bResAgeEqu &&
m_Restrict.m_Record.m_iAge != m_Record.m_Record.m_iAge)
return (FALSE);
if (m_Restrict.m_bResAgeMin &&
m_Restrict.m_iAgeMin > m_Record.m_Record.m_iAge)
return (FALSE);
if (m_Restrict.m_bResAgeMax &&
m_Restrict.m_iAgeMax < m_Record.m_Record.m_iAge)
return (FALSE);
if (m_Restrict.m_bResBedID &&
strcmp(m_Restrict.m_Record.m_sBedID, m_Record.m_Record.m_sBedID))
return (FALSE);
if (m_Restrict.m_bResCheck &&
strcmp(m_Restrict.m_Record.m_sCheck, m_Record.m_Record.m_sCheck))
return (FALSE);
// if (m_Restrict.m_bResCheckDate &&
// strcmp(m_Restrict.m_Record.m_sCheck, m_Record.m_Record.m_sCheck))
// return (FALSE);
if (m_Restrict.m_bResCheckPos &&
strcmp(m_Restrict.m_Record.m_sCheckPos, m_Record.m_Record.m_sCheckPos))
return (FALSE);
if (m_Restrict.m_bResCheckStyle &&
strcmp(m_Restrict.m_Record.m_sCheckStyle, m_Record.m_Record.m_sCheckStyle))
return (FALSE);
if (m_Restrict.m_bResClass &&
strcmp(m_Restrict.m_Record.m_sClass, m_Record.m_Record.m_sClass))
return (FALSE);
if (m_Restrict.m_bResDoctor &&
strcmp(m_Restrict.m_Record.m_sDoctor, m_Record.m_Record.m_sDoctor))
return (FALSE);
if (m_Restrict.m_bResHospID &&
strcmp(m_Restrict.m_Record.m_sHospID, m_Record.m_Record.m_sHospID))
return (FALSE);
return (TRUE);
}
BOOL
CRecordFile::ResetRestrict()
{
return (m_Restrict.Reset());
}
BOOL
CRestrict::Reset()
{
m_bResID = FALSE;
m_bResName = FALSE;
m_bResSex = FALSE;
m_bResClass = FALSE;
m_bResCheck = FALSE;
m_bResAddress = FALSE;
m_bResPostCode = FALSE;
m_bResTelephone = FALSE;
m_bResCheckDate = FALSE;
m_bResDoctor = FALSE;
m_bResDevice = FALSE;
m_bResHospital = FALSE;
m_bResIllName = FALSE;
m_bResHospID = FALSE;
m_bResBedID = FALSE;
m_bResCheckStyle = FALSE;
m_bResCheckPos = FALSE;
m_bResAgeMin = FALSE;
m_bResAgeEqu = FALSE;
m_bResAgeMax = FALSE;
m_bResNameFree = FALSE;
return (TRUE);
}
BOOL
CRecordFile::SetSavePath(CHAR* sSavePath)
{
m_sSavePath = _T(sSavePath);
return (::CreateDirectory(m_sSavePath, NULL));
}
BOOL
CRecordFile::SetImagePath(CHAR* sImagePath)
{
m_sImagePath = _T(sImagePath);
return (TRUE);
}
BOOL
CRecordFile::CloseFile()
{
if (INVALID_HANDLE_VALUE != m_hFindFile)
{
::FindClose(m_hFindFile);
m_hFindFile = INVALID_HANDLE_VALUE;
}
return (TRUE);
}
/*
拷贝文件集合
源目录 - m_sImagePath
目标目录 -
*/
INT
CRecordFile::CopyFileSet(CHAR* sargSourcePath, CHAR* sargTargetPath, CHAR *sargMatch)
{
WIN32_FIND_DATA FindFileData;
CString sFileMatch;
CString sSourcePath;
CString sSourceFile;
CString sTargetPath;
CString sTargetFile;
BOOL bFindSuccess;
HANDLE hFindFile = NULL;
INT iCopiedCount = 0;
sSourcePath = sargSourcePath;
sTargetPath = sargTargetPath;
sFileMatch = sSourcePath + sargMatch;
hFindFile = ::FindFirstFile(TO_CHAR(sFileMatch), &FindFileData);
bFindSuccess = (INVALID_HANDLE_VALUE != hFindFile);
while (bFindSuccess)
{
sSourceFile = sSourcePath + FindFileData.cFileName;
sTargetFile = sTargetPath + FindFileData.cFileName;
::CopyFile(TO_CHAR(sSourceFile), TO_CHAR(sTargetFile), FALSE);
iCopiedCount++;
bFindSuccess = ::FindNextFile(hFindFile, &FindFileData);
}
if (INVALID_HANDLE_VALUE != hFindFile) ::FindClose(hFindFile);
return (iCopiedCount);
}
CString
CRecordFile::GetDataPath()
{
return (m_sReadPath);
}
BOOL
CRecordFile::GetCDReadPath()
{
CHAR sDriverPath[10] = "A:\\";
CHAR cDriver;
UINT uiReturn;
BOOL bFindCD = FALSE;
for (cDriver = 'A'; cDriver <= 'Z'; cDriver++)
{
sDriverPath[0] = cDriver;
uiReturn = ::GetDriveType(sDriverPath);
if (uiReturn == DRIVE_CDROM)
{
bFindCD = TRUE;
break;
}
}
if (bFindCD)
{
m_sReadPath = sDriverPath;
m_sReadPath += _T("DATA\\");
}
else
{
m_sReadPath = _T("");
}
return (bFindCD);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -