DataMigration.jsp 39 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 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.io.File" %>
<%@ page import="weaver.general.GCONST" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="java.util.LinkedHashMap" %>
<%@ page import="weaver.upgradetool.dbupgrade.upgrade.*" %>
<%@ page import="java.util.Date" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ include file="/system/upgradetoe9/DBUpgradeInit.jsp"%>
<%
    /**
     * 数据迁移的页面
     */
%>
<html>
<%
//    String skintrigger= Util.null2String(request.getParameter("skintrigger"),"0");
//    Date date=new Date();
//    FileOperation fileOperation=new FileOperation();
//    String dbfilename="ecology_"+date.getTime();
//    fileOperation.doGenerateExportFile(dbfilename);
//    fileOperation.doGenerateImportFile(dbfilename);
    /**
     * 执行关闭触发器的操作
     */
//    if(!skintrigger.equalsIgnoreCase("1")){
//        DBUpgradeOperation operationUtil=new DBUpgradeOperation();
//        operationUtil.closeDBTrigger();//执行关闭触发器操作
//    }
    RecordSet rs=new RecordSet();
    String dbtype=rs.getDBType();
    String dbname="";
    if("oracle".equalsIgnoreCase(dbtype)){
       dbname="ORACLE";
    }else if("mysql".equalsIgnoreCase(dbtype)){
      dbname="MYSQL";
    }else if("dm".equalsIgnoreCase(dbtype)){
        dbname="DM";
    }else{
        dbname="SQLSERVER";
        rs.executeUpdate("update dbupgradedetail set status=2 where mainsequence=30.00");
        rs.executeUpdate("update dbupgradeaction set status=2 where mainsequence=30.00");
    }
    String showvisibility="";
    if(dbname.equalsIgnoreCase("SQLSERVER")){
        showvisibility="display: none";
    }
%>

<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" src="/system/upgradetoe9/js/upgradeDialog.js"></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;
        }
        input,select,textarea{
            /*border:#e7e7e7 1px solid;*/
            vertical-align:middle;
        }

        input,select{
            line-height:24px;
            height:24px;
        }
        table input{
            border: 1px solid #ccc!important;
            border-radius: 3px;/* !*css3属性IE不支持*!*/
            padding: 6px 0px 5px 10px;
        }
        .progressbar{
            width: 98%;
            /* margin-left: 10%;*/
            border-radius: 7px;
            border: 1px solid #008000;
            float: left;
            -webkit-box-shadow: 3px 3px 3px #ADADAD;
            -moz-box-shadow: 3px 3px 3px #ADADAD;
            box-shadow: 3px 3px 3px #ADADAD;
        }
        .btn-primary{
            height: 25%;
            text-decoration:none;
            background:#337AB7;
            color:#f2f2f2;
            padding: 0 20px 0 20px;
            font-size:14px;
            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-primary:hover{
            background:#286090;
        }
        .btn-success{
            height: 25%;
            text-decoration:none;
            background:#5CB85C;
            color:#f2f2f2;
            padding: 0 20px 0 20px;
            font-size:14px;
            font-family: 微软雅黑,宋体,Arial,Helvetica,Verdana,sans-serif;
            /*font-weight:bold;*/
            border-radius:5px;
        }
        .btn-success:hover{
            background:#b8b1b6;
        }
        .btn-success-disabled:hover{
            background:#5CB85C;
        }
        .btn-success-disabled{
            height: 25%;
            text-decoration:none;
            background: #b8b1b6;
            color:#f2f2f2;
            padding: 0 20px 0 20px;
            font-size:14px;
            font-family: 微软雅黑,宋体,Arial,Helvetica,Verdana,sans-serif;
            /*font-weight:bold;*/
            border-radius:5px;
        }
        .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;
        }
        .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;
        }
        .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;

        }
        .e8_btn_submit_hover{
            background-color:#0170C1 !important;
            color:white;
        }
        /*.showtable tr{*/
            /*height: 20px;*/
        /*}*/

        .redtext{
            color: #D35026;
            font-size: 16px;

        }
        .ullist{
            margin-left: -20px;
            padding-top: 10px;
            list-style: none;
            padding-bottom:10px;
            /*background-color:#fff3dc;*/
        }
        .listyle1{
            line-height: 30px;
            color: #6c6c6c;
            font-size: 16px;
        }
        .header{
            height: 40px;
            background-color: #f8f8f8;
        }
        .header p{
            height: 40px;
            background-color: #f8f8f8;
        }
        .header td p span{
            /*font-weight: bold;*/
            font-size: 16px;
        }
        .sqlcontent{
            background-color:#fff3dc;
        }
        .ullist1{
            padding-top: 5px;
            list-style: none;
            line-height: 25px;
            color: red;
            font-size: 16px;
            padding-bottom:40px;
        }
        a{
            text-decoration: none;
        }
        a img:hover{
            background-color:black ;
        }
        .downfilestyle{
            font-size: 10px;
            color: red;
        }


        /*滚动条*/
        .doing {
            background-image: url(./images/doing.gif);
            width:30px;
            height:30px;
            background-repeat:no-repeat;
            display:inline-block;
            background-position:center;

        }
        .done {
            background-image: url(./images/ok.png);
            width:30px;
            height:30px;
            background-repeat:no-repeat;
            display:inline-block;
            background-position:center;
        }
        .error {
            background-image: url(./images/error.gif);
            width:30px;
            height:30px;
            background-repeat:no-repeat;
            display:inline-block;
            background-position:center;
        }
        .none {
            width:30px;
            height:30px;
        }
        .processdiv {
            margin:10px;
            font-size:16px;
            height:30px;
        }
        .processdiv .processmsgdiv {
            height:30px;
            line-height:30px;
            display:inline-block;
            color:#333333;
        }
        .processdiv>div{
            float:left;

        }
        .processdiv>a{
            font-size:14px;
            margin-left:5px;
            height:30px;
            line-height:30px;
        }

        .scrollbar{
            width: 30px;
            height: 300px;
            margin: 0 auto;
        }
        #logarea1::-webkit-scrollbar {/*滚动条整体样式*/
            width: 10px;     /*高宽分别对应横竖滚动条的尺寸*/
            height: 1px;
        }
        #logarea1::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
            border-radius: 10px;
            -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            background: #535353;
        }
        #logarea1::-webkit-scrollbar-track {/*滚动条里面轨道*/
            -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            border-radius: 10px;
            background: #EDEDED;
        }
        #sqlmsgtext::-webkit-scrollbar {/*滚动条整体样式*/
            width: 10px;     /*高宽分别对应横竖滚动条的尺寸*/
            height: 1px;
        }
        #sqlmsgtext::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
            border-radius: 10px;
            -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            background: #535353;
        }
        #sqlmsgtext::-webkit-scrollbar-track {/*滚动条里面轨道*/
            -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            border-radius: 10px;
            background: #EDEDED;
        }
        a {
            text-decoration:underline!important;
            cursor:hand!important;
        }

        .showresults{
            overflow-x: hidden;
            overflow-y: scroll;
        }

    </style>

</head>
<%
%>
<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;">
            <div style="margin-right:2px">
                <%if(dbname.equalsIgnoreCase("oracle")){%>
                <button style="margin-right:10px;visibility:hidden ;" id="continueExcute" type="button" name="continueExcute"  onclick="continueExcute1()" class="e8_btn_submit">继续执行</button>
                <button style="margin-right:10px;visibility:hidden ;" id="opentri" type="button" name="opentri"  onclick="openTrigger1()" class="e8_btn_submit">开启E9触发器</button>
                <%--<button style="margin-right:10px;" id="closetri" type="button" name="closetri"  onclick="closeTrigger()" class="e8_btn_submit">关闭E9触发器</button>--%>
                <button style="margin-right:10px;" id="startExcute" type="button" name="startExcute"  onclick="startExcute()" class="e8_btn_submit">开始自动执行</button>
                <%}%>
                <button style="margin-right:10px;" id="checkdbdate" type="button" name="checkdbdate"  onclick="logfileload()" class="e8_btn_submit">迁移数据检测</button>
                <button style="margin-right:10px;" id="next" type="button" name="next"  onclick="next()" class="e8_btn_submit">下一步</button>
            </div>
        </td>
    </tr>
</table>
<body style="height:100%;width:100%;">
<iframe name="downiframe" id="downiframe" src="" style="display:none;" ></iframe>

