Пример #1
0
        private void LoadPluginData2(string pluginType)
        {
            new Thread((ThreadStart)(delegate()
            {
                try
                {
                    labloading.Invoke((MethodInvoker) delegate() { labloading.Visible = true; });

                    List <PluginClass> plist = new List <PluginClass>();

                    string url = CommonHelper.plugin_serverurl + "/Controller.aspx?controller=efwplus_website@PluginController&method=getpluginlist_client&plugintype=" + pluginType;
                    HttpWebResponse response = HttpWebResponseUtility.CreateGetHttpResponse(url, null, null, null);
                    string ret = HttpWebResponseUtility.GetHttpData(response);
                    string data = (HttpWebResponseUtility.ToResult(ret) as Newtonsoft.Json.JavaScriptArray).ToArray()[0].ToString();
                    DataTable dt = HttpWebResponseUtility.ToDataTable(JavaScriptConvert.DeserializeObject(data));

                    gridweb.Invoke((MethodInvoker) delegate() { gridweb.DataSource = dt; });

                    DataGridViewLabelXColumn bcx = gridweb.Columns["ctitle"] as DataGridViewLabelXColumn;
                    if (bcx != null)
                    {
                        bcx.BeforeCellPaint += bcx_BeforeCellPaint;
                    }

                    labloading.Invoke((MethodInvoker) delegate() { labloading.Visible = false; });
                }
                catch (Exception err)
                {
                    //MessageBox.Show("请求数据失败!\n" + err.Message);
                    MessageBoxEx.Show("请求数据失败!\n" + err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            })).Start();
        }
Пример #2
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);
            }
        }