BackupPhoto.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #include "stdafx.h"
  2. #include "BackupPhoto.h"
  3. #include "Global.h"
  4. #include "DataBaseOpt.h"
  5. #include "Lock.h"
  6. #include "OrderDirMgr.h"
  7. typedef HRESULT (WINAPI *GetClassBackupObject)(REFCLSID, REFIID, LPVOID*);
  8. BackupPhoto::BackupPhoto()
  9. {
  10. m_hDllInst = NULL;
  11. m_pFactory = NULL;
  12. m_pInterface = NULL;
  13. }
  14. BackupPhoto::~BackupPhoto()
  15. {
  16. FreeBakModule();
  17. }
  18. /************************************************************************/
  19. /*
  20. 函数:LoadBakModule
  21. 描述:加载备份模块
  22. 参数:
  23. IN LPCTSTR strDll dll文件
  24. 返回:1成功,0失败
  25. */
  26. /************************************************************************/
  27. int BackupPhoto::LoadBakModule(IN LPCTSTR strDll)
  28. {
  29. if(strDll == NULL || _tcscmp(strDll, _T("")) == 0)
  30. return 0;
  31. HRESULT hr = NULL;
  32. if(m_hDllInst)
  33. return 1;
  34. if(m_hDllInst == NULL)
  35. {
  36. m_hDllInst = LoadLibrary(strDll);
  37. if(m_hDllInst == NULL)
  38. {
  39. CString strError = _T("");
  40. strError.Format(_T("打开%s失败\n"), strDll);
  41. WriteLogin(strError);
  42. return 0;
  43. }
  44. }
  45. if(m_hDllInst && m_pFactory && m_pInterface)
  46. return 1;
  47. GetClassBackupObject getDelFileObj = NULL;
  48. getDelFileObj = (GetClassBackupObject)GetProcAddress(m_hDllInst, "GetClassBackupObject");
  49. if(getDelFileObj == NULL)
  50. {
  51. WriteLogin(_T("打开GetClassDelFileObject失败\n"));
  52. return 0;
  53. }
  54. if(m_pFactory == NULL)
  55. {
  56. hr = getDelFileObj(CLSID_SC_BACKUPINTERFACE, IID_IClassFactory, (void**)&m_pFactory);
  57. if(FAILED(hr))
  58. {
  59. WriteLogin(_T("获取CSC_DelfilesFactory指针失败\n"));
  60. return 0;
  61. }
  62. }
  63. if(m_pInterface == NULL)
  64. {
  65. hr = m_pFactory->CreateInstance(NULL, IID_IUnknown, (void**)&m_pInterface);
  66. if(FAILED(hr))
  67. {
  68. WriteLogin(_T("创建ISC_DelFilesInterface失败\n"));
  69. m_pFactory->Release();
  70. return 0;
  71. }
  72. }
  73. return 1;
  74. }
  75. /************************************************************************/
  76. /*
  77. 函数:FreeBakModule
  78. 描述:释放备份接口
  79. 参数:
  80. IN HINSTANCE hInstance dll实例句柄
  81. 返回:1成功,0失败
  82. */
  83. /************************************************************************/
  84. void BackupPhoto::FreeBakModule()
  85. {
  86. if(m_pInterface)
  87. m_pInterface->Release();
  88. if(m_pFactory)
  89. m_pFactory->Release();
  90. if(m_hDllInst != NULL)
  91. FreeLibrary(m_hDllInst);
  92. }
  93. /************************************************************************/
  94. /*
  95. 函数: InitBackupInfo
  96. 描述: 初始化备份信息
  97. 参数:
  98. IN LPCTSTR lpDomain, // 店域名,如果为NULL或_T(""),为本店
  99. IN LPCTSTR lpOrderNum, // 订单号
  100. IN LPCTSTR lpDest, // 备份的目标目录,如:\\\\127.0.0.1\\客户原片备份(管理软件)$
  101. IN const BYTE byPhotoType, // 相片类型
  102. IN const BOOL bBakMImage // 是否备份M图
  103. 返回; TRUE成功,FALSE失败
  104. */
  105. /************************************************************************/
  106. BOOL BackupPhoto::InitBackupInfo(
  107. IN LPCTSTR lpDomain,
  108. IN LPCTSTR lpOrderNum,
  109. IN LPCTSTR lpDest, // 备份的目标目录,如:\\\\127.0.0.1\\客户原片备份(管理软件)$
  110. IN const BYTE byPhotoType, // 相片类型
  111. IN const BOOL bBakMImage
  112. )
  113. {
  114. if(m_pInterface == NULL)
  115. return FALSE;
  116. return m_pInterface->InitBackupInfo(lpDomain, lpOrderNum, lpDest, byPhotoType, bBakMImage);
  117. }
  118. /************************************************************************/
  119. /*
  120. 函数: AddShareDirData
  121. 描述: 添加共享目录数据
  122. 参数:
  123. IN const BOOL bEnable, //是否可用
  124. IN LPCTSTR lpBranchId, //域名
  125. IN LPCTSTR lpShareDir, //共享目录
  126. IN const BYTE byMinCapacity, //最小容量
  127. IN const BYTE byMaxCapacity, //最大容量
  128. IN const BYTE byPhotoType, //相片类型
  129. IN const BYTE byPriority //优先级
  130. 返回; TRUE成功,FALSE失败
  131. */
  132. /************************************************************************/
  133. BOOL BackupPhoto::InitShareDirData(
  134. IN const BOOL bEnable, //是否可用
  135. IN LPCTSTR lpBranchId, //域名
  136. IN LPCTSTR lpShareDir, //共享目录
  137. IN const BYTE byMinCapacity, //最小容量
  138. IN const BYTE byMaxCapacity, //最大容量
  139. IN const BYTE byPhotoType, //相片类型
  140. IN const BYTE byPriority //优先级
  141. )
  142. {
  143. if(m_pInterface == NULL)
  144. return FALSE;
  145. return m_pInterface->InitShareDirData(bEnable, lpBranchId, lpShareDir, byMinCapacity, byMaxCapacity, byPhotoType, byPriority);
  146. }
  147. BOOL BackupPhoto::InitShareDirData(LPTblNetShareInfo lp)
  148. {
  149. if(m_pInterface == NULL || lp == NULL)
  150. return FALSE;
  151. return m_pInterface->InitShareDirData(lp->bEnable, lp->szBranchId, lp->szShareDirectory, lp->byMinCapacity, lp->byMaxCapacity, lp->byPhotoType, lp->byPriority);
  152. }
  153. int BackupPhoto::StartBackup(IN LPCTSTR lpLocalDomain, IN PFCALLBACK callbackfun/*回调函数通知备份完成*/)
  154. {
  155. if(m_pInterface == NULL)
  156. return FALSE;
  157. return m_pInterface->StartBackup(lpLocalDomain, callbackfun);
  158. }
  159. BOOL BackupPhoto::IsBackupping()
  160. {
  161. if(m_pInterface == NULL)
  162. return FALSE;
  163. return m_pInterface->IsBackup();
  164. }