public virtual void Main(object sender, HostEventArgs e) { }
int RunScript(string strCode, string strRef, out string strError) { strError = ""; string [] saRef = null; int nRet; string strWarning = ""; nRet = Script.GetRefs(strRef, out saRef, out strError); if (nRet == -1) return -1; string[] saAddRef = { Environment.CurrentDirectory + "\\digitalplatform.dll", Environment.CurrentDirectory + "\\digitalplatform.IO.dll", Environment.CurrentDirectory + "\\digitalplatform.Text.dll", Environment.CurrentDirectory + "\\digitalplatform.Xml.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 + "\\dp2rms.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 = Script.CreateAssembly( strCode, saRef, null, // strLibPaths, null, // strOutputFile, out strError, out strWarning); if (assembly == null) { strError = "脚本编译发现错误或警告:\r\n" + strError; return -1; } // 得到Assembly中Host派生类Type Type entryClassType = Script.GetDerivedClassType( assembly, "dp2rms.Host"); // new一个Host派生对象 Host hostObj = (Host)entryClassType.InvokeMember(null, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.CreateInstance, null, null, null); // 为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; }