当前位置: 首页>>代码示例>>C#>>正文


C# Stop.EndLoop方法代码示例

本文整理汇总了C#中DigitalPlatform.Stop.EndLoop方法的典型用法代码示例。如果您正苦于以下问题:C# Stop.EndLoop方法的具体用法?C# Stop.EndLoop怎么用?C# Stop.EndLoop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DigitalPlatform.Stop的用法示例。


在下文中一共展示了Stop.EndLoop方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchAllLocation


//.........这里部分代码省略.........
                    {
#if NO
                        strError = "not found";
                        return 0;   // not found
#endif 
                        continue;
                    }
                    if (lRet == -1)
                        return -1;

                    long lHitCount = lRet;

                    long lStart = 0;
                    long lCount = lHitCount;
                    DigitalPlatform.CirculationClient.localhost.Record[] searchresults = null;

                    // 装入浏览格式
                    for (; ; )
                    {
                        Application.DoEvents();	// 出让界面控制权

                        if (stop != null && stop.State != 0)
                        {
                            strError = "用户中断";
                            return -1;
                        }

                        lRet = channel.GetSearchResult(
                            stop,
                            "batchno",   // strResultSetName
                            lStart,
                            lCount,
                            "keycount",
                            "zh",
                            out searchresults,
                            out strError);
                        if (lRet == -1)
                        {
                            strError = "GetSearchResult() error: " + strError;
                            return -1;
                        }

                        if (lRet == 0)
                        {
                            // MessageBox.Show(this, "未命中");
                            continue;
                        }

                        // 处理浏览结果
                        foreach (Record record in searchresults)
                        {
                            if (record.Cols == null)
                            {
                                strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出馆藏地的功能";
                                return -1;
                            }

                            if (this._libraryCodeList.Count > 0 
                                && MatchLibraryCode(this._libraryCodeList, record.Path) == false)
                                continue;

                            // 跳过数字为 0 的事项
                            if (record.Cols.Length > 0 && record.Cols[0] == "0")
                                continue;

                            ListViewItem item = new ListViewItem();
                            item.Text = string.IsNullOrEmpty(record.Path) == false ? record.Path : "[空]";
                            ListViewUtil.ChangeItemText(item, 1, record.Cols[0]);

                            this.listView_records.Items.Add(item);
                        }

                        lStart += searchresults.Length;
                        lCount -= searchresults.Length;

                        stop.SetMessage("共命中 " + (lTotalCount + lHitCount).ToString() + " 条,已装入 " + (lTotalCount + lStart).ToString() + " 条");

                        if (lStart >= lHitCount || lCount <= 0)
                            break;
                    }

                    lTotalCount += lHitCount;
                }

                if (lTotalCount == 0)
                {
                    strError = "not found";
                    return 0;
                }
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(channel.DoStop);
                stop.Initial("");

                // EnableControls(true);
            }
            return 1;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:SelectBatchNoDialog.cs

示例2: SearchAllBatchNo


//.........这里部分代码省略.........
                        + StringUtil.GetXmlStringSimple("")
                        + "</word><match>left</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang>";
                strQueryXml += "<operator value='OR' />";
                strQueryXml += "<item><word>"
        + StringUtil.GetXmlStringSimple("")
        + "</word><match>exact</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang></target>";
#endif

                long lRet = channel.Search(
                    stop,
                    text.ToString(),
                    "batchno",
                    "keycount", // strOutputStyle
                    out strError);
                if (lRet == 0)
                {
                    strError = "not found";
                    return 0;   // not found
                }
                if (lRet == -1)
                    return -1;

                long lHitCount = lRet;

                long lStart = 0;
                long lCount = lHitCount;
                DigitalPlatform.CirculationClient.localhost.Record[] searchresults = null;

                // 装入浏览格式
                for (; ; )
                {
                    Application.DoEvents();	// 出让界面控制权

                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        return -1;
                    }

                    lRet = channel.GetSearchResult(
                        stop,
                        "batchno",   // strResultSetName
                        lStart,
                        lCount,
                        "keycount",
                        "zh",
                        out searchresults,
                        out strError);
                    if (lRet == -1)
                    {
                        strError = "GetSearchResult() error: " + strError;
                        return -1;
                    }

                    if (lRet == 0)
                    {
                        // MessageBox.Show(this, "未命中");
                        return 0;
                    }

                    // 处理浏览结果
                    foreach (Record record in searchresults)
                    {
                        if (record.Cols == null)
                        {
                            strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出批次号的功能";
                            return -1;
                        }

                        // 跳过数字为 0 的事项
                        if (record.Cols.Length > 0 && record.Cols[0] == "0")
                            continue;

                        ListViewItem item = new ListViewItem();
                        item.Text = string.IsNullOrEmpty(record.Path) == false ? record.Path : "[空]";
                        ListViewUtil.ChangeItemText(item, 1, record.Cols[0]);

                        this.listView_records.Items.Add(item);
                    }

                    lStart += searchresults.Length;
                    lCount -= searchresults.Length;

                    stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条");

                    if (lStart >= lHitCount || lCount <= 0)
                        break;
                }

            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(channel.DoStop);
                stop.Initial("");

                // EnableControls(true);
            }
            return 1;
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:SelectBatchNoDialog.cs

示例3: ProcessSelectedRecords

        int ProcessSelectedRecords(Delegate_processLog func,
            out string strError)
        {
            strError = "";

            if (this.listView_records.SelectedItems.Count == 0)
            {
                strError = "尚未选定要处理的行";
                return -1;
            }

            Stop stop = new DigitalPlatform.Stop();
            stop.Register(MainForm.stopManager, true);	// 和容器关联

            stop.OnStop += new StopEventHandler(this.DoStopPrint);
            stop.Initial("正在处理日志记录 ...");
            stop.BeginLoop();

            try
            {
                stop.SetProgressRange(0, this.listView_records.SelectedItems.Count);
                int i = 0;
                foreach (ListViewItem item in this.listView_records.SelectedItems)
                {
                    Application.DoEvents();

                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        return -1;
                    }

                    OperLogItemInfo info = (OperLogItemInfo)item.Tag;

                    string strLogFileName = ListViewUtil.GetItemText(item, COLUMN_FILENAME);
                    string strIndex = ListViewUtil.GetItemText(item, COLUMN_INDEX);

                    string strXml = "";
                    // 从服务器获得
                    // return:
                    //      -1  出错
                    //      0   正常
                    //      1   用户中断
                    int nRet = GetXml(item,
            out strXml,
            out strError);
                    if (nRet == 1)
                        return -1;
                    if (nRet == -1)
                        return -1;

                    XmlDocument dom = new XmlDocument();
                    try
                    {
                        dom.LoadXml(strXml);
                    }
                    catch (Exception ex)
                    {
                        strError = "装载日志记录 '" + strLogFileName + ":" + strIndex + "' XML 到 DOM 时发生错误: " + ex.Message;
                        return -1;
                    }

                    if (func != null)
                    {
                        if (func(strLogFileName,
                            Convert.ToInt32(strIndex),
                dom,
                null) == false)
                            break;
                    }

                    stop.SetProgressValue(i + 1);
                    i++;
                }

                return 0;
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStopPrint);
                stop.Initial("处理完成");
                stop.HideProgress();

                if (stop != null) // 脱离关联
                {
                    stop.Unregister();	// 和容器关联
                    stop = null;
                }
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:91,代码来源:OperLogForm.cs

示例4: menu_printHtml_Click


//.........这里部分代码省略.........
            {
                stop.SetProgressRange(0, this.listView_records.SelectedItems.Count);
                int i = 0;
                foreach (ListViewItem item in this.listView_records.SelectedItems)
                {
                    Application.DoEvents();

                    if (stop != null && stop.State != 0)
                    {
                        strError = "用户中断";
                        goto ERROR1;
                    }

                    OperLogItemInfo info = (OperLogItemInfo)item.Tag;

                    string strLogFileName = ListViewUtil.GetItemText(item, COLUMN_FILENAME);
                    string strIndex = ListViewUtil.GetItemText(item, COLUMN_INDEX);

                    string strXml = "";
                    // 从服务器获得
                    // return:
                    //      -1  出错
                    //      0   正常
                    //      1   用户中断
                    int nRet = GetXml(item,
            out strXml,
            out strError);
                    if (nRet == 1)
                        return;
                    if (nRet == -1)

                        goto ERROR1;

                    Global.SetXmlString(this.webBrowser_xml,
    strXml,
    this.MainForm.DataDir,
    "operlogexml");

                    string strHtml = "";
                    // 创建解释日志记录内容的 HTML 字符串
                    // return:
                    //      -1  出错
                    //      0   成功
                    //      1   未知的操作类型
                    nRet = GetHtmlString(strXml,
                        false,
                        out strHtml,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    if (nRet == 1)
                        strHtml = strError;

                    StreamUtil.WriteText(strFilename,
        "<p class='record_title'>" + strLogFileName + " : " + strIndex + "</p>" + strHtml);

                    stop.SetProgressValue(i + 1);
                    i++;
                }
            }
            finally
            {
                this.GetSummary -= new GetSummaryEventHandler(OperLogForm_GetSummary);
                if (m_webExternalHost != null)
                {
                    m_webExternalHost.IsInLoop = false;
                    m_webExternalHost.Destroy();
                    m_webExternalHost = null;
                }

                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStopPrint);
                stop.Initial("打印页面创建完成");
                stop.HideProgress();

                if (stop != null) // 脱离关联
                {
                    stop.Unregister();	// 和容器关联
                    stop = null;
                }
            }

            StreamUtil.WriteText(strFilename,
"</body></html>");

            // TODO: 浏览器控件连接javascript host
            HtmlPrintForm printform = new HtmlPrintForm();

            printform.Text = "打印解释内容";
            printform.MainForm = this.MainForm;
            printform.Filenames = filenames;

            this.MainForm.AppInfo.LinkFormState(printform, "operlogform_printform_state");
            printform.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(printform);

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:OperLogForm.cs

示例5: menu_saveToDatabase_Click


//.........这里部分代码省略.........
                        string strMARC = "";

                        nRet = this.GetOneRecord(
                            "marc",
                            index,  // 即将废止
                            "index:" + index.ToString(),
                            bForceFull == true ? "force_full" : "", // false,
                            out strSavePath,
                            out strMARC,
                            out strXmlFragment,
                            out strOutStyle,
                            out baTimestamp,
                            out lVersion,
                            out record,
                            out currentEncoding,
                            out logininfo,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;


                        string strMarcSyntax = "";
                        if (record.m_strSyntaxOID == "1.2.840.10003.5.1")
                            strMarcSyntax = "unimarc";
                        if (record.m_strSyntaxOID == "1.2.840.10003.5.10")
                            strMarcSyntax = "usmarc";

                        // 有些格式不适合保存到目标数据库
                        if (strTargetMarcSyntax != strMarcSyntax)
                        {
                            if (bSkip == true)
                                continue;
                            strError = "记录 " + (index + 1).ToString() + " 的格式类型为 '" + strMarcSyntax + "',和目标库的格式类型 '" + strTargetMarcSyntax + "' 不符合,因此无法保存到目标库";
                            DialogResult result = MessageBox.Show(this,
        strError + "\r\n\r\n要跳过这些记录而继续保存后面的记录么?\r\n\r\n(Yes: 跳过格式不吻合的记录,继续保存后面的; No: 放弃整个保存操作)",
        "AmazonSearchForm",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question,
        MessageBoxDefaultButton.Button1);
                            if (result == System.Windows.Forms.DialogResult.No)
                                goto ERROR1;
                            bSkip = true;
                            continue;
                        }

                        string strProtocolPath = this.CurrentProtocol + ":"
    + this.CurrentResultsetPath
    + "/" + (index + 1).ToString();

                        string strOutputPath = "";
                        byte[] baOutputTimestamp = null;
                        string strComment = "copy from " + strProtocolPath; // strSavePath;
                        // return:
                        //      -2  timestamp mismatch
                        //      -1  error
                        //      0   succeed
                        nRet = dp2_searchform.SaveMarcRecord(
                            false,
                            strPath,
                            strMARC,
                            strMarcSyntax,
                            baTimestamp,
                            strXmlFragment,
                            strComment,
                            out strOutputPath,
                            out baOutputTimestamp,
                            out strError);
                        if (nRet == -1)
                            goto ERROR1;
                        nSavedCount++;

                    }
                    MessageBox.Show(this, "共保存记录 " + nSavedCount.ToString() + " 条");
                    return;
                }
                else if (strProtocol.ToLower() == "z3950")
                {
                    strError = "目前暂不支持Z39.50协议的保存操作";
                    goto ERROR1;
                }
                else
                {
                    strError = "无法识别的协议名 '" + strProtocol + "'";
                    goto ERROR1;
                }
            }
            finally
            {
                stop.EndLoop();

                stop.Unregister();	// 和容器关联
                stop = null;

                this.EnableControls(true);
            }

            // return 0;
        ERROR1:
            MessageBox.Show(this, strError);
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:AmazonSearchForm.cs

