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


C# LibraryChannel.SetBiblioInfo方法代码示例

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


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

示例1: SaveXmlBiblioRecordToDatabase

        // 保存XML格式的书目记录到数据库
        // parameters:
        //      bResave 是否为删除后重新保存的模式。在这种模式下,使用 strAction == "new"
        int SaveXmlBiblioRecordToDatabase(
            LibraryChannel channel,
            string strPath,
            bool bResave,
            string strXml,
            byte[] baTimestamp,
            out string strOutputPath,
            out byte[] baNewTimestamp,
            out string strWarning,
            out string strError)
        {
            strError = "";
            strWarning = "";
            baNewTimestamp = null;
            strOutputPath = "";

#if NO
            Progress.OnStop += new StopEventHandler(this.DoStop);
            Progress.Initial("正在保存书目记录 ...");
            Progress.BeginLoop();
#endif
            Progress.Initial("正在保存书目记录 ...");

            try
            {
                string strAction = "change";

                if (Global.IsAppendRecPath(strPath) == true || bResave == true)
                    strAction = "new";

                /*
                if (String.IsNullOrEmpty(strPath) == true)
                    strAction = "new";
                else
                {
                    string strRecordID = Global.GetRecordID(strPath);
                    if (String.IsNullOrEmpty(strRecordID) == true
                        || strRecordID == "?")
                        strAction = "new";
                }
                */
            REDO:
                long lRet = channel.SetBiblioInfo(
                    Progress,
                    strAction,
                    strPath,
                    "xml",
                    strXml,
                    baTimestamp,
                    "",
                    out strOutputPath,
                    out baNewTimestamp,
                    out strError);
                if (lRet == -1)
                {
                    strError = "保存书目记录 '" + strPath + "' 时出错: " + strError;
                    if (strAction == "change" && channel.ErrorCode == ErrorCode.NotFound)
                    {
                        strError = "保存书目记录 '" + strPath + "' 时出错: 原记录已经不存在";
                        DialogResult result = MessageBox.Show(this,
strError + "\r\n\r\n请问是否改为重新创建此记录?",
"EntityForm",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1);
                        if (result == System.Windows.Forms.DialogResult.Yes)
                        {
                            strAction = "new";
                            // TODO: 此时也需要进一步保存下属的册记录等。而且对象资源不可能恢复了
                            goto REDO;
                        }
                    }

                    goto ERROR1;
                }
                if (channel.ErrorCode == ErrorCode.PartialDenied)
                {
                    strWarning = "书目记录 '" + strPath + "' 保存成功,但所提交的字段部分被拒绝 (" + strError + ")。请留意刷新窗口,检查实际保存的效果";
                }
            }
            finally
            {
#if NO
                Progress.EndLoop();
                Progress.OnStop -= new StopEventHandler(this.DoStop);
                Progress.Initial("");
#endif
                Progress.Initial("");
            }

            return 1;
        ERROR1:
            return -1;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:97,代码来源:EntityForm.cs

示例2: DeleteBiblioRecordFromDatabase

        int DeleteBiblioRecordFromDatabase(
    string strServerName,
    string strPath,
    // string strXml,
    byte[] baTimestamp,
    out byte[] baNewTimestamp,
    out string strError)
        {
            strError = "";
            baNewTimestamp = null;

            AccountInfo _currentAccount = _base.GetAccountInfo(strServerName);
            if (_currentAccount == null)
            {
                strError = "服务器名 '" + strServerName + "' 没有配置";
                return -1;
            }
            _channel = _base.GetChannel(_currentAccount.ServerUrl, _currentAccount.UserName);

            try
            {
                string strAction = "delete";

                if (Global.IsAppendRecPath(strPath) == true)
                {
                    strError = "路径 '"+strPath+"' 不能用于删除操作";
                    return -1;
                }

                string strOutputPath = "";
            REDO:
                long lRet = _channel.SetBiblioInfo(
                    Progress,
                    strAction,
                    strPath,
                    "xml",
                    "", // strXml,
                    baTimestamp,
                    "",
                    out strOutputPath,
                    out baNewTimestamp,
                    out strError);
                if (lRet == -1)
                {
                    strError = "删除书目记录 '" + strPath + "' 时出错: " + strError;
                    goto ERROR1;
                }

                return 1;
            ERROR1:
                return -1;
            }
            finally
            {
                _base.ReturnChannel(_channel);
                this._channel = null;
                // _currentAccount = null;
            }
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:59,代码来源:EntityRegisterWizard.cs

示例3: DetectAccess

        // 探测当前用户对一个书目库的访问权限
        public static int DetectAccess(LibraryChannel channel,
            Stop stop,
            string strBiblioDbName,
            string strMarcSyntax,
            out string strBiblioAccess,
            out string strEntityAccess,
            out string strError)
        {
            strError = "";
            strBiblioAccess = "";
            strEntityAccess = "";

            // 样本记录
            MarcRecord record = new MarcRecord();
            record.add(new MarcField('$', "001???????"));
            record.add(new MarcField('$', "200$a书名$f作者"));
            record.add(new MarcField('$', "701$a作者"));

            string strXml = "";
            int nRet = MarcUtil.Marc2Xml(record.Text,
                strMarcSyntax,
                out strXml,
                out strError);
            if (nRet == -1)
                return -1;

            List<string> biblio_access_list = new List<string>();
            List<string> entity_access_list = new List<string>();

            // 模拟书目追加写入
            string strAction = "simulate_new";
            string strPath = strBiblioDbName + "/?";
            string strOutputPath = "";
            byte[] baNewTimestamp = null;
            long lRet = channel.SetBiblioInfo(
    stop,
    strAction,
    strPath,
    "xml",
    strXml,
    null,   // baTimestamp,
    "",
    out strOutputPath,
    out baNewTimestamp,
    out strError);
            if (lRet == -1)
            {
                // 注意检查部分允许写入的报错
                if (channel.ErrorCode != ErrorCode.AccessDenied)
                    return -1;
            }
            else
                biblio_access_list.Add("append");

            // 模拟书目覆盖写入
            strAction = "simulate_change";
            strPath = strBiblioDbName + "/0";
            lRet = channel.SetBiblioInfo(
stop,
strAction,
strPath,
"xml",
strXml,
null,   // baTimestamp,
"",
out strOutputPath,
out baNewTimestamp,
out strError);
            if (lRet == -1)
            {
                if (channel.ErrorCode != ErrorCode.AccessDenied)
                    return -1;
            }
            else
            {
                // 注意检查部分允许写入的报错
                if (channel.ErrorCode == ErrorCode.PartialDenied)
                    biblio_access_list.Add("partial_overwrite");
                else
                    biblio_access_list.Add("overwrite");
            }

            // 模拟书目删除
            strAction = "simulate_delete";
            strPath = strBiblioDbName + "/0";
            lRet = channel.SetBiblioInfo(
stop,
strAction,
strPath,
"xml",
strXml,
null,   // baTimestamp,
"",
out strOutputPath,
out baNewTimestamp,
out strError);
            if (lRet == -1)
            {
                if (channel.ErrorCode != ErrorCode.AccessDenied)
//.........这里部分代码省略.........
开发者ID:paopaofeng,项目名称:dp2,代码行数:101,代码来源:EntityRegisterWizard.cs

示例4: SaveXmlBiblioRecordToDatabase

        // 保存XML格式的书目记录到数据库
        // parameters:
        // return:
        //      -1  出错
        //      0   有警告,在 strWarning 中。一般是因为部分保存成功
        //      1   成功
        int SaveXmlBiblioRecordToDatabase(
            string strServerName,
            string strPath,
            string strXml,
            byte[] baTimestamp,
            out string strOutputPath,
            out byte[] baNewTimestamp,
            out string strWarning,
            out string strError)
        {
            strError = "";
            strWarning = "";
            baNewTimestamp = null;
            strOutputPath = "";

            AccountInfo _currentAccount = _base.GetAccountInfo(strServerName);
            if (_currentAccount == null)
            {
                strError = "服务器名 '" + strServerName + "' 没有配置";
                return -1;
            }
            _channel = _base.GetChannel(_currentAccount.ServerUrl, _currentAccount.UserName);

            try
            {
                string strAction = "change";

                if (Global.IsAppendRecPath(strPath) == true)
                    strAction = "new";

            REDO:
                long lRet = _channel.SetBiblioInfo(
                    Progress,
                    strAction,
                    strPath,
                    "xml",
                    strXml,
                    baTimestamp,
                    "",
                    out strOutputPath,
                    out baNewTimestamp,
                    out strError);
                if (lRet == -1)
                {
                    strError = "保存书目记录 '" + strPath + "' 时出错: " + strError;
                    goto ERROR1;
                }
                if (_channel.ErrorCode == ErrorCode.PartialDenied)
                {
                    strWarning = "书目记录 '" + strPath + "' 保存成功,但所提交的字段部分被拒绝 (" + strError + ")。请留意刷新窗口,检查实际保存的效果";
                    return 0;
                }

                return 1;
            ERROR1:
                return -1;
            }
            finally
            {
                _base.ReturnChannel(_channel);
                this._channel = null;
                // _currentAccount = null;
            }
        }
开发者ID:paopaofeng,项目名称:dp2,代码行数:70,代码来源:EntityRegisterWizard.cs

示例5: DeleteSelectedRecords


//.........这里部分代码省略.........
            {
                stop.SetProgressRange(0, items.Count);
                for (int i = 0; i < items.Count; i++)
                {
                    if (stop != null && stop.State != 0)
                    {
                        strError = "已中断";
                        goto ERROR1;
                    }

                    ListViewItem item = items[i];
                    string strRecPath = ListViewUtil.GetItemText(item, 0);

                    // 解析记录路径
                    string strServerName = "";
                    string strPurePath = "";
                    ParseRecPath(strRecPath,
                        out strServerName,
                        out strPurePath);

                    // 获得server url
                    dp2Server server = this.dp2ResTree1.Servers.GetServerByName(strServerName);
                    if (server == null)
                    {
                        strError = "名为 '" + strServerName + "' 的服务器在检索窗中尚未定义...";
                        goto ERROR1;
                    }
                    string strServerUrl = server.Url;

                    this.Channel = this.Channels.GetChannel(strServerUrl);

                    string[] results = null;
                    byte[] baTimestamp = null;
                    string strOutputPath = "";

                    stop.SetMessage("正在删除书目记录 " + strPurePath);

                    long lRet = Channel.GetBiblioInfos(
                        stop,
                        strPurePath,
                        "",
                        null,   // formats
                        out results,
                        out baTimestamp,
                        out strError);
                    if (lRet == -1)
                    {
                        result = MessageBox.Show(this,
    "在获得记录 '" + strRecPath + "' 的时间戳的过程中出现错误: " + strError + "。\r\n\r\n是否继续强行删除此记录? (Yes 强行删除;No 不删除;Cancel 放弃当前未完成的全部删除操作)",
    "dp2SearchForm",
    MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button1);
                        if (result == System.Windows.Forms.DialogResult.Cancel)
                            goto ERROR1;
                        if (result == System.Windows.Forms.DialogResult.No)
                            continue;
                    }
                    if (lRet == -1 || lRet == 0)
                        goto ERROR1;

                    byte[] baNewTimestamp = null;

                    lRet = Channel.SetBiblioInfo(
                        stop,
                        "delete",
                        strPurePath,
                        "xml",
                        "", // strXml,
                        baTimestamp,
                        "",
                        out strOutputPath,
                        out baNewTimestamp,
                        out strError);
                    if (lRet == -1)
                        goto ERROR1;

                    stop.SetProgressValue(i);

                    this.listView_browse.Items.Remove(item);
                }
            }
            finally
            {
                this._processing--;
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
                stop.HideProgress();
                stop.Style = StopStyle.None;

                this.EnableControlsInSearching(true);
                this.listView_browse.SelectedIndexChanged += new System.EventHandler(this.listView_browse_SelectedIndexChanged);
            }

            MessageBox.Show(this, "成功删除书目记录 " + items.Count + " 条");
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:dp2SearchForm.cs

示例6: SaveChangedRecords

        int SaveChangedRecords(List<ListViewItem> items,
    out string strError)
        {
            strError = "";

            int nReloadCount = 0;
            int nSavedCount = 0;

            stop.Style = StopStyle.EnableHalfStop;
            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在保存书目记录 ...");
            stop.BeginLoop();

            this.EnableControlsInSearching(false);
            this.listView_browse.Enabled = false;
            try
            {
                stop.SetProgressRange(0, items.Count);
                for (int i = 0; i < items.Count; i++)
                {
                    if (stop != null && stop.State != 0)
                    {
                        strError = "已中断";
                        return -1;
                    }

                    ListViewItem item = items[i];
                    string strRecPath = item.Text;
                    if (string.IsNullOrEmpty(strRecPath) == true)
                    {
                        stop.SetProgressValue(i);
                        goto CONTINUE;
                    }

                    BiblioInfo info = (BiblioInfo)this.m_biblioTable[strRecPath];
                    if (info == null)
                        goto CONTINUE;

                    if (string.IsNullOrEmpty(info.NewXml) == true)
                        goto CONTINUE;

                    stop.SetMessage("正在保存书目记录 " + strRecPath);

                    // 解析记录路径
                    string strServerName = "";
                    string strPurePath = "";
                    ParseRecPath(strRecPath,
                        out strServerName,
                        out strPurePath);

                    // 获得server url
                    dp2Server server = this.dp2ResTree1.Servers.GetServerByName(strServerName);
                    if (server == null)
                    {
                        strError = "名为 '" + strServerName + "' 的服务器在检索窗中尚未定义...";
                        return -1;
                    }
                    string strServerUrl = server.Url;

                    this.Channel = this.Channels.GetChannel(strServerUrl);

                    string strOutputPath = "";

                    byte[] baNewTimestamp = null;

                    long lRet = Channel.SetBiblioInfo(
                        stop,
                        "change",
                        strPurePath,
                        "xml",
                        info.NewXml,
                        info.Timestamp,
                        "",
                        out strOutputPath,
                        out baNewTimestamp,
                        out strError);
                    if (lRet == -1)
                    {
                        if (Channel.ErrorCode == ErrorCode.TimestampMismatch)
                        {
                            DialogResult result = MessageBox.Show(this,
    "保存书目记录 " + strRecPath + " 时遭遇时间戳不匹配: " + strError + "。\r\n\r\n此记录已无法被保存。\r\n\r\n请问现在是否要顺便重新装载此记录? \r\n\r\n(Yes 重新装载;\r\nNo 不重新装载、但继续处理后面的记录保存; \r\nCancel 中断整批保存操作)",
    "BiblioSearchForm",
    MessageBoxButtons.YesNoCancel,
    MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button1);
                            if (result == System.Windows.Forms.DialogResult.Cancel)
                                break;
                            if (result == System.Windows.Forms.DialogResult.No)
                                goto CONTINUE;

                            // 重新装载书目记录到 OldXml
                            string[] results = null;
                            // byte[] baTimestamp = null;
                            lRet = Channel.GetBiblioInfos(
                                stop,
                                strPurePath,
                                "",
                                new string[] { "xml" },   // formats
                                out results,
//.........这里部分代码省略.........
开发者ID:renyh1013,项目名称:dp2,代码行数:101,代码来源:dp2SearchForm.cs

示例7: SaveXmlRecord

        // 保存记录
        // parameters:
        //      strPath 格式为"中文图书/[email protected]本地服务器"
        //      strOutputPath   格式为"中文图书/[email protected]本地服务器"
        public int SaveXmlRecord(
            string strPath,
            string strXml,
            byte[] baTimestamp,
            out string strOutputPath,
            out byte[] baOutputTimestamp,
            out string strError)
        {
            strError = "";
            baOutputTimestamp = null;
            strOutputPath = "";

            // int nRet = 0;

            // 将strPath解析为server url和local path两个部分
            string strServerName = "";
            string strPurePath = "";
            ParseRecPath(strPath,
                out strServerName,
                out strPurePath);

            // 获得server url
            dp2Server server = this.dp2ResTree1.Servers.GetServerByName(strServerName);
            if (server == null)
            {
                strError = "名为 '" + strServerName + "' 的服务器在检索窗中尚未定义...";
                return -1;
            }
            string strServerUrl = server.Url;

            this.Channel = this.Channels.GetChannel(strServerUrl);

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

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

            try
            {
                string strAction = "change";

                if (IsAppendRecPath(strPath) == true)
                    strAction = "new";


                stop.SetMessage("正在保存书目记录 " + strPath + " ...");

                string strOutputBiblioRecPath = "";

                long lRet = Channel.SetBiblioInfo(
                    stop,
                    strAction,
                    strPurePath,
                    "xml",
                    strXml,
                    baTimestamp,
                    "",
                    out strOutputBiblioRecPath,
                    out baOutputTimestamp,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;

                strOutputPath = strOutputBiblioRecPath + "@" + strServerName;
                // this.BiblioTimestamp = baTimestamp;


            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
            }
            return 0;
        ERROR1:
            return -1;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:84,代码来源:dp2SearchForm.cs

示例8: DeleteOneRecord

        // 删除一条MARC/XML记录
        // parameters:
        //      strSavePath 内容为"中文图书/[email protected]本地服务器"。没有协议名部分。
        // return:
        //      -1  error
        //      0   suceed
        public int DeleteOneRecord(
            string strSavePath,
            byte[] baTimestamp,
            out byte[] baOutputTimestamp,
            out string strError)
        {
            baOutputTimestamp = null;
            strError = "";

            // 解析记录路径
            string strServerName = "";
            string strPurePath = "";
            ParseRecPath(strSavePath,
                out strServerName,
                out strPurePath);

            // 获得server url
            dp2Server server = this.dp2ResTree1.Servers.GetServerByName(strServerName);
            if (server == null)
            {
                strError = "名为 '" + strServerName + "' 的服务器在检索窗中尚未定义...";
                return -1;
            }
            string strServerUrl = server.Url;

            this.Channel = this.Channels.GetChannel(strServerUrl);

            stop.OnStop += new StopEventHandler(this.DoStop);
            stop.Initial("正在删除记录 ...");
            stop.BeginLoop();

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

            try
            {
                stop.SetMessage("正在删除书目记录 " + strPurePath + " ...");


                string[] formats = null;
                formats = new string[1];
                formats[0] = "xml";

                // string[] results = null;
                //                 byte[] baTimestamp = null;

                string strOutputBibilioRecPath = "";

                long lRet = Channel.SetBiblioInfo(
                    stop,
                    "delete",
                    strPurePath,
                    "xml",
                    "",
                    baTimestamp,
                    "",
                    out strOutputBibilioRecPath,
                    out baOutputTimestamp,
                    out strError);
                if (lRet == -1)
                    goto ERROR1;
            }
            finally
            {
                stop.EndLoop();
                stop.OnStop -= new StopEventHandler(this.DoStop);
                stop.Initial("");
            }
            return 0;
        ERROR1:
            return -1;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:78,代码来源:dp2SearchForm.cs


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