MigrationSetting.jsp 12.9 KB
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.*" %>
<%@ page import="weaver.upgradetool.dbupgrade.upgrade.PropUtil" %>
<%@ page import="weaver.upgradetool.dbupgrade.upgrade.UpgradeRecordSet" %>
<%@ include file="/system/upgradetoe9/DBUpgradeInit.jsp"%>
<html>
<%
%>
<script type="text/javascript" src="/system/upgradetoe9/js/jquery-1.8.3.min_wev8.js"></script>
<link rel="stylesheet" href="/system/upgradetoe9/css/seachBody_wev8.css" type="text/css" />
<!--弹出层 开始 -->
<link type="text/css" rel="stylesheet" href="/system/upgradetoe9/css/dialog.css" />
<script type="text/javascript" src="/system/upgradetoe9/js/dialog.js"></script>
<!--弹出层 结束 -->
<script type="text/javascript">
    $("document").ready(function () {
        $("input").focus(function(){
            $("#next").attr('disabled',true);
            $("#next").removeClass("e8_btn_submit");
            $("#next").addClass("e8_btn_disabled");
        })
    });
</script>
<head>
    <title> E-cology迁移程序</title>
    <style>
        TABLE {
            FONT-SIZE: 9pt;
            FONT-FAMILY: Verdana;
        }
        BODY {
            FONT-SIZE: 9pt;
            MARGIN: 0px;
            FONT-FAMILY: Verdana;
            LIST-STYLE-TYPE: circle;
        }
        table input{
            border: 1px solid #ccc!important;
            border-radius: 3px;/* !*css3属性IE不支持*!*/
            padding: 6px 0px 5px 10px;
        }
        #dbform{
            width: 100%;
            height:auto;
            vertical-align:center;
            font-weight: bold;
        }
        .btn-disabled{
            height: 35px;
            text-decoration:none;
            background:#959595;
            color:black;
            padding: 5px 20px 5px 20px;
            font-size:16px;
            font-family: 微软雅黑,宋体,Arial,Helvetica,Verdana,sans-serif;
            /*font-weight:bold;*/
            border-radius:5px;

            -webkit-transition:all linear 0.10s;
            -moz-transition:all linear 0.10s;
            transition:all linear 0.10s;

        }
        .btn-success{
            height: 35px;
            text-decoration:none;
            background:#5CB85C;
            color:#f2f2f2;
            padding: 5px 20px 5px 20px;
            font-size:16px;
            font-family: 微软雅黑,宋体,Arial,Helvetica,Verdana,sans-serif;
            /*font-weight:bold;*/
            border-radius:5px;


        }
        .btn-success:hover{
            background:#449D44;
        }
        .e8_btn_disabled{
            border:0px;cursor:pointer;
            padding-left:0;
            padding-left:10px;
            padding-right:10px;
            height:30px;
            line-height:30px;

            background-color:#959595;
            color:white;
            width:auto;
        }
        .e8_btn_submit{
            border:0px;cursor:pointer;
            padding-left:0;
            padding-left:10px;
            padding-right:10px;
            height:30px;
            line-height:30px;

            background-color:#558ED5;
            color:white;
            width:auto;
        }
        .e8_btn_submit_hover{
            background-color:#0170C1 !important;
            color:white;
        }
    </style>

</head>
<%
    String titlename = "";
    PropUtil prop = PropUtil.getInstance();
    String dbserver = Util.null2String(prop.getValues("dbserver"));
    String dbport = Util.null2String(prop.getValues("dbport"));
    String dbname = Util.null2String(prop.getValues("dbname"));
    String username = Util.null2String(prop.getValues("username"));
    UpgradeRecordSet rs=new UpgradeRecordSet();
    String dbtype = Util.null2String(prop.getValues("dbtype"));
    if("".equals(dbtype)){
        dbtype=rs.getDBType().toLowerCase();
    }
    if("".equals(dbport)){
        if(dbtype.equals("sqlserver")){
            dbport="1433";
        }else if(dbtype.equals("oracle")){
            dbport="1521";
        }

    }
    String sourcepath = Util.null2String(prop.getValues("sourcepath"));
