using System; using System.Windows.Forms; using System.IO; using System.Text; using dp2rms; using DigitalPlatform.Xml; using DigitalPlatform.Marc; using DigitalPlatform.IO; using DigitalPlatform.GcatClient; using DigitalPlatform; using DigitalPlatform.Library; using DigitalPlatform.rms.Client; using DigitalPlatform.Text; public class MyHost : Host { DupDlg dupdlg = null; string [] cfgFields = new string [] { "200(a-9)", "701(a-9)", "711(a-9)", "702(a-9)", "712(a-9)" }; /* // 为产生著者号码的用户名和密码 string UserName = ""; string Password = ""; */ public override void Main(object sender, HostEventArgs e) { ScriptActionCollection actions = new ScriptActionCollection(); actions.NewItem("加拼音", "给.....加拼音", "AddPinyin", false); actions.NewItem("7*1$a <-- 200$f", "将200$f内容加入701/711字段$a", "Copy200fTo7x1a", false); actions.NewItem("7*2$a <-- 200$g", "将200$g内容加入702/712字段$a", "Copy200gTo7x2a", false); actions.NewItem("加入著者号", "根据701/711/702/712$a内容, 创建905$a", "AddAuthorNumber", false); actions.NewItem("加入种次号", "根据905$d内容, 创建905$e", "AddZhongcihao", false); actions.NewItem("维护种次号", "根据905$d内容中的类号, 出现维护种次号的界面", "ManageZhongcihao", false); actions.NewItem("210$a$c <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建出版社子字段210$a$c", "AddPublisher", false); actions.NewItem("102$a$b <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建102字段$a国家代码$b地区代码", "Add102", false); actions.NewItem("加入主题词", "根据690$a中的中图法类号, 自动查获对应的主题词,加入606$a", "Class2Subject", false); actions.NewItem("测试查重", "成批测试查重", "TestDup", false); ScriptActionMenuDlg dlg = new ScriptActionMenuDlg(); dlg.Actions = actions; dlg.StartPosition = FormStartPosition.CenterScreen; dlg.ShowDialog(); if (dlg.DialogResult == DialogResult.OK) { this.Invoke(dlg.SelectedAction.ScriptEntry); } } void Copy200gTo7x2a() { Copy200gfTo7xxa("g", "702"); } void Copy200fTo7x1a() { Copy200gfTo7xxa("f", "701"); } void Copy200gfTo7xxa(string strFromSubfield, string strToField) { Field field_200 = this.DetailForm.MarcEditor.Record.Fields.GetOneField("200",0); SubfieldCollection subfields_200 = field_200.Subfields; Subfield subfield_f = subfields_200[strFromSubfield]; if (subfield_f == null) { MessageBox.Show(this.DetailForm, "200$"+strFromSubfield+"不存在"); return; } string strContent = subfield_f.Value; // 看看当前活动字段是不是701 Field field_701 = null; field_701 = this.DetailForm.MarcEditor.FocusedField; if (field_701 != null) { if (field_701.Name != strToField) field_701 = null; } if (field_701 == null) { field_701 = this.DetailForm.MarcEditor.Record.Fields.GetOneField(strToField, 0); if (field_701 == null) { field_701 = this.DetailForm.MarcEditor.Record.Fields.Add(strToField, " ", "", true); } } if (field_701 == null) throw(new Exception("error ...")); Subfield subfield_701a = field_701.Subfields["a"]; if (subfield_701a == null) { subfield_701a = new Subfield(); subfield_701a.Name = "a"; } subfield_701a.Value = strContent; field_701.Subfields["a"] = subfield_701a; } void AddPinyin() { PinyinStyle style = PinyinStyle.None; // 在这里修改拼音大小写风格 for(int i=0;i