123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- #include "stdafx.h"
- #include "BackupPhoto.h"
- #include "Global.h"
- #include "DataBaseOpt.h"
- #include "Lock.h"
- #include "OrderDirMgr.h"
- typedef HRESULT (WINAPI *GetClassBackupObject)(REFCLSID, REFIID, LPVOID*);
- BackupPhoto::BackupPhoto()
- {
- m_hDllInst = NULL;
- m_pFactory = NULL;
- m_pInterface = NULL;
- }
- BackupPhoto::~BackupPhoto()
- {
- FreeBakModule();
- }
- /************************************************************************/
- /*
- 函数:LoadBakModule
- 描述:加载备份模块
- 参数:
- IN LPCTSTR strDll dll文件
- 返回:1成功,0失败
- */
- /************************************************************************/
- int BackupPhoto::LoadBakModule(IN LPCTSTR strDll)
- {
- if(strDll == NULL || _tcscmp(strDll, _T("")) == 0)
- return 0;
- HRESULT hr = NULL;
- if(m_hDllInst)
- return 1;
- if(m_hDllInst == NULL)
- {
- m_hDllInst = LoadLibrary(strDll);
- if(m_hDllInst == NULL)
- {
- CString strError = _T("");
- strError.Format(_T("打开%s失败\n"), strDll);
- WriteLogin(strError);
- return 0;
- }
- }
- if(m_hDllInst && m_pFactory && m_pInterface)
- return 1;
- GetClassBackupObject getDelFileObj = NULL;
- getDelFileObj = (GetClassBackupObject)GetProcAddress(m_hDllInst, "GetClassBackupObject");
- if(getDelFileObj == NULL)
- {
- WriteLogin(_T("打开GetClassDelFileObject失败\n"));
- return 0;
- }
- if(m_pFactory == NULL)
- {
- hr = getDelFileObj(CLSID_SC_BACKUPINTERFACE, IID_IClassFactory, (void**)&m_pFactory);
- if(FAILED(hr))
- {
- WriteLogin(_T("获取CSC_DelfilesFactory指针失败\n"));
- return 0;
- }
- }
- if(m_pInterface == NULL)
- {
- hr = m_pFactory->CreateInstance(NULL, IID_IUnknown, (void**)&m_pInterface);
- if(FAILED(hr))
- {
- WriteLogin(_T("创建ISC_DelFilesInterface失败\n"));
- m_pFactory->Release();
- return 0;
- }
- }
- return 1;
- }
- /************************************************************************/
- /*
- 函数:FreeBakModule
- 描述:释放备份接口
- 参数:
- IN HINSTANCE hInstance dll实例句柄
- 返回:1成功,0失败
- */
- /************************************************************************/
- void BackupPhoto::FreeBakModule()
- {
- if(m_pInterface)
- m_pInterface->Release();
- if(m_pFactory)
- m_pFactory->Release();
- if(m_hDllInst != NULL)
- FreeLibrary(m_hDllInst);
- }
- /************************************************************************/
- /*
- 函数: InitBackupInfo
- 描述: 初始化备份信息
- 参数:
- IN LPCTSTR lpDomain, // 店域名,如果为NULL或_T(""),为本店
- IN LPCTSTR lpOrderNum, // 订单号
- IN LPCTSTR lpDest, // 备份的目标目录,如:\\\\127.0.0.1\\客户原片备份(管理软件)$
- IN const BYTE byPhotoType, // 相片类型
- IN const BOOL bBakMImage // 是否备份M图
- 返回; TRUE成功,FALSE失败
- */
- /************************************************************************/
- BOOL BackupPhoto::InitBackupInfo(
- IN LPCTSTR lpDomain,
- IN LPCTSTR lpOrderNum,
- IN LPCTSTR lpDest, // 备份的目标目录,如:\\\\127.0.0.1\\客户原片备份(管理软件)$
- IN const BYTE byPhotoType, // 相片类型
- IN const BOOL bBakMImage
- )
- {
- if(m_pInterface == NULL)
- return FALSE;
- return m_pInterface->InitBackupInfo(lpDomain, lpOrderNum, lpDest, byPhotoType, bBakMImage);
- }
- /************************************************************************/
- /*
- 函数: AddShareDirData
- 描述: 添加共享目录数据
- 参数:
- IN const BOOL bEnable, //是否可用
- IN LPCTSTR lpBranchId, //域名
- IN LPCTSTR lpShareDir, //共享目录
- IN const BYTE byMinCapacity, //最小容量
- IN const BYTE byMaxCapacity, //最大容量
- IN const BYTE byPhotoType, //相片类型
- IN const BYTE byPriority //优先级
- 返回; TRUE成功,FALSE失败
- */
- /************************************************************************/
- BOOL BackupPhoto::InitShareDirData(
- IN const BOOL bEnable, //是否可用
- IN LPCTSTR lpBranchId, //域名
- IN LPCTSTR lpShareDir, //共享目录
- IN const BYTE byMinCapacity, //最小容量
- IN const BYTE byMaxCapacity, //最大容量
- IN const BYTE byPhotoType, //相片类型
- IN const BYTE byPriority //优先级
- )
- {
- if(m_pInterface == NULL)
- return FALSE;
- return m_pInterface->InitShareDirData(bEnable, lpBranchId, lpShareDir, byMinCapacity, byMaxCapacity, byPhotoType, byPriority);
- }
- BOOL BackupPhoto::InitShareDirData(LPTblNetShareInfo lp)
- {
- if(m_pInterface == NULL || lp == NULL)
- return FALSE;
- return m_pInterface->InitShareDirData(lp->bEnable, lp->szBranchId, lp->szShareDirectory, lp->byMinCapacity, lp->byMaxCapacity, lp->byPhotoType, lp->byPriority);
- }
- int BackupPhoto::StartBackup(IN LPCTSTR lpLocalDomain, IN PFCALLBACK callbackfun/*回调函数通知备份完成*/)
- {
- if(m_pInterface == NULL)
- return FALSE;
- return m_pInterface->StartBackup(lpLocalDomain, callbackfun);
- }
- BOOL BackupPhoto::IsBackupping()
- {
- if(m_pInterface == NULL)
- return FALSE;
- return m_pInterface->IsBackup();
- }
|