- Renamed CSProj for both Gsm and Firelance. - Made namespace names consistent.
36 lines
1012 B
C#
36 lines
1012 B
C#
using Firelance.Interfaces;
|
|
using MongoDB.Bson;
|
|
using MongoDB.Driver;
|
|
using System;
|
|
|
|
namespace Firelance
|
|
{
|
|
public class FirelanceMgr : IFlcBaseDBConnection, IFlcMongoDBConnecton
|
|
{
|
|
public IMongoDatabase Database { get; private set; }
|
|
|
|
public void OpenConnection(string dbLocation, int port)
|
|
{
|
|
var client = new MongoClient($"mongodb://{dbLocation}:{port}");
|
|
var settings = new MongoDatabaseSettings { GuidRepresentation = GuidRepresentation.Standard };
|
|
|
|
Database = client.GetDatabase(dbLocation, settings);
|
|
}
|
|
|
|
public bool IsConnectionOpen()
|
|
{
|
|
int connectionCnt = 0;
|
|
|
|
try { connectionCnt = Database.Client.ListDatabases().ToList().Count; }
|
|
catch { }
|
|
|
|
return (connectionCnt > 0) ? true : false;
|
|
}
|
|
|
|
public void CloseCurrentConnection()
|
|
{
|
|
throw new NotSupportedException("MongoDB does not support closing connections.");
|
|
}
|
|
}
|
|
}
|