示例6: GetBiblioDbNames

        // 获得一个书目库名列表
        // parameters:
        //      stop    如果!=null,表示使用这个stop,它已经OnStop +=
        //              如果==null,表示会自动使用this.stop,并自动OnStop+=
        // return:
        //      -1  error
        //      0   OK
        int GetBiblioDbNames(
            Stop stop,
            string strServerName,
            string strServerUrl,
            out List<string> dbnames,
            out string strError)
        {
            dbnames  = new List<string>();
            strError = "";

            bool bInitialStop = false;
            if (stop == null)
            {
                stop = this.stop;

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在获得服务器 " + strServerUrl + " 的信息 ...");
                stop.BeginLoop();

                bInitialStop = true;
            }

            dp2ServerInfo info = null;

            try
            {
                info = this.MainForm.ServerInfos.GetServerInfo(stop,
                    false,
                    this.Channels,
                    strServerName,
                    strServerUrl,
                    this.MainForm.TestMode,
                    out strError);
                if (info == null)
                    return -1;
            }
            finally
            {
                if (bInitialStop == true)
                {
                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");
                }
            }

            for (int i = 0; i < info.BiblioDbProperties.Count; i++)
            {
                BiblioDbProperty prop = info.BiblioDbProperties[i];

                dbnames.Add(prop.DbName);
            }

            return 0;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:62,代码来源:ZhongcihaoForm.cs

示例7: GetBatchNoTable


//.........这里部分代码省略.........
                        "批次号",
                        "left",
                        strLang,
                        "batchno",   // strResultSetName
                        "desc",
                        "keycount", // strOutputStyle
                        out strError);
                }
                else
                {
                    Debug.Assert(false, "");
                }


                if (lRet == -1)
                    goto ERROR1;

                if (lRet == 0)
                {
                    strError = "没有找到任何" + strName + "批次号检索点";
                    return;
                }

                long lHitCount = lRet;

                long lStart = 0;
                long lCount = lHitCount;
                DigitalPlatform.LibraryClient.localhost.Record[] searchresults = null;

                // 装入浏览格式
                for (; ; )
                {
                    Application.DoEvents();	// 出让界面控制权

                    if (stop != null)
                    {
                        if (stop.State != 0)
                        {
                            strError = "用户中断";
                            goto ERROR1;
                        }
                    }

                    lRet = Channel.GetSearchResult(
                        stop,
                        "batchno",   // strResultSetName
                        lStart,
                        lCount,
                        "keycount",
                        strLang,
                        out searchresults,
                        out strError);
                    if (lRet == -1)
                    {
                        strError = "GetSearchResult() error: " + strError;
                        goto ERROR1;
                    }

                    if (lRet == 0)
                    {
                        // MessageBox.Show(this, "未命中");
                        return;
                    }

                    // 处理浏览结果
                    for (int i = 0; i < searchresults.Length; i++)
                    {
                        if (searchresults[i].Cols == null)
                        {
                            strError = "请更新应用服务器和数据库内核到最新版本,才能使用列出" + strName + "批次号的功能";
                            goto ERROR1;
                        }

                        KeyCount keycount = new KeyCount();
                        keycount.Key = searchresults[i].Path;
                        keycount.Count = Convert.ToInt32(searchresults[i].Cols[0]);
                        e.KeyCounts.Add(keycount);
                    }

                    lStart += searchresults.Length;
                    lCount -= searchresults.Length;

                    stop.SetMessage("共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条");

                    if (lStart >= lHitCount || lCount <= 0)
                        break;
                }
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(Channel.DoStop);
                stop.Initial("");

                // EnableControls(true);
            }
            return;
        ERROR1:
            MessageBox.Show(owner, strError);
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:Global.cs

