OrderDirMgr.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef __ORDERDIRMGR_H__
  2. #define __ORDERDIRMGR_H__
  3. #include <vector>
  4. //////////////////////////////////////////////////////////////////////////
  5. // 共享目录信息表NetShareInfo;
  6. typedef struct ST_TblNetShareInfo
  7. {
  8. BOOL bEnable; //是否可用
  9. TCHAR szBranchId[MAX_PATH]; //域名
  10. TCHAR szShareDirectory[MAX_PATH]; //共享目录
  11. BYTE byMinCapacity; //最小容量
  12. BYTE byMaxCapacity; //最大容量
  13. BYTE byPhotoType; //相片类型
  14. BYTE byPriority; //优先级
  15. ST_TblNetShareInfo()
  16. {
  17. memset(szBranchId,0,sizeof(TCHAR)*MAX_PATH);
  18. memset(szShareDirectory,0,sizeof(TCHAR)*MAX_PATH);
  19. bEnable = FALSE;
  20. byMinCapacity = 0;
  21. byMaxCapacity = 0;
  22. byPhotoType = 0;
  23. byPriority = 0;
  24. }
  25. ST_TblNetShareInfo(const ST_TblNetShareInfo &another)
  26. {
  27. bEnable = another.bEnable;
  28. byMinCapacity = another.byMinCapacity;
  29. byMaxCapacity = another.byMaxCapacity;
  30. byPriority = another.byPriority;
  31. byPhotoType = another.byPhotoType;
  32. _stprintf_s(szBranchId,_T("%s"),another.szBranchId);
  33. _stprintf_s(szShareDirectory,_T("%s"),another.szShareDirectory);
  34. }
  35. ST_TblNetShareInfo& operator=(const ST_TblNetShareInfo &another)
  36. {
  37. if ( this == &another )
  38. {
  39. return *this;
  40. }
  41. bEnable = another.bEnable;
  42. byMinCapacity = another.byMinCapacity;
  43. byMaxCapacity = another.byMaxCapacity;
  44. byPriority = another.byPriority;
  45. byPhotoType = another.byPhotoType;
  46. _stprintf_s(szBranchId,_T("%s"),another.szBranchId);
  47. _stprintf_s(szShareDirectory,_T("%s"),another.szShareDirectory);
  48. return *this;
  49. }
  50. void Clone(IN const BOOL bEnable, IN LPCTSTR lpBranchId, IN LPCTSTR lpDir, IN const BYTE byPhotoType, IN const BYTE byMinCapacity, IN const BYTE byMaxCapacity, IN const BYTE byPriority)
  51. {
  52. if(lpBranchId == NULL || lpDir == NULL)
  53. return;
  54. this->bEnable = bEnable;
  55. this->byMaxCapacity = byMaxCapacity;
  56. this->byMinCapacity = byMinCapacity;
  57. this->byPhotoType = byPhotoType;
  58. this->byPriority = byPriority;
  59. #ifdef _UNICODE
  60. wcscpy(this->szBranchId, lpBranchId);
  61. wcscpy(this->szShareDirectory, lpDir);
  62. #else
  63. strcpy(this->szBranchId, lpBranchId);
  64. strcpy(this->szShareDirectory, lpDir);
  65. #endif //#ifdef _UNICODE
  66. }
  67. }TblNetShareInfo, *LPTblNetShareInfo;
  68. //订单目录
  69. typedef struct _SOrderDirInfo
  70. {
  71. TCHAR szPath[MAX_PATH]; // 备份相片的全路径
  72. TCHAR szDomain[64]; // 域名
  73. TCHAR szOrder[64]; // 订单号
  74. TCHAR szOptTime[64]; // 操作时间
  75. BYTE byPhotoType; // 相片类型
  76. _SOrderDirInfo()
  77. {
  78. memset(szPath, 0, sizeof(TCHAR)*MAX_PATH);
  79. memset(szOrder, 0, sizeof(TCHAR)*64);
  80. byPhotoType = 0;
  81. }
  82. }SORDERDIRINFO, *LPSORDERDIRINFO;
  83. class DataBaseOpt;
  84. class OrderDirMgr
  85. {
  86. public:
  87. OrderDirMgr();
  88. ~OrderDirMgr();
  89. static OrderDirMgr* GetInstance()
  90. {
  91. static OrderDirMgr obj;
  92. return &obj;
  93. }
  94. int InitShareDir(IN DataBaseOpt* pDBOpt, IN LPCTSTR lpLocalDomain);
  95. int GetBackupDirFromDB(IN DataBaseOpt* pDBOpt, IN LPCTSTR lpLocalDomain);
  96. int GetShareDirFromDB(IN DataBaseOpt* pDBOpt);
  97. void LoadLocalShareDir(IN LPCTSTR lpLocalDomain);
  98. void GetOrderOfDir(IN CString& strST, IN CString& strET, IN LPCTSTR lpLocalDomain);
  99. void FindAllOrderDir(IN CString& strST, IN CString& strET, IN LPCTSTR lpLocalDomain, IN LPCTSTR lpRootDir, IN LPCTSTR lpDir, IN const BYTE byPhotoType, OUT std::vector<LPSORDERDIRINFO>& vOrderDir);
  100. void ClearShareInfo();
  101. void ClearOrderInfo();
  102. void ScreeningOrderDir(IN CArray<CStringArray,CStringArray>& logsArr, IN const CString& strLocalDomain);
  103. int FindEnableBakDir(IN const BYTE nPhotoType, OUT CString& strTargetDir);
  104. BOOL GetDiskSpaceInfo(IN LPCTSTR lpRootPathName,IN OUT double &dTotalNum, IN OUT double &dFreeNum);
  105. std::vector<LPSORDERDIRINFO>* GetOrderDirs(){return &m_vOrderDir;}
  106. std::vector<LPTblNetShareInfo>* GetShareDirs(){return &m_vShareDir;}
  107. private:
  108. std::vector<LPTblNetShareInfo> m_vShareDir; // 共享目录组
  109. std::vector<LPSORDERDIRINFO> m_vOrderDir;
  110. };
  111. #endif //#ifndef __SHAREDIRMGR_H__