%>
<jsp:include page="/system/upgradetoe9/CommonTabHead.jsp">
    <jsp:param name="mouldID" value="upgrade"/>
    <jsp:param name="step" value="<%=currentStep%>"/>
    <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">
            <button style="margin-right:10px;" id="next" type="button" name="next" disabled="true" onclick="next()" class="e8_btn_disabled">下一步</button>
        </td>
    </tr>
</table>
<body style="height:100%;width:100%;">

<div style="width:20%;height:100%;float:left;background:#fcfcfc;">
    <jsp:include page="MigrationStep.jsp"></jsp:include>
</div>
<div style="width:75%;height:100%;float:right">
    <div style="width: auto;margin-left: 50px">
        <form>
            <table id="dbform" cellspacing="10px" cellpadding="5px">
                <colgroup>
                    <col width="20%">
                    <col width="80%">
                </colgroup>
                <tbody>
                <th class=Separator>
                 <td style="height: 80px" ><h1>源数据库参数设置</h1></td>
                </th>
                <tr>
                    <td >验证码:   </td>
                    <td><input id="verifycode"  type="password" name="verifycode" value="" maxlength=16 size=40></td>
                </tr>
                <tr>
                    <td>数据库类型:</td>
                    <td>
                        <select id="dbtype" name="dbtype" onchange="changeDBType()">
                            <option value="1" <% if(dbtype.equals("sqlServer2000")) {%>selected<%}%>>SqlServer 2000</option>
                            <option value="2" <% if(dbtype.equals("sqlServer2005")) {%>selected<%}%>>SqlServer 2005</option>
                            <option value="3" <% if(dbtype.equals("sqlserver2008")) {%>selected<%}%>>SqlServer 2008</option>
                            <option value="4" <% if(dbtype.equals("sqlserver2014")) {%>selected<%}%>>SqlServer 2014</option>
                            <option value="5" <% if(dbtype.equals("oracle9i")) {%>selected<%}%>>Oracle 9i</option>
                            <option value="6" <% if(dbtype.equals("oracle10g")) {%>selected<%}%>>Oracle 10g</option>
                            <option value="7" <% if(dbtype.equals("oracle11g")) {%>selected<%}%>>Oracle 11g</option>
                            <option value="8" <% if(dbtype.equals("oracle12c")) {%>selected<%}%>>Oracle 12c</option>
                            <!--option value="3">DB2</option-->
                            <%-- <option value="4">Mysql</option>--%>
                        </select>

                    </td>
                </tr>
                <tr>
                    <td>数据库服务器IP:</td>
                    <td>
                        <input type="text" id="dbserver" name="dbserver" maxlength="40" value="<%=dbserver%>" size="40">
                    </td>
                </tr>
                <tr>
                    <td>数据库端口号:</td>
                    <td>
                        <input type="text" id="dbport"  name="dbport" maxlength="40" size="40" value="<%=dbport%>">
                    </td>
                </tr>
                <tr>
                    <td>数据库名称:</td>
                    <td>
                        <input type="text" id="dbname"  name="dbname" maxlength="40" size="40" value="<%=dbname%>">
                    </td>
                </tr>
                <tr>
                    <td>用户名:</td>
                    <td>
                        <input type="text" id="username" name="username" maxlength="40" size="40" value="<%=username%>">
                    </td>
                </tr>
                <tr>
                    <td>密码:</td>
                    <td>
                        <input type="password" id="password" name="password" maxlength="40" size="40" value="">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button"  id="testConn" class="btn-success"  value="测试连接" onclick="testConnection()" />
                    <td>
                        <input type="hidden" id="method" name="method" value="submit">
                    </td>
                </tr>
                </tbody>
            </table>

        </form>
    </div>
