public FrmIssue(string plugintype) { InitializeComponent(); _plugintype = plugintype; List <PluginClass> plist2 = new List <PluginClass>(); if (plugintype == "WinformModulePlugin") { PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; List <PluginClass> plist = PluginSysManage.GetAllPlugin(); plist2.AddRange(plist.FindAll(x => (x.plugintype == "WinformModulePlugin"))); } else if (plugintype == "WcfModulePlugin") { PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; List <PluginClass> plist = PluginSysManage.GetAllPlugin(); plist2.AddRange(plist.FindAll(x => (x.plugintype == "WcfModulePlugin"))); } else if (plugintype == "WebModulePlugin") { PluginSysManage.pluginsysFile = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml"; List <PluginClass> plist = PluginSysManage.GetAllPlugin(); plist2.AddRange(plist.FindAll(x => (x.plugintype == "WebModulePlugin"))); } gridplugin.AutoGenerateColumns = false; gridplugin.DataSource = plist2; }
public static Dictionary <string, AppDomain> DomainDic; //程序域来动态管理插件 /// <summary> /// 加载所有插件 /// </summary> public static void LoadAllPlugin() { PluginDic = null; List <string> pflist = PluginSysManage.GetAllPluginFile(); for (int i = 0; i < pflist.Count; i++) { AddPlugin(AppGlobal.AppRootPath + pflist[i]); } }
//将菜单设置为启动项 private void btnSetstartitem_Click(object sender, EventArgs e) { //FrmDevSetting setting = new FrmDevSetting(); //setting.ShowDialog(); if (gridpluginmenu.CurrentCell == null) { return; } if (treePlugin.SelectedNode == null || treePlugin.SelectedNode.Tag == null) { return; } PluginClass pc = (PluginClass)treePlugin.SelectedNode.Tag; List <menuClass> mlist = gridpluginmenu.DataSource as List <menuClass>; menuClass menu = mlist[gridpluginmenu.CurrentCell.RowIndex]; if (pc.plugintype == "WebModulePlugin") { string netwebserver = CommonHelper.AppRootPath + "\\NetWebServer.exe.config"; XmlDocument xmlDoc_webserver = new System.Xml.XmlDocument(); xmlDoc_webserver.Load(netwebserver); XmlNode node = xmlDoc_webserver.DocumentElement.SelectSingleNode("appSettings/add[@key='defaultpage']"); node.Attributes["value"].Value = menu.menupath; xmlDoc_webserver.Save(netwebserver); } else if (pc.plugintype == "WinformModulePlugin") { string pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; string appconfig = CommonHelper.WinformPlatformPath + "\\EFWWin.exe.config"; XmlDocument xmlDoc_app = new System.Xml.XmlDocument(); xmlDoc_app.Load(appconfig); PluginSysManage.pluginsysFile = pluginsysFile; XmlNode node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='ClientType']"); node.Attributes["value"].Value = "Winform"; xmlDoc_app.Save(appconfig); PluginSysManage.SetWinformEntry(menu.pluginname, menu.viewname == "" ? menu.controllername : menu.controllername + "|" + menu.viewname); } else if (pc.plugintype == "WcfModulePlugin") { string pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; string appconfig = CommonHelper.WinformPlatformPath + "\\EFWWin.exe.config"; XmlDocument xmlDoc_app = new System.Xml.XmlDocument(); xmlDoc_app.Load(appconfig); PluginSysManage.pluginsysFile = pluginsysFile; XmlNode node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='ClientType']"); node.Attributes["value"].Value = "WCFClient"; xmlDoc_app.Save(appconfig); PluginSysManage.SetWcfClientEntry(menu.pluginname, menu.viewname == "" ? menu.controllername : menu.controllername + "|" + menu.viewname); } MessageBoxEx.Show("设置启动项成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public static Dictionary <string, AppDomain> DomainDic; //程序域来动态管理插件 /// <summary> /// 加载所有插件 /// </summary> public static void LoadAllPlugin() { PluginDic = new Dictionary <string, ModulePlugin>(); //RemotePluginDic = new List<RemotePlugin>(); List <string> pflist = PluginSysManage.GetAllPluginFile(); for (int i = 0; i < pflist.Count; i++) { AddPlugin(AppGlobal.AppRootPath + pflist[i]); } }
/// <summary> /// 加载插件,之后必须重启中间件 /// </summary> /// <param name="plugfile"></param> public static void AddPlugin(string pluginfile) { string filepath = AppGlobal.AppRootPath + pluginfile;//转为绝对路径 ModulePlugin mp = new ModulePlugin(); mp.appType = AppGlobal.appType; mp.LoadPlugin(filepath); PluginSysManage.AddPlugin(mp.plugin.name, mp.plugin.title, pluginfile, mp.plugin.version); }
private void FrmDevSetting_Load(object sender, EventArgs e) { tabControl.SelectedIndex = 1; xmlDoc_plugin = new System.Xml.XmlDocument(); xmlDoc_plugin.Load(pluginsysFile); xmlDoc_app = new System.Xml.XmlDocument(); xmlDoc_app.Load(appconfig); xmlDoc_webserver = new System.Xml.XmlDocument(); xmlDoc_webserver.Load(netwebserver); PluginSysManage.pluginsysFile = pluginsysFile; plist = PluginSysManage.GetAllPlugin(); XmlNode node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='ClientType']"); if (node != null) { string ClientType = node.Attributes["value"].Value; if (ClientType == "Winform") { rbwinform.Checked = true; } else if (ClientType == "WCFClient") { rbwcfclient.Checked = true; } rbwinform_CheckedChanged(null, null); } node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='WCF_endpoint']"); if (node != null) { txtwcfendpoint.Text = node.Attributes["value"].Value; } node = xmlDoc_webserver.DocumentElement.SelectSingleNode("appSettings/add[@key='defaultpage']"); if (node != null) { txtStartPage.Text = node.Attributes["value"].Value; } node = xmlDoc_webserver.DocumentElement.SelectSingleNode("appSettings/add[@key='port']"); if (node != null) { txtPort.Text = node.Attributes["value"].Value; } }
public static Dictionary <string, ModulePlugin> PluginDic;//本地插件 /// <summary> /// 加载所有插件 /// </summary> public static void LoadAllPlugin() { PluginDic = new Dictionary <string, ModulePlugin>(); List <string> pflist = PluginSysManage.GetAllPluginFile(); for (int i = 0; i < pflist.Count; i++) { //AddPlugin(pflist[i]); string filepath = AppGlobal.AppRootPath + pflist[i];//转为绝对路径 ModulePlugin mp = new ModulePlugin(); mp.appType = AppGlobal.appType; mp.LoadPlugin(filepath); mp.LoadAttribute(filepath); PluginDic.Add(mp.plugin.name, mp); } }
private void loadplugintree() { List <PluginClass> plist = new List <PluginClass>(); PluginSysManage.pluginsysFile = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml"; List <PluginClass> plist1 = PluginSysManage.GetAllPlugin(); plist.AddRange(plist1.FindAll(x => x.plugintype == "WebModulePlugin")); PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; List <PluginClass> plist2 = PluginSysManage.GetAllPlugin(); plist.AddRange(plist2.FindAll(x => (x.plugintype == "WinformModulePlugin" || x.plugintype == "WcfModulePlugin"))); LoadTree(plist); }
static void setprivatepath() { //AppDomain.CurrentDomain.SetupInformation.PrivateBinPath = @"Component;ModulePlugin\Books_Wcf\dll;ModulePlugin\WcfMainUIFrame\dll"; string privatepath = @"Component"; foreach (var p in PluginSysManage.GetWinformPlugin()) { privatepath += ";" + p.Replace("plugin.xml", "dll"); } AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", privatepath); AppDomain.CurrentDomain.SetData("BINPATH_PROBE_ONLY", privatepath); var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static); var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance); m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", privatepath }); }
static bool AppGlobal_Init() { try { AppGlobal.AppStart(); if (missingDll.Count > 0) { string msg = "缺失的程序集:\r"; for (int i = 0; i < missingDll.Count; i++) { msg += missingDll[i] + "\r"; } MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } string entryplugin; string entrycontroller; switch (appType) { case AppType.Winform: PluginSysManage.GetWinformEntry(out entryplugin, out entrycontroller); EFWCoreLib.WinformFrame.Controller.WinformController controller = EFWCoreLib.WinformFrame.Controller.ControllerHelper.CreateController(entryplugin + "@" + entrycontroller); //controller.Init(); if (controller == null) { throw new Exception("插件配置的启动项(插件名或控制器名称)不正确!"); } ((System.Windows.Forms.Form)controller.DefaultView).Show(); winfromMain.MainForm = ((System.Windows.Forms.Form)controller.DefaultView); break; } return(true); } catch (Exception err) { //记录错误日志 ZhyContainer.CreateException().HandleException(err, "HISPolicy"); //Application.Exit(); //throw new Exception(err.Message + "\n\n请联系管理员!"); MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); //AppExit(); return(false); } }
private void rbwinform_CheckedChanged(object sender, EventArgs e) { cbpname.DisplayMember = "name"; cbpname.ValueMember = "name"; string entryplugin, entrycontroller; if (rbwinform.Checked) { cbpname.DataSource = plist.FindAll(x => x.plugintype == "WinformModulePlugin"); PluginSysManage.GetWinformEntry(out entryplugin, out entrycontroller); } else { cbpname.DataSource = plist.FindAll(x => x.plugintype == "WcfModulePlugin"); PluginSysManage.GetWcfClientEntry(out entryplugin, out entrycontroller); } cbpname.SelectedValue = entryplugin; txtcname.Text = entrycontroller; }
//添加现有插件项目 private void AddProject_Click(object sender, EventArgs e) { openPlugin.InitialDirectory = CommonHelper.PathCombine(CommonHelper.AppRootPath, "..\\"); if (openPlugin.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string file = openPlugin.FileName; PluginXmlManage.pluginfile = file; pluginxmlClass plugin = PluginXmlManage.getpluginclass(); string pluginsyspath = null; string plugintype = ""; if (plugin.plugintype == "Web") { plugintype = "WebModulePlugin"; pluginsyspath = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml"; } else if (plugin.plugintype == "Winform") { plugintype = "WinformModulePlugin"; pluginsyspath = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; } else if (plugin.plugintype == "Wcf") { plugintype = "WcfModulePlugin"; pluginsyspath = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; } if (PluginSysManage.ContainsPlugin(plugintype, plugin.name) == false) { PluginSysManage.pluginsysFile = pluginsyspath; PluginSysManage.AddPlugin(plugintype, plugin.name, "ModulePlugin/" + plugin.name + "/plugin.xml", plugin.title, "1"); MessageBoxEx.Show("插件添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadPluginData("-1"); } else { MessageBoxEx.Show("你选择的插件已添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void LoadPluginData(string pluginType) { List <PluginClass> plist = new List <PluginClass>(); PluginSysManage.pluginsysFile = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml"; List <PluginClass> plist1 = PluginSysManage.GetAllPlugin(); plist.AddRange(plist1.FindAll(x => x.plugintype == "WebModulePlugin" && x.isdevelopment == "1")); PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; List <PluginClass> plist2 = PluginSysManage.GetAllPlugin(); plist.AddRange(plist2.FindAll(x => (x.plugintype == "WinformModulePlugin" || x.plugintype == "WcfModulePlugin") && x.isdevelopment == "1")); List <PluginClass> list = null; if (pluginType == "-1") { list = plist; } else { switch (pluginType) { case "web": list = plist.FindAll(x => x.plugintype == "WebModulePlugin"); break; case "winform": list = plist.FindAll(x => x.plugintype == "WinformModulePlugin"); break; case "wcf": list = plist.FindAll(x => x.plugintype == "WcfModulePlugin"); break; } } griddev.Invoke((MethodInvoker) delegate() { griddev.DataSource = list; }); }
private void btnSave_Click(object sender, EventArgs e) { XmlNode node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='ClientType']"); if (rbwinform.Checked) { node.Attributes["value"].Value = "Winform"; PluginSysManage.SetWinformEntry(cbpname.Text, txtcname.Text); } else if (rbwcfclient.Checked) { node.Attributes["value"].Value = "WCFClient"; PluginSysManage.SetWcfClientEntry(cbpname.Text, txtcname.Text); } node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='WCF_endpoint']"); node.Attributes["value"].Value = txtwcfendpoint.Text; xmlDoc_app.Save(appconfig); MessageBoxEx.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void loadTitle() { this.Text = "efwplus Studio(插件开发工具)"; string appconfig = CommonHelper.WinformPlatformPath + "\\EFWWin.exe.config"; XmlDocument xmlDoc_app = new System.Xml.XmlDocument(); xmlDoc_app.Load(appconfig); string netwebserver = CommonHelper.AppRootPath + "\\NetWebServer.exe.config"; XmlDocument xmlDoc_webserver = new System.Xml.XmlDocument(); xmlDoc_webserver.Load(netwebserver); XmlNode node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='ClientType']"); if (node != null) { string ClientType = node.Attributes["value"].Value; if (ClientType == "Winform") { PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; PluginSysManage.GetWinformEntry(out entryplugin, out entrycontroller); } else if (ClientType == "WCFClient") { PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; PluginSysManage.GetWcfClientEntry(out entryplugin, out entrycontroller); } } node = xmlDoc_webserver.DocumentElement.SelectSingleNode("appSettings/add[@key='defaultpage']"); if (node != null) { starturl = node.Attributes["value"].Value; } //this.Text = "efwplus开发平台" + " " + "当前启动插件[" + entryplugin + "] 控制器[" + entrycontroller + "]"; labelItemtitle.Text = "Win启动项:[" + entryplugin + "@" + entrycontroller + "] Web启动项:[" + starturl + "]"; }
//下载安装 private void btnDownSetup_Click(object sender, EventArgs e) { try { if (gridweb.CurrentCell == null) { return; } DataTable dt = gridweb.DataSource as DataTable; int rowindex = gridweb.CurrentCell.RowIndex; int Id = Convert.ToInt32(dt.Rows[rowindex]["Id"]); string name = dt.Rows[rowindex]["name"].ToString(); string title = dt.Rows[rowindex]["title"].ToString(); string downloadpath = dt.Rows[rowindex]["downloadpath"].ToString(); string ptype = dt.Rows[rowindex]["plugintype"].ToString(); string url = CommonHelper.plugin_serverurl + downloadpath; string localpath = ""; //string pluginpath = ""; //string pluginsyspath = ""; bool ishave = false; switch (ptype) { case "web": localpath = CommonHelper.WebPlatformPath + "\\ModulePlugin\\" + name + ".zip"; //pluginpath = CommonHelper.WebPlatformPath + "\\ModulePlugin\\" + name; //pluginsyspath = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml"; PluginSysManage.pluginsysFile = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml"; if (PluginSysManage.ContainsPlugin("WebModulePlugin", name)) { ishave = true; } break; case "winform": localpath = CommonHelper.WinformPlatformPath + "\\ModulePlugin\\" + name + ".zip"; //pluginpath = CommonHelper.WinformPlatformPath + "\\ModulePlugin\\" + name; //pluginsyspath = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; if (PluginSysManage.ContainsPlugin("WinformModulePlugin", name)) { ishave = true; } break; case "wcf": localpath = CommonHelper.WinformPlatformPath + "\\ModulePlugin\\" + name + ".zip"; //pluginpath = CommonHelper.WinformPlatformPath + "\\ModulePlugin\\" + name; //pluginsyspath = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; if (PluginSysManage.ContainsPlugin("WcfModulePlugin", name)) { ishave = true; } break; } //先判断此插件本地是否存在 if (ishave == true) { //MessageBox.Show("你选择的插件本地已安装!"); MessageBoxEx.Show("你选择的插件本地已安装!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } frmprogress progress = new frmprogress(); //上传 UpDownLoadFileHelper updown = new UpDownLoadFileHelper(); updown.Cdelegate = new UpDownLoadFileHelper.controldelegate(progress.refreshControl); updown.UpDown = UpDownLoadFileHelper.updown.载; updown.Completed = delegate() { progress.Close(); //解压安装 if (CommonHelper.PluginSetup(localpath) == true) { File.Delete(localpath); //MessageBox.Show("已下载,并且完成安装!"); MessageBoxEx.Show("已下载,并且完成安装!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadPluginData1("-1");//本地插件 } }; updown.Cancelled = delegate() { progress.Close(); //MessageBox.Show("下载失败!"); MessageBoxEx.Show("下载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }; updown.Start(url, localpath); progress.ShowDialog(); } catch (Exception err) { MessageBoxEx.Show("下载失败!\r\n" + err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 卸载插件,之后必须重启中间件 /// </summary> /// <param name="plugname"></param> public static void RemovePlugin(string pluginname) { PluginSysManage.RemovePlugin(pluginname); }
//移除插件 private void biDelete_Click(object sender, EventArgs e) { if (griddev.CurrentCell == null) { return; } if (MessageBoxEx.Show("是否移除此插件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No) { return; } List <PluginClass> plist = griddev.DataSource as List <PluginClass>; PluginClass pc = plist[griddev.CurrentCell.RowIndex]; FileInfo finfo = null; if (pc.plugintype == "WinformModulePlugin" || pc.plugintype == "WcfModulePlugin") { finfo = new FileInfo(CommonHelper.WinformPlatformPath + "\\" + pc.path); if (finfo != null) { //移除dll PluginXmlManage.pluginfile = finfo.FullName; pluginxmlClass plugin = PluginXmlManage.getpluginclass(); foreach (setupClass ic in plugin.setup) { string dllpath = CommonHelper.PathCombine(finfo.Directory.FullName, ic.copyto); if (new FileInfo(dllpath).Exists) { File.Delete(dllpath); } } PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; PluginSysManage.DeletePlugin(pc.plugintype, pc.name); if (finfo.Directory.Exists) { finfo.Directory.Delete(true); } } } else if (pc.plugintype == "WebModulePlugin") { finfo = new FileInfo(CommonHelper.WebPlatformPath + "\\" + pc.path); if (finfo != null) { //移除dll PluginXmlManage.pluginfile = finfo.FullName; pluginxmlClass plugin = PluginXmlManage.getpluginclass(); foreach (setupClass ic in plugin.setup) { string dllpath = CommonHelper.PathCombine(finfo.Directory.FullName, ic.copyto); if (new FileInfo(dllpath).Exists) { File.Delete(dllpath); } } PluginSysManage.pluginsysFile = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml"; PluginSysManage.DeletePlugin(pc.plugintype, pc.name); if (finfo.Directory.Exists) { finfo.Directory.Delete(true); } } } LoadPluginData(_pluginType); }
static void AppGlobal_Init(object sender, EventArgs e) { try { AppGlobal.AppStart(); if (missingDll.Count > 0) { string msg = "缺失的程序集:\r"; for (int i = 0; i < missingDll.Count; i++) { msg += missingDll[i] + "\r"; } MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } string entryplugin; string entrycontroller; switch (appType) { case AppType.Winform: #if WinfromFrame PluginSysManage.GetWinformEntry(out entryplugin, out entrycontroller); EFWCoreLib.WinformFrame.Controller.WinformController controller = EFWCoreLib.WinformFrame.Controller.ControllerHelper.CreateController(entryplugin + "@" + entrycontroller); //controller.Init(); if (controller == null) { throw new Exception("插件配置的启动项(插件名或控制器名称)不正确!"); } ((System.Windows.Forms.Form)controller.DefaultView).Show(); winfromMain.MainForm = ((System.Windows.Forms.Form)controller.DefaultView); #endif break; case AppType.WCFClient: #if WcfFrame PluginSysManage.GetWcfClientEntry(out entryplugin, out entrycontroller); EFWCoreLib.WcfFrame.ClientController.WcfClientController wcfcontroller = EFWCoreLib.WcfFrame.ClientController.ControllerHelper.CreateController(entryplugin + "@" + entrycontroller); if (wcfcontroller == null) { throw new Exception("插件配置的启动项(插件名或控制器名称)不正确!!"); } EFWCoreLib.WcfFrame.ClientController.ReplyClientCallBack callback = new WcfFrame.ClientController.ReplyClientCallBack(); EFWCoreLib.WcfFrame.ClientController.WcfClientManage.CreateConnection(callback); //wcfcontroller.Init(); ((System.Windows.Forms.Form)wcfcontroller.DefaultView).Show(); winfromMain.MainForm = ((System.Windows.Forms.Form)wcfcontroller.DefaultView); #endif break; } } catch (Exception err) { //记录错误日志 ZhyContainer.CreateException().HandleException(err, "HISPolicy"); //Application.Exit(); //throw new Exception(err.Message + "\n\n请联系管理员!"); MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); AppExit(); } }
//更新插件 private void btnUpdate_Click(object sender, EventArgs e) { try { if (gridlocal.CurrentCell == null) { return; } List <PluginClass> plist = gridlocal.DataSource as List <PluginClass>; PluginClass pc = plist[gridlocal.CurrentCell.RowIndex]; string url = CommonHelper.plugin_serverurl + "/Controller.aspx?controller=efwplus_website@PluginController&method=getplugin_client&name=" + pc.name; HttpWebResponse response = HttpWebResponseUtility.CreateGetHttpResponse(url, null, null, null); string ret = HttpWebResponseUtility.GetHttpData(response); string pversion = (HttpWebResponseUtility.ToResult(ret) as JavaScriptObject)["pversion"].ToString(); string downloadpath = (HttpWebResponseUtility.ToResult(ret) as JavaScriptObject)["downloadpath"].ToString(); string p_url = CommonHelper.plugin_serverurl + downloadpath; string path = ""; string localpath = ""; string pluginsysFile = ""; if (pc.plugintype == "WebModulePlugin") { path = CommonHelper.WebPlatformPath + "\\" + pc.path; localpath = CommonHelper.WebPlatformPath + "\\ModulePlugin\\" + pc.name + ".zip"; pluginsysFile = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml"; } else if (pc.plugintype == "WinformModulePlugin") { path = CommonHelper.WinformPlatformPath + "\\" + pc.path; localpath = CommonHelper.WinformPlatformPath + "\\ModulePlugin\\" + pc.name + ".zip"; pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; } else if (pc.plugintype == "WcfModulePlugin") { path = CommonHelper.WinformPlatformPath + "\\" + pc.path; localpath = CommonHelper.WinformPlatformPath + "\\ModulePlugin\\" + pc.name + ".zip"; pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml"; } PluginXmlManage.pluginfile = path; pluginxmlClass plugin = PluginXmlManage.getpluginclass(); if (pversion == plugin.version) { //MessageBox.Show("不用更新,已经是最新版的插件!"); MessageBoxEx.Show("不用更新,已经是最新版的插件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } frmprogress progress = new frmprogress(); //下载 UpDownLoadFileHelper updown = new UpDownLoadFileHelper(); updown.Cdelegate = new UpDownLoadFileHelper.controldelegate(progress.refreshControl); updown.UpDown = UpDownLoadFileHelper.updown.载; updown.Completed = delegate() { progress.Close(); //先卸载原来插件 PluginSysManage.pluginsysFile = pluginsysFile; PluginSysManage.DeletePlugin(pc.plugintype, pc.name); Directory.Delete(new FileInfo(path).Directory.FullName, true); //解压安装 if (CommonHelper.PluginSetup(localpath) == true) { File.Delete(localpath); MessageBoxEx.Show("更新完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }; updown.Cancelled = delegate() { progress.Close(); MessageBoxEx.Show("下载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }; updown.Start(p_url, localpath); progress.ShowDialog(); } catch (Exception err) { MessageBoxEx.Show("更新失败!\r\n" + err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void StartIssue(object sender, EventArgs e) { string mppath = null; string moduleplugin = null; string pluginxml = null; if (_plugintype == "WinformModulePlugin") { mppath = CommonHelper.WinformPlatformPath + "\\ModulePlugin"; moduleplugin = tbIssuePath.Text + "\\WinformPlatform\\ModulePlugin"; pluginxml = CommonHelper.WinformPlatformPath; CommonHelper.CopyFolder(CommonHelper.WinformPlatformPath, tbIssuePath.Text + "\\WinformPlatform", "ModulePlugin|WebPlugin"); PluginSysManage.pluginsysFile = tbIssuePath.Text + "\\WinformPlatform\\Config\\pluginsys.xml"; } else if (_plugintype == "WcfModulePlugin") { mppath = CommonHelper.WinformPlatformPath + "\\ModulePlugin"; moduleplugin = tbIssuePath.Text + "\\WinformPlatform\\ModulePlugin"; pluginxml = CommonHelper.WinformPlatformPath; CommonHelper.CopyFolder(CommonHelper.WinformPlatformPath, tbIssuePath.Text + "\\WinformPlatform", "ModulePlugin|WebPlugin"); PluginSysManage.pluginsysFile = tbIssuePath.Text + "\\WinformPlatform\\Config\\pluginsys.xml"; } else if (_plugintype == "WebModulePlugin") { mppath = CommonHelper.WebPlatformPath + "\\ModulePlugin"; moduleplugin = tbIssuePath.Text + "\\WebPlatform\\ModulePlugin"; pluginxml = CommonHelper.WebPlatformPath; CommonHelper.CopyFolder(CommonHelper.WebPlatformPath, tbIssuePath.Text + "\\WebPlatform", "ModulePlugin|WebPlugin"); PluginSysManage.pluginsysFile = tbIssuePath.Text + "\\WebPlatform\\Config\\pluginsys.xml"; } PluginSysManage.DeletePlugin("WebModulePlugin"); PluginSysManage.DeletePlugin("WinformModulePlugin"); PluginSysManage.DeletePlugin("WcfModulePlugin"); for (int i = 0; i < list.Count; i++) { if (list[i].isdevelopment == "0")//插件包 { CommonHelper.CopyFolder(mppath + "\\" + list[i].name, moduleplugin + "\\" + list[i].name); } else { //开发插件 string _mppath = mppath + "\\" + list[i].name; string _moduleplugin = moduleplugin + "\\" + list[i].name; string _pluginxml = pluginxml + "\\" + list[i].path; PluginXmlManage.pluginfile = _pluginxml; pluginxmlClass plugin = PluginXmlManage.getpluginclass(); foreach (issueClass ic in plugin.issue) { if (ic.type == "dir") { if (ic.source != "") { CommonHelper.CopyFolder(_mppath + "\\" + ic.source, _moduleplugin + "\\" + ic.path); } else { if (Directory.Exists(_mppath + "\\" + ic.path)) { CommonHelper.CopyFolder(_mppath + "\\" + ic.path, _moduleplugin + "\\" + ic.path); } else { Directory.CreateDirectory(_moduleplugin + "\\" + ic.path); } } } else if (ic.type == "file") { if (ic.source != "") { new FileInfo(_mppath + "\\" + ic.source).CopyTo(_moduleplugin + "\\" + ic.path, true); } else { new FileInfo(_mppath + "\\" + ic.path).CopyTo(_moduleplugin + "\\" + ic.path, true); } } } } PluginSysManage.AddPlugin(list[i].plugintype, list[i].name, list[i].path, list[i].title, list[i].isdevelopment); } MessageBoxEx.Show("发布程序包成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
//安装插件升级包 public static void SetUpPluginUpgrade() { string pufile = System.Windows.Forms.Application.StartupPath + "\\pluginupgrade.txt"; if (File.Exists(pufile) == true) { List <string> addplugin = new List <string>(); //新增插件 List <string> updateplugin = new List <string>(); //更新插件 List <string> deleteplugin = new List <string>(); //删除插件 using (StreamReader sr = new StreamReader(pufile)) { string addrow = sr.ReadLine(); addplugin = addrow.Split(':')[1].Split(',').ToList(); string updaterow = sr.ReadLine(); updateplugin = updaterow.Split(':')[1].Split(',').ToList(); string deleterow = sr.ReadLine(); deleteplugin = deleterow.Split(':')[1].Split(',').ToList(); } //删除 File.Delete(pufile); foreach (string p in addplugin) { if (p.Trim() != "") { string path = rootpath + "ModulePlugin\\" + p; //删除本地插件 if (Directory.Exists(path)) { Directory.Delete(path, true); } //解压插件包 string zipfile = rootpath + @"FileStore\PluginUpgrade\" + p + ".zip"; FastZipHelper.decompress(rootpath + "ModulePlugin\\", zipfile); //修改pluginsys.xml配置文件 string pluginfile = "ModulePlugin\\" + p + "\\plugin.xml"; PluginSysManage.AddPlugin(pluginfile); } } foreach (string p in updateplugin) { if (p.Trim() != "") { string path = rootpath + "ModulePlugin\\" + p; //删除本地插件 if (Directory.Exists(path)) { Directory.Delete(path, true); } //解压插件包 string zipfile = rootpath + @"FileStore\PluginUpgrade\" + p + ".zip"; FastZipHelper.decompress(rootpath + "ModulePlugin\\", zipfile); //修改pluginsys.xml配置文件 string pluginfile = "ModulePlugin\\" + p + "\\plugin.xml"; PluginSysManage.RemovePlugin(p); PluginSysManage.AddPlugin(pluginfile); } } foreach (string p in deleteplugin) { if (p.Trim() != "") { string path = rootpath + "ModulePlugin\\" + p; //修改pluginsys.xml配置文件 PluginSysManage.RemovePlugin(p); //删除本地插件 if (Directory.Exists(path)) { Directory.Delete(path, true); } } } } }