⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textsearchdlg.cpp

📁 oracle long raw类型
💻 CPP
字号:
// TextSearchDlg.cpp : implementation file
//

#include "stdafx.h"
#include "TextSearch.h"
#include "TextSearchDlg.h"
#include   <direct.h>
#include  <io.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
ODatabase m_oDatabase;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTextSearchDlg dialog

CTextSearchDlg::CTextSearchDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTextSearchDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTextSearchDlg)
	m_DataName = _T("DATAMDB");
	m_PassWord = _T("ccis");
	m_UserName = _T("ccis");
	m_PhotoField = _T("frontfacephoto");
	m_TableName = _T("frontface");
	m_ConditionField = _T("pid");
	m_Condition = _T("1");
	m_End = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTextSearchDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTextSearchDlg)
	DDX_Control(pDX, IDC_Sum, m_Sum);
	DDX_Control(pDX, IDC_Save, m_BtnSave);
	DDX_Control(pDX, IDC_Search, m_BtnSearch);
	DDX_Text(pDX, IDC_DataName, m_DataName);
	DDX_Text(pDX, IDC_PassWord, m_PassWord);
	DDX_Text(pDX, IDC_UserName, m_UserName);
	DDX_Text(pDX, IDC_PhotoField, m_PhotoField);
	DDX_Text(pDX, IDC_TableName, m_TableName);
	DDX_Text(pDX, IDC_ConditionField, m_ConditionField);
	DDX_Text(pDX, IDC_Condition, m_Condition);
	DDX_Text(pDX, IDC_End, m_End);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTextSearchDlg, CDialog)
	//{{AFX_MSG_MAP(CTextSearchDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_Search, OnSearch)
	ON_BN_CLICKED(IDC_Save, OnSave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTextSearchDlg message handlers

BOOL CTextSearchDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	//m_strData.SetWindowText("orcl");

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);	
	// Set small icon
		
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CTextSearchDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CTextSearchDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	if (IsIconic())
	{
	SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CTextSearchDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CTextSearchDlg::OnSearch() 
{
	SendMessage(WM_CLOSE);

}


void CTextSearchDlg::OnSave() 
{
	//	m_DataName;数据库名
	//	m_PassWord;密码
	//	m_UserName;用户名
	//	m_PhotoField;照片字段名
	//	m_TableName;照片表名
	//	m_ConditionField;依据字段名
	//	m_Condition;
	//	m_End;
	////////////////////////////////////////
	CString strPath;
	TCHAR szFull[_MAX_PATH];
	TCHAR szDrive[_MAX_DRIVE];
	TCHAR szDir[_MAX_DIR];
	::GetModuleFileName(NULL, szFull, sizeof(szFull)/sizeof(TCHAR));
	_tsplitpath(szFull, szDrive, szDir, NULL, NULL);
	_tcscpy(szFull, szDrive);
	_tcscat(szFull, szDir);
	strPath = CString(szFull);//获取当前目录
	UpdateData(TRUE);

	OStartup();
	oresult or;
	or=m_oDatabase.Open(m_DataName,m_UserName,m_PassWord);
	if(!or==OSUCCESS)
	{
		if(m_oDatabase.IsOpen())
			m_oDatabase.Close();
		AfxMessageBox("连接失败!");
		return ;
	}
	else
	{
		ODynaset	oDyn;
		ODynaset	oDynB;
		CString		strSQL;
		int			nImageLength;
		BYTE*		pImageFile;	
		OField		oFieldImage;
		CString		pStrRsc;
	
		if(m_End==""&&m_Condition=="")
		{
			//::AfxMessageBox("1");
			
			strSQL.Format("select %s,%s from %s",m_PhotoField,m_ConditionField,m_TableName);
		}
		else
		{
			if(m_End!="")
			{
			//	::AfxMessageBox("2");
				strSQL.Format("select %s,%s from %s where %s>='%s' and %s<='%s'",m_PhotoField,m_ConditionField,m_TableName,m_ConditionField,m_Condition,m_ConditionField,m_End);
			}
			else
			{
			//	::AfxMessageBox("3");
			strSQL.Format("select %s,%s from %s where %s>='%s'",m_PhotoField,m_ConditionField,m_TableName,m_ConditionField,m_Condition);
			}
		}
		oDynB.Open(m_oDatabase,strSQL);
		
		DWORD Rsc=0;
		UpdateData(FALSE);
	//	m_Sum.SetWindowText(strSQL);
		int iS=GetTickCount();
		oDynB.MoveFirst();
		while(!oDynB.IsEOF())
		{
			int SL;
			SL=oDynB.GetField(m_ConditionField);
			/////////////////////////////////////////////////////
			CString a;
			a.Format("%d  %d",SL,Rsc);
			CStdioFile  fa;
			fa.Open(strPath+"SSPW.log",CFile::modeCreate|CFile::modeWrite);				
			fa.WriteString(a);				
			fa.Close();
			strSQL.Format("select %s,%s from %s where %s='%s'",m_PhotoField,m_ConditionField,m_TableName,m_ConditionField,(CString)oDynB.GetField(m_ConditionField));
			oDyn.Open(m_oDatabase,strSQL);
			///////////////////////////////////////////////////////
			if(Rsc%5000==0)
			{
				pStrRsc.Format("%d",(int)Rsc/5000);
				mkdir(strPath+pStrRsc);
			}
			oFieldImage = oDyn.GetField(m_PhotoField);
			nImageLength  = oFieldImage.GetServerSize();
			if(nImageLength>0)
			{		                        
				oFieldImage.GetChunk((const char**)&pImageFile, 0, nImageLength);
			}
			CString str;							
			str.Format("%s%s\\%s.jpg",strPath,pStrRsc,(CString)oDyn.GetField(m_ConditionField));
			if(_access(str, 0 )==0)
			{
				str.Format("%s%s\\%s_1.jpg",strPath,pStrRsc,(CString)oDyn.GetField(m_ConditionField));
				if(_access(str, 0 )==0)
				{
					str.Format("%s%s\\%s_2.jpg",strPath,pStrRsc,(CString)oDyn.GetField(m_ConditionField));
					if(_access(str, 0 )==0)
					str.Format("%s%s\\%s_3.jpg",strPath,pStrRsc,(CString)oDyn.GetField(m_ConditionField));
				}
			}
			Rsc++;
			if((CString)oDyn.GetField(m_ConditionField)=="")
			{
				break;
			}
			else
			{
				CFile a;
				a.Open(str,CFile::modeCreate|CFile::modeWrite);				
				a.Write(pImageFile,nImageLength);				
				a.Close();
				delete[] pImageFile;
				pImageFile=NULL;
			}
				oDyn.Close();
				oDynB.MoveNext();
		}
			CString a2;
			a2.Format("%d",GetTickCount()-iS);
			AfxMessageBox(a2);
	}
		
		

}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -