public static void InitializeStorage()
{
if (!string.IsNullOrEmpty(Preferences.StorageUsername)) {
// if (null != Preferences.StorageUsername && string.Empty != Preferences.StorageUsername) {
Preferences.StorageConnectionString =
//@"Data Source=" +
@"Server=" +
Preferences.StorageServer +
//";Initial Catalog=" +
";Database=" +
Preferences.StorageDatabase +
";Username=" +
Preferences.StorageUsername +
";Password=" +
Preferences.StoragePassword +
";";
} else {
Preferences.StorageConnectionString =
//@"Data Source=" +
@"Server=" +
Preferences.StorageServer +
//";Initial Catalog=" +
";Database=" +
Preferences.StorageDatabase +
";Integrated Security=SSPI;";
}
try {
// cmdlet.WriteVerbose("building configuration...");
if (null == Fluently.Configure()) {
Console.WriteLine("Fluently == null");
}
Console.WriteLine("Fluently != null");
Fluently.Configure();
// .Database(MsSqlConfiguration
// .MsSql2008
// //.ConnectionString(Preferences.StorageConnectionString))
// //.ConnectionString(x => x.Is(connString)))
// .ConnectionString(x => x.Is(Preferences.StorageConnectionString)))
// //.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ProductMap>())
// .Mappings(m => m.FluentMappings
// .AddFromAssemblyOf<TestSuiteMap>())
// //.AddFromAssemblyOf<System.Object>())
// .ExposeConfiguration(CreateSchema)
// .BuildConfiguration();
// cmdlet.WriteVerbose("creating session factory...");
SessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration
.MsSql2008
.ConnectionString(Preferences.StorageConnectionString))
.Mappings(m =>m.FluentMappings
//.AddFromAssembly(Assembly.GetExecutingAssembly()))
.AddFromAssemblyOf<TestSuiteMap>())
//.AddFromAssemblyOf<System.Object>())
.BuildSessionFactory();
// cmdlet.WriteVerbose("session factory has been created...");
}
catch (Exception eSession) {
// 20140720
// cmdlet.WriteError(
// cmdlet,
// eSession.InnerException.Message,
// "SessionFailed",
// ErrorCategory.InvalidOperation,
// true);
throw new Exception(
eSession.InnerException.Message);
}
}