// dp2circulation编目自动创建数据C#脚本程序 // 最后修改时间2007/12/3 using System; using System.Windows.Forms; using System.IO; using System.Text; using dp2Circulation; using DigitalPlatform.Xml; using DigitalPlatform.Marc; using DigitalPlatform.IO; using DigitalPlatform.GcatClient; using DigitalPlatform; using DigitalPlatform.Text; public class MyHost : Host { DigitalPlatform.GcatClient.Channel GcatChannel = null; string [] cfgFields = new string [] { "200(a-9)", "701(a-9)", "711(a-9)", "702(a-9)", "712(a-9)" }; public override void Main(object sender, HostEventArgs e) { Field curfield = this.DetailForm.MarcEditor.FocusedField; ScriptActionCollection actions = new ScriptActionCollection(); bool bActive = false; // 加拼音 actions.NewItem("加拼音", "给.....加拼音", "AddPinyin", false); // 7*1$a <-- 200$f if (curfield != null && (curfield.Name == "701" || curfield.Name == "711") ) bActive = true; else bActive = false; actions.NewItem("7*1$a <-- 200$f", "将200$f内容加入701/711字段$a", "Copy200fTo7x1a", bActive); // 7*2$a <-- 200$g if (curfield != null && (curfield.Name == "702" || curfield.Name == "712") ) bActive = true; else bActive = false; actions.NewItem("7*2$a <-- 200$g", "将200$g内容加入702/712字段$a", "Copy200gTo7x2a", bActive); // 410 <-- 225 if (curfield != null && (curfield.Name == "225" || curfield.Name == "410") ) bActive = true; else bActive = false; actions.NewItem("410 <-- 225", "将225$a内容加入410 $1200 $a", "Copy225To410", bActive); // 加入著者号 if (curfield != null && curfield.Name == "905") bActive = true; else bActive = false; actions.NewItem("加入著者号", "根据701/711/702/712$a内容, 创建905$e", "AddAuthorNumber", bActive); // 加入种次号 if (curfield != null && curfield.Name == "905" && this.DetailForm.MarcEditor.FocusedSubfieldName == 'd') bActive = true; else bActive = false; actions.NewItem("加入种次号", "根据905$d内容, 创建905$e", "AddZhongcihao", bActive); // 维护种次号 actions.NewItem("维护种次号", "根据905$d内容中的类号, 出现维护种次号的界面", "ManageZhongcihao", false); // 出版地 if (curfield != null && curfield.Name == "210") bActive = true; else bActive = false; actions.NewItem("210$a$c <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建出版社子字段210$a$c", "AddPublisher", bActive); // 规整ISBN为13 if (curfield != null && curfield.Name == "010") bActive = true; else bActive = false; actions.NewItem("规整ISBN-13", "对010$a中ISBN进行规整", "HyphenISBN_13", bActive); // 规整ISBN为10 if (curfield != null && curfield.Name == "010") bActive = true; else bActive = false; actions.NewItem("规整ISBN-10", "对010$a中ISBN进行规整", "HyphenISBN_10", bActive); // 102国家代码 地区代码 if (curfield != null && curfield.Name == "102") bActive = true; else bActive = false; actions.NewItem("102$a$b <-- 010$a", "根据010$a中ISBN出版社代码, 自动创建102字段$a国家代码$b地区代码", "Add102", bActive); ScriptActionMenuDlg dlg = new ScriptActionMenuDlg(); dlg.Actions = actions; if ((Control.ModifierKeys & Keys.Alt)== Keys.Alt) dlg.AutoRun = false; else dlg.AutoRun = this.DetailForm.MainForm.AppInfo.GetBoolean("detailform", "gen_auto_run", false); // dlg.StartPosition = FormStartPosition.CenterScreen; this.DetailForm.MainForm.AppInfo.LinkFormState(dlg, "gen_data_dlg_state"); dlg.ShowDialog(); this.DetailForm.MainForm.AppInfo.UnlinkFormState(dlg); this.DetailForm.MainForm.AppInfo.SetBoolean("detailform", "gen_auto_run", dlg.AutoRun); if (dlg.DialogResult == DialogResult.OK) { this.Invoke(dlg.SelectedAction.ScriptEntry); } } void AddPinyin() { this.DetailForm.MarcEditor.Enabled = false; try { PinyinStyle style = PinyinStyle.None; // 在这里修改拼音大小写风格 for(int i=0;i