示例8: SmartHanziTextToPinyin


//.........这里部分代码省略.........
                        }
#endif


                        string strSampleText = "";
                        int nOffs = -1;
                        SelPinyinDlg.GetOffs(dom.DocumentElement,
                            nodeChar,
                out strSampleText,
                out nOffs);

                        {	// 如果是多个拼音
                            SelPinyinDlg dlg = new SelPinyinDlg();
                            float ratio_single = dlg.listBox_multiPinyin.Font.SizeInPoints / dlg.Font.SizeInPoints;
                            float ratio_sample = dlg.textBox_sampleText.Font.SizeInPoints / dlg.Font.SizeInPoints;
                            GuiUtil.SetControlFont(dlg, this.Font, false);
                            // 维持字体的原有大小比例关系
                            dlg.listBox_multiPinyin.Font = new Font(dlg.Font.FontFamily, ratio_single * dlg.Font.SizeInPoints, GraphicsUnit.Point);
                            dlg.textBox_sampleText.Font = new Font(dlg.Font.FontFamily, ratio_sample * dlg.Font.SizeInPoints, GraphicsUnit.Point);
                            // 这个对话框比较特殊 GuiUtil.SetControlFont(dlg, this.Font, false);

                            dlg.Text = "请选择汉字 '" + strHanzi + "' 的拼音 (来自服务器 " + this.MainForm.PinyinServerUrl + ")";
                            dlg.SampleText = strSampleText;
                            dlg.Offset = nOffs;
                            dlg.Pinyins = strCharPinyins;
                            if (index < pinyin_parts.Length)
                                dlg.ActivePinyin = pinyin_parts[index];
                            dlg.Hanzi = strHanzi;

                            MainForm.AppInfo.LinkFormState(dlg, "SelPinyinDlg_state");

                            dlg.ShowDialog(this);

                            MainForm.AppInfo.UnlinkFormState(dlg);

                            Debug.Assert(DialogResult.Cancel != DialogResult.Abort, "推断");

                            if (dlg.DialogResult == DialogResult.Abort)
                            {
                                return 0;   // 用户希望整个中断
                            }

                            DomUtil.SetAttr(nodeChar, "sel", dlg.ResultPinyin);

                            if (dlg.DialogResult == DialogResult.Cancel)
                            {
                                SelPinyinDlg.AppendText(ref strPinyin, strHanzi);
                                nStatus = 2;
                            }
                            else if (dlg.DialogResult == DialogResult.OK)
                            {
                                SelPinyinDlg.AppendPinyin(ref strPinyin,
                                    SelPinyinDlg.ConvertSinglePinyinByStyle(
                                    dlg.ResultPinyin,
                                    style)
                                    );
                                nStatus = 2;
                            }
                            else
                            {
                                Debug.Assert(false, "SelPinyinDlg返回时出现意外的DialogResult值");
                            }

                            index++;
                        }

                    }
                }

