コード例 #1
0
ファイル: BatchTaskForm.cs プロジェクト: pxmarc/dp2
        void DoRefresh()
        {
            this.m_lock.AcquireWriterLock(m_nLockTimeout);
            this.m_nInRefresh++;
            this.toolStripButton_refresh.Enabled = false;
            // this.EnableControls(false);
            try
            {
                string strError = "";

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在获取任务 '" + MonitorTaskName + "' 的最新信息 ...");
                stop.BeginLoop();

                try
                {
                    for (int i = 0; i < 10; i++)  // 最多循环获取10次
                    {
                        Application.DoEvents();
                        if (stop != null && stop.State != 0)
                        {
                            strError = "用户中断";
                            goto ERROR1;
                        }

                        BatchTaskInfo param      = new BatchTaskInfo();
                        BatchTaskInfo resultInfo = null;

                        if ((this.MessageStyle & MessageStyle.Result) == 0)
                        {
                            param.MaxResultBytes = 0;
                        }
                        else
                        {
                            param.MaxResultBytes = 4096;
                            if (i >= 5)  // 如果发现尚未来得及获取的内容太多,就及时扩大“窗口”尺寸
                            {
                                param.MaxResultBytes = 100 * 1024;
                            }
                        }

                        param.ResultOffset = this.CurResultOffs;

                        stop.SetMessage("正在获取任务 '" + MonitorTaskName + "' 的最新信息 (第 " + (i + 1).ToString() + " 批 共10批)...");

                        long lRet = Channel.BatchTask(
                            stop,
                            MonitorTaskName,
                            "getinfo",
                            param,
                            out resultInfo,
                            out strError);
                        if (lRet == -1)
                        {
                            goto ERROR1;
                        }

                        Global.WriteHtml(this.webBrowser_info,
                                         GetResultText(resultInfo.ResultText));
                        ScrollToEnd();

                        // DateTime now = DateTime.Now;

                        if ((this.MessageStyle & MessageStyle.Progress) != 0)
                        {
                            this.label_progress.Text = // now.ToLongTimeString() + " -- " +
                                                       resultInfo.ProgressText;
                        }

                        if ((this.MessageStyle & MessageStyle.Result) == 0)
                        {
                            // 没有必要显示累积
                            break;
                        }

                        if (this.CurResultOffs == 0)
                        {
                            this.CurResultVersion = resultInfo.ResultVersion;
                        }
                        else if (this.CurResultVersion != resultInfo.ResultVersion)
                        {
                            // 说明服务器端result文件其实已经更换
                            this.CurResultOffs = 0; // rewind
                            Global.WriteHtml(this.webBrowser_info,
                                             "***新内容 version=" + resultInfo.ResultVersion.ToString() + " ***\r\n");
                            ScrollToEnd();
                            goto COINTINU1;
                        }

                        if (resultInfo.ResultTotalLength < param.ResultOffset)
                        {
                            // 说明服务器端result文件其实已经更换
                            this.CurResultOffs = 0; // rewind
                            Global.WriteHtml(this.webBrowser_info,
                                             "***新内容***\r\n");
                            ScrollToEnd();
                            goto COINTINU1;
                        }
                        else
                        {
                            // 存储用以下次
                            this.CurResultOffs = resultInfo.ResultOffset;
                        }

COINTINU1:
                        // 如果本次并没有“触底”,需要立即循环获取新的信息。但是循环有一个最大次数,以应对服务器疯狂发生信息的情形。
                        if (resultInfo.ResultOffset >= resultInfo.ResultTotalLength)
                        {
                            break;
                        }
                    }
                }
                finally
                {
                    this.toolStripButton_refresh.Enabled = true;
                    // this.EnableControls(true);
                    this.m_nInRefresh--;
                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");
                }

                return;

ERROR1:
                this.label_progress.Text = strError;
            }
            finally
            {
                this.m_lock.ReleaseWriterLock();
            }
        }
