public static void cloudCleaner() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); foreach (string collection in collNames) { if (collection.Contains("NUB")) { var coll = db.GetCollection <BsonDocument>(collection); var project = BsonDocument.Parse( "{minute: {$minute: '$time'}}"); try { var aggregationDocument = coll.Aggregate() .Project(project) .Match(BsonDocument.Parse("{'minute':{$gt:0 }}")) .ToList(); foreach (BsonDocument bd in aggregationDocument) { var id = bd.GetValue("_id").ToString(); ObjectId oid = new ObjectId(id); coll.DeleteOne(Builders <BsonDocument> .Filter.Eq("_id", oid)); } } catch (Exception e) { } } } }
public static void checkAveraging() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); int tenmincollections = 0; int averagedcollections = 0; foreach (string collection in collNames) { if (collection[0] == 's') { if (collection.Contains("average")) { averagedcollections++; } else { string[] parts = collection.Split('_'); if (parts[5] == "10") { tenmincollections++; } } } } }
public void printCityRegionGroups() { db = MongoTools.connect("mongodb://localhost", "climaColombia"); var coll = db.GetCollection <StationGroup>("cityRegionGroups"); allRegionGroups = coll.Find(FilterDefinition <StationGroup> .Empty).ToList(); StreamWriter sw = new StreamWriter("regiongroups.csv"); foreach (StationGroup sg in allRegionGroups) { StringBuilder sb = new StringBuilder(); sb.Append(sg.name + ","); foreach (int code in sg.stationcodes) { sb.Append(code + ","); } sw.WriteLine(sb.ToString()); } sw.Close(); cities = MapTools.readCities(); stations = StationGrouping.getAllStationsFromDB(db); JSONout.writeGroup(allRegionGroups, @"C:\Users\Admin\Documents\projects\IAPP\climaColombiaOrg\tools\cityGroups\cityregiongroups.json", stations, cities); }
public static List <StationSummary> getCollectionAsList(string collectionname) { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); var coll = db.GetCollection <StationSummary>(collectionname); var t = coll.Find(FilterDefinition <StationSummary> .Empty).ToList(); //db.DropCollection(collection); return(t); }
public void convert(string key) { //("mongodb://localhost/?maxPoolSize=555"); db = MongoTools.connect("mongodb://localhost/?maxPoolSize=1000", "climaColombia"); Task t1 = Task.Run(() => convert10min(key)); //add the processed data to mongo //t1.Wait(); //foreach(CollectionMongo cm in newAveragedData) //{ // insertMany(cm.records, cm.name); //} }
public void clean() { //("mongodb://localhost/?maxPoolSize=555"); db = MongoTools.connect("mongodb://localhost/?maxPoolSize=1000", "climaColombia"); Task t1 = Task.Run(() => cleanUp()); //add the processed data to mongo t1.Wait(); foreach (CollectionMongo cm in newCleanData) { insertMany(cm.records, cm.name); } }
public static void checkRadiationLoaded() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); foreach (string collection in collNames) { if (collection.Contains("rad")) { var rad = 0; } } }
public static void dropIndexes() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); foreach (string collection in collNames) { if (collection[0] == 's') { IMongoCollection <BsonDocument> coll = db.GetCollection <BsonDocument>(collection); coll.Indexes.DropAllAsync(); } } }
public static void cleanUpByKeyword(String key) { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); foreach (string collection in collNames) { if (collection.Contains(key)) { var coll = db.GetCollection <BsonDocument>(collection); var t = coll.Find(new BsonDocument()).ToList(); db.DropCollection(collection); } } }
public StationGrouping(bool allideam) { db = MongoTools.connect("mongodb://localhost", "climaColombia"); getData(); if (allideam) { makeGroupsALLIDEAM(); } else { makeGroups(); } writeStationGroupIDs(); outputJSON(); storeInMongo(); writeStationCoords(); }
public static bool checkIndexes() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); int withindex = 0; int cleanCollection = 0; foreach (string collection in collNames) { if (collection.Contains("Clean")) { cleanCollection++; var coll = db.GetCollection <BsonDocument>(collection); IMongoIndexManager <BsonDocument> index = coll.Indexes; using (IAsyncCursor <BsonDocument> cursor = coll.Indexes.List()) { while (cursor.MoveNext()) { IEnumerable <BsonDocument> batch = cursor.Current; foreach (BsonDocument b in batch) { if (b["key"].AsBsonDocument.Contains("time")) { withindex++; } } } } } } bool success = false; if (withindex == cleanCollection) { success = true; } return(success); }
public static void removeCollections() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); foreach (string collection in collNames) { //all station record collections start with an s_ string[] parts = collection.Split('_'); string firstletter = parts[0]; if (firstletter == "s") { string vname = parts[4]; if (vname == "PA") { var coll = db.GetCollection <BsonDocument>(collection); db.DropCollection(collection); } } } }
public TenMinuteConversion() { db = MongoTools.connect("mongodb://localhost/?maxPoolSize=1000", "climaColombia"); }
private void loadToMongo() { db = MongoTools.connect("mongodb://localhost", "climaColombia"); insertManyRecord(); }
public CityYearBuilder() { db = MongoTools.connect("mongodb://localhost", "climaColombia"); this.logFile = "syntheticYearBuilder_" + DateTime.Now.Millisecond + ".txt"; this.addLineToLogFile("INFO: process launched"); }
public IndexStationVariableCollections() { db = MongoTools.connect("mongodb://localhost/?maxPoolSize=3000", "climaColombia"); }
private void connect(string connectionString, string dbName) { db = MongoTools.connect(connectionString, dbName); }
public FlexiQuery() { db = MongoTools.connect("mongodb://localhost", "climaColombia"); getActiveStations(); }
public TemporalAnalysis() { db = MongoTools.connect("mongodb://localhost", "climaColombia"); }
public CleanRecords() { db = MongoTools.connect("mongodb://localhost/?maxPoolSize=1000", "climaColombia"); }
public MonthlySummary() { db = MongoTools.connect("mongodb://localhost", "climaColombia"); }
public void setup() { neededData = readRequiredData(); db = MongoTools.connect("mongodb://localhost", "climaColombia"); defineCityRegionGroups(); }