static public ServiceConfig GetInstance() { if (_instance == null) { lock (_synRoot) { if (_instance == null) { try { ConfigureHandler handler = new ConfigureHandler(ServiceConfig.Reset); DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.ConfigureAndWatch("dao.config", handler); } catch (Exception ex) { throw ex; } _instance = new ServiceConfig(); // TODO:默认为sqlMapDao指定的Context, 要提供对多个Context的支持. _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao"); } } } return(_instance); }
static public ServiceConfig GetInstance() { if (_instance == null) { lock (_synRoot) { if (_instance == null) { try { ConfigureHandler _handler = new ConfigureHandler(ServiceConfig.Reset); DomDaoManagerBuilder _builder = new DomDaoManagerBuilder(); //_builder.Configure(); _builder.ConfigureAndWatch("dao.config", _handler); _instance = new ServiceConfig(); _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao"); } catch (Exception e) { LogHelper.Error(e.Message); } } } } return(_instance); }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); container = new UnityContainer(); IControllerFactory controllerFactory = new IocControllerFactory(container); RegistManager.RegistAll(container); ControllerBuilder.Current.SetControllerFactory(controllerFactory); builder = new DomDaoManagerBuilder(); builder.ConfigureAndWatch(daoConfig, new ConfigureHandler(OnConfigChange)); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); container = new UnityContainer(); IControllerFactory controllerFactory = new IocControllerFactory(container); RegistManager.RegistAll(container); ControllerBuilder.Current.SetControllerFactory(controllerFactory); builder = new DomDaoManagerBuilder(); builder.ConfigureAndWatch(daoConfig, new ConfigureHandler(OnConfigChange)); }
/// <summary> /// 取得服务实例,实例为单实例对象,释放实例只能用Reset()方法。 /// </summary> /// <param name="daoFilePath">dao文件路径, 如传入空则由AppSettings["DaoFile"]决定</param> /// <returns>服务实例</returns> public static ServiceConfig GetInstance(string daoFilePath) { if (_instance == null) { object synRoot = _synRoot; lock (synRoot) { if (_instance == null) { ConfigureHandler configureHandler = new ConfigureHandler(Reset); DomDaoManagerBuilder domDaoManagerBuilder = new DomDaoManagerBuilder(); string text = string.IsNullOrEmpty(daoFilePath) ? ConfigurationManager.Configuration.GetSection("serviceCore:daoFile").Value : daoFilePath; if (!Path.IsPathRooted(text)) { text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, text); } if (!File.Exists(text)) { throw new Exception("AppSettings中指定的配置文件(DaoFile)不存在!"); } try { domDaoManagerBuilder.ConfigureAndWatch(text, configureHandler); } catch (Exception ex2) { Exception ex = ex2; while (ex.InnerException != null) { ex = ex.InnerException; } throw new Exception("dao.config不存在或错! " + ex2.Message, ex); } _instance = new ServiceConfig { DaoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao") }; ModifyConnectString(_instance.DaoManager, "SqlMapDao"); } } } return(_instance); }
protected void Application_Start() { HttpConfiguration rou = new HttpConfiguration(); AreaRegistration.RegisterAllAreas(); //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); RouteConfig.Register(rou); MvcHandler.DisableMvcResponseHeader = true; container = new UnityContainer(); IControllerFactory controllerFactory = new IocControllerFactory(container); RegistManager.RegistAll(container); ControllerBuilder.Current.SetControllerFactory(controllerFactory); builder = new DomDaoManagerBuilder(); builder.ConfigureAndWatch(daoConfig, new ConfigureHandler(OnConfigChange)); }
static public ServiceConfig GetInstance() { if (_instance == null) { lock (SynRoot) { if (_instance == null) { var handler = new ConfigureHandler(Reset); try { var builder = new DomDaoManagerBuilder(); builder.ConfigureAndWatch("dao.config", handler); //IBatisNet.DataAccess.DaoManager.ConfigureAndWatch(handler); // var builder = new DomDaoManagerBuilder(); // builder.ConfigureAndWatch(handler); // builder.Configure(); } catch (Exception e) { Console.WriteLine(e.Message); } _instance = new ServiceConfig { DaoManager = IBatisNet.DataAccess. DaoManager.GetInstance("Ssds") }; //_instance.DaoManager.SessionStore = new HybridWebThreadSessionStore(_instance.DaoManager.Id); } } } return(_instance); }
/// <summary> /// 获取数据链接配置 /// </summary> /// <param name="daoid">数据链接配置ID</param> /// <returns></returns> public static ServiceConfig GetInstance(string daoid) { if (_instance == null) { lock (_synRoot) { if (_instance == null) { string[] str = projectlist.Split(','); //生成配置文件SqlServerMap.config string name = "SqlServerMap"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName + name + "Pub.config"); XmlNode sqlMapConfig = xmlDoc.DocumentElement; //获取节点 XmlNodeList sqlMapList = sqlMapConfig.ChildNodes; //获取所有字节点 foreach (XmlNode child in sqlMapList) { if (child.Name.Equals("sqlMaps")) { foreach (string st in str) { if (File.Exists(fileName + st + "Map.config")) { XmlDocument xmlDocOA = new XmlDocument(); xmlDocOA.Load(fileName + st + "Map.config"); XmlNode sqlMapConfigOA = xmlDocOA.DocumentElement;//获取节点 XmlNode sqlMapsOA = sqlMapConfigOA.FirstChild; XmlNodeList courseNodeList = sqlMapsOA.ChildNodes; if (courseNodeList != null) { foreach (XmlNode courseNode in courseNodeList) { if (courseNode.Attributes != null) { string value = courseNode.Attributes.GetNamedItem("resource").Value; XmlNode newNode = xmlDoc.CreateElement("sqlMap", xmlDoc.DocumentElement.NamespaceURI); CreateAttribute(newNode, "resource", value); child.AppendChild(newNode); } } } } } break; } } xmlDoc.Save(fileName + name + ".config"); ConfigureHandler handler = new ConfigureHandler(ServiceConfig.Reset); DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.ConfigureAndWatch("Config/dao.config", handler); _instance = new ServiceConfig(); //清空数据库连接键值列表 daoManageKeyList = null; } } } if (daoManageKeyList == null || !daoManageKeyList.Contains(daoid)) { lock (_synRoot) { if (daoManageKeyList == null || !daoManageKeyList.Contains(daoid)) { // TODO:默认为sqlMapDao指定的Context, 要提供对多个Context的支持. _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance(daoid); } } } return(_instance); }