コード例 #2
0
ファイル: BatchTaskForm.cs プロジェクト: pxmarc/dp2
        // 停止批处理任务
        // parameters:
        //      strAction   "stop"或者"abort"
        int StopBatchTask(string strTaskName,
                          string strAction,
                          out string strError)
        {
            strError = "";

            if (string.IsNullOrEmpty(strAction))
            {
                strAction = "stop";
            }

            Debug.Assert(strAction == "stop" || strAction == "abort", "");

            this.m_lock.AcquireWriterLock(m_nLockTimeout);

            try
            {
                EnableControls(false);

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

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

                try
                {
                    BatchTaskInfo param      = new BatchTaskInfo();
                    BatchTaskInfo resultInfo = null;

                    long lRet = Channel.BatchTask(
                        stop,
                        strTaskName,
                        strAction,  // "stop",
                        param,
                        out resultInfo,
                        out strError);
                    if (lRet == -1)
                    {
                        goto ERROR1;
                    }

                    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();
            }
        }
コード例 #3
0
ファイル: BatchTaskForm.cs プロジェクト: pxmarc/dp2
        // 暂停批处理任务
        int PauseAllBatchTask(out string strError)
        {
            strError = "";

            BatchTaskStartInfo startinfo = new BatchTaskStartInfo();

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

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在暂停全部批处理任务 ...");
                stop.BeginLoop();

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

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

                    BatchTaskInfo resultInfo = null;

                    long lRet = Channel.BatchTask(
                        stop,
                        "",
                        "pause",
                        param,
                        out resultInfo,
                        out strError);
                    if (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();
            }
        }
コード例 #4
0
ファイル: BatchTaskMonitor.aspx.cs プロジェクト: gvhung/dp2
    protected void Page_Load(object sender, EventArgs e)
    {
        // Debug.WriteLine("Page_Load()");

        if (WebUtil.PrepareEnvironment(this,
                                       ref app,
                                       ref sessioninfo) == false)
        {
            return;
        }

        string strError = "";

        // 是否登录?
        if (sessioninfo.UserID == "")
        {
            if (this.Page.Request["forcelogin"] == "on")
            {
                sessioninfo.LoginCallStack.Push(Request.RawUrl);
                Response.Redirect("login.aspx", true);
                return;
            }
            if (this.Page.Request["forcelogin"] == "userid")
            {
                sessioninfo.LoginCallStack.Push(Request.RawUrl);
                Response.Redirect("login.aspx?loginstyle=librarian", true);
                return;
            }
            sessioninfo.LoginCallStack.Push(Request.RawUrl);
            Response.Redirect("login.aspx", true);
            return;
        }

        LoginState loginstate = GlobalUtil.GetLoginState(this.Page);

        if (loginstate != LoginState.Librarian)
        {
            strError = "只有工作人员身份才能使用本模块";
            goto ERROR1;
        }

        string strAction = this.Request["action"];

        string strName = this.Request["name"];

        if (string.IsNullOrEmpty(strName) == true)
        {
            strName = "CacheBuilder";
        }

        this.Label_taskName.Text = strName;

        ResultInfo result_info = new ResultInfo();

        if (strAction == "getinfo")
        {
            string strResultOffset   = this.Request["result_offset"];
            string strMaxResultBytes = this.Request["max_result_bytes"];

            if (string.IsNullOrEmpty(strResultOffset) == true)
            {
                result_info.ErrorString = "未指定 result_offset 参数";
                goto END1;
            }
            long lResultOffset = 0;
            Int64.TryParse(strResultOffset, out lResultOffset);
            int nMaxResultBytes = 4096;
            Int32.TryParse(strMaxResultBytes, out nMaxResultBytes);

            BatchTaskInfo param = new BatchTaskInfo();
            BatchTaskInfo info  = null;

            param.ResultOffset   = lResultOffset;
            param.MaxResultBytes = nMaxResultBytes;

            Debug.WriteLine("GetBatchTaskInfo()");

            int nRet = app.GetBatchTaskInfo(strName,
                                            param,
                                            out info,
                                            out strError);
            if (nRet == -1)
            {
                result_info.ErrorString = strError;
                goto END1;
            }

            result_info.Name              = info.Name;
            result_info.MaxResultBytes    = info.MaxResultBytes;
            result_info.ResultText        = GetResultText(info.ResultText);
            result_info.ProgressText      = info.ProgressText;
            result_info.ResultOffset      = info.ResultOffset;
            result_info.ResultTotalLength = info.ResultTotalLength;
            result_info.ResultVersion     = info.ResultVersion;

END1:
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ResultInfo));

            using (MemoryStream ms = new MemoryStream())
            {
                ser.WriteObject(ms, result_info);
                string strResult = Encoding.UTF8.GetString(ms.ToArray());
                this.Response.Write(strResult);
                this.Response.End();
            }
            return;
        }

        return;

ERROR1:
        this.Response.Write(strError);
        this.Response.End();
    }
