Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

定制索取号创建规则一例 #1163

Open
DigitalPlatform opened this issue Oct 9, 2022 · 0 comments
Open

定制索取号创建规则一例 #1163

DigitalPlatform opened this issue Oct 9, 2022 · 0 comments

Comments

@DigitalPlatform
Copy link
Owner

某用户单位希望创建的索取号为以下形态

分类号/同类书区分号/出版年份

即,在一般的索取号后面增加第三行“出版年份”。

升级 dp2circulation 到最新版,定制“中文图书”的 dp2circulation_marc_autogen.cs 文件,增加下列函数即可:

    public override string MergeLines(string strHeadLine,
    string strClass,
    string strQufenhao)
    {
        string text = base.MergeLines(strHeadLine, strClass, strQufenhao);

        string strMARC = this.DetailForm.MarcEditor.Marc;
        var record = new MarcRecord(strMARC);
        var publish_time = record.select("field[@name='210']/subfield[@name='d']").FirstContent;

        return text + "/" + GetYear(publish_time);

        string GetYear(string text)
        {
            if (string.IsNullOrEmpty(text))
                return "";
            int index = text.IndexOf(".");
            if (index == -1)
                return text;
            return text.Substring(0, index).Trim();
        }
    }

定制的原理是,dp2circulation_marc_autogen.cs 代码内的 MyHost 类是从宿主程序的 DetailHost 类派生的一个类,MyHost 类中重载基类的 MergeLines() 函数,这个函数是用来在创建索取号最后一步合成多行的,只需要在基类的此函数合成的字符串基础上追加第三行内容即可。第三行内容是从书目记录 MARC 中取相应字段子字段得到的,用了 MarcQuery 函数来操作 MARC 记录。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant