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


C# Stop.Initial方法代码示例

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


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

示例1: SearchAllLocation

        // 检索出实体库全部可用的馆藏地名称
        int SearchAllLocation(
    LibraryChannel channel,
    Stop stop,
    out string strError)
        {
            strError = "";

            long lTotalCount = 0;

            this.listView_records.Items.Clear();

            // EnableControls(false);
            stop.OnStop += new StopEventHandler(channel.DoStop);
            stop.Initial("正在列出全部馆藏地 ...");
            stop.BeginLoop();

            try
            {
                for (int i = 0; i < 2; i++)
                {
                    long lRet = Channel.SearchItem(
        stop,
        "<all>",
        "", // strBatchNo
        -1,
        "馆藏地点",
        i == 0 ? "left" : "exact",  // 第二次为检索空值
        "zh",
        "batchno",   // strResultSetName
        "", // "desc",
        "keycount", // strOutputStyle
        out strError);
                    if (lRet == 0)
                    {
#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();
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:SelectBatchNoDialog.cs

示例2: SearchAllBatchNo

        // 检索出盘点库内全部批次号名称
        int SearchAllBatchNo(
            LibraryChannel channel,
            Stop stop,
            string strInventoryDbName,
            out string strError)
        {
            strError = "";

            this.listView_records.Items.Clear();

            // EnableControls(false);
            stop.OnStop += new StopEventHandler(channel.DoStop);
            stop.Initial("正在列出全部批次号 ...");
            stop.BeginLoop();

            try
            {
                // 构造检索式
                StringBuilder text = new StringBuilder();

                text.Append("<target list='"
                        + StringUtil.GetXmlStringSimple(strInventoryDbName + ":" + "批次号")
                        + "'>");
                // 当前是否为全局用户
                bool bGlobalUser = this._libraryCodeList.Count == 0 || this._libraryCodeList.IndexOf("") != -1;
                    // 全局用户只认列表中 "" 一个值。这样可以检索出全部批次号,包括各个分馆的
                if (bGlobalUser == true && this._libraryCodeList.Count != 1)
                {
                    this._libraryCodeList.Clear();
                    this._libraryCodeList.Add("");
                }
                int i = 0;
                foreach (string librarycode in this.LibraryCodeList)
                {
                    if (i > 0)
                        text.Append("<operator value='OR' />");

                    text.Append("<item><word>"
                        + StringUtil.GetXmlStringSimple(bGlobalUser ? "" : librarycode + "-")
                        + "</word><match>left</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang>");
                    i++;
                }

                if (bGlobalUser == true)
                {
                    if (i > 0)
                        text.Append("<operator value='OR' />");

                    // 针对空批次号的检索。空只能被全局用户可见
                    text.Append("<item><word>"
            + StringUtil.GetXmlStringSimple("")
            + "</word><match>exact</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>zh</lang>");
                    i++;
                }

                text.Append("</target>");

#if NO
                // 构造检索式
                string strQueryXml = "<target list='"
                        + StringUtil.GetXmlStringSimple(strInventoryDbName + ":" + "批次号")
                        + "'><item><word>"
                        + 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;
//.........这里部分代码省略.........
开发者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

        // 打印解释内容
        void menu_printHtml_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_records.SelectedItems.Count == 0)
            {
                strError = "尚未选定要打印的行";
                goto ERROR1;
            }

            List<string> filenames = new List<string>();
            string strFileNamePrefix = this.MainForm.DataDir + "\\~operlog_print_";
            string strFilename = strFileNamePrefix + (1).ToString() + ".html";
            filenames.Add(strFilename);

            File.Delete(strFilename);

            StreamUtil.WriteText(strFilename,
    "<html>" +
    GetHeadString(false) +
    "<body>");

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

            stop.OnStop += new StopEventHandler(this.DoStopPrint);
            stop.Initial("正在创建打印页面 ...");
            stop.BeginLoop();

            m_webExternalHost = new WebExternalHost();
            m_webExternalHost.Initial(this.MainForm, null);
            m_webExternalHost.IsInLoop = true;

            this.GetSummary += new GetSummaryEventHandler(OperLogForm_GetSummary);
            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 = "用户中断";
                        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)
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:OperLogForm.cs

示例5: SmartHanziTextToPinyin

        // 汉字字符串转换为拼音
        // 如果函数中已经MessageBox报错,则strError第一字符会为空格
        // return:
        //      -1  出错
        //      0   用户希望中断
        //      1   正常
        public int SmartHanziTextToPinyin(
            string strText,
            PinyinStyle style,
            out string strPinyin,
            out string strError)
        {
            strPinyin = "";
            strError = "";

            Stop new_stop = new DigitalPlatform.Stop();
            new_stop.Register(MainForm.stopManager, true);	// 和容器关联
            new_stop.OnStop += new StopEventHandler(new_stop_OnStop);
            new_stop.Initial("正在获得 '" + strText + "' 的拼音信息 (从服务器 " + this.MainForm.PinyinServerUrl + ")...");
            new_stop.BeginLoop();

            m_gcatClient = null;
            try
            {

                m_gcatClient = GcatNew.CreateChannel(this.MainForm.PinyinServerUrl);

            REDO_GETPINYIN:
                int nStatus = -1;	// 前面一个字符的类型 -1:前面没有字符 0:普通英文字母 1:空格 2:汉字
                string strPinyinXml = "";
                // return:
                //      -2  strID验证失败
                //      -1  出错
                //      0   成功
                int nRet = GcatNew.GetPinyin(
                    new_stop,
                    m_gcatClient,
                    m_strPinyinGcatID,
                    strText,
                    out strPinyinXml,
                    out strError);
                if (nRet == -1)
                {
                    DialogResult result = MessageBox.Show(this,
    "从服务器 '" + this.MainForm.PinyinServerUrl + "' 获取拼音的过程出错:\r\n" + strError + "\r\n\r\n是否要临时改为使用本机加拼音功能? \r\n\r\n(注:临时改用本机拼音的状态在程序退出时不会保留。如果要永久改用本机拼音方式,请使用主菜单的“参数配置”命令,将“服务器”属性页的“拼音服务器URL”内容清空)",
    "EntityForm",
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button2);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        this.MainForm.ForceUseLocalPinyinFunc = true;
                        strError = "将改用本机拼音,请重新操作一次。(本次操作出错: " + strError + ")";
                        return -1;
                    }
                    strError = " " + strError;
                    return -1;
                }

                if (nRet == -2)
                {
                    IdLoginDialog login_dlg = new IdLoginDialog();
                    login_dlg.Text = "获得拼音 -- "
                        + ((string.IsNullOrEmpty(this.m_strPinyinGcatID) == true) ? "请输入ID" : strError);
                    login_dlg.ID = this.m_strPinyinGcatID;
                    login_dlg.SaveID = this.m_bSavePinyinGcatID;
                    login_dlg.StartPosition = FormStartPosition.CenterScreen;
                    if (login_dlg.ShowDialog(this) == DialogResult.Cancel)
                    {
                        return 0;
                    }

                    this.m_strPinyinGcatID = login_dlg.ID;
                    this.m_bSavePinyinGcatID = login_dlg.SaveID;
                    goto REDO_GETPINYIN;
                }

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strPinyinXml);
                }
                catch (Exception ex)
                {
                    strError = "strPinyinXml装载到XMLDOM时出错: " + ex.Message;
                    return -1;
                }

                foreach (XmlNode nodeWord in dom.DocumentElement.ChildNodes)
                {
                    if (nodeWord.NodeType == XmlNodeType.Text)
                    {
                        SelPinyinDlg.AppendText(ref strPinyin, nodeWord.InnerText);
                        nStatus = 0;
                        continue;
                    }

                    if (nodeWord.NodeType != XmlNodeType.Element)
                        continue;

//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:MarcDetailForm.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: DownloadObject

        static int DownloadObject(Stop stop,
            LibraryChannel channel,
            string strResPath,
            string strOutputFileName,
            out string strError)
        {
            strError = "";

            PathUtil.CreateDirIfNeed(Path.GetDirectoryName(strOutputFileName));

            TimeSpan old_timeout = channel.Timeout;
            channel.Timeout = new TimeSpan(0, 5, 0);

            if (stop != null)
                stop.Initial("正在下载对象 " + strResPath);
            try
            {
                byte[] baOutputTimeStamp = null;
                string strMetaData = "";
                string strOutputPath = "";

                long lRet = channel.GetRes(
                    stop,
                    strResPath,
                    strOutputFileName,
                    out strMetaData,
                    out baOutputTimeStamp,
                    out strOutputPath,
                    out strError);
                if (lRet == -1)
                {
                    strError = "下载对象 '" + strResPath + "' 到文件失败,原因: " + strError;
                    return -1;
                }
                return 0;
            }
            finally
            {
                channel.Timeout = old_timeout;
                if (stop != null)
                    stop.Initial("");
            }
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:43,代码来源:BiblioSearchForm.cs

示例8: GetBatchNoTable

        // 获得批次号表
        // parameters:
        //      strPubType  出版物类型。为 图书/连续出版物/(空) 之一
        internal static void GetBatchNoTable(GetKeyCountListEventArgs e,
            IWin32Window owner,
            string strPubType,  // 出版物类型
            string strType,
            Stop stop,
            LibraryChannel Channel)
        {
            string strError = "";
            long lRet = 0;


            if (e.KeyCounts == null)
                e.KeyCounts = new List<KeyCount>();

            string strName = "";
            if (strType == "order")
                strName = "订购";
            else if (strType == "item")
                strName = "册";
            else if (strType == "biblio")
                strName = "编目";
            else
                throw new Exception("未知的strType '" + strType + "' 值");

            // EnableControls(false);
            stop.OnStop += new StopEventHandler(Channel.DoStop);
            stop.Initial("正在列出全部" + strName + "批次号 ...");
            stop.BeginLoop();

            try
            {
                int nPerMax = 2000; // 一次检索命中的最大条数限制
                string strLang = "zh";

                string strDbName = "<all>";
                if (strPubType == "图书")
                    strDbName = "<all book>";
                else if (strPubType == "连续出版物")
                    strDbName = "<all series>";
                else
                    strDbName = "<all>";

                if (strType == "order")
                {
                    lRet = Channel.SearchOrder(
                        stop,
                        strDbName,  // "<all>",
                        "", // strBatchNo
                        nPerMax,   // -1,
                        "批次号",
                        "left",
                        strLang,
                        "batchno",   // strResultSetName
                        "desc",
                        "keycount", // strOutputStyle
                        out strError);
                }
                else if (strType == "biblio")
                {
                    string strQueryXml = "";

                    lRet = Channel.SearchBiblio(
                        stop,
                        strDbName,  // "<all>",    // 尽管可以用 this.comboBox_inputBiblioDbName.Text, 以便获得和少数书目库相关的批次号实例,但是容易造成误会:因为数据库名列表刷新后,这里却不会刷新?
                        "", // strBatchNo,
                        nPerMax,   // -1,    // nPerMax
                        "batchno",
                        "left",
                        strLang,
                        "batchno",   // strResultSetName
                        "desc",
                        "keycount", // strOutputStyle
                        "",
                        out strQueryXml,
                        out strError);
                }
                else if (strType == "item")
                {

                    lRet = Channel.SearchItem(
                        stop,
                        strDbName,   // "<all>",
                        "", // strBatchNo
                        nPerMax,  // -1,
                        "批次号",
                        "left",
                        strLang,
                        "batchno",   // strResultSetName
                        "desc",
                        "keycount", // strOutputStyle
                        out strError);
                }
                else
                {
                    Debug.Assert(false, "");
                }

//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:Global.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: InternalGetOneRecord

        // 获得一条MARC记录
        // 注:如果this.DtlpChannel被占用,启动启用新的通道
        // TODO: 尚未处理启用新通道时启用新Stop的课题
        // parameters:
        //      strPath 记录路径。格式为"localhost/中文图书/ctlno/1"
        //      strDirection    方向。为 prev/next/current之一。current可以缺省。
        //      strOutputPath   [out]返回的实际路径。格式和strPath相同。
        // return:
        //      -1  error 包括not found
        //      0   found
        //      1   为诊断记录
        int InternalGetOneRecord(
            string strStyle,
            string strPath,
            string strDirection,
            out string strMARC,
            out string strOutputPath,
            out string strOutStyle,
            out byte[] baTimestamp,
            out DigitalPlatform.Z3950.Record record,
            out Encoding currrentEncoding,
            out string strError)
        {
            strMARC = "";
            record = null;
            strError = "";
            currrentEncoding = this.CurrentEncoding;
            baTimestamp = null;
            strOutStyle = "marc";
            strOutputPath = ""; // TODO: 需要参考dp1batch看获得outputpath的方法

            if (strStyle != "marc")
            {
                strError = "DtlpSearchForm只支持获取MARC格式记录";
                return -1;
            }

            int nRet = 0;

            int nStyle = DtlpChannel.XX_STYLE; // 获得详细记录

            if (strDirection == "prev")
                nStyle |= DtlpChannel.PREV_RECORD;
            else if (strDirection == "next")
                nStyle |= DtlpChannel.NEXT_RECORD;

            /*
            // 将路径转换为内核可以接受的正规形态
            string strPath = DigitalPlatform.DTLP.Global.ModifyDtlpRecPath(strPath,
                "ctlno");
             * */
            Stop temp_stop = this.stop;
            DtlpChannel channel = null;

            bool bNewChannel = false;
            if (this.m_nInSearching == 0)
                channel = this.DtlpChannel;
            else
            {
                channel = this.DtlpChannels.CreateChannel(0);
                bNewChannel = true;

                temp_stop = new Stop();
                temp_stop.Tag = channel;
                temp_stop.Register(MainForm.stopManager, true);	// 和容器关联

                temp_stop.OnStop += new StopEventHandler(this.DoNewStop);
                temp_stop.Initial("正在初始化浏览器组件 ...");
                temp_stop.BeginLoop();

            }

                byte[] baPackage = null;
            Encoding encoding = null;
            try
            {

                nRet = channel.Search(strPath,
                    nStyle,
                    out baPackage);
                if (nRet == -1)
                {
                    int errorcode = channel.GetLastErrno();

                    if (errorcode == DtlpChannel.GL_NOTEXIST
                        && (strDirection == "prev" || strDirection == "next"))
                    {
                        if (strDirection == "prev")
                            strError = "到头";
                        else if (strDirection == "next")
                            strError = "到尾";
                        goto ERROR1;
                    }
                    strError = "检索出错:\r\n"
                        + "检索式: " + strPath + "\r\n"
                        + "错误码: " + errorcode + "\r\n"
                        + "错误信息: " + channel.GetErrorString(errorcode) + "\r\n";
                    goto ERROR1;
                }

//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:DtlpSearchForm.cs

示例12: 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

示例13: SmartHanziTextToPinyin

        // 汉字字符串转换为拼音。新版本
        // 如果函数中已经MessageBox报错,则strError第一字符会为空格
        /// <summary>
        /// 汉字字符串转换为拼音,智能方式
        /// </summary>
        /// <param name="owner">用于函数中 MessageBox 和对话框 的宿主窗口</param>
        /// <param name="strText">输入字符串</param>
        /// <param name="style">转换为拼音的风格</param>
        /// <param name="strDuoyinStyle">是否自动选择多音字。auto/first 的一个或者组合。如果为 auto,first 表示优先按照智能拼音选择,没有智能拼音的,选择第一个</param>
        /// <param name="strPinyin">返回拼音字符串</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错; 0: 用户希望中断; 1: 正常; 2: 结果字符串中有没有找到拼音的汉字</returns>
        public int SmartHanziTextToPinyin(
            IWin32Window owner,
            string strText,
            PinyinStyle style,
            string strDuoyinStyle,  // bool bAutoSel,
            out string strPinyin,
            out string strError)
        {
            strPinyin = "";
            strError = "";

            bool bAuto = StringUtil.IsInList("auto", strDuoyinStyle);
            bool bFirst = StringUtil.IsInList("first", strDuoyinStyle);

            bool bNotFoundPinyin = false;   // 是否出现过没有找到拼音、只能把汉字放入结果字符串的情况

            Stop new_stop = new DigitalPlatform.Stop();
            new_stop.Register(this.stopManager, true);	// 和容器关联
            new_stop.OnStop += new StopEventHandler(new_stop_OnStop);
            new_stop.Initial("正在获得 '" + strText + "' 的拼音信息 (从服务器 " + this.PinyinServerUrl + ")...");
            new_stop.BeginLoop();

            m_gcatClient = null;
            try
            {

                m_gcatClient = GcatNew.CreateChannel(this.PinyinServerUrl);

            REDO_GETPINYIN:
                //int nStatus = -1;	// 前面一个字符的类型 -1:前面没有字符 0:普通英文字母 1:空格 2:汉字
                string strPinyinXml = "";
                // return:
                //      -2  strID验证失败
                //      -1  出错
                //      0   成功
                int nRet = GcatNew.GetPinyin(
                    new_stop,
                    m_gcatClient,
                    m_strPinyinGcatID,
                    strText,
                    out strPinyinXml,
                    out strError);
                if (nRet == -1)
                {
                    if (new_stop != null && new_stop.State != 0)
                        return 0;

                    DialogResult result = MessageBox.Show(owner,
    "从服务器 '" + this.PinyinServerUrl + "' 获取拼音的过程出错:\r\n" + strError + "\r\n\r\n是否要临时改为使用本机加拼音功能? \r\n\r\n(注:临时改用本机拼音的状态在程序退出时不会保留。如果要永久改用本机拼音方式,请使用主菜单的“参数配置”命令,将“服务器”属性页的“拼音服务器URL”内容清空)",
    "EntityForm",
    MessageBoxButtons.YesNo,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button2);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        this.ForceUseLocalPinyinFunc = true;
                        strError = "将改用本机拼音,请重新操作一次。(本次操作出错: " + strError + ")";
                        return -1;
                    }
                    strError = " " + strError;
                    return -1;
                }

                if (nRet == -2)
                {
                    IdLoginDialog login_dlg = new IdLoginDialog();
                    login_dlg.Text = "获得拼音 -- "
                        + ((string.IsNullOrEmpty(this.m_strPinyinGcatID) == true) ? "请输入ID" : strError);
                    login_dlg.ID = this.m_strPinyinGcatID;
                    login_dlg.SaveID = this.m_bSavePinyinGcatID;
                    login_dlg.StartPosition = FormStartPosition.CenterScreen;
                    if (login_dlg.ShowDialog(owner) == DialogResult.Cancel)
                    {
                        return 0;
                    }

                    this.m_strPinyinGcatID = login_dlg.ID;
                    this.m_bSavePinyinGcatID = login_dlg.SaveID;
                    goto REDO_GETPINYIN;
                }

                XmlDocument dom = new XmlDocument();
                try
                {
                    dom.LoadXml(strPinyinXml);
                }
                catch (Exception ex)
                {
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:PinyinExtension.cs


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