MigrationLogFileOperation.jsp
10.3 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
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="weaver.file.FileUpload"%>
<%@ page import="weaver.file.FileManage"%>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.upgradetool.dbupgrade.logger.DBUpgradeLogger" %>
<%@ page import="weaver.upgradetool.dbupgrade.upgrade.FileOperation" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ include file="/system/upgradetoe9/MigrationOperation.jsp"%>
<%
response.setHeader("cache-control", "no-cache");
response.setHeader("pragma", "no-cache");
response.setHeader("expires", "Mon 1 Jan 1990 00:00:00 GMT");
%>
<%
DBUpgradeLogger.write2File("开始执行数据库操作11");
RecordSet rs=new RecordSet();
int step2=0;
int step3=0;
int step4=0;
rs.executeQuery("select * from dbupgrademain where sequence=?","20.00");
if(rs.next()){
step2=Util.getIntValue(rs.getString("status"),0);
}
rs.executeQuery("select * from dbupgrademain where sequence=?","30.00");
if(rs.next()){
step3=Util.getIntValue(rs.getString("status"),0);
}
rs.executeQuery("select * from dbupgrademain where sequence=?","40.00");
if(rs.next()){
step4=Util.getIntValue(rs.getString("status"),0);
}
String result="";
if(step2==2&&step3>0&&step4==0){
}else{
result="操作出现错误";
}
if(result.length()<=0){
try {
FileUpload fu = new FileUpload(request,false);//获取上传的问题
FileManage fm = new FileManage();
String code = Util.null2String(fu.getParameter("code")).trim();
char[] c_code=new char[16];
new FileReader(GCONST.getRootPath()+File.separator+"WEB-INF"+File.separator+"code.key").read(c_code);
String realcode=new String(c_code).trim();
if(code.equals("")){//表示code为空或者upload出错
// JSONObject json=new JSONObject();
// json.put("status","1");
// json.put("message","验证码为空");
// out.print(json.toString());
// DBUpgradeLogger.write2File("数据不存在32");
// return;
result="验证码为空";
}
if(!realcode.equals(code)&&!code.equals("")&&result.length()<=0){//不相等的时候
//out.println(code);
//SystemEnv.getHtmlLabelName(129308, 7)无效的验证码
// JSONObject json=new JSONObject();
// json.put("status","1");
// json.put("message","验证码无效");
// out.print(json.toString());
// DBUpgradeLogger.write2File("数据不存在41");
// return;
result="验证码无效";
}
if(result.length()<=0){
String logdirectory=GCONST.getRootPath()+"system"+File.separatorChar+"upgradetoe9"+File.separatorChar+"resource"+File.separatorChar+"logfile";
String logfilepath2=logdirectory+File.separatorChar+"DBimporttemlog"+".log";
File file1=new File(logdirectory);
if(!file1.exists()|| !file1.isDirectory()) {//如果目录不存在的话 或者不是文件夹的话 创建文件夹
file1.mkdir();
}
if(file1.exists() && file1.isDirectory()){
}else{
result="目录创建失败,请检查程序是否对目录有创建权限";
}
//
File filelog=new File(logdirectory);
if(filelog.exists() && filelog.isFile()) {//如果存在的话且是文件的话删除文件
file1.delete();
}
if(filelog.exists() && filelog.isFile()){
result="日志文件删除失败,请检查程序是否对目录有删除权限";
}
if(result.length()<=0){
int fileid = 0 ;
//上传日志文件
fileid = Util.getIntValue(fu.uploadFiles("log"), 0);
String sql = "select isaesencrypt,aescode,filerealpath from imagefile where imagefileid = " + fileid;
boolean r1 = rs.executeSql(sql);
DBUpgradeLogger.write2File("fileid"+fileid);
if (!r1) {
//代表数据不存在 上传成功
//需要返回状态码
// JSONObject json=new JSONObject();
// json.put("status","1");
// json.put("message","数据上传失败");
// out.print(json.toString());
DBUpgradeLogger.write2File("数据不存在66");
// return;
result="数据上传失败";
}
//
String uploadfilepath = "";
String isaesencrypt = "";
String aescode = "";
if (rs.next()) {
uploadfilepath = rs.getString("filerealpath");
isaesencrypt = rs.getString("isaesencrypt");
aescode = rs.getString("aescode");
}
String logfiname = UUID.randomUUID().toString();
if (!uploadfilepath.equals("")) {
try{
DBUpgradeLogger.write2File(uploadfilepath+"文件复制"+logfilepath2);
FileOperation.copyFile(uploadfilepath,logfilepath2);
}catch(Exception e){
DBUpgradeLogger.write2File("文件复制失败");
DBUpgradeLogger.write2File("文件复制失"+e.getMessage());
}
fm.DeleteFile(uploadfilepath);
}else{
// DBUpgradeLogger.write2File("文件复制失败");
// JSONObject json=new JSONObject();
// json.put("status","1");
// json.put("message","数据上传失败");
// out.print(json.toString());
result="数据上传失败";
// return;
}
if(result.length()<=0){
File filelog2=new File(logfilepath2);
if(filelog2.exists()&&filelog2.isFile()){
}else{
result="数据上传失败,请检查程序对目录是否有读写权限";
}
}
}
}
}catch(Exception e) {
DBUpgradeLogger.write2File("文件上传失败92");
DBUpgradeLogger.write2File(e.getMessage());
// JSONObject json=new JSONObject();
// json.put("status","1");
// json.put("message","日志上传出错");
// out.print(json.toString());
// return;
result="数据上传出现错误";
}
}
// JSONObject json=new JSONObject();
// json.put("status","0");
// out.print(json.toString());
// DBUpgradeLogger.write2File("文件上传成功");
// return;
%>
<script type="text/javascript" src="/wui/common/jquery/jquery.min_wev8.js"></script>
<script type="text/javascript">
<%
if(result.length()<=0){
%>
$("document").ready(function () {
parentWin = parent.getParentWindow(window);
//在被打开的页面中,使用如下语句获取Dialog对象:
dialog = parent.getDialog(window);
parent.checkdbdate();
dialog.close();
});
<%}%>
</script>
<html>
<body>
<%
if(result.length()>0){
%>
<TABLE class=ViewForm width="100%" cellspacing="0">
<COLGROUP> <COL width="15%"> <COL width="80%"><TBODY>
<tr class=Title >
<TD colSpan=2 style="background-color:#f8f8f8;font-weight: bold;text-align:center;height:50px;color:#545454;border:1px solid #eaeaea;padding-bottom:5px;">
<span style="display:inline-block;line-height:32px;height:32px;">
<span style="display:inline-block;height:32px;line-height:45px;font-size:18px;">提交反馈信息</span>
</span>
</TD>
</tr>
<tr>
<td style="height:240px;border-left:1px solid #eaeaea;border-bottom:1px solid #f4f4f4;text-align:center;padding-right:10px;width:100%">
<img src="/images/ecology8/fail_wev8.png" style="vertical-align:middle;width:32px;height:32px;"/>
<%--</td>--%>
<%--<td style="font-size:14px;color:#d62c2c;border-bottom:1px solid #f4f4f4;border-right:1px solid #eaeaea;text-align:center;padding-right:30px;">--%>
<span>
<span style="color:#d62c2c;font-size:18px;">
<%=Util.toScreen(result,7,"2")%>
</span>
</span>
</td>
<%--<%}else{ %>--%>
<%--<td colspan="2" style="height:240px;font-size:14px;color:#5c5c5c;border-left:1px solid #eaeaea;border-bottom:1px solid #f4f4f4;border-right:1px solid #eaeaea;text-align:center;padding-right:30px;">--%>
<%--<span style="display:inline-block;background-image:url(/images/ecology8/success_wev8.png);background-repeat:no-repeat;background-position:0 50%;height:32px;">--%>
<%--<span style="display:inline-block;height:32px;line-height:32px;color:#209e29;font-size:18px;padding-left:42px;">--%>
<%--<%=Util.toScreen(message,7,"2")%>--%>
<%--</span>--%>
<%--</span>--%>
<%--</td>--%>
<%--<%} %>--%>
</tr>
<%--<tr>--%>
<%--<td colspan="2" style="text-align:right;height:60px;border-left:1px solid #eaeaea;border-bottom:1px solid #eaeaea;border-right:1px solid #eaeaea;">--%>
<%--<%if(_mess.equals("1")){ %>--%>
<%--<input style="margin-right:18px;font-size:14px;height:35px;width:100px;text-align:center;background-color:#65a9ff;" class="e8_btn_top_first" id=btnSave accessKey=S name=btnSave onclick="javascript:top.location='/index.htm'" type=button value="登 录"></input>--%>
<%--<%}else{ %>--%>
<%--<input style="margin-right:18px;font-size:14px;height:35px;width:100px;text-align:center;background-color:#65a9ff;" class="e8_btn_top_first" id=btnSave accessKey=S name=btnSave type=button onclick="javascript:top.location='/system/InLicense.jsp'" value="重新提交"></input>--%>
<%--<%} %>--%>
<%--<input style="margin-right:18px;font-size:14px;height:35px;width:100px;text-align:center;background-color:#65a9ff;display:none;" class="e8_btn_top_first" id=btnClose accessKey=S name=btnSave type=button onclick="javascript:parent.parent.getDialog(parent).close();" value="关 闭"></input>--%>
<%--<script type="text/javascript">--%>
<%--try{--%>
<%--if(parent.setTabObjName){--%>
<%--jQuery("#btnSave").hide();--%>
<%--jQuery("#btnClose").show();--%>
<%--}--%>
<%--}catch(e){}--%>
<%--</script>--%>
<%--</td>--%>
<%--</tr>--%>
</TBODY>
</TABLE>
<%}%>
</body>
</html>