123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- /*************************************************************
- /* Copyright (C), 2014-2020, lyfz. Co., Ltd.
- /* 文件名: AdoImpl.h
- /* 作者: Jeff.w
- /* 创建日期: 2014-08-16
- /* 版本号: V1.0
- /* 描述: 核心层底,数据库ADO编程
- /* 其它:
- /* 主要类模块:
- /* 历史修改记录:
- /* 作者 时间 版本 描述
- /* Jeff.w 14/08/18 1.0 创建这个模块
- ***************************************************************/
- #ifndef __ADO_IMPL_HEADER__
- #define __ADO_IMPL_HEADER__
- #pragma once
- //#include <list>//随存随取,使用vector比较好;
- #include <vector>
- using namespace std;
- #include "AdoDef.h"
- #include "ADODatabase.h"
- #include "ADORecordset.h"
- #include "ADOCommand.h"
- typedef struct tbl_dindan
- {
- TString _id;
- TString _money1;
- TString _money2;
- TString _money3;
- TString _name1;
- TString _name2;
- TString _taoxiid;
- TString _taoxiname;
- TString _taoxijiage;
- TString _taoxizs;
- TString _time1;
- TString _time2;
- TString _time3;
- TString _bm;
- TString _ren;
- TString _discount;
- TString _payed1;
- TString _payed2;
- TString _payed3;
- TString _payed4;
- TString _payed5;
- TString _time4;
- TString _time5;
- TString _takezs;
- TString _choosezs;
- TString _status;
- TString _clothescount2;
- TString _outside2;
- TString _style;
- TString _payed3time;
- TString _payed4ren;
- TString _payed4time;
- TString _status2;
- TString _status3;
- TString _waiter1;
- TString _waiter2;
- TString _waiter3;
- TString _waiter4;
- TString _bz;
- TString _taketime;
- TString _clothescount;
- TString _outside;
- TString _bz2;
- TString _bz3;
- TString _urgent;
- TString _status4;
- TString _status5;
- TString _waiter5;
- TString _waiter6;
- TString _pinyin1;
- TString _pinyin2;
- TString _waiter7;
- TString _status6;
- TString _phone1;
- TString _phone2;
- TString _status7;
- TString _memberno;
- TString _waiter8;
- TString _time6;
- TString _status8;
- TString _bruncount;
- TString _tichenren1;
- TString _tichenren2;
- TString _tichenren3;
- TString _tichenren4;
- TString _tichenren5;
- TString _send1;
- TString _send2;
- TString _send3;
- TString _datetime4;
- TString _datetime5;
- TString _datetime6;
- TString _waiter12;
- TString _waiter13;
- TString _waiter14;
- TString _waiter22;
- TString _waiter23;
- TString _waiter24;
- TString _waiter1rate;
- TString _waiter12rate;
- TString _waiter13rate;
- TString _waiter14rate;
- TString _waiter2rate;
- TString _waiter22rate;
- TString _waiter23rate;
- TString _waiter24rate;
- TString _ren2;
- TString _renrate;
- TString _ren2rate;
- TString _txtype;
- TString _delphotos;
- TString _delphotos2;
- TString _growthtxselname;
- TString _designno;
- TString _designreplaceno;
- TString _size;
- TString _dindantype;
- TString _contractno1;
- TString _contractno2;
- TString _cfno;
- TString _calldate;
- TString _from;
- TString _reason;
- TString _time7;
- TString _time8;
- TString _time9;
- TString _time10;
- TString _authorize;
- TString _discount2;
- TString _authorize2;
- TString _bz4;
- int _satisfaction1;
- int _satisfaction2;
- int _satisfaction3;
- int _satisfaction4;
- int _satisfaction5;
- int _satisfaction6;
- int _satisfaction7;
- TString _bz5;
- int _send4;
- int _send5;
- TString _waiter9;
- TString _curno;
- TString _xplrr;
- TString _xplrtime;
- int _satisfaction8;
- TString _visitpeople1;
- TString _visitpeople2;
- TString _visitpeople3;
- TString _visitpeople4;
- TString _visitpeople5;
- TString _visitpeople6;
- TString _visitpeople7;
- TString _visitpeople8;
- TString _visittime1;
- TString _visittime2;
- TString _visittime3;
- TString _visittime4;
- TString _visittime5;
- TString _visittime6;
- TString _visittime7;
- TString _visittime8;
- }Tbl_dindan, *pTbl_dindan;
- typedef struct tbl_IncrementalBackup
- {
- bool _isbackup;
- TString _branchid;
- TString _opttime;
- TString _order;
- int _phototype;
- TString _content;
- TString _userid;
- TString _username;
- TString _baktime;
- }Tbl_IncrementalBackup,*pTbl_IncrementalBackup;
- // 声明回调函数;
- typedef int (CALLBACK *RecordsetCallback)(IN const DWORD& dwCallBackType, IN LPVOID lpParamter, IN const int& nRecordCount, IN CADORecordset* pRet);
- // Jeff.一个数据库只有一个AdoImpl实例;
- // 该类使用线程,监测线程的作用是判断数据库是否断开并重连;
- // 未对二进制文件支持操作;
- class AdoImpl
- {
- CString m_strQuery;
- CString m_strLastError;
- DWORD m_dwLastError;
- inline CString GetQuery() {return m_strQuery;};
- inline void SetQuery(LPCSTR strQuery) {m_strQuery = strQuery;};
- private:
- CRITICAL_SECTION m_csAdo;
- TCHAR m_szConnectString[1024];// 暂使用1024魔数,后期升级再定义;
- CADODatabase *m_pADODatabase;
- BOOL OpenADORecordSet(IN CADORecordset *pRSet, IN LPCTSTR lpSQL);
- void CloseADORecordSet(IN CADORecordset* pRSet);
- void DeleteADORecordSet(IN CADORecordset* pRSet);
- public:
- AdoImpl(void);
- virtual ~AdoImpl(void);
- void dump_com_error(_com_error &e);
- void SetConnectString(
- IN const int &nType,
- IN LPCTSTR lpDataSource,
- IN LPCTSTR lpDatabaseTCPPort,
- IN LPCTSTR lpDatabaseAccount,
- IN LPCTSTR lpDatabasePassWord,
- IN LPCTSTR lpDatabaseName,
- IN LPCTSTR lpDatabaseFile = NULL);
- BOOL IsOpen();
- BOOL Opendatabase(IN LPCTSTR lpConnectString = NULL);
- void Closedatabase();
- int Execute(IN LPCTSTR lpSQL);//不返回记录集;
- bool GetADODateBaseStatus();
- CADODatabase *GetAdoDatabase(){return m_pADODatabase;};
- // 应用层接口;
- public:
- DWORD GetTableRecordCount(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters); // 返回要查询的表的记录数;
- // 使用回调函数来处理具体的数据;
- int GetFieldValueList(IN LPCTSTR lpTableName, IN LPCTSTR lpFields, IN LPCTSTR lpFilters, IN const DWORD &dwCallBackType,IN LPVOID lpCallBack, IN OUT LPVOID lpParamter);
- // 其他类型;
- int GetFieldValueList(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters, IN LPCTSTR lpSql, OUT INT &nFieldCount, __out vector<TString>& vtRet); // 此函数不支持2进制文件的select;
- int GetFieldValueList(IN LPCTSTR lpTableName, IN LPCTSTR lpSql, OUT int &nFieldCount, OUT CArray<CStringArray,CStringArray>& strArray);
- int GetClientServiceViewData(IN LPCTSTR lpSql, OUT CArray<CStringArray,CStringArray>& strArray,IN LPCTSTR lpFilters=NULL);
- int GetTbl_dindan_Values(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters, IN LPCTSTR lpSql, INT &nFieldCount, OUT vector<TString>& vtRet);
- int GetTbl_dindan_Values(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters, IN LPCTSTR lpSql, INT &nFieldCount, OUT vector<Tbl_dindan>& vtRet);
- int GetTbl_IncrementalBackup_Values(IN LPCTSTR lpTableName, IN LPCTSTR lpFilters, IN LPCTSTR lpSql, INT &nFieldCount, OUT vector<Tbl_IncrementalBackup>& vtRet);
- };
- #endif
|