/// <summary> /// Validates that all of our assembly paths point to valid assemblies containing RavenDB index definitions /// </summary> /// <returns>A JobReport containing the results of each particular assembly path</returns> public JobReport CanLoadAssemblies() { var assemblyReport = new JobReport(); foreach (var assemblyPath in BuildInstructions.AssemblyPaths) { var jobResult = new JobResult() { ResourceName = assemblyPath }; //Check to see if we can locate the assembly in the GAC / filesystem if (AssemblyRuntimeLoader.CanFindAssembly(assemblyPath)) { //Check to see if the assembly has any indexes in it if (AssemblyRuntimeLoader.HasRavenDbIndexes(AssemblyRuntimeLoader.LoadAssembly(assemblyPath))) { //Success! jobResult.WasFound = true; } else { //Fail - wasn't able to find any RavenDB indexes in this assembly jobResult.WasFound = false; jobResult.JobException = new InvalidOperationException(string.Format("Was able to load the assembly at {0}, but didn't find any RavenDB indexes", assemblyPath)); } } else //we were unable to find the assembly { jobResult.WasFound = false; jobResult.JobException = new FileNotFoundException(string.Format("Unable to find assembly located at {0}", assemblyPath)); } assemblyReport.JobResults.Add(jobResult); } return assemblyReport; }
/// <summary> /// Validates all of our connection strings before we run the job /// </summary> /// <returns>a JobReport containing the results of each particular connection string</returns> public JobReport CanConnectToDbs() { //If there are any errors with the connection string syntax themselves, those will be passed directly to the caller LoadDbInstances(); var connectivityReport = new JobReport(); foreach (var db in RavenInstances) { var connectivityResult = new JobResult() { ResourceName = db.Key }; try { //Attempt to open a session var databaseStatistics = db.Value.DatabaseCommands.GetStatistics(); //See if we can get the store identifier if (databaseStatistics != null) { connectivityResult.WasFound = true; } } catch (Exception ex) { //If there was an exception thrown here, it means there was probably something wrong with our database connection string connectivityResult.WasFound = false; connectivityResult.JobException = ex; } //Add the result of this particular connection attempt to the report connectivityReport.JobResults.Add(connectivityResult); } return connectivityReport; }