소스 검색

#IQRV #comment [ResourceWatcher] 支持版本切换

gifur 3 년 전
부모
커밋
33bdf83be6

+ 32 - 4
Module/mod_ResourceWatcher/ResourceWatcher.xml

@@ -127,11 +127,8 @@
 				<!-- 保留字段 -->
 				<param name="reserved1" type="array_int"/>
      		<param name="reserved2" type="array_string"/>
-				
 			</res>
 		</twoway>
-		
-		
 		<twoway  name="ExtractEventLog" overlap="true">
 			<req>
 				<!-- 0x0000:不筛选,0x0001:应用程序,0x0002:安全,0x0004:Setup,0x0008:系统,0x0100:自定义,0x00FF:全部类型(不包括自定义)-->
@@ -262,8 +259,39 @@
 				<param name="intParam" type="int"/>
 			</res>
 		</twoway>
+    <twoway name="GetTerminalVersionList" overlap="true">
+      <req>
+        <param name="filter1" type="int"/>
+        <param name="filter2" type="int"/>
+        <param name="filter3" type="int"/>
+        <param name="filter4" type="string"/>
+      </req>
+      <res>
+        <param name="current" type="int"/>
+        <param name="index" type="array_int"/>
+        <param name="version" type="array_string"/>
+        <param name="remark" type="array_string"/>
+        <param name="type" type="array_int"/>
+        <param name="status" type="array_int"/>
+        <param name="msg" type="string"/>
+      </res>
+    </twoway>
+    <twoway name="ManipulateVersion" overlap="true">
+      <req>
+        <!-- 0:无;1:设置为此版本为当前版本;2:删除此版本-->
+        <param name="operation" type="int"/>
+        <param name="value" type="string"/>
+        <param name="additional1" type="int"/>
+        <param name="additional2" type="int"/>
+        <param name="additional3" type="string"/>
+      </req>
+      <res>
+        <param name="result" type="int"/>
+        <param name="addition" type="int"/>
+        <param name="msg" type="string"/>
+      </res>
+    </twoway>
 	</class>
-	
 	<message name="QueryCardSwiper">
 			<param name="status" type = "int" />	
 	</message>

+ 58 - 0
Module/mod_ResourceWatcher/ResourceWatcher_client_g.h

@@ -416,6 +416,64 @@ public:
 		return Error;
 	}
 
