Ejemplo n.º 1
0
 public virtual void Main(object sender, HostEventArgs e)
 {
 }
Ejemplo n.º 2
0
        public virtual void Main(object sender, HostEventArgs e)
        {

        }
Ejemplo n.º 3
0
        int RunVerifyCsScript(
    object sender,
    GenerateDataEventArgs e,
    string strCode,
    string strRef,
            out VerifyHost hostObj,
    out string strError)
        {
            strError = "";
            string[] saRef = null;
            int nRet;
            hostObj = null;

            nRet = ScriptManager.GetRefsFromXml(strRef,
                out saRef,
                out strError);
            if (nRet == -1)
                return -1;

            // 2007/12/4
            ScriptManager.RemoveRefsBinDirMacro(ref saRef);

            string[] saAddRef = {
                                    "system.dll",
                                    "system.xml.dll",
                                    "system.windows.forms.dll",
                                    "system.drawing.dll",
                                    "System.Runtime.Serialization.dll",

									Environment.CurrentDirectory + "\\digitalplatform.dll",
									Environment.CurrentDirectory + "\\digitalplatform.IO.dll",
									Environment.CurrentDirectory + "\\digitalplatform.Text.dll",
									Environment.CurrentDirectory + "\\digitalplatform.Xml.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marceditor.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marckernel.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marcfixedfieldcontrol.dll",
									Environment.CurrentDirectory + "\\digitalplatform.gcatclient.dll",
									Environment.CurrentDirectory + "\\digitalplatform.script.dll",
									Environment.CurrentDirectory + "\\digitalplatform.commoncontrol.dll",
									Environment.CurrentDirectory + "\\digitalplatform.circulationclient.dll",
									Environment.CurrentDirectory + "\\dp2catalog.exe"
								};

            if (saAddRef != null)
            {
                string[] saTemp = new string[saRef.Length + saAddRef.Length];
                Array.Copy(saRef, 0, saTemp, 0, saRef.Length);
                Array.Copy(saAddRef, 0, saTemp, saRef.Length, saAddRef.Length);
                saRef = saTemp;
            }

            Assembly assembly = null;
            string strErrorInfo = "";
            string strWarningInfo = "";
            nRet = ScriptManager.CreateAssembly_1(strCode,
                saRef,
                null,   // strLibPaths,
                out assembly,
                out strErrorInfo,
                out strWarningInfo);
            if (nRet == -1)
            {
                strError = "脚本编译发现错误或警告:\r\n" + strErrorInfo;
                return -1;
            }

            // 得到Assembly中VerifyHost派生类Type
            Type entryClassType = ScriptManager.GetDerivedClassType(
                assembly,
                "dp2Catalog.VerifyHost");
            if (entryClassType == null)
            {

                strError = "dp2Catalog.VerifyHost派生类没有找到";
                return -1;
            }

            {
                // new一个VerifyHost派生对象
                hostObj = (VerifyHost)entryClassType.InvokeMember(null,
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Public | BindingFlags.NonPublic |
                    BindingFlags.Instance | BindingFlags.CreateInstance, null, null,
                    null);

                if (hostObj == null)
                {
                    strError = "new VerifyHost派生类对象失败";
                    return -1;
                }

                // 为Host派生类设置参数
                hostObj.DetailForm = this;
                hostObj.Assembly = assembly;

                HostEventArgs e1 = new HostEventArgs();
                e1.e = e;   // 2009/2/24

                hostObj.Main(sender, e1);
            }

            return 0;
        }
Ejemplo n.º 4
0
    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);
		}
	}
Ejemplo n.º 5
0
        int RunScript(string strCode,
            string strRef,
            out string strError)
        {
            strError = "";
            string[] saRef = null;
            int nRet;
            // string strWarning = "";

            nRet = ScriptManager.GetRefsFromXml(strRef,
                out saRef,
                out strError);
            if (nRet == -1)
                return -1;

            // 2007/12/4
            ScriptManager.RemoveRefsBinDirMacro(ref saRef);

            string[] saAddRef = {
                                    // 2011/5/4 增加
                                    "system.dll",
                                    "system.xml.dll",
                                    "system.windows.forms.dll",
                                    "system.drawing.dll",
                                    "System.Runtime.Serialization.dll",

									Environment.CurrentDirectory + "\\digitalplatform.dll",
									Environment.CurrentDirectory + "\\digitalplatform.IO.dll",
									Environment.CurrentDirectory + "\\digitalplatform.Text.dll",
									Environment.CurrentDirectory + "\\digitalplatform.Xml.dll",
									Environment.CurrentDirectory + "\\digitalplatform.script.dll",

									//Environment.CurrentDirectory + "\\digitalplatform.xmleditor.dll",
									//Environment.CurrentDirectory + "\\digitalplatform.rms.dll",
									//Environment.CurrentDirectory + "\\digitalplatform.rms.client.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marceditor.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marckernel.dll",
									Environment.CurrentDirectory + "\\digitalplatform.marcfixedfieldcontrol.dll",
									Environment.CurrentDirectory + "\\digitalplatform.gcatclient.dll",
									//Environment.CurrentDirectory + "\\digitalplatform.library.dll",
									// Environment.CurrentDirectory + "\\Interop.SHDocVw.dll",
									Environment.CurrentDirectory + "\\dp2catalog.exe"
								};

            if (saAddRef != null)
            {
                string[] saTemp = new string[saRef.Length + saAddRef.Length];
                Array.Copy(saRef, 0, saTemp, 0, saRef.Length);
                Array.Copy(saAddRef, 0, saTemp, saRef.Length, saAddRef.Length);
                saRef = saTemp;
            }

            /*
            Assembly assembly = ScriptManager.CreateAssembly(
                strCode,
                saRef,
                null,	// strLibPaths,
                null,	// strOutputFile,
                out strError,
                out strWarning);
            if (assembly == null)
            {
                strError = "脚本编译发现错误或警告:\r\n" + strError;
                return -1;
            }*/
            Assembly assembly = null;
            string strErrorInfo = "";
            string strWarningInfo = "";
            nRet = ScriptManager.CreateAssembly_1(strCode,
                saRef,
                null,   // strLibPaths,
                out assembly,
                out strErrorInfo,
                out strWarningInfo);
            if (nRet == -1)
            {
                strError = "脚本编译发现错误或警告:\r\n" + strErrorInfo;
                return -1;
            }

            // 得到Assembly中Host派生类Type
            Type entryClassType = ScriptManager.GetDerivedClassType(
                assembly,
                "dp2Catalog.MarcDetailHost");
            if (entryClassType == null)
            {
                strError = "dp2Catalog.MarcDetailHost派生类没有找到";
                return -1;
            }

            // new一个MarcDetailHost派生对象
            MarcDetailHost hostObj = (MarcDetailHost)entryClassType.InvokeMember(null,
                BindingFlags.DeclaredOnly |
                BindingFlags.Public | BindingFlags.NonPublic |
                BindingFlags.Instance | BindingFlags.CreateInstance, null, null,
                null);

            if (hostObj == null)
            {
                strError = "new Host派生类对象失败";
                return -1;
            }

            // 为Host派生类设置参数
            hostObj.DetailForm = this;
            hostObj.Assembly = assembly;

            HostEventArgs e = new HostEventArgs();

            /*
            nRet = this.Flush(out strError);
            if (nRet == -1)
                return -1;
             * */


            hostObj.Main(null, e);

            /*
            nRet = this.Flush(out strError);
            if (nRet == -1)
                return -1;
             * */

            return 0;
        }