日期:2014-05-18  浏览次数:20461 次

这个页面执行完毕后IE自动关闭是怎么实现的。
功能是每隔一段时间(通过任务计划实现)服务器自动打开这个页面,然后自动备份数据并打压缩包,再自动传送到ftp服务器上去。
目前我不能执行这个页面,但是他可以完成后自动关闭,我看了代码,不知道为什么会自动把IE关闭掉。
后台代码:(前台没任何特殊性)
C# code
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;
using System.Net;

public partial class BackupDB_Default : System.Web.UI.Page
{
    #region Define Variables
    bool isSuccess = false;

    string ftpServerIP = "101.101.10.104";//Remote Server
    int ftpPort = 21;
    string ftpUserID = "T";
    string ftpPassword = "abcdef11";

    string pBackupDBAndCompressFilesPath = @"D:\DataCenter";
    string pBackupDBFileName = "Iridian2#168EW@370$.bak";
    string pCompressFileName = "Iridian2#168EW@370$.rar";
    #endregion

    #region Page_Load
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Directory.Exists(pBackupDBAndCompressFilesPath))
                BackupDatabase();
        }
    }
    #endregion

    #region BackupDatabase
    private void BackupDatabase()
    {
        //SQLDMO.dll is a COM Object ,Microsoft SQl Server provider
        SQLDMO.Backup pBackup = new SQLDMO.BackupClass();
        SQLDMO.SQLServer pSqlServer = new SQLDMO.SQLServerClass();

        try
        {
            pSqlServer.LoginSecure = false;
            pSqlServer.Connect("110.110.10.5", "sa", "1111");//Server IP,Database Login UserName and Password
            pBackup.Action = SQLDMO.SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database;
            pBackup.Database = "Iridian2";
            pBackup.Files = pBackupDBAndCompressFilesPath + "\\" + pBackupDBFileName;
            pBackup.BackupSetName = "Iridian2";
            pBackup.BackupSetDescription = "Database Backup";
            pBackup.Initialize = true;
            pBackup.SQLBackup(pSqlServer);
            isSuccess = true;
        }
        catch (Exception ex)
        {
            isSuccess = false;
            Response.Write(ex.Message);
        }
        finally
        {
            pSqlServer.DisConnect();

            if (isSuccess)
            {
                bool isCompressSuccess = false;

                if (File.Exists(pBackupDBAndCompressFilesPath + "\\" + pBackupDBFileName))
                    isCompressSuccess = CompressDBBackupFile(pBackupDBAndCompressFilesPath + "\\" + pBackupDBFileName, pBackupDBAndCompressFilesPath, pCompressFileName);

                if (isCompressSuccess)
                SendZipFileToAnotherComputer(pCompressFileName);
            }
        }
    }
    #endregion

    #region CompressDBBackupFile
    private bool CompressDBBackupFile(string patch, string rarPatch, string rarName)
    {
        bool excuteSuccess = false;
        String the_Info;
        ProcessStartInfo the_StartInfo;
        Process the_Process = new Process();
        try
        {
            the_Info = " a    " + rarName + "  " + patch + "  -r  -o+  -m5  -pEW#123@";//Set Password:EW#123@
            the_StartInfo = new ProcessStartInfo();
            the_StartInfo.FileName = @"C:\Program Files\WinRAR\WinRAR.exe";//Winrar install path
            the_StartInfo.Arguments = the_Info;
            the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            the_StartInfo.WorkingDirectory = rarPatch;
            the_Process.StartInfo = the_StartInfo;
            the_Process.Start();
            excuteSuccess = true;
        }
        catch (Exception ex)
        {
            excuteSucce