daily pastebin goal
89%
SHARE
TWEET

Justin Dearing

a guest Mar 3rd, 2011 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [string] $mongoDriverPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\.NETFramework\v3.5\AssemblyFoldersEx\MongoDB CSharpDriver 0.11").'(default)';
  2. [string] $AtlantisSchemaEngineBaseDir = "C:\justin's projects\Atlantis Schema Engine\";
  3. [string] $SqlServerInstance = '.\MyInstance';
  4. [string] $dbName = 'master'
  5.  
  6. Add-Type -Path "$($mongoDriverPath)\MongoDB.Bson.dll";
  7. Add-Type -Path "$($mongoDriverPath)\MongoDB.Driver.dll";
  8. Add-Type -Path "$($AtlantisSchemaEngineBaseDir)\Atlantis.SchemaEngine\bin\Debug\Atlantis.SchemaEngine.dll"
  9.  
  10.  
  11.  
  12. [MongoDB.Driver.MongoDatabase] $db = [MongoDB.Driver.MongoDatabase]::Create('mongodb://localhost/atlantisSchemaEngine');
  13. [string] $cnStr = "Data Source=$SqlServerInstance;Initial Catalog=$dbName;Integrated Security=SSPI;";
  14. $schemaReader = [Atlantis.SchemaEngine.Container.SQLServer.SQLServerSchemaReaderFactory]::GetSpecificSQLServerSchemaReader($cnStr, [Atlantis.SchemaEngine.Enumerations.ContainerMode]::Comparison)
  15. [Atlantis.SchemaEngine.Container.SchemaContainer] $dbObjects = $schemaReader.ReadObjects();
  16.  
  17. foreach ($dbObject in $dbObjects) {
  18.     try {
  19.         Invoke-GenericMethod $db["alantisSchema.$($dbName)"] Insert Atlantis.SchemaEngine.SchemaElements.SysEntry $dbObject
  20.         [MongoDB.Bson.BsonDocument] $doc = New-Object -TypeName MongoDB.Bson.BsonDocument;
  21.         $doc["Name"] = "Justin";
  22.         Invoke-GenericMethod $db["test"] Insert MongoDB.Bson.BsonDocument $doc;
  23.        
  24.         #[MongoDB.Bson.BsonExtensionMethods]::ToBsonDocument($dbObject);
  25.         break;
  26.     } catch [Exception] {
  27.         $_.Exception.ToString();
  28.         break;
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top