+	ErrorCodeEnum GetTerminalVersionList(ResourceWatcherService_GetTerminalVersionList_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		return pFunc->AsyncRequest(ResourceWatcherService_Method_GetTerminalVersionList, ResourceWatcherService_MethodSignature_GetTerminalVersionList, Buf, spAsyncWait, dwTimeout);
+	}
+	ErrorCodeEnum GetTerminalVersionList(ResourceWatcherService_GetTerminalVersionList_Req &Req, ResourceWatcherService_GetTerminalVersionList_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = GetTerminalVersionList(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum GetTerminalVersionList(ResourceWatcherService_GetTerminalVersionList_Req &Req, ResourceWatcherService_GetTerminalVersionList_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = GetTerminalVersionList(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
+	ErrorCodeEnum ManipulateVersion(ResourceWatcherService_ManipulateVersion_Req &Req, CSmartPointer<IAsynWaitSp> &spAsyncWait, DWORD dwTimeout)
+	{
+		CSmartPointer<IClientSessionFunction> pFunc = GetFunction();
+		CAutoBuffer Buf = SpObject2Buffer(Req);
+		return pFunc->AsyncRequest(ResourceWatcherService_Method_ManipulateVersion, ResourceWatcherService_MethodSignature_ManipulateVersion, Buf, spAsyncWait, dwTimeout);
+	}
+	ErrorCodeEnum ManipulateVersion(ResourceWatcherService_ManipulateVersion_Req &Req, ResourceWatcherService_ManipulateVersion_Ans &Ans, DWORD dwTimeout)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = ManipulateVersion(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+	ErrorCodeEnum ManipulateVersion(ResourceWatcherService_ManipulateVersion_Req &Req, ResourceWatcherService_ManipulateVersion_Ans &Ans, DWORD dwTimeout, DWORD &dwUserError)
+	{
+		CSmartPointer<IAsynWaitSp> spAsyncWait;
+		ErrorCodeEnum Error = ManipulateVersion(Req, spAsyncWait, dwTimeout);
+		if (Error == Error_Succeed) {
+			bool bEnd = false;
+			Error = SpWaitAnswerObject(spAsyncWait, Ans, bEnd, dwUserError, dwTimeout);
+			LOG_ASSERT(Error || bEnd);
+		}
+		return Error;
+	}
+
 
 	bool SafeDelete()
 	{

+ 63 - 0
Module/mod_ResourceWatcher/ResourceWatcher_def_g.h

@@ -25,6 +25,8 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_Method_CheckNetType 9
 #define ResourceWatcherService_Method_GetBizLinks 10
 #define ResourceWatcherService_Method_BizLinkDetect 11
+#define ResourceWatcherService_Method_GetTerminalVersionList 12
+#define ResourceWatcherService_Method_ManipulateVersion 13
 
 #define ResourceWatcherService_MethodSignature_Fetch -1944912560
 #define ResourceWatcherService_MethodSignature_GetDevInfo 296205965
@@ -39,6 +41,8 @@ namespace ResourceWatcher {
 #define ResourceWatcherService_MethodSignature_CheckNetType 1341887614
 #define ResourceWatcherService_MethodSignature_GetBizLinks 651862197
 #define ResourceWatcherService_MethodSignature_BizLinkDetect 1476437131
+#define ResourceWatcherService_MethodSignature_GetTerminalVersionList 598083609
+#define ResourceWatcherService_MethodSignature_ManipulateVersion 671931256
 
 struct ResourceWatcherService_Fetch_Req
 {
@@ -395,6 +399,65 @@ struct ResourceWatcherService_BizLinkDetect_Ans
 
 };
 
+struct ResourceWatcherService_GetTerminalVersionList_Req
+{
+	int filter1;
+	int filter2;
+	int filter3;
+	CSimpleStringA filter4;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & filter1 & filter2 & filter3 & filter4;
+	}
+
+};
+
+struct ResourceWatcherService_GetTerminalVersionList_Ans
+{
+	int current;
+	CAutoArray<int> index;
+	CAutoArray<CSimpleStringA> version;
+	CAutoArray<CSimpleStringA> remark;
+	CAutoArray<int> type;
+	CAutoArray<int> status;
+	CSimpleStringA msg;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & current & index & version & remark & type & status & msg;
+	}
+
+};
+
+struct ResourceWatcherService_ManipulateVersion_Req
+{
+	int operation;
+	CSimpleStringA value;
+	int additional1;
+	int additional2;
+	CSimpleStringA additional3;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & operation & value & additional1 & additional2 & additional3;
+	}
+
+};
+
+struct ResourceWatcherService_ManipulateVersion_Ans
+{
+	int result;
+	int addition;
+	CSimpleStringA msg;
+
+	void Serialize(SpBuffer &Buf)
+	{
+		auto & buf = Buf & result & addition & msg;
+	}
+
+};
+
 
 ///////////////////////////
 

+ 50 - 0
Module/mod_ResourceWatcher/ResourceWatcher_server_g.h

@@ -121,6 +121,20 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case ResourceWatcherService_Method_GetTerminalVersionList:
+			if (dwSignature == ResourceWatcherService_MethodSignature_GetTerminalVersionList) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_ManipulateVersion:
+			if (dwSignature == ResourceWatcherService_MethodSignature_ManipulateVersion) {
+				bOverlap = true;
+			} else {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -197,6 +211,16 @@ public:
 				Error = Error_MethodSignatureFailed;
 			}
 			break;
+		case ResourceWatcherService_Method_GetTerminalVersionList:
+			if (dwSignature != ResourceWatcherService_MethodSignature_GetTerminalVersionList) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
+		case ResourceWatcherService_Method_ManipulateVersion:
+			if (dwSignature != ResourceWatcherService_MethodSignature_ManipulateVersion) {
+				Error = Error_MethodSignatureFailed;
+			}
+			break;
 		default:
 			Error = Error_MethodNotFound;
 			break;
@@ -269,6 +293,16 @@ public:
 	/// override by user
 	}
 
+	virtual void Handle_GetTerminalVersionList(SpReqAnsContext<ResourceWatcherService_GetTerminalVersionList_Req, ResourceWatcherService_GetTerminalVersionList_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
+	virtual void Handle_ManipulateVersion(SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req, ResourceWatcherService_ManipulateVersion_Ans>::Pointer ctx)
+	{
+	/// override by user
+	}
+
 	virtual void OnRequest(CSmartPointer<ITransactionContext> pTransactionContext)
 	{
 		CAutoBuffer Buf;
@@ -389,6 +423,22 @@ public:
 						Handle_BizLinkDetect(ctx);
 					}
 					break;
+				case ResourceWatcherService_Method_GetTerminalVersionList:
+					{
+						SpReqAnsContext<ResourceWatcherService_GetTerminalVersionList_Req,ResourceWatcherService_GetTerminalVersionList_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_GetTerminalVersionList_Req,ResourceWatcherService_GetTerminalVersionList_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						Handle_GetTerminalVersionList(ctx);
+					}
+					break;
+				case ResourceWatcherService_Method_ManipulateVersion:
+					{
+						SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req,ResourceWatcherService_ManipulateVersion_Ans>::Pointer ctx;
+						ctx.Attach(new SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req,ResourceWatcherService_ManipulateVersion_Ans>(pTransactionContext));
+						SpBuffer2Object(Buf, ctx->Req);
+						Handle_ManipulateVersion(ctx);
+					}
+					break;
 				default:
 					assert(0);
 					break;

+ 174 - 1
Module/mod_ResourceWatcher/mod_ResourceWatcher.cpp

@@ -17,6 +17,7 @@
 
 #include "publicFunExport.h"
 #include <map>
+#include <regex.h>
 
 struct SogouRunVersionInfo 
 {
@@ -137,7 +138,6 @@ void ResourceWatcherServiceSession::Handle_GetThirdPartyInstallState(SpReqAnsCon
 {
     LOG_FUNCTION();
     m_pEntity->GetThirdPartyInstallState(ctx);
-
 }
 
 void ResourceWatcherServiceSession::Handle_InstallThirdPartyProgram(SpReqAnsContext<ResourceWatcherService_InstallThirdPartyProgram_Req, ResourceWatcherService_InstallThirdPartyProgram_Ans>::Pointer ctx)
@@ -164,6 +164,18 @@ void ResourceWatcherServiceSession::Handle_GetBizLinks(SpReqAnsContext<ResourceW
     m_pEntity->GetBizLinks(ctx);
 }
 
+void ResourceWatcherServiceSession::Handle_GetTerminalVersionList(SpReqAnsContext<ResourceWatcherService_GetTerminalVersionList_Req, ResourceWatcherService_GetTerminalVersionList_Ans>::Pointer ctx)
+{
+    LOG_FUNCTION();
+    m_pEntity->GetTerminalVersionList(ctx);
+}
+
+void ResourceWatcherServiceSession::Handle_ManipulateVersion(SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req, ResourceWatcherService_ManipulateVersion_Ans>::Pointer ctx)
+{
+    LOG_FUNCTION();
+    m_pEntity->ManipulateVersion(ctx);
+}
+
 void ResourceWatcherEntity::UpdateDNS(SpReqAnsContext<ResourceWatcherService_UpdateDNS_Req, ResourceWatcherService_UpdateDNS_Ans>::Pointer ctx)
 {
     ctx->Answer(Error_NotImpl);
@@ -626,6 +638,167 @@ void ResourceWatcherEntity::InstallThirdPartyProgram(SpReqAnsContext<ResourceWat
     return;
 }
 
+void ResourceWatcherEntity::GetTerminalVersionList(SpReqAnsContext<ResourceWatcherService_GetTerminalVersionList_Req, ResourceWatcherService_GetTerminalVersionList_Ans>::Pointer ctx)
+{
+    CSimpleStringA strVersionBaseDir(true);
+    GetFunction()->GetPath("RootVer", strVersionBaseDir);
+
+    const CSimpleStringA strActiveFile = strVersionBaseDir + SPLIT_SLASH_STR + "active.txt";
+    CSystemStaticInfo staticInfo;
+    GetFunction()->GetSystemStaticInfo(staticInfo);
+    CSimpleStringA strCurrVer = staticInfo.InstallVersion.ToString();
+    Dbg("get current version [%s]", (LPCTSTR)strCurrVer);
+
+    std::vector<std::string> verlist;
+    array_header_t* arr;
+    arr = fileutil_get_sub_dirs_a(strVersionBaseDir);
+    if (arr) {
+        do {
+            regex_t reg;
+            CSimpleStringA strPattern("^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[\(\)A-Za-z_-]*$");
+            int ret = regcomp(&reg, strPattern, REG_EXTENDED | REG_NOSUB);
+            if (ret) {
+                char ebuff[256];
+                regerror(ret, &reg, ebuff, 256);
+                Dbg("regex failed: %s", ebuff);
+                ctx->Ans.msg = CSimpleStringA::Format("内部错误:REGEX %s", ebuff);
+                ctx->Ans.current = -1;
+                break;
+            } else {
+                for (int i = 0; i < arr->nelts; ++i) {
+                    char* versionDir = ARRAY_IDX(arr, i, char*);
+                    char* versionDirName = &versionDir[strVersionBaseDir.GetLength() + 1];
+                    ret = regexec(&reg, versionDirName, 0, NULL, 0);
+                    if (0 == ret) {
+                        Dbg("filename %s matched!", versionDirName);
+                        verlist.push_back(std::string(versionDirName));
+                    }
+                }
+            }
+        } while (false);
+        toolkit_array_free2(arr);
+    }
+
+    if (!verlist.empty()) {
+        const int count = verlist.size();
+        ctx->Ans.index.Init(count);
+        ctx->Ans.version.Init(count);
+        ctx->Ans.remark.Init(count);
+        ctx->Ans.type.Init(count);
+        ctx->Ans.status.Init(count);
+
+        for (int i = 0; i < count; ++i) {
+            ctx->Ans.index[i] = i;
+            ctx->Ans.version[i] = verlist[i].c_str();
+            if (verlist[i].compare(strCurrVer.GetData()) == 0) {
+                ctx->Ans.current = i;
+            }
+            ctx->Ans.remark[i] = "";
+            ctx->Ans.type[i] = ctx->Ans.status[i] = 0;
+        }
+    }
+
+    ctx->Answer(Error_Succeed);
+}
+
+namespace
+{
+bool UpdateCurrentVersionName(LPCTSTR filePath, LPCTSTR versionStr, LPCTSTR backupPath)
+{
+    if (fileutil_copy_file(backupPath, filePath) != 0) {
+        return false;
+    }
+    FILE* fp = fopen(filePath, "wb+");
+    if (fp == NULL) {
+        return false;
+    }
+
+    bool result(false);
+    do 
+    {
+        int ret = fwrite(versionStr, strlen(versionStr), 1, fp);
+        if (ret != 1) {
+            Dbg("fwrite failed: %d", ret);
+            break;
+        }
+        fflush(fp);
+        fclose(fp);
+
+        fp = fopen(filePath, "rb");
+        if (fp != NULL) {
+            char value[32] = { 0 };
+            int ret2 = fread(value, strlen(versionStr), 1, fp);
+            if (ret2 == 1) {
+                if (strcmp(value, versionStr) == 0)
+                    Dbg("read agagin the value is the same!");
+                else {
+                    break;
+                }
+            }
+        }
+        result = true;
+    } while (false);
+
+    fclose(fp);
+
+    if (!result && backupPath) {
+        fileutil_copy_file(filePath, backupPath);
+        fileutil_delete_file(backupPath);
+    }
+    if (result && backupPath) {
+        fileutil_delete_file(backupPath);
+    }
+    return result;
+}
+}
+
+void ResourceWatcherEntity::ManipulateVersion(SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req, ResourceWatcherService_ManipulateVersion_Ans>::Pointer ctx)
+{
+    ErrorCodeEnum result(Error_Succeed);
+    int tmpResult(0);
+    CSimpleStringA tmpMsg(true);
+
+    switch (ctx->Req.operation) {
+    case 1: //设置为此版本为当前版本
+    {
+        CSimpleStringA strVersionBaseDir(true);
+        GetFunction()->GetPath("RootVer", strVersionBaseDir);
+        const CSimpleStringA strActiveFile = strVersionBaseDir + SPLIT_SLASH_STR + "active.txt";
+        const CSimpleStringA strActiveFileBackup = strActiveFile + "activebak.txt";
+        CSystemStaticInfo staticInfo;
+        GetFunction()->GetSystemStaticInfo(staticInfo);
+        CSimpleStringA strCurrVer = staticInfo.InstallVersion.ToString();
+        Dbg("get current version [%s]", (LPCTSTR)strCurrVer);
+
+        if (!UpdateCurrentVersionName(strActiveFile, ctx->Req.value, strActiveFileBackup)) {
+            tmpResult = Error_Unexpect;
+            tmpMsg = "切换版本失败";
+        }
+    }
+        break;
+    case 2: //删除此版本
+    {
+        CSimpleStringA strVersionBaseDir(true);
+        GetFunction()->GetPath("RootVer", strVersionBaseDir);
+        const CSimpleStringA strVersionDirPath = strVersionBaseDir + SPLIT_SLASH_STR + ctx->Req.value;
+        if (ExistsDirA(strVersionDirPath)) {
+            if (!RemoveDirRecursiveA(strVersionDirPath)) {
+                tmpResult = Error_Unexpect;
+                tmpMsg = "删除版本失败";
+            }
+        }
+    }
+        break;
+    default:
+        result = Error_NotSupport;
+        break;
+    }
+
+    ctx->Ans.result = tmpResult;
+    ctx->Ans.msg = tmpMsg;
+    ctx->Answer(result);
+}
+
 #if defined(RVC_OS_WIN)
 //1: 32bit process running at 64bit platform
 //0: 

+ 10 - 0
Module/mod_ResourceWatcher/mod_ResourceWatcher.h

@@ -49,6 +49,11 @@ public:
 	virtual void Handle_CheckNetType(SpReqAnsContext<ResourceWatcherService_CheckNetType_Req, ResourceWatcherService_CheckNetType_Ans>::Pointer ctx);
 
 	virtual void Handle_GetBizLinks(SpReqAnsContext<ResourceWatcherService_GetBizLinks_Req, ResourceWatcherService_GetBizLinks_Ans>::Pointer ctx);
+
+	virtual void Handle_GetTerminalVersionList(SpReqAnsContext<ResourceWatcherService_GetTerminalVersionList_Req, ResourceWatcherService_GetTerminalVersionList_Ans>::Pointer ctx);
+
+	virtual void Handle_ManipulateVersion(SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req, ResourceWatcherService_ManipulateVersion_Ans>::Pointer ctx);
+
 private:
 	ResourceWatcherEntity* m_pEntity;
 };
@@ -212,6 +217,11 @@ public:
 		m_fsm.GetBizLinks(ctx);
 	}
 
+    void GetTerminalVersionList(SpReqAnsContext<ResourceWatcherService_GetTerminalVersionList_Req, ResourceWatcherService_GetTerminalVersionList_Ans>::Pointer ctx);
+
+    void ManipulateVersion(SpReqAnsContext<ResourceWatcherService_ManipulateVersion_Req, ResourceWatcherService_ManipulateVersion_Ans>::Pointer ctx);
+
+
 	void OperateFile(
 		SpReqAnsContext<ResourceWatcherService_OperateFile_Req, 
 		ResourceWatcherService_OperateFile_Ans>::Pointer ctx)

+ 204 - 8
addin/res/ManagerDesktop/js/page/vermanagement.js

@@ -1,10 +1,22 @@
 function vermanagementGenPage() {
-    var page = '<div id="vermanagement_page">\
-    <div id="vermanagement_tip" align="center" style="display: block;">\
-    <div class="color_descroption_gray"\
-    style="width:auto;margin-top:200px;font-size:18px;line-height:120%;">\
-    <span>相关功能正在开发中,敬请期待!</span>\
+    var page = '<div id="vermanagement_page" style="display: block;">\
+    <div class="maintitle">\
+    <div>终端版本管理</div>\
+    <div class="page_description_text">管理本地的终端应用程序版本,支持删除和版本切换</div>\
     </div>\
+    <div id="vermanagementContent">\
+    <div class="clearboth" id="apn_list" style="padding-top:70px;">\
+    <div class="table_top">\
+    <div class="table_list_title">终端应用版本列表\
+    </div>\
+    <div class="pull-right">&nbsp;\
+    </div>\
+    </div>\
+    <div class="border_left border_right color_Darkgray" style="width:678px;padding-top:-1px;">\
+    <div id="version_lists" class="clearboth" style="width:100%;overflow:hidden;">\
+    </div>\
+    </div>\
+    <div class="table_bottom">\
     </div>\
     </div>';
 
@@ -18,7 +30,184 @@ function vermanagementGenPage() {
 
 var vermanagementController = (function() {
 
-    function initPage() {
+    var CONST = {
+        SWITCH_ON: '1',
+        PROFILE_MAX_NUM: 100
+    };
+    
+    var weblistCount = 0;
+    var isNewWebConfig = true;
+
+    var modifyIndex = -1;
+    var profilesArray = [];
+    var modifyProfile = {};
+
+    function loadData(flag) {
+        let req = new Request();
+        req.filter1 = 0;
+        req.filter2 = 0;
+        req.filter3 = 0;
+        req.filter4 = '';
+
+        profilesArray = [];
+        weblistCount = 0;
+
+        if(typeof flag === 'undefined') {
+            utilStartSubmitDialog();
+        }
+        RVC.ResourceWatcherEntity.GetTerminalVersionList(req, function(ret) {
+            if(typeof flag === 'undefined'){
+                utilStopSubmitDialog();
+            }
+            console.log('result: ' + ret.errorCode);
+            if (ret.errorCode === 0) {
+                let result = JSON.parse(ret[RVC.ResourceWatcherEntity.sigResponseUUID])
+                console.log('count: ' + result.index.length + ' ' + result);
+
+                if (result.index.length === 0) {
+                    $('#version_lists').css('height', 0);
+                    $('#version_lists').hide();
+                    return;
+                } else if (result.index.length <= 8) {
+                    $('#version_lists').css('height', (result.index.length * 70 - 12) + result.index.length + 'px');
+                } else {
+                    $('#version_lists').css('height', '561px');
+                }
+                $('#version_lists').show();
+                $('#version_lists').empty();
+                RVC.Scroll.initScroll('#version_lists');
+                for (var n = 0; n < result.index.length; n++)
+                {
+                    var templateData = {
+                        profileItemIndex: result.index[n],
+                        profileItemName: result.version[n],
+                        profileItemRemark: result.remark[n],
+                        profileItemStatus: false
+                    };
+                    if(result.index[n] == result.current) {
+                        templateData.profileItemStatus = true;
+                    }
+                    profilesArray.push(templateData);
+
+                    var profileHtml;
+                    if (n === result.index.length - 1) {
+                        profileHtml = '<div  id="version_list_{{profileItemIndex}}" style="height:59px;cursor:pointer;" class="list_item_hover">';
+                        if (templateData.profileItemStatus) {
+                            profileHtml += '<div id="version_list_name_{{profileItemIndex}}"  class="pull-left padding-left-20" style="height:45px;padding-top:14px;width:600px;">';
+                        } else {
+                            profileHtml += '<div id="version_list_name_{{profileItemIndex}}"  class="pull-left padding-left-20" style="height:45px;padding-top:14px;width:600px;" onclick="RVC.VersionController.ActiveVersion({{profileItemIndex}})">';
+                        }
+                    } else {
+                        profileHtml = '<div  id="version_list_{{profileItemIndex}}" class="border_bottom list_item_hover" style="height:70px;cursor:pointer;">';
+                        if (templateData.profileItemStatus) {
+                            profileHtml += '<div id="version_list_name_{{profileItemIndex}}"  class="pull-left padding-left-20" style="height:56px;padding-top:14px;width:600px;">';
+                        } else {
+                            profileHtml += '<div id="version_list_name_{{profileItemIndex}}"  class="pull-left padding-left-20" style="height:56px;padding-top:14px;width:600px;" onclick="RVC.VersionController.ActiveVersion({{profileItemIndex}})">';
+                        }
+                    }
+                    if (templateData.profileItemStatus) {
+                        profileHtml += '<pre class="version_profile_name_{{profileItemIndex}}" style="font-size:16px;margin-top:0px;"><span class="version_profile_itemname pull-left" style="line-height:21px;" title="{{profileItemName}}">{{profileItemName}}</span><span class="pull-left" style="line-height:21px;">(当前应用)</span><div class="clearboth"></div></pre>';
+                    } else {
+                        profileHtml += '<pre class="version_profile_name_{{profileItemIndex}}" style="font-size:16px;margin-top:0px;"><span class="version_profile_itemname" title="{{profileItemName}}">{{profileItemName}}</span></pre>';
+                    }
+                    profileHtml += '<div class="version_version_name_{{profileItemIndex}} color_descroption_gray version_profile_itemapnname" style="margin-top:-10px;font-size:14px;" title="{{profileItemRemark}}">{{profileItemRemark}}</div></div>';
+                    if (templateData.profileItemStatus) {
+                        profileHtml += '<div class="pull-right"></div></div>';
+                    } else {
+                        if (n === 0) {
+                            profileHtml += '<div class="pull-right"><div class="btn_delete mobileconnet_btn_delete" onclick="RVC.VersionController.RemoveVersion({{profileItemIndex}})" >&nbsp;</div></div></div>';
+                        } else {
+                            profileHtml += '<div class="pull-right"><div class="btn_delete mobileconnet_btn_delete" onclick="RVC.VersionController.RemoveVersion({{profileItemIndex}})" >&nbsp;</div></div></div>';
+                        }
+                    }
+                    
+                    $('#version_lists .scroll_text').secureAppend(profileHtml, templateData);
+                    
+                }
+                weblistCount = result.index.length;
+
+            } else if(typeof flag === 'undefined') {
+                RVC.ResourceWatcherEntity.commErrorCallback(ret);
+            }
+        });
+    }
+
+    function preShowVersionList()
+    {
+        $('#version_lists').show();
+        $('#version_lists').empty();
+        RVC.Scroll.initScroll('#version_lists');
+    }
+
+    RVC.VersionController = RVC.ObjController.extend({
+
+        ActiveVersion: function(index)
+        {
+            utilStartConfirmDialog("确定要切换使用当前版本吗?", function(){
+                let req = new Request();
+                req.operation = 1; //切换版本
+                req.value = profilesArray[index].profileItemName;
+                req.additional1 = 0;
+                req.additional2 = 0;
+                req.additional3 = '';
+
+                utilStartSubmitDialog();
+                RVC.ResourceWatcherEntity.ManipulateVersion(req, function(ret) {
+                    utilStopSubmitDialog();
+                    if (ret.errorCode === 0) {
+                        let result = JSON.parse(ret[RVC.ResourceWatcherEntity.sigResponseUUID])
+                        if(result.result == 0) {
+                            utilStartConfirmDialog("切换成功!点击确认立即重启应用以使用版本", function(){
+                                RVC.HealthmanagerEntityCtrl.RestartApp(true);
+                            })
+                            //preShowVersionList();
+                            //loadData();
+                        } else {
+                            utilStartAlertDialog("操作失败:[" + result.result + "] " + result.msg);
+                        }
+                        
+                    } else {
+                        RVC.ResourceWatcherEntity.commErrorCallback(ret);
+                    }
+                });
+            });
+        },
+
+        RemoveVersion: function(index)
+        {
+            utilStartConfirmDialog("确定要删除该版本吗?", function() {
+                let req = new Request();
+                req.operation = 2; //删除
+                req.value = profilesArray[index].profileItemName;
+                req.additional1 = 0;
+                req.additional2 = 0;
+                req.additional3 = '';
+
+                utilStartSubmitDialog();
+                RVC.ResourceWatcherEntity.ManipulateVersion(req, function(ret) {
+                    utilStopSubmitDialog();
+                    if (ret.errorCode === 0) {
+                        let result = JSON.parse(ret[RVC.CenterSettingEntity.sigResponseUUID])
+                        preShowVersionList();
+                        loadData();
+                    } else {
+                        RVC.ResourceWatcherEntity.commErrorCallback(ret);
+                    }
+                });
+            });
+        }
+
+    });
+
+    function bindEvents() {
+
+
+    }
+
+    function initPage() 
+    {
+        preShowVersionList();
+        loadData(true);
 
     }
 
@@ -26,13 +215,20 @@ var vermanagementController = (function() {
 
     function init() {
 
+        initPage();
+        
         if (fistTime) {
             fistTime = false;
+            bindEvents();
         }
-        initPage();
+        
+    }
+
+    function destory() {
+        clearAllErrorMsg();
     }
     
-    return { init: init };
+    return { init: init, destory: destory };
 }());
 
 window.vermanagementRenderPage = function () {

+ 16 - 2
addin/res/ManagerDesktop/js/public.js

@@ -2353,12 +2353,16 @@ $(function () {
         methodID: {
             UpdateDNS : 5,
             GetNetworkInfo: 6,
-            GetThirdPartyInstallState:7
+            GetThirdPartyInstallState:7,
+            GetTerminalVersionList:12,
+            ManipulateVersion:13
         },
         methodSignature: {
             UpdateDNS : -943970884,
             GetNetworkInfo: 1741482404,
-            GetThirdPartyInstallState:-15861483
+            GetThirdPartyInstallState:-15861483,
+            GetTerminalVersionList:598083609,
+            ManipulateVersion:671931256
         },
 
         GetNetworkInfo: function(req, callback) {
@@ -2379,6 +2383,16 @@ $(function () {
             this.webSocketInvokeEx(req, 
                 ({id:this.methodID.GetThirdPartyInstallState, sig:this.methodSignature.GetThirdPartyInstallState}),
                  callback);
+        },
+        GetTerminalVersionList: function(req, callback) {
+            this.webSocketInvokeEx(req, 
+                ({id:this.methodID.GetTerminalVersionList, sig:this.methodSignature.GetTerminalVersionList}),
+                 callback);
+        },
+        ManipulateVersion: function(req, callback) {
+            this.webSocketInvokeEx(req, 
+                ({id:this.methodID.ManipulateVersion, sig:this.methodSignature.ManipulateVersion}),
+                 callback);
         }
     });