selectZip.jsp
14.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/updateclient/systeminfo/init_wev8.jsp"%>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<%@ page import="com.weaver.general.GCONSTUClient" %>
<%@ page import="com.weaver.function.ConfigInfo" %>
<%@ page import="wscheck.MD5Coder" %>
<html>
<head>
<title> E-cology升级程序</title>
<LINK href="/css/Weaver_wev8.css" type=text/css rel=STYLESHEET>
<link rel="stylesheet" href="/wui/theme/ecology8/weaveredittable/css/WeaverEditTable_wev8.css">
<script src="/wui/theme/ecology8/weaveredittable/js/WeaverEditTable_wev8.js"></script>
<script type="text/javascript" src="/js/updateclient/selectZip.js?r=2"></script>
<script type="text/javascript" src="/js/updateclient/jquery.form.js?r=2"></script>
<link rel="stylesheet" href="/js/jquery-clockpicker/assets/css/bootstrap.min_wev8.css">
<script src="/js/jquery-clockpicker/assets/js/bootstrap.min_wev8.js"></script>
<script type="text/javascript">
var xhr = new XMLHttpRequest();
function uploadFile() {
$(parent.document.getElementById("nextbutton")).attr("disabled","disabled");
var fileObj = $("#zipfile"); // js 获取文件对象
//console.info("上传的文件:"+fileObj);
var FileController = "/uploadzip.do"; // 接收上传文件的后台地址
// FormData 对象
var form = new FormData();
// form.append("author", "hooyes"); // 可以增加表单数据
form.append("uploadzip", $("input[name='uploadzip']").val());// 文件对象
form.append("localfile",$("input:radio[name='localfile']").val());
form.append("file", fileObj);
form.append("upfilepath", encodeURIComponent($("#zipfile").val()));
// XMLHttpRequest 对象
xhr.open("POST", FileController, true);
xhr.onload = function() {
};
xhr.upload.addEventListener("progress", progressFunction, false);
//2.设置回调函数
xhr.onreadystatechange = backFun;
xhr.send(form);
}
//回调函数
function backFun(data){
//if(xhr.readyState == 4 && xhr.status == 200){
/* var res = xhr.responseText;
if(res != undefined) { //上传成功
//开始校验补丁包校验码
var checkPackageCode = checkPackage();
if ("success" == checkPackageCode) {
window.location.href="/updateclient/check.jsp";
} else {
$("#msg_show").html("校验码校验失败,请选择正确的补丁包和校验码。");
$("#progressBar").width("0%");
$("#uploadmessage").html("");
donext--;
return;
}
} else {
$("#msg_show").html("补丁包上传失败!");
return;
}*/
data = JSON.parse(data);
if(data.checkStatus=="success"){
window.location.href="/updateclient/check.jsp";
} else {
$("#msg_show").html("校验码校验失败,请选择正确的补丁包和校验码。");
$("#progressBar").width("0%");
$("#uploadmessage").html("");
donext--;
return;
}
}
function checkPackage(){
var checkcode = $("#toolcode").val();
checkcode = $.trim(checkcode);
var result = "";
$.ajax({
url:'/checkProcess.do',
type:"post",
datatype:"json",
async:false,//同步
data:{
"toolCode":checkcode,
"codeCheck":"1"
},
success:function(data){
result= data.checkCode;
}
});
return result;
}
function progressFunction(evt) {
var progressBar = $("#progressBar");
if (evt.lengthComputable) {
var completePercent = Math.round(evt.loaded / evt.total * 100)+ "%";
progressBar.width(completePercent);
$("#uploadmessage").html("正在上传 " + completePercent);
}
}
function next() {
if(donext>0) {
top.Dialog.alert("正在上传附件!");
return;
}
if($("#zipfile").val()!=""||$("input:radio[name='localfile']").val()!=""){
var uploadzip = $("input:radio[name='uploadzip']:checked").val();
var zipval;
if(uploadzip=="local") {
zipval = $("input:radio[name='localfile']:checked").val();
if(undefined == zipval) {
top.Dialog.alert("请选择升级包");
return;
}
if(zipval.indexOf(".zip") < 0) {
top.Dialog.alert("上传的升级包格式不对!");
return;
}
$("#filename").val(zipval);
document.weaverform.submit();
donext++;
} else {
$("#filename").val(encodeURIComponent($("#zipfile").val()));
zipval = $("#zipfile").val();
if(zipval.indexOf(".zip") < 0) {
top.Dialog.alert("上传的升级包格式不对!");
return;
}
$("#msg_show").html("请输入补丁包校验码(泛微出包流程中的补丁包校验码)");
$("#myModal").modal();
donext++;
}
} else {
top.Dialog.alert("请选择升级包");
return;
}
}
function checkCode(){
$("#msg_show").html("正在进行补丁包校验");
var checkcode = $("#toolcode").val();
checkcode = $.trim(checkcode);
if(checkcode == "") {
$("#msg_show").html("请输入补丁包校验码!");
return;
}
$("#checkcode").val(checkcode);
uploadFile2();
}
function uploadFile2() {
var options = {
//提交表单之前做的验证
type:'POST',
beforeSubmit:function(xhr){
//$("#progressBar").width("1px");
$("#uploadmessage").html("<span style=\"color:red\">正在上传 ...");
},
//服务器返回结果处理
success:function(data){
$("#progressBar").width("100%");
$("#uploadmessage").html("正在上传 100%");
backFun(data);
},
error:function(xhr){
//checkPackage();
alert(xhr.responseText)
},
//进度条的监听器
xhr:function(evt){
xhr.upload.addEventListener("progress" , progressFunction, false);
return xhr;
}
}
//提交表单(uploadTaskForm --->表单的ID)
$("#weaverform").ajaxSubmit(options);//阻止页面跳转
}
function closeCodepanel(){
$("#myModal").modal('hide');
}
//IE低版本有问题
function next_old(){
if(donext>0) {
top.Dialog.alert("正在上传附件!");
return;
}
if($("#zipfile").val()!=""||$("input:radio[name='localfile']").val()!=""){
var uploadzip = $("input:radio[name='uploadzip']:checked").val();
var zipval;
if(uploadzip=="local") {
zipval = $("input:radio[name='localfile']").val();
if(zipval.indexOf(".zip") < 0) {
top.Dialog.alert("上传的升级包格式不对!");
return;
}
$("#filename").val(zipval);
document.weaverform.submit();
donext++;
} else {
$("#filename").val(zipval);
var obj = $("#zipfile");
var photoExt=obj.val().substr(obj.val().lastIndexOf(".")).toLowerCase();//获得文件后缀名
var fileSize = 0;
var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
if (isIE && !obj.files) {
var filePath = obj.val();
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
var file = fileSystem.GetFile(filePath);
fileSize = file.Size;
}else {
fileSize = obj.get(0).files[0].size;
}
//非zip无法上传
if(photoExt != ".zip") {
top.Dialog.alert("只能上传zip");
return false;
}
fileSize=Math.round(fileSize/1024*100)/100; //单位为KB
if(fileSize > 2097152){
top.Dialog.alert("文件不能大于2G!");
return false;
}
$("#progressBar").width("0%");
//uploadFile();
$("#myModal").modal();
donext++;
}
} else {
top.Dialog.alert("请选择升级包");
return;
}
}
$(document).ready(function(){
startMonitorMousedDown();
});
var monitorMousedDown = true;//对鼠标点击事件进行监控
var hasPrompt = false;//提示正在升级 只有在第一次离开页面并点击才会提示
function startMonitorMousedDown(){
$(window.document).mouseout(function(e){
var xx = e.originalEvent.x || e.originalEvent.layerX || 0;
var yy = e.originalEvent.y || e.originalEvent.layerY || 0;
if(!hasPrompt && (xx <= 0 || yy <= 0)) {
monitorMousedDown = true;
} else {
monitorMousedDown = false;
}
});
$(top.document).mousedown(function(e){
if(monitorMousedDown) {
monitorMousedDown = false;
top.Dialog.confirm("系统正在升级,请确认是否离开升级页面?如果确认离开,请点击“确定”并再次点击目标菜单。",
function(){
monitorMousedDown = false;
hasPrompt = true;
$(top.document).unbind('mousedown',this);
},
function(){
monitorMousedDown = true;
hasPrompt = false;
}
);
}
});
}
</script>
</head>
<%
String titlename ="";
String packagepath = GCONSTUClient.getPackagePath();
File packagefile = new File(packagepath);
String ziplist = "";
Date date = new Date();
String time = ""+date.getTime();
ConfigInfo.setTimestamp(time);
String localcode = MD5Coder.stringMD5(ConfigInfo.KWORD+time);
if(packagefile.exists()) {
File[] zips = packagefile.listFiles();
for(int i = 0; i < zips.length; i++) {
String zipname = zips[i].getName();
if(!zipname.endsWith("zip")) {
continue;
}
String fname = java.net.URLEncoder.encode(zipname,"UTF-8");
ziplist = ziplist + "<span style='display:block;''><input name='localfile' type='radio' value='"+fname+"'>"+zips[i].getName()+"</input></span>";
}
ziplist = ziplist + "<input name='localcode' id='localcode' type='hidden' value='"+localcode+"'></input>";
}
%>
<%@ include file="/systeminfo/TopTitle_wev8.jsp" %>
<%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp" %>
<%
RCMenu += "{"+SystemEnv.getHtmlLabelName(1402,user.getLanguage())+",javascript:next(),_self} " ;
RCMenuHeight += RCMenuHeightStep ;
%>
<%@ include file="/systeminfo/RightClickMenu_wev8.jsp" %>
<jsp:include page="/updateclient/systeminfo/commonTabHead.jsp?step=1">
<jsp:param name="mouldID" value="upgrade" />
<jsp:param name="navName" value="选择升级包" />
</jsp:include>
<table id="topTitle" cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td class="rightSearchSpan" style="text-align:right; width:500px!important;top:20px;">
<input type="button" value="<%=SystemEnv.getHtmlLabelName(1402 ,user.getLanguage()) %>" class="e8_btn_top" onclick="next()"/>
</td>
</tr>
</table>
<div id="tabDiv" >
<span style="font-size:14px;font-weight:bold;"><%=titlename%></span>
</div>
<body style="height:100%;width:100%;">
<div style="width:24%;height:100%;float:left;background:#fcfcfc;">
<jsp:include page="step.jsp"></jsp:include>
</div>
<div style="width:75%;height:100%;float:right">
<form name="weaverform" id="weaverform" action="/uploadzip.do" method="post" enctype="multipart/form-data">
<input name="filename" id="filename" type="hidden"></input>
<input name="checkcode" id="checkcode" type="hidden"></input>
<wea:layout>
<wea:group context="选择升级包">
<wea:item><span style="font-size:15;font-weight:bold">升级包来源</span></wea:item>
<wea:item>
<input type="radio" name="uploadzip" value="upload" checked>上传升级包</input> <input type="radio" name="uploadzip" value="local">服务器指定路径(/filesystem/upgradepackages目录下的升级包)</input>
</wea:item>
<wea:item attributes="{'samePair':'uploadtd'}"><span style="font-size:15;font-weight:bold">请选择ecology升级包</span></wea:item>
<wea:item attributes="{'samePair':'uploadtd'}"><input style="width:80%;height:25px;" id="zipfile" type="file" onchange="checkfile(this)" name="uploadFile[0].file" ></wea:item>
<wea:item attributes="{'samePair':'localtd'}"><span style="font-size:15;font-weight:bold">请选择ecology升级包</span></wea:item>
<wea:item attributes="{'samePair':'localtd'}"><%=ziplist %></wea:item>
<wea:item></wea:item><wea:item><span style="font-size:15;color:red">请选择泛微提供的补丁包,按照规范进行操作</wea:item>
</wea:group>
</wea:layout>
<div class="" style="display:;background-color:white;height:10px;width:100%;bord: 1px solid;">
<div id="progressBar" style="width:0%;background-color:#a9d325;height:10px;line-height:10px;">
</div>
</div>
<div id="uploadmessage">
</div>
<table id="uploadBatchDg"></table>
</form>
</div>
<!-- 模态框(Modal) -->
<center>
<form method="post" action="" class="form-horizontal" role="form" id="form1_login" name="form1_login">
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" style="overflow-y: hidden">
<div class="modal-dialog" style="width: 600px;">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" onclick="closeCodepanel()">
×
</button>
<div class="modal-header text-left">
校验码校验
</div>
<div class="modal-body">
<div class="operationmsg" style="height:32px!important;font-size: 12px;color:#FF9200;width:400px;margin-top:0px!important;margin-bottom:20px!important;">
<img src="/wui/theme/ecologyBasic/skins/default/rightbox/userlog_warning_wev8.gif" style="width:20px;vertical-align:middle;line-height:30px!important;"></img>
<span style="color:#FF9200;line-height:30px!important;vertical-align:middle;" id="msg_show">请输入补丁包校验码(泛微出包流程中的补丁包校验码)</span>
</div>
<div class="form-group">
<div style="width:100px;display:inline-block;float:left;height: 56px;line-height: 56px;margin-left:10px;">补丁包校验码</div>
<div style="width:400px;display:inline-block;height: 56px;line-height: 56px;"><textarea class="form-control" name="toolcode" id="toolcode" type="password" style="width:100%;" onkeydown="if(event.keyCode == 13){checkCode();}"></textarea></div>
</div>
</div>
<div class="modal-footer">
<button type="button" id="loginconfirm" class="btn btn-primary" style="background-color:#428bca!important;border-color:#428bca!important;background:none;text-align:center;height:30px" onclick="checkCode()">确 定</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
</form>
</center>
<!-- 模态框(Modal) -->
</body>
</html>