Exemplo n.º 1
0
 /// <summary>
 /// 安装插件
 /// </summary>
 /// <param name="_name"></param>
 /// <param name="_response">返回信息</param>
 public bool Install(string _name, ref string _response)
 {
     if (!JumboTCMS.Utils.DirFile.FileExists(site.Dir + "extends/" + _name + "/install.config"))
     {
         _response = "插件的安装文件损坏或不存在";
         return false;
     }
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.ConditionExpress = "1=1";
         int pId = _doh.MaxValue("jcms_normal_extends", "pId");
         string _Title = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + _name + "/install", "Title");
         string _Author = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + _name + "/install", "Author");
         string _Info = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + _name + "/install", "Info");
         string _Type = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + _name + "/install", "Type");
         string _BaseTable = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + _name + "/install", "BaseTable");
         string _ManageUrl = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + _name + "/install", "ManageUrl");
         int _Locked = JumboTCMS.Utils.Validator.StrToInt(JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + _name + "/install", "Locked"), 0);
         if (_BaseTable != "")//需要安装数据库
         {
             string _SqlScriptText = JumboTCMS.Utils.XmlCOM.ReadConfig(site.Dir + "extends/" + _name + "/install", "SqlScript" + base.DBType);
             string _SqlScriptFile = site.Dir + "extends/" + _name + "/install.sql";
             JumboTCMS.Utils.DirFile.SaveFile(_SqlScriptText, _SqlScriptFile);
             if (!ExecuteSqlInFile(HttpContext.Current.Server.MapPath(_SqlScriptFile)))
             {
                 _response = "数据表创建有误,可能已存在";
                 return false;
             }
         }
         _doh.Reset();
         _doh.AddFieldItem("Title", _Title);
         _doh.AddFieldItem("Name", _name);
         _doh.AddFieldItem("Author", _Author);
         _doh.AddFieldItem("Info", _Info);
         _doh.AddFieldItem("Type", _Type);
         _doh.AddFieldItem("BaseTable", _BaseTable);
         _doh.AddFieldItem("ManageUrl", _ManageUrl);
         _doh.AddFieldItem("Locked", _Locked);
         _doh.AddFieldItem("Enabled", 0);
         _doh.AddFieldItem("pId", pId + 1);
         _doh.Insert("jcms_normal_extends");
         _response = "插件安装成功";
     }
     return true;
 }