如何设置quartznet mongodb的连接字符串

如何设置quartznet mongodb的连接字符串,mongodb,connection-string,quartz.net,Mongodb,Connection String,Quartz.net,我正在使用下面的测试代码并得到一个错误(如代码所示)。我的连接字符串应该设置为什么 我使用的是Quartz.Impl.MongoDB 1.2、Quartz 2.1.2.400、MongoDB.Bson 1.9.2.235和MongoDB.Driver 1.9.2.235 我已经尝试将连接字符串设置为“服务器”=mongodb://localhost;数据库=quartznet 类程序 { 静态void Main(字符串[]参数) { //测试本地mongodb是否正常工作 变量连接字符串=”mo

我正在使用下面的测试代码并得到一个错误(如代码所示)。我的连接字符串应该设置为什么

我使用的是Quartz.Impl.MongoDB 1.2、Quartz 2.1.2.400、MongoDB.Bson 1.9.2.235和MongoDB.Driver 1.9.2.235

我已经尝试将连接字符串设置为“服务器”=mongodb://localhost;数据库=quartznet

类程序
{
静态void Main(字符串[]参数)
{
//测试本地mongodb是否正常工作
变量连接字符串=”mongodb://localhost";
var客户端=新的MongoClient(connectionString);
var server=client.GetServer();
var database=server.GetDatabase(“quartznet”);
var collection=database.GetCollection(“实体”);
var entity=新实体{Name=“Tom”};
收款。插入(实体);
var id=entity.id;
//本地mongodb正在工作。现在尝试设置Quartz调度程序
var properties=new NameValueCollection();
属性[“quartz.scheduler.instanceName”]=“MyApplicationScheduler”;//如果计划对多个调度器使用同一数据库,则需要使用该属性
属性[“quartz.scheduler.instanceId”]=System.Environment.MachineName+DateTime.UtcNow.Ticks;//需要唯一性
属性[“quartz.jobStore.type”]=“quartz.Impl.MongoDB.jobStore,quartz.Impl.MongoDB”;
/*
*从App.Config
*/
var scheduler=new Quartz.Impl.StdSchedulerFactory(properties).GetScheduler();//此行引发错误:
//内部异常:连接字符串“server=localhost;database=quartznet;”无效。
Console.ReadLine();
}
}
公共类实体
{
公共对象Id{get;set;}
公共字符串名称{get;set;}
}
答案是:mongodb://localhost/quartznet"

class Program
{
    static void Main(string[] args)
    {
        // test that the local mongodb is working
        var connectionString = "mongodb://localhost";
        var client = new MongoClient(connectionString);
        var server = client.GetServer();
        var database = server.GetDatabase("quartznet");
        var collection = database.GetCollection<Entity>("entities");

        var entity = new Entity { Name = "Tom" };
        collection.Insert(entity);
        var id = entity.Id; 

        // local mongodb is working.  Now try to set up a Quartz Scheduler

        var properties = new NameValueCollection();
        properties["quartz.scheduler.instanceName"] = "MyApplicationScheduler"; // needed if you plan to use the same database for many schedulers
        properties["quartz.scheduler.instanceId"] = System.Environment.MachineName + DateTime.UtcNow.Ticks; // requires uniqueness
        properties["quartz.jobStore.type"] = "Quartz.Impl.MongoDB.JobStore, Quartz.Impl.MongoDB";

        /*
         * From the App.Config
          <connectionStrings>
            <add name="quartznet-mongodb" connectionString="server=localhost;database=quartznet;" />
          </connectionStrings>
         */
        var scheduler = new Quartz.Impl.StdSchedulerFactory(properties).GetScheduler(); // error thrown on this line:
        // Inner exception: Invalid connection string 'server=localhost;database=quartznet;'.

        Console.ReadLine();
    }
}

public class Entity
{
    public ObjectId Id { get; set; }
    public string Name { get; set; }
}