protected string GetLocalSqlMap() { var daoManager = DaoManager.GetInstance(this); var sqlMapDaoSession = (AzureDaoSession)daoManager.LocalDaoSession; return(sqlMapDaoSession.DataSource.ConnectionString); }
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); }
/// <summary> /// Looks up the parent DaoManager, gets the local transaction /// (which should be a SqlMapDaoTransaction) and returns the /// SqlMap associated with this DAO. /// </summary> /// <returns>The SqlMap instance for this DAO.</returns> protected SqlMapper GetLocalSqlMap() { DaoManager daoManager = DaoManager.GetInstance(this); SqlMapDaoSession sqlMapDaoSession = (SqlMapDaoSession)daoManager.LocalDaoSession; return(sqlMapDaoSession.SqlMap); }
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 FixtureSetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure("dao_Oracle_" + ConfigurationSettings.AppSettings["providerType"] + ".config"); daoManager = DaoManager.GetInstance(); }
public void SetUp() { DomDaoManagerBuilder builder = new DomDaoManagerBuilder(); builder.Configure(@"..\..\..\NPetshop.Persistence\dao.config"); daoManager = DaoManager.GetInstance("SqlMapDao"); }
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 string GetDbtype() { IDaoManager instance; if (string.IsNullOrEmpty(this.ContextName)) { instance = DaoManager.GetInstance(); } else { instance = DaoManager.GetInstance(this.ContextName); } return(instance.LocalDataSource.DbProvider.Name); }
public IDaoManager getDaoManager(string name) { IDaoManager instance; if (string.IsNullOrEmpty(name)) { instance = DaoManager.GetInstance(); } else { instance = DaoManager.GetInstance(name); } return(instance); }
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"); }
static public ServiceConfig GetInstance() { if (_instance == null) { lock (_synRoot) { if (_instance == null) { ConfigureHandler handler = new ConfigureHandler(ServiceConfig.Reset); DaoManager.ConfigureAndWatch(handler); _instance = new ServiceConfig(); _instance._daoManager = DaoManager.GetInstance("SqlMapDao"); } } } 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(); }
public ISqlMapper GetSqlMap() { IDaoManager instance; if (string.IsNullOrEmpty(this.ContextName)) { instance = DaoManager.GetInstance(); } else { instance = DaoManager.GetInstance(this.ContextName); } ISqlMapper sqlMap = (instance.GetDaoSession() as SqlMapDaoSession).SqlMap; if (!string.IsNullOrEmpty(this.ConnectString)) { sqlMap.DataSource.ConnectionString = this.ConnectString; } return(sqlMap); }
/// <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> /// Get the sesion. /// </summary> /// <returns>A DaoSession</returns> protected DaoSession GetContext() { IDaoManager daoManager = DaoManager.GetInstance(this); return(daoManager.LocalDaoSession as DaoSession); }
public static void ThirdDbInit() { try { object[] args = new object[0]; IList <ZLSoft.Model.PLATFORM.DataSource> list = DB.List <ZLSoft.Model.PLATFORM.DataSource>(null); foreach (ZLSoft.Model.PLATFORM.DataSource current in list) { if (DaoManager.GetInstance(current.ID) == null) { if (dal.TheConfigurationScope.Providers.Contains(current.Provider)) { ExecuteSqlProviderAttacher.DBType dBType = ExecuteSqlProviderAttacher.CheckDBType(current.Provider); string sERVER_NAME = current.DataSourceName; string dATABASE = current.Database; string uSERNAME = current.UserName; string pASSWORD = current.Password; string key = "resource"; string mAPSFILE = "dbconfig/SqlMap_Interface.config"; string connectionString; if (dBType.ToString() == "NONE" || dBType == ExecuteSqlProviderAttacher.DBType.ORACLE) { connectionString = "Data Source={0};User ID={1};Password={2};"; connectionString = string.Format(connectionString, dATABASE, uSERNAME, pASSWORD); } else { if (dBType != ExecuteSqlProviderAttacher.DBType.SQLSERVER) { continue; } connectionString = ExecuteSqlProviderAttacher.GetSqlServerConnectString(sERVER_NAME, dATABASE, uSERNAME, pASSWORD); } DaoManager daoManager = DaoManager.NewInstance(current.ID); daoManager.IsDefault = false; daoManager.DbProvider = (dal.TheConfigurationScope.Providers[current.Provider] as IDbProvider); daoManager.DataSource = new IBatisNet.Common.DataSource { Name = sERVER_NAME, ConnectionString = connectionString, DbProvider = daoManager.DbProvider }; IDictionary dictionary = new Hashtable(); dictionary.Add("DataSource", daoManager.DataSource); dictionary.Add("UseConfigFileWatcher", false); dictionary.Add(key, mAPSFILE); Type type = TypeUtils.ResolveType("IBatisNet.DataAccess.DaoSessionHandlers.SqlMapDaoSessionHandler"); IDaoSessionHandler daoSessionHandler = System.Activator.CreateInstance(type, args) as IDaoSessionHandler; daoSessionHandler.Configure(dal.TheConfigurationScope.Properties, dictionary); daoManager.DaoSessionHandler = daoSessionHandler; DaoManager.RegisterDaoManager(daoManager.Id, daoManager); } } } } catch { } }