Пример #1
0
 public void Initialize()
 {
     _log.Info("Initializing Auditing Databases.");
     var publicCredentials = BuildPublicCredentials();
     var creatorCredentials = new DatabaseCredentials(_configuration.DatabaseCreatorUserName, _configuration.DatabaseCreatorPassword);
     foreach (var siteSubscriptionId in _configuration.SiteSubscriptionIds)
     {
         ServiceResponse response;
         var builder = new AuditingConnectionStringBuilder(_configuration.DatabaseInstanceName, siteSubscriptionId);
         var databaseInfo = new DatabaseInfo(_configuration.DatabaseInstanceName, builder.InitialCatalog, builder.UserId, builder.Password);
         var databaseManager = new DatabaseManager(_log, null);
         if (!DatabaseExists(builder.InitialCatalog))
         {
             _log.Info("Creating database " + builder.InitialCatalog);
             response = databaseManager.CreateDatabase(databaseInfo, publicCredentials.UserName, publicCredentials.Password, _scriptResourceName, new AuditingScriptLoader(), creatorCredentials);
         }
         else
         {
             _log.Info("Updating database " + builder.InitialCatalog);
             response = databaseManager.UpdateDatabaseSchema(databaseInfo, publicCredentials.UserName, _scriptResourceName, new AuditingScriptLoader());
         }
         CheckServiceResponse(response);
     }
     _log.Info("Auditing Databases Initialized.");
 }
 private IObjectContextFactory CreateObjectContextFactory(String siteSubscriptionId)
 {
     var userConnectionString = new AuditingConnectionStringBuilder(_configuration.DatabaseInstanceName, siteSubscriptionId).ToString();
     var objectContextFactory = new AuditingObjectContextFactory(userConnectionString);
     return objectContextFactory;
 }