コード例 #5
0
ファイル: BatchTaskForm.cs プロジェクト: pxmarc/dp2
        // 启动批处理任务
        // parameters:
        // return:
        //      -1  出错
        //      1   成功。strError 里面有提示成功的内容
        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);
                }
            }
            else if (strTaskName == "服务器同步")
            {
                StartServerReplicationDlg dlg = new StartServerReplicationDlg();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.Text      = "启动 服务器同步 任务";
                dlg.TaskName  = "服务器同步";
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }
            }
            else if (strTaskName == "大备份")
            {
                if (StringUtil.CompareVersion(Program.MainForm.ServerVersion, "2.117") < 0)
                {
                    strError = "dp2library 应在 2.117 版以上才能使用“大备份”任务相关的功能";
                    return(-1);
                }

                StartBackupDialog dlg = new StartBackupDialog();
                MainForm.SetControlFont(dlg, this.Font, false);
                dlg.StartInfo = startinfo;
                dlg.ShowDialog(this);
                if (dlg.DialogResult == System.Windows.Forms.DialogResult.Abort)
                {
                    if (StopBatchTask(strTaskName,
                                      "abort",
                                      out strError) == -1)
                    {
                        return(-1);
                    }
                    strError = "任务 '" + strTaskName + "' 已被撤销";
                    return(1);
                }
                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户放弃启动";
                    return(-1);
                }

                // 2017/9/30
                if (dlg.DownloadFiles)
                {
                    if (StringUtil.IsInList("download", MainForm._currentUserRights) == false)
                    {
                        strError = "启动“大备份”任务被拒绝。当前用户并不具备 download 权限,所以无法在大备份同时下载文件。请先为当前用户添加这个权限,再重新启动大备份任务";
                        return(-1);
                    }
                }
            }
            else if (strTaskName == "<日志备份>")
            {
                string strOutputFolder = "";

                // 备份日志文件。即,把日志文件从服务器拷贝到本地目录。要处理好增量复制的问题。
                // return:
                //      -1  出错
                //      0   放弃下载,或者没有必要下载。提示信息在 strError 中
                //      1   成功启动了下载
                int nRet = Program.MainForm.BackupOperLogFiles(ref strOutputFolder,
                                                               out strError);
                if (nRet != 1)
                {
                    if (nRet == 0 && string.IsNullOrEmpty(strError))
                    {
                        strError = "用户放弃启动";
                    }
                    return(-1);
                }
                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();
                Program.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;

                    if (strTaskName == "大备份" &&
                        resultInfo.StartInfo != null)
                    {
                        string        strOutputFolder = "";
                        List <string> paths           = StringUtil.SplitList(resultInfo.StartInfo.OutputParam);

                        StringUtil.RemoveBlank(ref paths);

                        List <dp2Circulation.MainForm.DownloadFileInfo> infos = MainForm.BuildDownloadInfoList(paths);

                        bool bAppend = false;
                        // 询问是否覆盖已有的目标下载文件。整体询问
                        // return:
                        //      -1  出错
                        //      0   放弃下载
                        //      1   同意启动下载
                        int nRet = Program.MainForm.AskOverwriteFiles(infos,    // paths,
                                                                      ref strOutputFolder,
                                                                      out bAppend,
                                                                      out strError);
                        if (nRet == -1)
                        {
                            return(-1);
                        }
                        if (nRet == 1)
                        {
                            paths = MainForm.GetFileNames(infos, (info) =>
                            {
                                return(info.ServerPath);
                            });
                            foreach (string path in paths)
                            {
                                if (string.IsNullOrEmpty(path) == false)
                                {
                                    // parameters:
                                    //      strOutputFolder 输出目录。
                                    //                      [in] 如果为 null,表示要弹出对话框询问目录。如果不为 null,则直接使用这个目录路径
                                    //                      [out] 实际使用的目录
                                    // return:
                                    //      -1  出错
                                    //      0   放弃下载
                                    //      1   成功启动了下载
                                    nRet = Program.MainForm.BeginDownloadFile(path,
                                                                              bAppend ? "append" : "overwrite",
                                                                              ref strOutputFolder,
                                                                              out strError);
                                    if (nRet == -1)
                                    {
                                        return(-1);
                                    }
                                    if (nRet == 0)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");

                    EnableControls(true);
                }

                strError = "任务 '" + strTaskName + "' 已成功启动";
                return(1);

ERROR1:
                return(-1);
            }
            finally
            {
                this.m_lock.ReleaseWriterLock();
            }
        }
コード例 #6
0
ファイル: BatchTaskForm.cs プロジェクト: renyh1013/dp2
        void DoRefresh()
        {
            this.m_lock.AcquireWriterLock(m_nLockTimeout);
            this.m_nInRefresh++;
            this.toolStripButton_refresh.Enabled = false;
            // this.EnableControls(false);
            try
            {
                string strError = "";

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在获取任务 '" + MonitorTaskName + "' 的最新信息 ...");
                stop.BeginLoop();

                try
                {

                    for (int i = 0; i < 10; i++)  // 最多循环获取10次
                    {
                        Application.DoEvents();
                        if (stop != null && stop.State != 0)
                        {
                            strError = "用户中断";
                            goto ERROR1;
                        }

                        BatchTaskInfo param = new BatchTaskInfo();
                        BatchTaskInfo resultInfo = null;

                        if ((this.MessageStyle & MessageStyle.Result) == 0)
                        {
                            param.MaxResultBytes = 0;
                        }
                        else
                        {
                            param.MaxResultBytes = 4096;
                            if (i >= 5)  // 如果发现尚未来得及获取的内容太多,就及时扩大“窗口”尺寸
                                param.MaxResultBytes = 100 * 1024;
                        }

                        param.ResultOffset = this.CurResultOffs;

                        stop.SetMessage("正在获取任务 '" + MonitorTaskName + "' 的最新信息 (第 " + (i + 1).ToString() + " 批 共10批)...");

                        long lRet = Channel.BatchTask(
                            stop,
                            MonitorTaskName,
                            "getinfo",
                            param,
                            out resultInfo,
                            out strError);
                        if (lRet == -1)
                            goto ERROR1;

                        Global.WriteHtml(this.webBrowser_info,
                            GetResultText(resultInfo.ResultText));
                        ScrollToEnd();

                        // DateTime now = DateTime.Now;

                        if ((this.MessageStyle & MessageStyle.Progress) != 0)
                        {
                            this.label_progress.Text = // now.ToLongTimeString() + " -- " + 
                                resultInfo.ProgressText;
                        }

                        if ((this.MessageStyle & MessageStyle.Result) == 0)
                        {
                            // 没有必要显示累积
                            break;
                        }

                        if (this.CurResultOffs == 0)
                            this.CurResultVersion = resultInfo.ResultVersion;
                        else if (this.CurResultVersion != resultInfo.ResultVersion)
                        {
                            // 说明服务器端result文件其实已经更换
                            this.CurResultOffs = 0; // rewind
                            Global.WriteHtml(this.webBrowser_info,
                                "***新内容 version=" + resultInfo.ResultVersion.ToString() + " ***\r\n");
                            ScrollToEnd();
                            goto COINTINU1;
                        }

                        if (resultInfo.ResultTotalLength < param.ResultOffset)
                        {
                            // 说明服务器端result文件其实已经更换
                            this.CurResultOffs = 0; // rewind
                            Global.WriteHtml(this.webBrowser_info,
                                "***新内容***\r\n");
                            ScrollToEnd();
                            goto COINTINU1;
                        }
                        else
                        {
                            // 存储用以下次
                            this.CurResultOffs = resultInfo.ResultOffset;
                        }

                    COINTINU1:
                        // 如果本次并没有“触底”,需要立即循环获取新的信息。但是循环有一个最大次数,以应对服务器疯狂发生信息的情形。
                        if (resultInfo.ResultOffset >= resultInfo.ResultTotalLength)
                            break;
                    }
                }
                finally
                {
                    this.toolStripButton_refresh.Enabled = true;
                    // this.EnableControls(true);
                    this.m_nInRefresh--;
                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");
                }

                return;
            ERROR1:
                this.label_progress.Text = strError;
            }
            finally
            {
                this.m_lock.ReleaseWriterLock();
            }
        }
コード例 #7
0
ファイル: BatchTaskForm.cs プロジェクト: renyh1013/dp2
        // 暂停批处理任务
        int PauseAllBatchTask(out string strError)
        {
            strError = "";

            BatchTaskStartInfo startinfo = new BatchTaskStartInfo();

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

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在暂停全部批处理任务 ...");
                stop.BeginLoop();

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

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

                    BatchTaskInfo resultInfo = null;

                    long lRet = Channel.BatchTask(
                        stop,
                        "",
                        "pause",
                        param,
                        out resultInfo,
                        out strError);
                    if (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();
            }
        }
コード例 #8
0
ファイル: BatchTaskForm.cs プロジェクト: renyh1013/dp2
        // 停止批处理任务
        int StopBatchTask(string strTaskName,
            out string strError)
        {
            strError = "";

            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();
                    BatchTaskInfo resultInfo = null;

                    long lRet = Channel.BatchTask(
                        stop,
                        strTaskName,
                        "stop",
                        param,
                        out resultInfo,
                        out strError);
                    if (lRet == -1)
                        goto ERROR1;

                    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();
            }
        }
コード例 #9
0
ファイル: BatchTaskForm.cs プロジェクト: renyh1013/dp2
        // 启动批处理任务
        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();
            }
        }
コード例 #10
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();
            }
        }