/// <summary> /// 重设BaseConfig /// </summary> /// <returns></returns> public static bool EditDntConfig() { BaseConfigInfo config = null; string filename = DefaultConfigFileManager.ConfigFilePath; try { config = (BaseConfigInfo)SerializationHelper.Load(typeof(BaseConfigInfo), filename); } catch { config = null; } try { if (config != null) { BaseConfigProvider.SetInstance(config); return(true); } } catch { } if (config == null) { try { BaseConfigInfoCollection bcc = (BaseConfigInfoCollection)SerializationHelper.Load(typeof(BaseConfigInfoCollection), filename); foreach (BaseConfigInfo bc in bcc) { if (Utils.GetTrueForumPath() == bc.Forumpath) { config = bc; break; } } if (config == null) { foreach (BaseConfigInfo bc in bcc) { if (Utils.GetTrueForumPath().StartsWith(bc.Forumpath)) { config = bc; break; } } } if (config != null) { BaseConfigProvider.SetInstance(config); return(true); } } catch { } } return(false); }
/// <summary> /// 获取真实基础配置对象 /// </summary> /// <returns></returns> public static BaseConfigInfo GetRealBaseConfig() { BaseConfigInfo newBaseConfig = null; string filename = BaseConfigFileManager.ConfigFilePath; try { newBaseConfig = (BaseConfigInfo)SerializationHelper.Load(typeof(BaseConfigInfo), filename); } catch { newBaseConfig = null; } if (newBaseConfig == null) { try { BaseConfigInfoCollection bcc = (BaseConfigInfoCollection)SerializationHelper.Load(typeof(BaseConfigInfoCollection), filename); foreach (BaseConfigInfo bc in bcc) { if (Utils.GetTrueSysPath() == bc.Syspath) { newBaseConfig = bc; break; } } if (newBaseConfig == null) { BaseConfigInfo rootConfig = null; foreach (BaseConfigInfo bc in bcc) { if (Utils.GetTrueSysPath().StartsWith(bc.Syspath) && bc.Syspath != "/") { newBaseConfig = bc; break; } if (("/").Equals(bc.Syspath)) { rootConfig = bc; } } if (newBaseConfig == null) { newBaseConfig = rootConfig; } } } catch { newBaseConfig = null; } } if (newBaseConfig == null) { throw new Exception("发生错误: 虚拟目录或网站根目录下没有正确的Yannyo.config文件,或者没有序列化权限"); } return(newBaseConfig); }
/// <summary> /// 获取真实基础配置对象 /// </summary> /// <returns></returns> public static BaseConfigInfo GetRealBaseConfig() { BaseConfigInfo newBaseConfig = null; string filename = BaseConfigFileManager.ConfigFilePath; //string filename = null; //HttpContext context = HttpContext.Current; //if(context != null) // filename = context.Server.MapPath("/DNT.config"); //else // filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DNT.config"); try { newBaseConfig = (BaseConfigInfo)SerializationHelper.Load(typeof(BaseConfigInfo), filename); } catch { newBaseConfig = null; } if (newBaseConfig == null) { try { BaseConfigInfoCollection bcc = (BaseConfigInfoCollection)SerializationHelper.Load(typeof(BaseConfigInfoCollection), filename); foreach (BaseConfigInfo bc in bcc) { if (Utils.GetTrueForumPath() == bc.Forumpath) { newBaseConfig = bc; break; } } if (newBaseConfig == null) { BaseConfigInfo rootConfig = null; foreach (BaseConfigInfo bc in bcc) { if (Utils.GetTrueForumPath().StartsWith(bc.Forumpath) && bc.Forumpath != "/") { newBaseConfig = bc; break; } if (("/").Equals(bc.Forumpath)) { rootConfig = bc; } } if (newBaseConfig == null) { newBaseConfig = rootConfig; } } } catch { newBaseConfig = null; } } if (newBaseConfig == null) { throw new Exception("发生错误: 虚拟目录或网站根目录下没有正确的DNT.config文件,或者没有序列化权限"); } return(newBaseConfig); }