</div>
</body>
</html>
<script type="text/javascript">

    function testConnection(){
        var verifycode =$("#verifycode").val();
        var dbtype=$("#dbtype").val();
        if(dbtype=='1'){
            dbtype = 'sqlserver2000';
        }else if(dbtype=='2'){
            dbtype = 'sqlserver2005';
        }else if(dbtype=='3'){
            dbtype = 'sqlserver2008';
        }else if(dbtype=='4'){
            dbtype = 'sqlserver2014';
        }else if(dbtype=='5'){
            dbtype = 'oracle9i';
        }else if(dbtype=='6'){
            dbtype = 'oracle10g';
        }else if(dbtype=='7'){
            dbtype = 'oracle11g';
        }else if(dbtype=='8'){
            dbtype = 'oracle12c';
        }
        var dbserver=$("#dbserver").val();
        var dbname= $("#dbname").val();
        var dbport= $("#dbport").val();
        var username=$("#username").val();
        var password=$("#password").val();
        var sourcepath=$("#sourcepath").val();
        var checkResult = checkform(verifycode,dbtype,dbserver,dbname,dbport,username,password,sourcepath);
        if(checkResult!=''){
            $.DialogByZ.Alert({Title: "提示", Content: checkResult,BtnL:"确定"});
            return;
        }
        $("#testConn").removeClass("btn-success");
        $("#testConn").addClass("btn-disabled");
        $("#testConn").attr('disabled',true);
        $.ajax({
            sync:false,
            dataType:'json',
            type:'post',
            url:'MigrationSettingOperation.jsp?method=testConnection',
            // timeout : 5000,
            data:{
                'verifycode': verifycode,
                'dbtype': dbtype,
                'dbserver': dbserver,
                'dbname': dbname,
                'dbport': dbport,
                'username': username,
                'password': password,
                'sourcepath': sourcepath,
            },
            success:function(data){
                var status = data.status;
                var message = data.message;
                $.DialogByZ.Alert({Title: "提示", Content: message,BtnL:"确定"});
                if(status=='success'){
                    $("#next").attr('disabled',false);
                    $("#next").removeClass("e8_btn_disabled");
                    $("#next").addClass("e8_btn_submit");
                }
                $("#testConn").attr('disabled',false);
                $("#testConn").removeClass("btn-disabled");
                $("#testConn").addClass("btn-success");
            },
            error:function () {
                $("#testConn").attr('disabled',false);
                $("#testConn").removeClass("btn-disabled");
                $("#testConn").addClass("btn-success");
            }
            /*,
            complete : function(XMLHttpRequest,status){ //请求完成后最终执行参数
                if(status=='timeout'){//超时,status还有success,error等值的情况
                    ajaxTimeoutTest.abort();
                    $.DialogByZ.Alert("超时");
                }
            }*/
        });
    };
    function changeDBType() {
        var dbtype=$("#dbtype").val();
        if(dbtype>=1&&dbtype<=4) {
            $('#dbport').val('1433');
        }
        else if(dbtype>=5&&dbtype<=8) {
            $('#dbport').val('1521');
        }
        else if(dbtype==9) {
            $('#dbport').val('3306');
        }
    };
    function checkform(verifycode,dbtype,dbserver,dbname,dbport,username,password){
        var message ='';
        if(verifycode==""){
            message="验证码不能为空!"
            return message;
        }
        if(dbtype==""){
            message="数据库类型不能为空!"
            return message;
        }
        if(dbserver==""){
            message="数据库服务器IP不能为空!"
            return message;
        }else{
            var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
            if(!reg.test(dbserver)){
                return "数据库服务器IP不合法!";
            }
        }
        if(dbname==""){
            message="数据库名称不能为空!"
            return message;
        }
        if(dbport==""){
            message="数据库端口号不能为空!"
            return message;
        }
        if(username==""){
            message="用户名不能为空!"
            return message;
        }
        if(password==""){
            message="密码不能为空!"
            return message;
        }
        return message;

    }
</script>