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

内务批导出到 ISO2709 功能中的 C# 脚本 #1197

Open
DigitalPlatform opened this issue Nov 24, 2024 · 1 comment
Open

内务批导出到 ISO2709 功能中的 C# 脚本 #1197

DigitalPlatform opened this issue Nov 24, 2024 · 1 comment

Comments

@DigitalPlatform
Copy link
Owner

如题。

@DigitalPlatform
Copy link
Owner Author

如何对修改前后的 MARC 记录内容进行调试?

方法一:使用 MarcRecordDialog::Show(MarcRecord record, ...) 函数

函数原型:

        public static DialogResult Show(MarcRecord record,
            string title = "MarcRecord",
            string style = "save_size")

样例代码:

public class MyVerifyHost : VerifyHost
{
    // 进行过滤
    public override VerifyResult Verify(string action, string marc)
    {
        string old_marc = marc;
        var record = new MarcRecord(marc, "4**");

        MarcRecordDialog.Show(MainForm, record, "修改前");

        // 删除 997 和 998 字段
        record.select("field[@name='997' or @name='998']").detach();

        MarcRecordDialog.Show(MainForm, record, "修改后");

        return new VerifyResult
        {
            Value = 0,
            ChangedMarc = record.Text,
            ErrorInfo = "",
        };
    }
}

显示两次对话框,分别显示修改前和修改后的内容。缺点是没有直接对照显示,观看起来不是太轻松。

方法二:使用 MarcRecordDialog::Show(MarcRecord record1, MarcRecord record2, ...) 函数

函数原型:

        public static DialogResult Show(
            MarcRecord record1,
            MarcRecord record2,
            string title = "MarcRecord",
            string style = "save_size")

样例代码:

public class MyVerifyHost : VerifyHost
{
    // 进行过滤
    public override VerifyResult Verify(string action, string marc)
    {
        string old_marc = marc;
        var record = new MarcRecord(marc, "4**");

        // 保存修改前的内容
        var record1 = record.clone() as MarcRecord;

        // 删除 997 和 998 字段
        record.select("field[@name='997' or @name='998']").detach();

        MarcRecordDialog.Show(record1, 
            record, 
            "对比修改前后的记录", 
            "save_size,left_title:修改前,right_title:修改后");

        return new VerifyResult
        {
            Value = 0,
            ChangedMarc = record.Text,
            ErrorInfo = "",
        };
    }
}

一个对话框左右两侧显示修改前后的内容对照,有彩色表示差异部分。

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