<div style="width:20%;height:100%;float:left;background:#fcfcfc;">
    <jsp:include page="MigrationStep.jsp"></jsp:include>
</div>
<div style="width:80%;height:100%;float:right">
    <div style="<%=showvisibility%>">
        <table style="width: 98%;height:20%;text-align: left;padding-left: 1%">
            <colgroup>
                <col width="50%">
                <col width="50%">
            </colgroup>
            <tbody>
            <tr style="text-align: left;height:40px">
                <td>
                    <div class="progressbar">
                        <div   id="process" style="background-color: #008000; height: 25px; border-radius: 5px; width:0%; ">
                        </div>
                    </div>
                </td>
                <td colSpan=2>
                    <div id="processInfo" style="font-size: medium;font-weight: bold;">当前进度:0%</div>
                </td>
            </tr>
            <tr style="text-align: left;height:40px">
                <td colSpan=2>
                    <div id="currentThread" style="font-size: medium;font-weight: bold">自动执行数据迁移准备工作</div>
                </td>
            </tr>
            <tr style="text-align: left;height:170px">
                <TD colSpan=2 style="border:1px solid #f8f8f8;">
                    <div style="width:100%;height:100%;float:left;background-color:#fff3dc;">
                        <div style="font-size:18px;height:40px;line-height:40px;background-color:#f8f8f8;"><img style="height:40px;line-height:40px;float:left" src="./images/workflowshow_wev8.png"></img><span style="height:40px;line-height:40px;float:left">执行进度</span></div>
                        <div id="processcontent" style="width:50%;text-align:left;background-color:white;float:left;background-color:#fff3dc;">
                        </div>
                    </div>
                </TD>
            </tr>
            </tbody>
        </table>
    </div>

    <%--<table style="width: 98%;height: auto;padding-left: 1%;padding-top: 1%" cellspacing="0" cellpadding="0" class="showtable" >--%>
        <%--<tr>--%>
            <%--<td >--%>
                <%--<p class="redtext">当前数据库为<%=dbname%>,脚本文件已生成,请按照下面文档步骤进行手动操作</p>--%>
            <%--</td>--%>
        <%--</tr>--%>
        <%--&lt;%&ndash;<tr>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<td>&ndash;%&gt;--%>
                    <%--&lt;%&ndash;<ul class="ullist">&ndash;%&gt;--%>
                        <%--&lt;%&ndash;<li class="listyle1">文档1:&nbsp;<a href="javascript:void(0)" onclick="downDoc('Importandexport.doc','导入导出详细操作文档.doc')">导入导出详细操作文档.doc</a>&nbsp;详细步骤可参考改文档&nbsp;<a href="javascript:void(0)" title="下载文档" oonclick="downDoc('Importandexport.doc','导入导出详细操作文档.doc')"><img src="images/down_wev8.png" style="width: 15px;height:13px"></a><span class="downfilestyle"></span></li>&ndash;%&gt;--%>
                        <%--&lt;%&ndash;<li class="listyle1">文档2:&nbsp;<a href="javascript:void(0)" onclick="downDoc('parfile.txt','Export.txt')">Export.txt</a>&nbsp;该脚本用于导出源数据数据&nbsp;<a href="javascript:void(0)" title="下载文档" onclick="downDoc('parfile.txt','Export.txt')"><img src="images/down_wev8.png" style="width: 15px;height:13px"></a></li>&ndash;%&gt;--%>
                        <%--&lt;%&ndash;<li class="listyle1">文档3:&nbsp;<a href="javascript:void(0)" onclick="downDoc('parfile_imp.txt','Import.txt')">Import.txt</a>&nbsp;该脚本用于将原数据库导出的dmp数据文件导入目标数据库数据&nbsp;<a href="javascript:void(0)" title="下载文档" onclick="downDoc('parfile_imp.txt','Import.txt')"><img src="images/down_wev8.png" style="width: 15px;height:13px"></a></li>&ndash;%&gt;--%>
                    <%--&lt;%&ndash;</ul>&ndash;%&gt;--%>
            <%--&lt;%&ndash;</td>&ndash;%&gt;--%>
            <%--&lt;%&ndash;<td>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<input type="hidden"  id="closetri" class="btn-success"  value="关闭E9触发器" onclick="closeTrigger()" />&ndash;%&gt;--%>
            <%--&lt;%&ndash;</td>&ndash;%&gt;--%>
        <%--&lt;%&ndash;</tr>&ndash;%&gt;--%>
    <%--</table>--%>
    <div style="padding-top: 10px">
        <table style="width: 98%;height: 15%;padding-left: 1%;visibility:hidden" cellspacing="0" cellpadding="0" class="showtable" id="sqltable">
            <colgroup>
                <col width="50%">
                <col width="50%">
            </colgroup>
            <tbody>
            <tr class="header">
                <td style="height:40px;line-height:40px;width:100%;">
                    <div><img src="images/sysadmin_doc_wev8.png" style="height:40px;line-height:40px;float:left;"><span style="height:40px;line-height:40px;float:left;font-size:18px;">当前数据库为<%=dbname%>,脚本文件已生成,请按照下面文档步骤进行手动操作</span></div>
                </td>
            </tr>
            <tr class="sqlcontent">
                <td>
                    <ul class="ullist">
                        <%if("oracle".equalsIgnoreCase(dbname)){%>
                        <li class="listyle1">文档1:&nbsp;<a href="javascript:void(0)" onclick="downDocdoc('Importandexport.doc')">导入导出详细操作文档.doc</a>&nbsp;详细步骤可参考该文档&nbsp;<a href="javascript:void(0)"  title="下载文档" onclick="downDoc('Importandexport.doc')"><img src="images/down_wev8.png" style="width: 15px;height:13px"></a></li>
                        <li class="listyle1">文档2:&nbsp;<a href="javascript:void(0)" onclick="downDoc('parfile.txt','Export.txt')">Export.txt</a>&nbsp;该脚本用于导出源数库数据&nbsp;<a href="javascript:void(0)" title="下载文档" onclick="downDoc('parfile.txt','Export.txt')"><img src="images/down_wev8.png" style="width: 15px;height:13px"></a></li>
                        <li class="listyle1">文档3:&nbsp;<a href="javascript:void(0)" onclick="downDoc('parfile_imp.txt','Import.txt')">Import.txt</a>&nbsp;该脚本用于将源数据库导出的dmp数据文件导入目标数据库&nbsp;<a href="javascript:void(0)" title="下载文档" onclick="downDoc('parfile_imp.txt','Import.txt')"><img src="images/down_wev8.png" style="width: 15px;height:13px"></a></li>
                        <% }else if("sqlserver".equalsIgnoreCase(dbname)){%>
                        <li class="listyle1">文档1:&nbsp;<a href="javascript:void(0)" onclick="downDoc('Importandexport2.doc','导入导出详细操作文档.doc')">导入导出详细操作文档.doc</a>&nbsp;详细步骤可参考该文档&nbsp;<a href="javascript:void(0)"  title="下载文档" onclick="downDoc('Importandexport2.doc','导入导出详细操作文档.doc')"><img src="images/down_wev8.png" style="width: 15px;height:13px"></a></li>
                        <% }%>
                    </ul>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div style="padding-top:10px">
        <table style="width: 98%;height:auto;max-height:250px;padding-left: 1%;visibility:hidden;overflow-y: scroll" cellspacing="0" cellpadding="0" class="showresults" id="showcheckresult">
            <colgroup>
                <col width="50%">
                <col width="50%">
            </colgroup>
            <tbody>
            <tr class="header">
                <td style="height:40px;line-height:40px;width:100%;">
                    <div><img src="images/sysadmin_doc_wev8.png" style="height:40px;line-height:40px;float:left" id="checkedimg"><span style="height:40px;line-height:40px;float:left;font-size:18px;">迁移数据检测结果</span></div>
                </td>
            </tr>
            <tr style="height:auto;line-height:20px;width: 100%;background-color: #fff3dc;"><!--color:white;opacity: 0.80-->
                <td>
                    <div id="checkresult" style="vertical-align: text-top;height: 100%;margin-bottom:10px;margin-top:10px;max-height:200px;overflow:auto;overflow-x: hidden">

                    </div>
                </td>
            </tr>
            </tbody>
        </table>

    </div>
</div>
</body>
</html>
<script type="text/javascript">
    var dbname="<%=dbname%>";
    var isexcute=0;
    var isOpenTri=0;
    var atuoScrollLog = true;
    var firstGetLog="1";
    var showDetailLog=true;
    var detailProcessInterval;
    var logintervaltime  = 1000;
    var logshow = "0";

    $("document").ready(function () {
        $("#next").attr('disabled',true);
        $("#next").removeClass("e8_btn_submit");
        $("#next").addClass("e8_btn_disabled");


    });

    jQuery(document).ready(function(){
        if(dbname.toLowerCase()==="sqlserver"){
            $("#sqltable").css('visibility','visible');
        }else{
            $("#checkdbdate").attr('disabled',true);
            $("#checkdbdate").removeClass("e8_btn_submit");
            $("#checkdbdate").addClass("e8_btn_disabled");
            initDetailProcess();
        }

    });

    /**
     * 获得进度的信息
     */
    function initDetailProcess() {
        var processhtml = "";
        $.ajax({
            dataType:'json',
            type:'post',
            url:'DataMigrationOperation.jsp',
            data:{
                "operation":"getActionExecuteInfo",
                "mainsequence":"<%=mainsequence%>"
            },
            success:function(data){
                var needDisplay = true;
                var processClass = "";
                var detailStatus = data.detailStatus;
                var percent = data.percent;
                var currentTask = data.currentTask;
                var taskStatus = data.taskStatus;
                var executesql = data.executesql;
                var actionProcessName = data.actionProcessName;
                //判断是否全部执行完成
                if(percent != undefined && parseInt(percent) == 100) {
                    changeBtnStatus();
                    $("#checkdbdate").removeClass("e8_btn_disabled");
                    $("#checkdbdate").addClass("e8_btn_submit");
                    $("#checkdbdate").attr('disabled',false);
                    currentTask="任务执行完成,请下载导入导出文档,根据文档执行数据迁移";
                }

                if(taskStatus == "failure") {
                    currentTask = currentTask+"执行失败!";
                    $("#process").css("background-color","rgb(234, 137, 129)");

                } else if(taskStatus == "init"){//未开始执行任务
                    if(isexcute==0){
                        isexcute=1;
                        clearIntarvals();
                    }

                    $("#startExcute").removeClass("e8_btn_disabled");
                    $("#startExcute").addClass("e8_btn_submit");
                    $("#startExcute").attr('disabled',false);
                }else {
                    $("#startExcute").removeClass("e8_btn_submit");
                    $("#startExcute").addClass("e8_btn_disabled");
                    $("#startExcute").attr('disabled','disabled');
                    $("#process").css("background-color","#008000");
                    clearIntarvals();
                    initIntervals();//初始化定时器
                }

                printProcess(percent,currentTask,actionProcessName);

                for(var i = 0,l = detailStatus.length; i < l; i++){
                    var status = detailStatus[i]["status"];
                    // if(dbname.toLowerCase()=="sqlserver"){
                    //     if(detailStatus[i]["name"]=="生成导入导出文件");
                    // }
                    processClass =  getStatusClass(status);
                    needDisplay = getStatusDisplay(status);
                    processhtml = processhtml +
                        "<div class=\"processdiv\">"+
                        "<div class=\""+processClass+"\"></div><div class=\"processmsgdiv\">任务"+(i+1)+":"+detailStatus[i]["name"]+
                        "</div>";
                    processhtml = processhtml +"</div>";
                }
                $("#processcontent").html(processhtml);
                if(percent != undefined && parseInt(percent) == 100) {
                        clearIntarvals();
                }
            },
            error:function () {
                clearIntarvals();//清空定时器
                $.DialogByZ.Alert({Title: "提示", Content: "DataMigrationOperation.jsp异常",BtnL:"确定"});
            }
        });
    }

    //根据状态获得样式的class
    function getStatusClass(status) {
        var processClass = "";
        if("0" == status) {
            processClass = "none";
        } else if("1" == status) {
            processClass = "doing";
        } else if("2" == status) {
            processClass = "done";
        } else if("3" == status) {
            processClass = "error";
        }
        return processClass;
    }

    //根据状态判断是否显示详情
    function getStatusDisplay(status) {
        return  logshow=='0';

    }

    //进度信息
    function printProcess(percent,currentTask) {
        $("#process").width(percent+'%')
        $("#processInfo").text('当前进度:'+percent+'%')
        $("#currentThread").text('当前进程:'+currentTask)
    }

    //开始自动执行
    function  startExcute(){
        initDetailProcess();
        $.ajax({
            dataType:'json',
            type:'post',
            url:'DataMigrationOperation.jsp',
            data:{
                "operation":"autoexecute",
                "mainsequence":"<%=mainsequence%>"
            },
            success:function(data){
                if(data.task_status=='failure'){
                    clearIntarvals();//清空定时器
                    $.DialogByZ.Alert({Title: "提示", Content: "Action执行失败",BtnL:"确定"});
                    $("#continueExcute").css('visibility','visible');
                    return;
                } else {

                }
            },
            error:function () {
                clearIntarvals();//清空定时器
                $.DialogByZ.Alert({Title: "提示", Content: "MigrationftAerOperation异常",BtnL:"确定"});
            }
        });
        initIntervals();//初始化定时器
    }
    //初始化定时器
    function initIntervals() {
        var intervaltime  = 1000;
        detailProcessInterval = setInterval('initDetailProcess()',intervaltime);
    }
    //清空定时器
    function clearIntarvals() {
        clearInterval(detailProcessInterval);
    }

    //修改下一步按钮状态
    function changeBtnStatus() {
          $("#sqltable").css('visibility','visible');
        clearIntarvals();//清空定时器
    }

    function downDocdoc(en_name) {//执行文件下载,文件实际的路径的名字,文件下载的名字
        document.getElementById("downiframe").src = "/system/upgradetoe9/resource/"+en_name;
    }
    function downDoc(en_name,cn_name) {//执行文件下载,文件实际的路径的名字,文件下载的名字
        cn_name = encodeURIComponent(cn_name);
        document.getElementById("downiframe").src = "/system/upgradetoe9/fileDownload.jsp?en_name="+en_name+"&cn_name="+cn_name;
    }
    function next() {
        $.DialogByZ.Confirm({Title: "提示", Content: "确定已经根据导入导出操作文档将数据迁移完成?",BtnL:"确定",FunL:next2,BtnR:"取消"})
    }
    function next2(){
    	 $.DialogByZ.Close();
         if(dbname.toLowerCase()=="sqlserver"){//如果是sqlserver不要开启触发器
             nextstep2();//直接跳到下一步
         }else{
             $.DialogByZ.Confirm({Title: "提示", Content: "数据迁移完成,自动开启触发器?",BtnL:"确定",FunL:openTrigger,BtnR:"取消"})
         }

    }
    //开启触发器  ,并跳到下一个页面
    function openTrigger(){
        // $("#next").attr('disabled',true);
        // $("#next").removeClass("e8_btn_submit");
        // $("#next").addClass("e8_btn_disabled");
        $.DialogByZ.Close();
        $.DialogByZ.Stayfade({Title: "提示", Content: "正在开启触发器,请稍候"});

        if(isOpenTri==0) {
            isOpenTri = 1;
            $.ajax({
                sync: false,
                dataType: 'json',
                type: 'post',
                url: 'DataMigrationOperation.jsp?',
                data: {
                    'operation': 'opentrigger',
                },
                success: function (data) {
                    var status = data.status;
                    if (status == 'success') {
                        $.ajax({
                            sync: false,
                            dataType: 'json',
                            type: 'post',
                            url: 'MigrationMainOperation.jsp?method=updateMainStatus',
                            data: {
                                'currentStep': "<%=currentStep%>",
                                'status': "<%=ToolUtil.EXECUTE_STATUS_FIN%>",
                            },
                            success: function (data) {
                                $("#next").attr('disabled',false);
                                $("#next").removeClass("e8_btn_disabled");
                                $("#next").addClass("e8_btn_submit");
                                $(".zbox-toast-container").remove();
                            	$.DialogByZ.Close();
                                $.DialogByZ.Alert({Title: "提示", Content: "开启触发器成功", BtnL: "确定", FunL: nextstep1});

                            },
                            error: function () {
                                $("#next").attr('disabled',false);
                                $("#next").removeClass("e8_btn_disabled");
                                $("#next").addClass("e8_btn_submit");
                                $(".zbox-toast-container").remove();
                            	$.DialogByZ.Close();
                                $.DialogByZ.Alert({Title: "提示", Content: "开启触发器失败", BtnL: "确定"});
                            }
                        });
                    } else {
                        $("#next").attr('disabled',false);
                        $("#next").removeClass("e8_btn_disabled");
                        $("#next").addClass("e8_btn_submit");
                        $(".zbox-toast-container").remove();
                    	$.DialogByZ.Close();
                        $.DialogByZ.Alert({Title: "提示", Content: "开启触发器失败", BtnL: "确定"});
                    }
                },
                error: function () {
                    alert("请求失败");
                }
            });
        }

    }
   function nextstep1(){
       window.parent.location.href = "MigrationMain.jsp";
   }
   function nextstep2(){
       $.ajax({
           sync:false,
           dataType:'json',
           type:'post',
           url:'MigrationMainOperation.jsp?method=updateMainStatus',
           data:{
               'currentStep': "<%=currentStep%>",
               'status': "<%=ToolUtil.EXECUTE_STATUS_FIN%>",
           },
           success:function(data){
               window.parent.location.href = "MigrationMain.jsp";
           },
           error:function () {
               $.DialogByZ.Alert({Title: "提示", Content: "无法进入下一步操作",BtnL:"确定"});
           }
       });
   }
    //开启触发器
    function openTrigger1(){
        $.ajax({
            sync:false,
            dataType:'json',
            type:'post',
            url:'DataMigrationOperation.jsp?',
            data:{
                'operation': 'opentrigger',
            },
            success:function(data) {
                var status = data.status;
                if (status == 'success') {
                    $.DialogByZ.Alert({Title: "提示", Content: "开启触发器成功", BtnL: "确定"});
                }
            },
            error:function () {
                $.DialogByZ.Alert({Title: "提示", Content: "开启触发器失败", BtnL: "确定"});
            }
        });
    }
    function logfileload(){
        if(dbname.toLowerCase()=="oracle"){
            openDialog("日志文件提交","/system/upgradetoe9/MigrationUpLoadFile.jsp");
        }else{
            checkdbdate();
        }

    }
    function openDialog(title,url) {
        var dlg=new Dialog;//定义Dialog对象
        //var dlg=Dialog;
        dlg.currentWindow = Window;
        dlg.Model=true;
        dlg.Width=600;//定义长度
        dlg.Height=400;
        dlg.URL=url;
        dlg.Title=title;
        dlg.show();
    }
    //检查迁移数据
    function checkdbdate(){
        $("#sqltable").css('visibility','visible');
        $("#showcheckresult").css('visibility','visible');
        $.ajax({
            sync:false,
            dataType:'json',
            type:'post',
            url:'DataMigrationOperation.jsp',
            data:{
                'operation': 'datamigration2',
            },
            success:function(data){
                if( data.status==0){//无错误执行数据检测
                    $("#next").attr('disabled',false);
                    $("#next").removeClass("e8_btn_disabled");
                    $("#next").addClass("e8_btn_submit");
                    checkdata1();
                }else if(data.status==1){//有错误执行数据的二次迁移
                    $("#next").attr('disabled',false);
                    $("#next").removeClass("e8_btn_disabled");
                    $("#next").addClass("e8_btn_submit");
                    var resultstr1=""+
                        "                    <ul class=\"ullist\">\n" +
                        "                        <li class=\"listyle1\">文档1:&nbsp;<a href=\"javascript:void(0)\" onclick=\"downDoc('parfilesecond_exp.txt','Export2.txt')\">Export2.txt</a>&nbsp;该脚本用于导出原先未迁移成功的源数据&nbsp;<a href=\"javascript:void(0)\" title=\"下载文档\" onclick=\"downDoc('parfilesecond_exp.txt','Export2.txt')\"><img src=\"images/down_wev8.png\" style=\"width: 15px;height:13px\"></a></li>\n" +
                        "                        <li class=\"listyle1\">文档2:&nbsp;<a href=\"javascript:void(0)\" onclick=\"downDoc('parfilesecond_imp.txt','Import2.txt')\">Import2.txt</a>&nbsp;该脚本用于将源数据库导出未迁移成功的dmp数据文件导入目标数据库&nbsp;<a href=\"javascript:void(0)\" title=\"下载文档\" onclick=\"downDoc('parfilesecond_imp.txt','Import2.txt')\"><img src=\"images/down_wev8.png\" style=\"width: 15px;height:13px\"></a></li>\n" +
                        "                    </ul> ";

                    $("#checkresult").html(resultstr1);
                    $.DialogByZ.Alert({Title: "提示", Content: "部分导入数据出现问题,请下载脚本文件重新导入", BtnL: "确定"});
                }else if(data.status==3){//数据未上传
                    $.DialogByZ.Alert({Title: "提示", Content: "导入日志不存在,请重新上传", BtnL: "确定"});
                }
            },
            error:function () {
                $.DialogByZ.Alert({Title: "提示", Content: "解析数据库出现错误", BtnL: "确定"});

            }
        });


        // $.ajax({
        //     sync:false,
        //     dataType:'json',
        //     type:'post',
        //     url:'DataMigrationOperation.jsp?',
        //     data:{
        //         'operation': 'analyzetable',
        //     },
        //     success:function(data){
        //         checkdata1();
        //     },
        //     error:function () {
        //         $.DialogByZ.Alert({Title: "提示", Content: "解析数据库出现错误", BtnL: "确定"});
        //
        //     }
        // });
    }
    function checkdata1(){
        $("#checkedimg").attr('src','images/doing.gif');
        $("#checkresult").html("<h3 style=\"margin: 0px\">&nbsp; &nbsp; 数据对比中,需要1分钟左右。。。</h3>");
        $.ajax({
            sync:false,
            dataType:'json',
            type:'post',
            url:'DataMigrationOperation.jsp?',
            data:{
                'operation': 'checkdbdate',
            },
            success:function(data){
                var status = data.status;
                var resultstr=data.result;

                $("#next").attr('disabled',false);
                $("#next").removeClass("e8_btn_disabled");
                $("#next").addClass("e8_btn_submit");
                $("#sqltable").css('visibility','visible');
                $("#showcheckresult").css('visibility','visible');
                if(status==1){
                    $("#opentri").css('visibility','visible');
                    $("#checkresult").html(resultstr);
                    $("#checkedimg").attr('src','images/sysadmin_doc_wev8.png')
                }else{
                    $("#checkresult").html("<h3 style=\"margin: 0px\">&nbsp; &nbsp; 迁移数据比对无差异,数据迁移完成,请点击‘下一步’</h3>");
                    $("#checkedimg").attr('src','images/sysadmin_doc_wev8.png')
                }
            },
            error:function () {
                $("#closetri").attr('disabled',false);
                $("#closetri").removeClass("btn-disabled");
                $("#closetri").addClass("btn-success");
            }
        });
    }
    //关闭触发器
    function closeTrigger(){
        $.ajax({
            sync:false,
            dataType:'json',
            type:'post',
            url:'DataMigrationOperation.jsp?',
            data:{
                'operation': 'closetrigger',
            },
            success:function(data){
                var status = data.status;
                if(status=='success'){
                    $("#next").attr('disabled',false);
                    $("#next").removeClass("e8_btn_disabled");
                    $("#next").addClass("e8_btn_submit");

                    $("#closetri").attr('disabled',true);
                    $("#closetri").removeClass("e8_btn_submit");
                    $("#closetri").addClass("e8_btn_disabled");
                }
            },
            error:function () {
                $("#closetri").attr('disabled',false);
                $("#closetri").removeClass("e8_btn_disabled");
                $("#closetri").addClass("e8_btn_submit");
            }
        });
    }

    function continueExcute1(){
        $.DialogByZ.Confirm({Title: "提示", Content: "确定可以跳过这个Action?",BtnL:"确定",FunL:continueExcete2,BtnR:"取消"})
    }
    function continueExcete2(){
        $.DialogByZ.Close();
        $.ajax({
            sync:false,
            dataType:'json',
            type:'post',
            url:'InitDatabaseOperation.jsp',
            data:{
                "method":"continueAction",
                "mainsequence":"<%=mainsequence%>"
            },
            success:function(data){
                if(data.status=="0"){
                    $("#continueExcute").css('visibility','hidden');
                    startExcute();

                }else{
                    $.DialogByZ.Alert({Title: "提示", Content: "continueExceute Action 出现异常",BtnL:"确定"});
                }
            },
            error:function () {
                $.DialogByZ.Alert({Title: "提示", Content: "continueExceute Action 出现异常",BtnL:"确定"});
            }
        });
    }
</script>