upgradefiles.js
7.55 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
var timeout2;
$(document).ready(function(){
var process = $("#process").val();
if(process != "" && process != "0") {
//bindnextclick(process);
getData();
clearInterval(timeout2);
timeout2=setInterval(getData,1000);
} else {
doUpgrade();
}
});
function bindnextclick(process){
$("#next").unbind("click");
if(process =="100") {
$("#message").html("备份成功!请点击“下一步”开始执行脚本。<br><span style='font-size:10px;'>备份目录:"+$("#backuppath").val()+"</span>");
$("#next").click(function(){
});
}
}
var clicktag = 0;
function next() {
if (clicktag == 0) {
clicktag = 1;
$.get('/getProcess.do?date=' + (new Date()).valueOf(), function (res) {
var pro = res.progress;
var backuppath = res.backuppath;
if (pro == "100") {
window.onbeforeunload = null;
processSql();
} else {
top.Dialog.alert("正在备份!");
}
});
setTimeout(function() {
clicktag = 0;
}, 500);
} else {
alert("请勿频繁点击!");
}
}
function doUpgrade()
{
$("#message").html("开始备份,请稍候...");
$("#bak").show();
$.get('/upgrade.do?date='+(new Date()).valueOf(),function(data)
{
var result = data;
if(""+result.isSuccess=="true")
{
clearInterval(timeout2);
$("#pro").css("width","100%");
$("#promsg").html("100%");
$("#message").html("备份成功!请点击“下一步”开始执行脚本。<br><span style='font-size:10px;'>系统已备份,备份目录:"+decodeURIComponent(decodeURIComponent(result.backuppath))+"</span>");
$("#next").attr("disabled",false);
$("#next").unbind("click");
}
else if(""+result.isSuccess=="false")
{
if("100" == pro) {
clearInterval(timeout2);
top.Dialog.confirm("覆盖文件失败,确认还原?",
function(){
window.location.href="/updateclient/backup.jsp";
},
function(){
$("#message").html("覆盖文件失败!<br><span style='font-size:10px;'>系统已备份,备份目录:"+decodeURIComponent(decodeURIComponent(result.backuppath))+"</span>");
});
} else {
if(res.message == "BackupError" || res.message == "BackupClassbeanError") {
clearInterval(timeout2);
if(monitorMousedDown){
monitorMousedDown = false;
$("#message").html(res.message);
$("#message").html("覆盖文件失败!请重新升级。");
top.Dialog.confirm("覆盖文件失败,确认还原?(还原后系统仍不能正常使用,请联系泛微技术排查原因。)",
function(){
$.post('/backup.do?statusreset=1&date='+(new Date()).valueOf(),function(data){
window.location.href="/updateclient/checkDB.jsp";
});
},
function(){
});
}
}
}
return;
}
});
timeout2=setInterval(getData,1000);
}
function processSql() {
$.post('/processSql.do?date='+(new Date()).valueOf(),function(data){
window.location.href="/updateclient/processSql.jsp";
});
}
function getData()
{
$("#bak").show();
$.get('/getProcess.do?date='+(new Date()).valueOf(),function(res){
//var backuppath = $("#backuppath").val();
var pro = res.progress;
var backuppath = res.backuppath;
backuppath = decodeURIComponent(decodeURIComponent(backuppath));
var filecount = res.filecount;
var filecurrent = res.filecurrent;
var covererror = res.covererror;
if(""+res.isSuccess=="false") {
var pro = res.progress;
if("100" == pro) {
clearInterval(timeout2);
top.Dialog.confirm("覆盖文件失败,确认还原?",
function(){
window.location.href="/updateclient/backup.jsp";
},
function(){
$("#message").html("覆盖文件失败!<br><span style='font-size:10px;'>系统已备份,备份目录:"+decodeURIComponent(decodeURIComponent(result.backuppath))+"</span>");
});
} else {
if(res.message == "BackupError" || res.message == "BackupClassbeanError") {
clearInterval(timeout2);
if(monitorMousedDown){
monitorMousedDown = false;
$("#message").html(res.message);
$("#message").html("覆盖文件失败!请重新升级。");
top.Dialog.confirm("覆盖文件失败,确认还原?(还原后系统仍不能正常使用,请联系泛微技术排查原因。)",
function(){
$.post('/backup.do?statusreset=1&date='+(new Date()).valueOf(),function(data){
window.location.href="/updateclient/checkDB.jsp";
});
},
function(){
});
}
return;
}
}
}
$("#backuppath").val(backuppath);
$("#pro").css("width",pro+"%");
$("#promsg").html(pro+"%");
$("#pro").show();
if(covererror=="1") {//部分文件没有覆盖全
window.location.href="/updateclient/errorFiles.jsp?process="+pro;
clearInterval(timeout2);
}
if(pro == "0") {
$("#message").html("正在备份ecology,请稍候...");
} else if(pro == "5"){
$("#message").html("正在备份ecology,请稍候...");
}else if(pro == "25") {
$("#message").html("正在备份resin,请稍候...");
} else if(pro == "50") {
$("#message").html("正在覆盖ecology,请稍候...(补丁包中文件总数:"+filecount+",已覆盖数量:"+filecurrent+")<br><span style='font-size:10px;'>系统已备份,备份目录:"+backuppath+"</span>");
} else if(pro == "75") {
$("#message").html("正在覆盖resin,请稍候...(补丁包中文件总数:"+filecount+",已覆盖数量:"+filecurrent+")<br><span style='font-size:10px;'>系统已备份,备份目录:"+backuppath+"</span>");
} else if(pro == "90") {
$("#message").html("正在删除临时文件,请稍候...<br><span style='font-size:10px;'>系统已备份,备份目录:"+backuppath+"</span>");
} else {
$("#message").html("备份成功!请点击“下一步”开始执行脚本。<br><span style='font-size:10px;'>系统已备份,备份目录:"+backuppath+"</span>");
clearInterval(timeout2);
}
});
}
var dWidth = 600;
var dHeight = 500;
function doOpen(url,title){
if(typeof dialog == 'undefined' || dialog==null){
dialog = new window.top.Dialog();
}
dialog.currentWindow = window;
dialog.Title = title;
dialog.Width = dWidth || 700;
dialog.Height = dWidth || 300;
dialog.Drag = true;
dialog.maxiumnable = true;
dialog.URL = url;
dialog.show();
}