Exemplo n.º 1
0
        //添加现有插件项目
        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);
                }
            }
        }
Exemplo n.º 2
0
        //下载安装
        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);
            }
        }