public void Execute(IJobExecutionContext context) { try { _logger.Info(string.Format("开始创建AppApi日志Mongo索引。。。")); var dbName = "ApiLog{0}".Fmt(DateTime.Now.ToString("yyyyMM")); var connections = _mongoProxy.ListConnections(dbName); if (connections != null && connections.Count > 0) { foreach (var connection in connections) { var collectionName = connection.FromJson <ConnectionModel>().name; var indexNames = _mongoProxy.GetIndexNames(dbName, collectionName); if (!indexNames.Contains(INDEX_NAME)) { _mongoProxy.CreateIndex(dbName, collectionName, INDEX_NAME, "{LogTime:-1, Mobile:1}"); } } } _logger.Info("创建AppApi日志Mongo索引完成"); } catch (Exception ex) { _logger.Error(string.Format("创建AppApi日志Mongo索引出错,{0}", ex.Message)); } }
public ActionResult ListConnectionsForAjax(string database) { List <string> Collections = new List <string>(); foreach (var collection in mongo.ListConnections(database)) { Collections.Add(collection.FromJson <MongoCollectionModel>().name); } return(Json(Collections)); }
public ActionResult ListConnectionsForAjax(string database) { BsonDefaults.GuidRepresentation = GuidRepresentation.Standard; List <string> Collections = new List <string>(); foreach (var collection in mongo.ListConnections(database)) { Collections.Add(collection.FromJson <MongoCollectionModel>().name); } return(Json(Collections)); }