2016-08-19 20:45:52 +08:00
|
|
|
|
using System.Configuration;
|
2015-08-05 19:28:16 +08:00
|
|
|
|
|
2016-08-20 05:10:55 +08:00
|
|
|
|
namespace BuildFeed.Model
|
2015-08-05 19:28:16 +08:00
|
|
|
|
{
|
2016-08-20 05:10:55 +08:00
|
|
|
|
public static class MongoConfig
|
2015-09-13 06:56:15 +08:00
|
|
|
|
{
|
2015-11-09 22:13:36 +08:00
|
|
|
|
public static string Host { get; }
|
|
|
|
|
public static int Port { get; }
|
|
|
|
|
public static string Database { get; }
|
2015-08-05 19:28:16 +08:00
|
|
|
|
|
2015-09-13 06:56:15 +08:00
|
|
|
|
static MongoConfig()
|
|
|
|
|
{
|
2016-08-19 20:45:52 +08:00
|
|
|
|
Host = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoHost"])
|
|
|
|
|
? ConfigurationManager.AppSettings["data:MongoHost"]
|
|
|
|
|
: "localhost";
|
2015-08-05 19:28:16 +08:00
|
|
|
|
|
2015-09-13 06:56:15 +08:00
|
|
|
|
int _port;
|
|
|
|
|
bool success = int.TryParse(ConfigurationManager.AppSettings["data:MongoPort"], out _port);
|
|
|
|
|
if (!success)
|
|
|
|
|
{
|
|
|
|
|
_port = 27017; // mongo default port
|
|
|
|
|
}
|
|
|
|
|
Port = _port;
|
2015-08-05 19:28:16 +08:00
|
|
|
|
|
2016-08-19 20:45:52 +08:00
|
|
|
|
Database = !string.IsNullOrEmpty(ConfigurationManager.AppSettings["data:MongoDB"])
|
|
|
|
|
? ConfigurationManager.AppSettings["data:MongoDB"]
|
|
|
|
|
: "MongoAuth";
|
2015-09-13 06:56:15 +08:00
|
|
|
|
}
|
2016-01-09 02:23:23 +08:00
|
|
|
|
|
|
|
|
|
public static void SetupIndexes()
|
|
|
|
|
{
|
2016-08-21 07:09:56 +08:00
|
|
|
|
BuildRepository b = new BuildRepository();
|
2016-01-09 02:23:23 +08:00
|
|
|
|
b.SetupIndexes();
|
|
|
|
|
}
|
2015-09-13 06:56:15 +08:00
|
|
|
|
}
|
2015-08-05 19:28:16 +08:00
|
|
|
|
}
|