Beispiel #1
0
        public MongoDbBaseDataAccess()
        {
            var user     = CPSSAuthenticate.GetCurrentUser();
            var filePath = "~/config/mongodbconfig.config";

            if (user != null)
            {
                filePath = string.Format("~/config/{0}/mongodbconfig.config", user.CompanySerialNum);
                if (!ExistsFileHelper.ExistsFile(filePath))
                {
                    var config = new MongoDbConfig
                    {
                        Server   = WebConfigHelper.GetMongoDbServer(),
                        Database = string.Format("MongoDbLog_{0}", user.CompanySerialNum)
                    };
                    ConfigHelper.Save(config, filePath);
                }
            }
            //if (!ExistsFileHelper.ExistsFile(filePath)) throw new Exception("MongoDb库连接配置文件不存在。");
            var mongoDbConfig = ConfigHelper.GetConfig <MongoDbConfig>(filePath);

            this.InitMongoDataBase(mongoDbConfig.Server, mongoDbConfig.Database);
        }