//移除插件 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); }
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); }
//更新插件 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); } }