2012-03-30 01:35:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Configuration;
|
2012-02-05 06:34:36 +00:00
|
|
|
|
using System.Linq;
|
2012-03-30 01:35:35 +00:00
|
|
|
|
using MongoDB.Bson;
|
|
|
|
|
using MongoDB.Driver;
|
2012-02-05 06:34:36 +00:00
|
|
|
|
using NzbDrone.Services.Service.Migrations;
|
2012-02-17 22:04:22 +00:00
|
|
|
|
using Services.PetaPoco;
|
|
|
|
|
|
2012-02-05 06:34:36 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Services.Service.Datastore
|
|
|
|
|
{
|
|
|
|
|
public static class Connection
|
|
|
|
|
{
|
|
|
|
|
public static string GetConnectionString
|
|
|
|
|
{
|
|
|
|
|
get { return ConfigurationManager.ConnectionStrings["SqlExpress"].ConnectionString; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IDatabase GetPetaPocoDb()
|
|
|
|
|
{
|
|
|
|
|
var db = new Database("SqlExpress")
|
|
|
|
|
{
|
2012-03-01 05:39:15 +00:00
|
|
|
|
KeepConnectionAlive = false,
|
2012-02-05 06:34:36 +00:00
|
|
|
|
ForceDateTimesToUtc = false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return db;
|
|
|
|
|
}
|
2012-03-30 01:35:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static MongoDatabase GetMongoDb()
|
|
|
|
|
{
|
|
|
|
|
var serverSettings = new MongoServerSettings()
|
|
|
|
|
{
|
|
|
|
|
ConnectionMode = ConnectionMode.Direct,
|
|
|
|
|
ConnectTimeout = TimeSpan.FromSeconds(10),
|
|
|
|
|
DefaultCredentials = new MongoCredentials("nzbdrone", "nzbdronepassword"),
|
|
|
|
|
GuidRepresentation = GuidRepresentation.Standard,
|
|
|
|
|
Server = new MongoServerAddress("ds031747.mongolab.com", 31747),
|
|
|
|
|
SafeMode = new SafeMode(true) { J = true },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var server = MongoServer.Create(serverSettings);
|
|
|
|
|
|
|
|
|
|
return server.GetDatabase("nzbdrone_ex");
|
|
|
|
|
}
|
2012-02-05 06:34:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|