Example #1
0
        private void treePlugin_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag != null)
            {
                PluginClass pc   = (PluginClass)e.Node.Tag;
                string      path = null;
                if (pc.plugintype == "WebModulePlugin")
                {
                    path = CommonHelper.WebPlatformPath + "\\" + pc.path;
                }
                else if (pc.plugintype == "WinformModulePlugin")
                {
                    path = CommonHelper.WinformPlatformPath + "\\" + pc.path;
                }
                else if (pc.plugintype == "WcfModulePlugin")
                {
                    path = CommonHelper.WinformPlatformPath + "\\" + pc.path;
                }

                pluginxmlClass plugin = null;
                if (File.Exists(path))
                {
                    PluginXmlManage.pluginfile = path;
                    plugin = PluginXmlManage.getpluginclass();
                }

                if (plugin != null)
                {
                    gridpluginmenu.AutoGenerateColumns = false;
                    gridpluginmenu.DataSource          = plugin.menu;
                }
            }
        }
Example #2
0
        private void savepluginxml()
        {
            plugin.title   = txttitle.Text;
            plugin.author  = txtauthor.Text;
            plugin.version = txtversion.Text;

            if (plugin.data.FindIndex(x => x.key == "introduction") > -1)
            {
                plugin.data.Find(x => x.key == "introduction").value = txtintroduction.Text;
            }
            else
            {
                baseinfodataClass data = new baseinfodataClass();
                data.key   = "introduction";
                data.value = txtintroduction.Text;
                plugin.data.Add(data);
            }

            if (plugin.data.FindIndex(x => x.key == "headpic") > -1)
            {
                plugin.data.Find(x => x.key == "headpic").value = pb_headpic.Tag.ToString();
            }
            else
            {
                baseinfodataClass data = new baseinfodataClass();
                data.key   = "headpic";
                data.value = pb_headpic.Tag.ToString();
                plugin.data.Add(data);
            }

            if (plugin.data.FindIndex(x => x.key == "updaterecord") > -1)
            {
                plugin.data.Find(x => x.key == "updaterecord").value = txtupdaterecord.Text;
            }
            else
            {
                baseinfodataClass data = new baseinfodataClass();
                data.key   = "updaterecord";
                data.value = txtupdaterecord.Text;
                plugin.data.Add(data);
            }

            if (plugin.data.FindIndex(x => x.key == "StartItem") > -1)
            {
                plugin.data.Find(x => x.key == "StartItem").value = txtStartItem.Text;
            }
            else
            {
                baseinfodataClass data = new baseinfodataClass();
                data.key   = "StartItem";
                data.value = txtStartItem.Text;
                plugin.data.Add(data);
            }

            PluginXmlManage.pluginfile = path;
            PluginXmlManage.savepluginclass(plugin);
        }
Example #3
0
        public FrmPack(PluginClass pc)
        {
            InitializeComponent();
            this.txtname.Text       = pc.name;
            this.txttitle.Text      = pc.title;
            this.txtupdatedate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");


            if (pc.plugintype == "WebModulePlugin")
            {
                plugintype = "web";
                path       = CommonHelper.WebPlatformPath + "\\" + pc.path;
            }
            else if (pc.plugintype == "WinformModulePlugin")
            {
                plugintype = "winform";
                path       = CommonHelper.WinformPlatformPath + "\\" + pc.path;
            }
            else if (pc.plugintype == "WcfModulePlugin")
            {
                plugintype = "wcf";
                path       = CommonHelper.WinformPlatformPath + "\\" + pc.path;
            }

            FileInfo finfo = new FileInfo(path);

            if (finfo.Exists)
            {
                prjpath = finfo.Directory.FullName;
                prjname = finfo.Directory.Name;
            }


            PluginXmlManage.pluginfile = path;
            plugin = PluginXmlManage.getpluginclass();
            if (pc.name != plugin.name)
            {
                MessageBoxEx.Show("plugin.xml 与 pluginsys.xml 的名称不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            txtname.Text         = plugin.name;
            txttitle.Text        = plugin.title;
            txtauthor.Text       = plugin.author;
            txtversion.Text      = plugin.version;
            txtintroduction.Text = plugin.data.FindIndex(x => x.key == "introduction") > -1 ? plugin.data.Find(x => x.key == "introduction").value : "";
            txtupdaterecord.Text = plugin.data.FindIndex(x => x.key == "updaterecord") > -1 ? plugin.data.Find(x => x.key == "updaterecord").value : "";
            if (plugin.data.FindIndex(x => x.key == "headpic") > -1 && plugin.data.Find(x => x.key == "headpic").value != "")
            {
                //pb_headpic.Image = Image.FromFile(prjpath + "\\" + plugin.data.Find(x => x.key == "headpic").value);
                pb_headpic.Tag = plugin.data.Find(x => x.key == "headpic").value;
            }
            else
            {
                pb_headpic.Tag = "/ModulePlugin/efwplus_website/headpic/default.png";
            }
            txtStartItem.Text = plugin.data.FindIndex(x => x.key == "StartItem") > -1 ? plugin.data.Find(x => x.key == "StartItem").value : "";
        }
        private void loadplugin(PluginClass pc)
        {
            if (pc.plugintype == "WebModulePlugin")
            {
                path = CommonHelper.WebPlatformPath + "\\" + pc.path;
            }
            else if (pc.plugintype == "WinformModulePlugin")
            {
                path = CommonHelper.WinformPlatformPath + "\\" + pc.path;
            }
            else if (pc.plugintype == "WcfModulePlugin")
            {
                path = CommonHelper.WinformPlatformPath + "\\" + pc.path;
            }

            if (File.Exists(path))
            {
                textEditorControl.LoadFile(path);
            }

            PluginXmlManage.pluginfile = path;
            plugin = PluginXmlManage.getpluginclass();

            //将plugin赋值给控件
            if (plugin != null)
            {
                txtname.Text            = plugin.name;
                txttitle.Text           = plugin.title;
                txtauthor.Text          = plugin.author;
                txtversion.Text         = plugin.version;
                cbplugintype.Text       = plugin.plugintype;
                txtdefaultdbkey.Text    = plugin.defaultdbkey;
                txtdefaultcachekey.Text = plugin.defaultcachekey;

                gridbasedata.AutoGenerateColumns = false;
                gridbasedata.DataSource          = plugin.data;

                griddll.AutoGenerateColumns = false;
                griddll.DataSource          = plugin.dll;

                gridissue.AutoGenerateColumns = false;
                gridissue.DataSource          = plugin.issue;

                gridsetup.AutoGenerateColumns = false;
                gridsetup.DataSource          = plugin.setup;

                gridmenu.AutoGenerateColumns = false;
                gridmenu.DataSource          = plugin.menu;
            }
        }
Example #5
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);
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (tabControl.SelectedIndex == 3)//plugin.xml
            {
                textEditorControl.SaveFile(path);
            }
            else
            {
                //将控件给plugin赋值
                plugin.name            = txtname.Text;
                plugin.title           = txttitle.Text;
                plugin.author          = txtauthor.Text;
                plugin.version         = txtversion.Text;
                plugin.plugintype      = cbplugintype.Text;
                plugin.defaultdbkey    = txtdefaultdbkey.Text;
                plugin.defaultcachekey = txtdefaultcachekey.Text;

                PluginXmlManage.savepluginclass(plugin);
            }

            MessageBoxEx.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            loadplugin(_pc);
        }
Example #7
0
        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);
        }
Example #8
0
        //移除插件
        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);
        }
Example #9
0
        //更新插件
        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);
            }
        }