SVNProc.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __SVN_PROC__
  2. #define __SVN_PROC__
  3. #pragma once
  4. enum SVNTYPE {
  5. SVN_EXPORT, // 导出;
  6. SVN_CHECKOUT, // 检出;
  7. SVN_ROLLBACK // 回退(up to);
  8. };
  9. enum SVNPATH {
  10. PATH_RES, // 资源路径;
  11. PATH_SCRIPT, // 脚本路径;
  12. PATH_TESTER // tester路径;
  13. };
  14. typedef struct SVNINFO {
  15. SVNPATH path;
  16. std::string strVersion;
  17. std::string strSVNAddress;
  18. bool bUpdate;
  19. std::string strSavePath;
  20. }SVNInfo, *pSVNInfo;
  21. class CSVNProc:public CObject
  22. {
  23. public:
  24. CSVNProc(void);
  25. ~CSVNProc(void);
  26. CSVNProc& operator=(CSVNProc& obj);
  27. protected:
  28. DECLARE_SERIAL(CSVNProc);
  29. void Serialize(CArchive& ar);
  30. void SVNProcess(std::string strSVNAddress, std::string strSavePath, DWORD dwSVNVersion, SVNTYPE type);
  31. public:
  32. // 导出指定版本号的svn路径;
  33. void Export(std::string strSVNAddress, std::string strSavePath, DWORD dwSVNVersion);
  34. // 检出指定版本号的svn路径;
  35. void Checkout(std::string strSVNAddress, std::string strSavePath, DWORD dwSVNVersion);
  36. // 回退指定版本号的svn路径;
  37. void Rollback(std::string strSVNAddress, std::string strSavePath, DWORD dwSVNVersion);
  38. // 检测版本:有新版本返回TRUE;
  39. BOOL CheckNewVersion(
  40. std::string url = "http://192.168.1.103:8580/btc_execute_se/ajaxInteractiveManage!getSvnVersion.action",
  41. std::string strContent = "");
  42. public:
  43. SVNPATH m_svnpath;
  44. // 是否需要更新;
  45. BOOL m_bNeedUpdate;
  46. // SVN地址;
  47. CString m_strSVNAddress;
  48. // SVN保存目录:
  49. CString m_strSVNSavePath;
  50. // SVN版本号;
  51. DWORD m_dwSVNVersion;
  52. };
  53. typedef CTypedPtrArray<CObArray, CSVNProc*> CSVNArray;
  54. class CSVNMgr
  55. {
  56. CSVNMgr() {};
  57. CSVNArray m_arySVN;
  58. public:
  59. static CSVNMgr* GetInstance()
  60. {
  61. static CSVNMgr* pInstance = NULL;
  62. if (pInstance == NULL) {
  63. pInstance = new CSVNMgr();
  64. }
  65. return pInstance;
  66. }
  67. ~CSVNMgr() {};
  68. private:
  69. BOOL ParseJson(std::string json);
  70. BOOL HttpRequest(std::string url, std::string strContent, std::string& data);
  71. CSVNProc *IsSVNExist(std::string strSVNAddress);
  72. void UpdatedSVN(CSVNProc *pSVN, DWORD dwVersion);
  73. BOOL HasNewVersion();
  74. public:
  75. void Load(LPCTSTR lpFileName =_T("svn.data"));
  76. void Store(LPCTSTR lpFileName = _T("svn.data"));
  77. // 检测版本:有新版本返回TRUE;
  78. BOOL CheckNewVersion(std::string url, std::string strContent);
  79. void Update();
  80. };
  81. #endif // __SVN_PROC__