public string Ping() { try { return("Pong"); } catch (Exception ex) { string source = "We7.CMS.Install-InstallWebService—Ping"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); throw ex; } }
public BaseConfigInfo GetBaseConfig() { try { return(BaseConfigs.GetBaseConfig()); } catch (Exception ex) { string source = "We7.CMS.Install-InstallWebService—GetBaseconfig"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); throw ex; } }
[SoapHeader("header")] //用户身份验证的soap header public BaseConfigInfo GetBaseConfig() { //验证是否有权访问(当然,也可以通过查询数据库实现,具体视项目要求) if (!CheckAdmin(header.UserName, header.PassWord)) { throw new Exception("无权使用此服务"); } try { return(BaseConfigs.GetBaseConfig()); } catch (Exception ex) { string source = "We7.CMS.Install-InstallWebService—GetBaseconfig"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); throw ex; } }
public string CopyTableDataFromCloneSite(string fromPath, string toPath, List <string> tables) { try { string xmlPath = Path.Combine(toPath, "App_Data\\XML"); BaseConfigInfo oldConfig = BaseConfigs.Deserialize(Path.Combine(fromPath, "config\\db.config")); oldConfig.DBConnectionString = oldConfig.DBConnectionString.Replace("{$App}", fromPath); BaseConfigInfo newConfig = BaseConfigs.Deserialize(Path.Combine(toPath, "config\\db.config")); newConfig.DBConnectionString = newConfig.DBConnectionString.Replace("{$App}", toPath); DBMigrator.DoMigrate(xmlPath, oldConfig, newConfig, tables); return("0"); } catch (Exception ex) { string source = "We7.CMS.Install-InstallWebService—CopyTableDataFromCloneSite"; EventLogHelper.WriteToLog(source, ex); throw We7Helper.RaiseException("CopyTableDataFromCloneSite", ex.Message, "", ex.Source, We7Helper.FaultCode.Server); } }
/// <summary> /// 重启应用程序 /// </summary> public static void LoadHelperFactory() { lock (lockHelper2) { //如果数据库配置文件存在,加载配置 if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); //加载数据库映射表 string root = AppDomain.CurrentDomain.BaseDirectory; string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data/XML"); ObjectAssistant assistat = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString.Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory); assistat.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistat.LoadDataSource(dataPath); } catch (Thinkment.Data.DataException ex) { Debug.WriteLine(ex.ToString()); string source = "CD.Utils_CDHelper_ResetApplication"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); throw ex; } HelperFactory hf = new HelperFactory(); hf.Assistant = assistat; hf.Root = root; hf.Initialize(); AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf); } } }
public string DownLoad(string siteLoginName, string sitePassword, string pltype, string pluginName, string cmd, string action, string pluginPath) { string source = ""; try { if (CheckAdmin(siteLoginName, sitePassword)) { //PluginHelper return(new PluginHelper(GetPluginType(pltype)).RunCommand(pluginName, cmd, action, pluginPath)); } else { return(new PluginJsonResult(false, "安装站点的用户名与密码错误!").ToString());; } } catch (Exception ex) { EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); throw ex; } }
[SoapHeader("header")] //用户身份验证的soap header public string InitDBConfig(string setupDbType, DatabaseInfo dbi) { //验证是否有权访问(当然,也可以通过查询数据库实现,具体视项目要求) if (!CheckAdmin(header.UserName, header.PassWord)) { throw new Exception("无权使用此服务"); } string source = "We7.CMS.Install-InstallWebService-SetSiteConfig"; try { BaseConfigInfo baseConfig = Installer.GenerateConnectionString(setupDbType, dbi); string file = Server.MapPath("~/config/db.config"); BaseConfigs.SaveConfigTo(baseConfig, file); BaseConfigs.ResetConfig(); if (dbi.CreateDB) { Exception ex = null; int ret = Installer.CreateDatabase(baseConfig, out ex); if (ret == -1) { string msg = "数据库已存在,请重新命名或去掉重新“创建新数据库”前面的勾,使用已有数据库。"; Exception ex1 = new Exception(msg); EventLogHelper.WriteToLog(source, ex1, EventLogEntryType.Error); return(msg); } else if (ret == 0) { string exceptionMsgs = ex.Message; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); return("创建数据库发生错误。错误原因:" + exceptionMsgs); } } //设置数据库脚本路径 //string basePath = Server.MapPath("/install/SQL"); //if (!Directory.Exists(basePath)) //{ // basePath = Server.MapPath("../install/SQL"); //} if (!Directory.Exists(Server.MapPath("/_data/"))) { Directory.CreateDirectory(Server.MapPath("/_data/")); } List <string> files = new List <string>(); files.Add("create.xml"); files.Add("install.xml"); files.Add("update.xml"); Installer.ExcuteSQLGroup(baseConfig, files); //创建内容模型表 Installer.CreateModelTables(); ApplicationHelper.ResetApplication(); return("0"); } catch (Exception ex) { EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); return("创建数据库发生错误。错误原因:" + ex.Message); } }
/// <summary> /// 重启网站 /// </summary> public static void ResetApplication() { lock (lockHelper) { HttpContext context = HttpContext.Current; context.Application.Clear(); if (context.Session != null) { context.Session.Clear(); } BaseConfigs.ResetConfig(); SiteConfigs.ResetConfig(); GeneralConfigs.ResetConfig(); PluginManager.LoadPlugins(); context.Application["We7.Application.OnlinePeople.Key"] = 0; //如果数据库配置文件存在,加载配置 if (BaseConfigs.ConfigFileExist()) { BaseConfigInfo baseconfig = BaseConfigs.GetBaseConfig(); //加载数据库映射表 string root = context.Server.MapPath("~/"); string dataPath = context.Server.MapPath("~/App_Data/XML"); ObjectAssistant assistat = new ObjectAssistant(); try { if (baseconfig != null && baseconfig.DBConnectionString != "") { baseconfig.DBConnectionString = baseconfig.DBConnectionString. Replace("{$App}", AppDomain.CurrentDomain.BaseDirectory).Replace("\\\\", "\\"); assistat.LoadDBConnectionString(baseconfig.DBConnectionString, baseconfig.DBDriver); } assistat.LoadDataSource(dataPath); } catch (Thinkment.Data.DataException ex) { Debug.WriteLine(ex.ToString()); string source = "CD.Utils_CDHelper_ResetApplication"; EventLogHelper.WriteToLog(source, ex, EventLogEntryType.Error); string msg = string.Format("注意检查:/app_data/xml里的配置文件:\r\n错误代码:{0}\r\n错误消息:{1}" , ex.ErrorCode, ex.Message); We7.Framework.LogHelper.WriteLog(typeof(ApplicationHelper), msg); throw ex; } HelperFactory hf = new HelperFactory(); /* * 添加内容模型表结构(系统内置字段已在LoadDataSource里添加) * author:丁乐 */ ModelHelper.ReCreateModelIndex(); MoudelMonitoring.SetModelDataDic(assistat); hf.Assistant = assistat; hf.Root = root; hf.Initialize(); context.Application.Add("We7.HelperFactory", hf); AppCtx.Cache.AddObject(HelperFactory.CacheKey, hf); MoudelMonitoring ml = new MoudelMonitoring(); //监控内容模型 } } }