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); }
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); }
public NPetshopContainer() : base() { TypedFactoryFacility facility = new TypedFactoryFacility(); AddFacility("typedfactory", facility); facility.AddTypedFactoryEntry( new FactoryEntry("stateFactory", typeof(IStateFactory), "Create", "Release")); // Add DaoManager bool test = Convert.ToBoolean(ConfigurationSettings.AppSettings["test"]); DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); if (test) { builder.Configure(@"..\..\..\NPetshop.Persistence\dao.config"); } else { builder.Configure(@"..\NPetshop.Persistence\dao.config"); } this.Kernel.AddComponentInstance("DaoManager", typeof(DaoManager), DaoManager.GetInstance("SqlMapDao")); // Add services AddServices(); // Add Controllers AddControllers(); AddMVC(test); }
private void OnConfigChange(object obj) { if (builder == null) { builder = new DomDaoManagerBuilder(); } builder.Configure(daoConfig); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_MSSQL_" + Configuration["providerType"] + ".config"); daoManager = DaoManager.GetInstance(); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + Configuration["database"] + "_" + Configuration["providerType"] + ".config"); daoManager = DaoManager.GetInstance("SqlMapDao"); }
public void SetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure(@"..\..\..\NPetshop.Persistence\dao.config"); daoManager = DaoManager.GetInstance("SqlMapDao"); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_Oracle_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); daoManager = DaoManager.GetInstance(); }
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)); }
public void FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); #if dotnet2 builder.Configure("dao_MySql_" + ConfigurationManager.AppSettings["providerType"] + ".config"); #else builder.Configure("dao_MySql_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); #endif daoManager = DaoManager.GetInstance(); }
public void SetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); daoManager = DaoManager.GetInstance("SqlMapDao"); daoManager2 = DaoManager.GetInstance("NHibernateDao"); InitScript(daoManager.LocalDataSource, ScriptDirectory + "account-init.sql"); InitScript(daoManager2.LocalDataSource, ScriptDirectory + "user-init.sql"); }
public void SetUp() { string scriptDirectory = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Resources.ApplicationBase, ".."), ".."), "Scripts"), ConfigurationSettings.AppSettings["database"]) + Path.DirectorySeparatorChar; // Resources.RootDirectory + Path.DirectorySeparatorChar + // "Scripts" + Path.DirectorySeparatorChar + // ConfigurationSettings.AppSettings["database"]+ Path.DirectorySeparatorChar; DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao" + "_" + ConfigurationSettings.AppSettings["database"] + "_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); _daoManager = DaoManager.GetInstance("NHibernateDao"); InitScript(_daoManager.LocalDataSource, scriptDirectory + "user-init.sql"); }
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); }
static public ServiceConfig GetInstance() { try { if (_instance == null) { lock (_synRoot) { if (_instance == null) { try { // 读取dao.config Assembly thisExe = Assembly.GetExecutingAssembly(); Stream stream = thisExe.GetManifestResourceStream(thisExe.GetName().Name + ".dao.config"); ConfigureHandler handler = new ConfigureHandler(ServiceConfig.Reset); // ibatis 读取配置 DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure(stream); // builder.ConfigureAndWatch(handler); _instance = new ServiceConfig(); // TODO:默认为sqlMapDao指定的Context, 要提供对多个Context的支持. _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao"); // 转换到配置文件的数据库连接。 string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; _instance._daoManager.LocalDataSource.ConnectionString = connectionString; } catch (Exception e) { ILog log = log4net.LogManager.GetLogger("TraceAppender"); log.Error(e); } } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(_instance); }
public void MultipleContext() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_Multiple_Context.config"); IDaoManager daoManager1 = DaoManager.GetInstance("Contex1"); IDaoManager daoManager2 = DaoManager.GetInstance("Contex2"); Assert.IsNotNull(daoManager1); Assert.IsNotNull(daoManager2); Assert.IsTrue(daoManager2.LocalDataSource.ConnectionString != daoManager1.LocalDataSource.ConnectionString); Assert.IsTrue(daoManager2.LocalDataSource.DbProvider.Name != daoManager1.LocalDataSource.DbProvider.Name); daoManager1.OpenConnection(); daoManager2.OpenConnection(); daoManager1.CloseConnection(); daoManager2.CloseConnection(); }
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); }
static public ServiceConfig GetInstanceByFile() { if (_instance == null) { lock (_synRoot) { if (_instance == null) { //Define the Absoluate File path to Found the Dao File [f**k this shit] string filepath = @"E:\ADO.NEt Entity FrameWork Program\MyBatis_Demo\BatisDemonstarate_DUI\CustomerWeb_UI\Dao.Config"; if (File.Exists(filepath)) { DomDaoManagerBuilder getbuilder = new DomDaoManagerBuilder(); getbuilder.Configure(filepath); _instance = new ServiceConfig(); _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao"); } } } } return(_instance); }
/// <summary> /// 获得本地SqlMap /// </summary> /// <returns>获得与DAO相关的SqlMap</returns> protected ISqlMapper GetLocalSqlMap() { if (_sqlMapper == null) { //DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); //builder.Configure(); IDaoManager daoManager = DaoManager.GetInstance(this); if (daoManager == null) { var builder = new DomDaoManagerBuilder(); builder.Configure(); daoManager = DaoManager.GetInstance(this); } var sqlMapDaoSession = (SqlMapDaoSession)daoManager.LocalDaoSession; _sqlMapper = sqlMapDaoSession.SqlMap; _sqlMapper.DataSource.ConnectionString = _sqlMapper.DataSource.ConnectionString; //SymmetricEncryption.DecryptString(_sqlMapper.DataSource.ConnectionString); } return(_sqlMapper); }
/// <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); }