Ejemplo n.º 1
0
        // 启动批处理任务
        int StartBatchTask(string strTaskName,
            out string strError)
        {
            strError = "";

            BatchTaskStartInfo startinfo = new BatchTaskStartInfo();
            if (strTaskName == "日志恢复")
            {
                StartLogRecoverDlg dlg = new StartLogRecoverDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return -1;
                }
            }
            else if (strTaskName == "dp2Library 同步")
            {
                StartReplicationDlg dlg = new StartReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return -1;
                }
            }
            else if (strTaskName == "重建检索点")
            {
                StartRebuildKeysDlg dlg = new StartRebuildKeysDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return -1;
                }
            }
            else if (strTaskName == "预约到书管理")
            {
                StartArriveMonitorDlg dlg = new StartArriveMonitorDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return -1;
                }
            }
            /*
        else if (strTaskName == "跟踪DTLP数据库")
        {
            StartTraceDtlpDlg dlg = new StartTraceDtlpDlg();
        MainForm.SetControlFont(dlg, this.Font, false);
            dlg.StartInfo = startinfo;
            dlg.ShowDialog(this);
            if (dlg.DialogResult != DialogResult.OK)
            {
                strError = "用户放弃启动";
                return -1;
            }
        }
             * */
            else if (strTaskName == "正元一卡通读者信息同步")
            {
                StartZhengyuanReplicationDlg dlg = new StartZhengyuanReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return -1;
                }
            }
            else if (strTaskName == "迪科远望一卡通读者信息同步")
            {
                StartDkywReplicationDlg dlg = new StartDkywReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                startinfo.Start = "!breakpoint";    // 一开始就有适当的缺省值,避免从头开始跟踪
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return -1;
                }
            }
            else if (strTaskName == "读者信息同步")
            {
#if NO
                StartPatronReplicationDlg dlg = new StartPatronReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                startinfo.Start = "!breakpoint";    // 一开始就有适当的缺省值,避免从头开始跟踪
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return -1;
                }
#endif
                startinfo.Start = "activate";   // 表示立即启动,忽略服务器原有定时启动参数
            }
            else if (strTaskName == "超期通知")
            {
                startinfo.Start = "activate";   // 表示立即启动,忽略服务器原有定时启动参数
            }
            else if (strTaskName == "创建 MongoDB 日志库")
            {
                StartLogRecoverDlg dlg = new StartLogRecoverDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.Text = "启动 创建 MongoDB 日志库 任务";
                dlg.TaskName = "创建 MongoDB 日志库";
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return -1;
                }
            }

            this.m_lock.AcquireWriterLock(m_nLockTimeout);
            try
            {
                EnableControls(false);

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在"
                    + "启动"
                    + "任务 '" + strTaskName + "' ...");
                stop.BeginLoop();

                this.Update();
                this.MainForm.Update();

                try
                {
                    BatchTaskInfo param = new BatchTaskInfo();
                    param.StartInfo = startinfo;

                    BatchTaskInfo resultInfo = null;

                    // return:
                    //      -1  出错
                    //      0   启动成功
                    //      1   调用前任务已经处于执行状态,本次调用激活了这个任务
                    long lRet = Channel.BatchTask(
                        stop,
                        strTaskName,
                        "start",
                        param,
                        out resultInfo,
                        out strError);
                    if (lRet == -1 || lRet == 1)
                        goto ERROR1;

                    if (resultInfo != null)
                    {
                        Global.WriteHtml(this.webBrowser_info,
                            GetResultText(resultInfo.ResultText));
                        ScrollToEnd();
                    }

                    this.label_progress.Text = resultInfo.ProgressText;
                }
                finally
                {
                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");

                    EnableControls(true);
                }

                return 1;
            ERROR1:
                return -1;
            }
            finally
            {
                this.m_lock.ReleaseWriterLock();
            }
        }
Ejemplo n.º 2
0
        // 启动批处理任务
        int StartBatchTask(string strTaskName,
                           out string strError)
        {
            strError = "";

            BatchTaskStartInfo startinfo = new BatchTaskStartInfo();

            if (strTaskName == "日志恢复")
            {
                StartLogRecoverDlg dlg = new StartLogRecoverDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
            }
            else if (strTaskName == "dp2Library 同步")
            {
                StartReplicationDlg dlg = new StartReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
            }
            else if (strTaskName == "重建检索点")
            {
                StartRebuildKeysDlg dlg = new StartRebuildKeysDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
            }
            else if (strTaskName == "预约到书管理")
            {
                StartArriveMonitorDlg dlg = new StartArriveMonitorDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
            }

            /*
             * else if (strTaskName == "跟踪DTLP数据库")
             * {
             * StartTraceDtlpDlg dlg = new StartTraceDtlpDlg();
             * MainForm.SetControlFont(dlg, this.Font, false);
             * dlg.StartInfo = startinfo;
             * dlg.ShowDialog(this);
             * if (dlg.DialogResult != DialogResult.OK)
             * {
             *  strError = "用户放弃启动";
             *  return -1;
             * }
             * }
             * */
            else if (strTaskName == "正元一卡通读者信息同步")
            {
                StartZhengyuanReplicationDlg dlg = new StartZhengyuanReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
            }
            else if (strTaskName == "迪科远望一卡通读者信息同步")
            {
                StartDkywReplicationDlg dlg = new StartDkywReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                startinfo.Start = "!breakpoint";    // 一开始就有适当的缺省值,避免从头开始跟踪
                dlg.StartInfo   = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
            }
            else if (strTaskName == "读者信息同步")
            {
#if NO
                StartPatronReplicationDlg dlg = new StartPatronReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                startinfo.Start = "!breakpoint";    // 一开始就有适当的缺省值,避免从头开始跟踪
                dlg.StartInfo   = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
#endif
                startinfo.Start = "activate";   // 表示立即启动,忽略服务器原有定时启动参数
            }
            else if (strTaskName == "超期通知")
            {
                startinfo.Start = "activate";   // 表示立即启动,忽略服务器原有定时启动参数
            }
            else if (strTaskName == "创建 MongoDB 日志库")
            {
                StartLogRecoverDlg dlg = new StartLogRecoverDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.Text      = "启动 创建 MongoDB 日志库 任务";
                dlg.TaskName  = "创建 MongoDB 日志库";
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
            }

            this.m_lock.AcquireWriterLock(m_nLockTimeout);
            try
            {
                EnableControls(false);

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在"
                             + "启动"
                             + "任务 '" + strTaskName + "' ...");
                stop.BeginLoop();

                this.Update();
                this.MainForm.Update();

                try
                {
                    BatchTaskInfo param = new BatchTaskInfo();
                    param.StartInfo = startinfo;

                    BatchTaskInfo resultInfo = null;

                    // return:
                    //      -1  出错
                    //      0   启动成功
                    //      1   调用前任务已经处于执行状态,本次调用激活了这个任务
                    long lRet = Channel.BatchTask(
                        stop,
                        strTaskName,
                        "start",
                        param,
                        out resultInfo,
                        out strError);
                    if (lRet == -1 || lRet == 1)
                    {
                        goto ERROR1;
                    }

                    if (resultInfo != null)
                    {
                        Global.WriteHtml(this.webBrowser_info,
                                         GetResultText(resultInfo.ResultText));
                        ScrollToEnd();
                    }

                    this.label_progress.Text = resultInfo.ProgressText;
                }
                finally
                {
                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");

                    EnableControls(true);
                }

                return(1);

ERROR1:
                return(-1);
            }
            finally
            {
                this.m_lock.ReleaseWriterLock();
            }
        }