#if _TEST_PINYIN
#else
                // return:
                //      -2  strID验证失败
                //      -1  出错
                //      0   成功
                nRet = GcatNew.SetPinyin(
                    new_stop,
                    m_gcatClient,
                    "",
                    dom.DocumentElement.OuterXml,
                    out strError);
                if (nRet == -1)
                    return -1;
#endif

                return 1;
            }
            finally
            {
                new_stop.EndLoop();
                new_stop.OnStop -= new StopEventHandler(new_stop_OnStop);
                new_stop.Initial("");
                new_stop.Unregister();
                if (m_gcatClient != null)
                {
                    m_gcatClient.Close();
                    m_gcatClient = null;
                }
            }
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:MarcDetailForm.cs

示例9: button_test_loginAttack_Click

        private void button_test_loginAttack_Click(object sender, EventArgs e)
        {
            LibraryChannel channel = new LibraryChannel();
            channel.Url = this.MainForm.LibraryServerUrl;

            channel.BeforeLogin -= new DigitalPlatform.CirculationClient.BeforeLoginEventHandle(Channel_BeforeLogin);
            channel.BeforeLogin += new DigitalPlatform.CirculationClient.BeforeLoginEventHandle(Channel_BeforeLogin);


            _stop = new DigitalPlatform.Stop();
            _stop.Register(this.MainForm.stopManager, true);	// 和容器关联

            _stop.OnStop += new StopEventHandler(this.DoStop);
            _stop.Style = StopStyle.EnableHalfStop;
            _stop.Initial("正在试探密码 ...");
            _stop.BeginLoop();

            this.button_test_loginAttack.Enabled = false;
            this.numericUpDown_test_tryChannelCount.Enabled = false;
            try
            {
                for (int i = 0; i < this.numericUpDown_test_tryChannelCount.Value; i++)
                {
                    Application.DoEvents();

                    if (_stop != null && _stop.State != 0)
                        break;


                    string strUserName = "supervisor";
                    string strPassword = i.ToString();

                    string strRights = "";
                    string strLibraryCode = "";
                    string strOutputUserName = "";
                    string strError = "";
                    long lRet = channel.Login(
                        strUserName,
                        strPassword,
                        "",
                        out strOutputUserName,
                        out strRights,
                        out strLibraryCode,
                        out strError);
#if NO
                    if (lRet == -1)
                    {
                        if (channel.ErrorCode == DigitalPlatform.CirculationClient.localhost.ErrorCode.OutofSession)
                            break;
                    }
#endif

                    _stop.SetMessage(i.ToString() + " username="+strUserName+" password="+strPassword+" lRet = " + lRet.ToString() + " " + strError);
                }
            }
            finally
            {
                this.numericUpDown_test_tryChannelCount.Enabled = true;
                this.button_test_loginAttack.Enabled = true;

                _stop.EndLoop();
                _stop.OnStop -= new StopEventHandler(this.DoStop);
                _stop.Initial("");

                if (_stop != null) // 脱离关联
                {
                    _stop.Unregister();	// 和容器关联
                    _stop = null;
                }
            }

        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:72,代码来源:TestForm.cs

示例10: button_test_channelAttack_Click

        private void button_test_channelAttack_Click(object sender, EventArgs e)
        {

            _stop = new DigitalPlatform.Stop();
            _stop.Register(this.MainForm.stopManager, true);	// 和容器关联

            _stop.OnStop += new StopEventHandler(this.DoStop);
            _stop.Style = StopStyle.EnableHalfStop;
            _stop.Initial("正在测试耗费通道 ...");
            _stop.BeginLoop();

            this.button_test_channelAttack.Enabled = false;
            this.numericUpDown_test_tryChannelCount.Enabled = false;
            try
            {
                for (int i = 0; i < this.numericUpDown_test_tryChannelCount.Value; i++ )
                {
                    Application.DoEvents();

                    if (_stop != null && _stop.State != 0)
                        break;

                    LibraryChannel channel = new LibraryChannel();
                    channel.Url = this.MainForm.LibraryServerUrl;

                    channel.BeforeLogin -= new DigitalPlatform.CirculationClient.BeforeLoginEventHandle(Channel_BeforeLogin);
                    channel.BeforeLogin += new DigitalPlatform.CirculationClient.BeforeLoginEventHandle(Channel_BeforeLogin);

                    string strValue = "";
                    string strError = "";
                    long lRet = channel.GetSystemParameter(_stop,
                        "library",
                        "name",
                        out strValue,
                        out strError);
#if NO
                    if (lRet == -1)
                    {
                        if (channel.ErrorCode == DigitalPlatform.CirculationClient.localhost.ErrorCode.OutofSession)
                            break;
                    }
#endif

                    _stop.SetMessage(i.ToString());
                }
            }
            finally
            {
                this.numericUpDown_test_tryChannelCount.Enabled = true;
                this.button_test_channelAttack.Enabled = true;

                _stop.EndLoop();
                _stop.OnStop -= new StopEventHandler(this.DoStop);
                _stop.Initial("");

                if (_stop != null) // 脱离关联
                {
                    _stop.Unregister();	// 和容器关联
                    _stop = null;
                }
            }
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:62,代码来源:TestForm.cs

示例11: GetUtilDbName

        // 获得publisher等实用库的库名
        public int GetUtilDbName(
            Stop stop,
            string strServerName,
            string strServerUrl,
            string strFuncName, // "publisher"
            out string strUtilDbName,
            out string strError)
        {
            strUtilDbName = "";
            strError = "";

            bool bInitialStop = false;
            if (stop == null)
            {
                stop = this.stop;

                stop.OnStop += new StopEventHandler(this.DoStop);
                stop.Initial("正在获得服务器 " + strServerUrl + " 的信息 ...");
                stop.BeginLoop();

                bInitialStop = true;
            }

            dp2ServerInfo info = null;

            try
            {
                info = this.MainForm.ServerInfos.GetServerInfo(stop,
                    this.m_bInSearching,
                    this.Channels,
                    strServerName,
                    strServerUrl,
                    this.MainForm.TestMode,
                    out strError);
                if (info == null)
                    return -1;
            }
            finally
            {
                if (bInitialStop == true)
                {
                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");
                }
            }

            for (int i = 0; i < info.UtilDbProperties.Count; i++)
            {
                UtilDbProperty prop = info.UtilDbProperties[i];
                if (prop.Type == "publisher")
                {
                    strUtilDbName = prop.DbName;
                    return 1;
                }

            }

            return 0;    // not found
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:61,代码来源:dp2SearchForm.cs

示例12: ReloadFullElementSet

        // 为选定的行装入Full元素集的记录
        public void ReloadFullElementSet()
        {
            string strError = "";
            int nRet = 0;

            ZConnection connection = this.GetCurrentZConnection();
            if (connection == null)
            {
                strError = "当前ZConnection为空";
                goto ERROR1;
            }

            if (connection.VirtualItems.SelectedIndices.Count == 0)
            {
                strError = "尚未选定要装入完整格式的浏览行";
                goto ERROR1;
            }


            DigitalPlatform.Stop stop = null;
            stop = new DigitalPlatform.Stop();
            stop.Register(this.MainForm.stopManager, true);	// 和容器关联

            stop.BeginLoop();

            this.EnableControls(false);
            try
            {
                List<int> selected = new List<int>();
                selected.AddRange(connection.VirtualItems.SelectedIndices);
                stop.SetProgressRange(0, selected.Count);

                for (int i = 0; i < selected.Count; i++)
                {
                    Application.DoEvents();	// 出让界面控制权

                    if (stop != null)
                    {
                        if (stop.State != 0)
                        {
                            strError = "用户中断";
                            goto ERROR1;
                        }
                    }

                    int index = selected[i];

                    stop.SetMessage("正在重新装载记录 "+(index+1).ToString()+" 的详细格式...");

                    byte[] baTimestamp = null;
                    string strSavePath = "";
                    string strOutStyle = "";
                    LoginInfo logininfo = null;
                    long lVersion = 0;
                    string strXmlFragment = "";
                    DigitalPlatform.Z3950.Record record = null;
                    Encoding currentEncoding = null;
                    string strMARC = "";

                    nRet = this.GetOneRecord(
                        "marc",
                        index,  // 即将废止
                        "index:" + index.ToString(),
                        "force_full", // false,
                        out strSavePath,
                        out strMARC,
                        out strXmlFragment,
                        out strOutStyle,
                        out baTimestamp,
                        out lVersion,
                        out record,
                        out currentEncoding,
                        out logininfo,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    stop.SetProgressValue(i);

                }

                return;
            }
            finally
            {
                stop.EndLoop();
                stop.SetMessage("");
                stop.Unregister();	// 和容器关联
                stop = null;

                this.EnableControls(true);
            }

    // return 0;
        ERROR1:
            MessageBox.Show(this, strError);
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:98,代码来源:ZSearchForm.cs

示例13: SmartHanziTextToPinyin


//.........这里部分代码省略.........
                            {
                                SelPinyinDlg.AppendText(ref strPinyin, strHanzi);
                                //nStatus = 2;
                                bNotFoundPinyin = true;
                            }
                            else if (dlg.DialogResult == DialogResult.OK)
                            {
                                SelPinyinDlg.AppendPinyin(ref strPinyin,
                                    SelPinyinDlg.ConvertSinglePinyinByStyle(
                                    dlg.ResultPinyin,
                                    style)
                                    );
                                //nStatus = 2;
                            }
                            else
                            {
                                Debug.Assert(false, "SelPinyinDlg返回时出现意外的DialogResult值");
                            }

                            index++;
                        }
                    }
                }

#if _TEST_PINYIN
#else
                // 2014/10/22
                // 删除 word 下的 Text 节点
                XmlNodeList text_nodes = dom.DocumentElement.SelectNodes("word/text()");
                foreach (XmlNode node in text_nodes)
                {
                    Debug.Assert(node.NodeType == XmlNodeType.Text, "");
                    node.ParentNode.RemoveChild(node);
                }

                // 把没有p属性的<char>元素去掉,以便上传
                XmlNodeList nodes = dom.DocumentElement.SelectNodes("//char");
                foreach (XmlNode node in nodes)
                {
                    string strP = DomUtil.GetAttr(node, "p");
                    string strSelValue = DomUtil.GetAttr(node, "sel");  // 2013/9/13

                    if (string.IsNullOrEmpty(strP) == true
                        || string.IsNullOrEmpty(strSelValue) == true)
                    {
                        XmlNode parent = node.ParentNode;
                        parent.RemoveChild(node);

                        // 把空的<word>元素删除
                        if (parent.Name == "word"
                            && parent.ChildNodes.Count == 0
                            && parent.ParentNode != null)
                        {
                            parent.ParentNode.RemoveChild(parent);
                        }
                    }

                    // TODO: 一个拼音,没有其他选择的,是否就不上载了?
                    // 注意,前端负责新创建的拼音仍需上载;只是当初原样从服务器过来的,不用上载了
                }

                if (dom.DocumentElement.ChildNodes.Count > 0)
                {
                    // return:
                    //      -2  strID验证失败
                    //      -1  出错
                    //      0   成功
                    nRet = GcatNew.SetPinyin(
                        new_stop,
                        m_gcatClient,
                        "",
                        dom.DocumentElement.OuterXml,
                        out strError);
                    if (nRet == -1)
                    {
                        if (new_stop != null && new_stop.State != 0)
                            return 0;
                        return -1;
                    }
                }
#endif

                if (bNotFoundPinyin == false)
                    return 1;   // 正常结束

                return 2;   // 结果字符串中有没有找到拼音的汉字
            }
            finally
            {
                new_stop.EndLoop();
                new_stop.OnStop -= new StopEventHandler(new_stop_OnStop);
                new_stop.Initial("");
                new_stop.Unregister();
                if (m_gcatClient != null)
                {
                    m_gcatClient.Close();
                    m_gcatClient = null;
                }
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:PinyinExtension.cs


注:本文中的DigitalPlatform.Stop.EndLoop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。