public void Execute(Character.NPC actor, ITrigger trigger = null) { if (actor.StanceState != CharacterEnums.CharacterStanceState.Decomposing) { Commands.CommandParser.ExecuteCommand(actor, "EMOTE", "carcass last bit of flesh has rotted away from its dead corpse."); actor.Description = "The only remains of " + actor.FirstName + " are just bones."; actor.SetStanceState(CharacterEnums.CharacterStanceState.Decomposing); actor.NextAiAction = DateTime.Now.AddMinutes(5).ToUniversalTime(); } else { Commands.CommandParser.ExecuteCommand(actor, "EMOTE", "carcass has its bones break down to dust and carried off by the wind."); MongoUtils.MongoData.ConnectToDatabase(); MongoDB.Driver.MongoDatabase db = MongoUtils.MongoData.GetDatabase("World"); MongoDB.Driver.MongoCollection npcs = db.GetCollection("NPCs"); MongoDB.Driver.IMongoQuery query = MongoDB.Driver.Builders.Query.EQ("_id", actor.MobTypeID); MongoDB.Bson.BsonDocument doc = npcs.FindOneAs <MongoDB.Bson.BsonDocument>(query); doc["Current"] = doc["Current"].AsInt32 - 1; npcs.Save(doc); db = MongoUtils.MongoData.GetDatabase("Characters"); npcs = db.GetCollection("NPCCharacters"); query = MongoDB.Driver.Builders.Query.EQ("_id", MongoDB.Bson.ObjectId.Parse(actor.ID)); npcs.Remove(query); } }
public void GlobalInit() { _document = new BsonDocument { { "int", 42 }, { "bool", true }, { "string1", "string" }, { "string2", "" }, { "array", new BsonArray { "item1", 42, true } }, { "inner", new BsonDocument { { "innerString", "inner string" } } } }; _bsonDocument = new MongoDB.Bson.BsonDocument { { "int", 42 }, { "bool", true }, { "string1", "string" }, { "string2", "" }, { "array", new MongoDB.Bson.BsonArray { "item1", 42, true } }, { "inner", new MongoDB.Bson.BsonDocument { { "innerString", "inner string" } } } }; }
static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 2 && translator.Assignable <MongoDB.Bson.BsonDocument>(L, 2)) { MongoDB.Bson.BsonDocument _document = (MongoDB.Bson.BsonDocument)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonDocument)); MongoDB.Bson.IO.BsonDocumentWriter gen_ret = new MongoDB.Bson.IO.BsonDocumentWriter(_document); translator.Push(L, gen_ret); return(1); } if (LuaAPI.lua_gettop(L) == 3 && translator.Assignable <MongoDB.Bson.BsonDocument>(L, 2) && translator.Assignable <MongoDB.Bson.IO.BsonDocumentWriterSettings>(L, 3)) { MongoDB.Bson.BsonDocument _document = (MongoDB.Bson.BsonDocument)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonDocument)); MongoDB.Bson.IO.BsonDocumentWriterSettings _settings = (MongoDB.Bson.IO.BsonDocumentWriterSettings)translator.GetObject(L, 3, typeof(MongoDB.Bson.IO.BsonDocumentWriterSettings)); MongoDB.Bson.IO.BsonDocumentWriter gen_ret = new MongoDB.Bson.IO.BsonDocumentWriter(_document, _settings); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.IO.BsonDocumentWriter constructor!")); }
private MongoDB.Bson.BsonDocument Aggrigate(MongoDB.Bson.BsonDocument _doc) { try { string destinationValue = ""; string[] sourceKeyArr = SourceKeys.Split(','); foreach (string sourceKey in sourceKeyArr) { if (_doc[sourceKey] != null) { if (this.SourceKeyTransformation.Key == sourceKey) { destinationValue += this.SourceKeyTransformation.Execute(_doc); } else { destinationValue += _doc[sourceKey] + Delimiter; } } } if (destinationValue.EndsWith(Delimiter)) { destinationValue = destinationValue.TrimEnd(Delimiter.ToCharArray()); } _doc.Add(DestinationKey, destinationValue); } catch (Exception exp) { Console.WriteLine(exp.Message); throw; } return(_doc); }
public bool save(Hashtable json_data) { MongoDB.Bson.BsonDocument _d = new MongoDB.Bson.BsonDocument(json_data); _collection.Save(_d); return(true); }
public ArrayList find(string db, string collection, Hashtable json_query) { var _mongoclient = getMongoCLient(); var _db = _mongoclient.GetDatabase(db); var _collection = _db.GetCollection <MongoDB.Bson.BsonDocument>(collection) as MongoDB.Driver.IMongoCollection <MongoDB.Bson.BsonDocument>; var _bson_query = new MongoDB.Bson.BsonDocument(json_query); var _query = new MongoDB.Driver.BsonDocumentFilterDefinition <MongoDB.Bson.BsonDocument>(_bson_query); var c = _collection.FindSync <MongoDB.Bson.BsonDocument>(_query); ArrayList _list = new ArrayList(); do { var _c = c.Current; if (_c != null) { foreach (var data in _c) { var _data = data.ToHashtable(); _data.Remove("_id"); _list.Add(_data); } } } while (c.MoveNext()); releaseMongoClient(_mongoclient); return(_list); }
public List <FerroFTS.Data.service> GetVehicleServices(string sOu, string sOuService, DateTime sStartDate, DateTime sEndDate) { MongoDB.Driver.FilterDefinition <FerroFTS.Data.service> oFilter; FerroData.Mongo.DataMongo <FerroFTS.Data.service> oData = new FerroData.Mongo.DataMongo <FerroFTS.Data.service>(); MongoDB.Driver.FindOptions <FerroFTS.Data.service> oOptions = new MongoDB.Driver.FindOptions <FerroFTS.Data.service>(); List <FerroFTS.Data.service> oList = new List <Data.service>(); try { //***************************************************************** //Convertimos fechas //***************************************************************** sStartDate = Data.Common.ParseUTC(sStartDate); sEndDate = Data.Common.ParseUTC(sEndDate); /*'***************************************************************** * Agregamos datos al filtro ******************************************************************'*/ oFilter = new MongoDB.Bson.BsonDocument("ou", sOu); oFilter = (oFilter & new MongoDB.Bson.BsonDocument("ou_service", sOuService)); oFilter = (oFilter & new MongoDB.Bson.BsonDocument("utc_datetime", new MongoDB.Bson.BsonDocument("$gte", sStartDate))); oFilter = (oFilter & new MongoDB.Bson.BsonDocument("utc_datetime", new MongoDB.Bson.BsonDocument("$gte", sStartDate))); oData.Session = this._Session; oList = oData.Find(oFilter, oOptions); return(oList); } catch (Exception ex) { throw new Exception((ex.StackTrace.Substring((ex.StackTrace.LastIndexOf("\r\n") + 4)) + ("\r\n" + ex.Message))); } }
static int _m_Deserialize(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); MongoDB.Bson.Serialization.Serializers.PartiallyRawBsonDocumentSerializer gen_to_be_invoked = (MongoDB.Bson.Serialization.Serializers.PartiallyRawBsonDocumentSerializer)translator.FastGetCSObj(L, 1); { MongoDB.Bson.Serialization.BsonDeserializationContext _context = (MongoDB.Bson.Serialization.BsonDeserializationContext)translator.GetObject(L, 2, typeof(MongoDB.Bson.Serialization.BsonDeserializationContext)); MongoDB.Bson.Serialization.BsonDeserializationArgs _args; translator.Get(L, 3, out _args); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.Deserialize(_context, _args); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public Post Update(Post model) { var filter = new MongoDB.Bson.BsonDocument("_id", model.Id); collection.FindOneAndUpdate(filter, Translate(model)); return(ReadById(model.Id)); }
public Post ReadById(string id) { var filter = new MongoDB.Bson.BsonDocument("_id", id); var fetched = collection.Find(filter).FirstOrDefault(); return(fetched); }
public bool Delete(string id) { var filter = new MongoDB.Bson.BsonDocument("_id", id); var fetched = collection.DeleteOne(filter).DeletedCount == 1; return(fetched); }
public List <FerroFTS.Data.last_location> GetVehicleRoute(string sOu, string sidVehicle, string svehicle, DateTime sStartDate, DateTime sEndDate) { MongoDB.Driver.FilterDefinition <FerroFTS.Data.last_location> oFilter; FerroData.Mongo.DataMongo <FerroFTS.Data.last_location> oData = new FerroData.Mongo.DataMongo <FerroFTS.Data.last_location>(); MongoDB.Driver.FindOptions <FerroFTS.Data.last_location> oOptions = new MongoDB.Driver.FindOptions <FerroFTS.Data.last_location>(); List <FerroFTS.Data.last_location> oList; try { oFilter = new MongoDB.Bson.BsonDocument("ou", sOu); //Vamos a buscar bien por indicativo bien por vehículo if (!string.IsNullOrEmpty(sidVehicle)) { oFilter = (oFilter & new MongoDB.Bson.BsonDocument("indicative", sidVehicle)); } if (!string.IsNullOrEmpty(svehicle)) { oFilter = (oFilter & new MongoDB.Bson.BsonDocument("vehicle", svehicle)); } oFilter = (oFilter & new MongoDB.Bson.BsonDocument("utc_datetime", new MongoDB.Bson.BsonDocument("$gte", sStartDate))); oFilter = (oFilter & new MongoDB.Bson.BsonDocument("utc_datetime", new MongoDB.Bson.BsonDocument("$lte", sEndDate))); oData.Session = this._Session; oList = oData.Find(oFilter, oOptions); return(oList); } catch (Exception ex) { throw new Exception((ex.StackTrace.Substring((ex.StackTrace.LastIndexOf("\r\n") + 4)) + ("\r\n" + ex.Message))); } }
public string Execute(MongoDB.Bson.BsonDocument _doc) { if (TransformationType.ToUpper() == "DATE") { return(GetDateTransformedString(_doc)); } return(""); }
static async Task HandleChangesAsync(IReadOnlyCollection <object> changes, CancellationToken cancellationToken) { MongoSink.BlobUploader blobUploader = new MongoSink.BlobUploader( blobConnectionString, blobContainer); MongoSink.MongoSink mongoSink = new MongoSink.MongoSink(destConnectionString, destDBName, destContainerName, insertRetries, blobConnectionString, blobContainer, isUpsert); SourceTransformation sourceTransformation = null; if (!string.IsNullOrEmpty(sourceKeyTransformationString)) { try { sourceTransformation = JsonConvert.DeserializeObject <SourceTransformation> (sourceKeyTransformationString); } catch (Exception exp) { Console.WriteLine(exp.Message); } } Transformation transformation = new Transformation(transformationType, sourceKeys, destinationKey, delimiter, sourceTransformation, swapKeyValues); Console.WriteLine("Received data from the source:" + changes.Count.ToString()); foreach (object item in changes) { try { //Console.WriteLine(item.ToString()); JObject objects = JObject.Parse(item.ToString()); objects.Remove("_lsn"); objects.Remove("_metadata"); objects.Remove("_id"); string json = objects.ToString(); MongoDB.Bson.BsonDocument bdoc = CosmosDbSchemaDecoder.GetBsonDocument(json, false); if (transformationType != "NONE") { transformation.Execute(bdoc); } await mongoSink.InsertAsync(bdoc, source.Token); } catch (Exception exp) { blobUploader.Upload(item.ToString()); } } }
public bool save(string db, string collection, Hashtable json_data) { var _db = _mongoserver.GetDatabase(db); var _collection = _db.GetCollection <MongoDB.Bson.BsonDocument> (collection) as MongoDB.Driver.MongoCollection <MongoDB.Bson.BsonDocument>; MongoDB.Bson.BsonDocument _d = new MongoDB.Bson.BsonDocument(json_data); _collection.Save(_d); return(true); }
static void Main(string[] args) { IDictionary <string, object> dicionario = new Dictionary <string, object> { { "nome", "Diego Gomes" } }; var documento = new MongoDB.Bson.BsonDocument(dicionario); Console.WriteLine(documento); Console.ReadKey(); }
static int _m_Add(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); MongoDB.Bson.RawBsonDocument gen_to_be_invoked = (MongoDB.Bson.RawBsonDocument)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonElement>(L, 2)) { MongoDB.Bson.BsonElement _element; translator.Get(L, 2, out _element); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.Add(_element); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <MongoDB.Bson.BsonValue>(L, 3)) { string _name = LuaAPI.lua_tostring(L, 2); MongoDB.Bson.BsonValue _value = (MongoDB.Bson.BsonValue)translator.GetObject(L, 3, typeof(MongoDB.Bson.BsonValue)); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.Add(_name, _value); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <MongoDB.Bson.BsonValue>(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4)) { string _name = LuaAPI.lua_tostring(L, 2); MongoDB.Bson.BsonValue _value = (MongoDB.Bson.BsonValue)translator.GetObject(L, 3, typeof(MongoDB.Bson.BsonValue)); bool _condition = LuaAPI.lua_toboolean(L, 4); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.Add(_name, _value, _condition); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.RawBsonDocument.Add!")); }
private static void SerializeCollectionFull(IEnumerable <BH.oM.XML.Environment.DocumentBuilder> documents, GBXML gbx, XMLSettings settings) { foreach (BH.oM.XML.Environment.DocumentBuilder db in documents) { MongoDB.Bson.BsonDocument bd = BH.Engine.Serialiser.Convert.ToBson(db); //Break the reference clone issue BH.oM.XML.Environment.DocumentBuilder dbBroken = (BH.oM.XML.Environment.DocumentBuilder)BH.Engine.Serialiser.Convert.FromBson(bd); SerializeLevels(dbBroken.Levels, dbBroken.ElementsAsSpaces, gbx, settings); SerializeCollection(dbBroken.ElementsAsSpaces, dbBroken.Levels, dbBroken.UnassignedPanels, gbx, settings); SerializeCollection(dbBroken.ShadingElements, gbx, settings); SerializeCollection(dbBroken.UnassignedPanels, gbx, settings); //Serialise unassigned panels as shading as an interim measure } }
public bool save(string db, string collection, Hashtable json_data) { var _db = _mongoserver.GetDatabase(db); var _collection = _db.GetCollection <MongoDB.Bson.BsonDocument> (collection) as MongoDB.Driver.MongoCollection <MongoDB.Bson.BsonDocument>; MongoDB.Bson.BsonDocument _d = new MongoDB.Bson.BsonDocument(json_data); var ret = _collection.Insert(_d); if (ret != null && ret.HasLastErrorMessage) { log.log.operation(new System.Diagnostics.StackFrame(), service.timerservice.Tick, ret.LastErrorMessage); } return(true); }
private MongoDB.Bson.BsonDocument Swap(MongoDB.Bson.BsonDocument _doc) { var keys = JsonConvert.DeserializeObject <List <SwapKeyValue> >(this.SwapKeyValues); foreach (SwapKeyValue skv in keys) { MongoDB.Bson.BsonElement v = new MongoDB.Bson.BsonElement(); if (_doc.TryGetElement(skv.Source, out v)) { _doc.Add(new MongoDB.Bson.BsonElement(skv.Destination, _doc[skv.Source])); _doc.Remove(skv.Source); } } return(_doc); }
public bool remove(string db, string collection, Hashtable json_query) { var _mongoclient = getMongoCLient(); var _db = _mongoclient.GetDatabase(db); var _collection = _db.GetCollection <MongoDB.Bson.BsonDocument>(collection) as MongoDB.Driver.IMongoCollection <MongoDB.Bson.BsonDocument>; var _bson_query = new MongoDB.Bson.BsonDocument(json_query); var _query = new MongoDB.Driver.BsonDocumentFilterDefinition <MongoDB.Bson.BsonDocument>(_bson_query); _collection.DeleteOne(_query); releaseMongoClient(_mongoclient); return(true); }
public AlertingRepository(string connection) { if (string.IsNullOrWhiteSpace(connection)) { connection = "mongodb://localhost:27017"; } _client = new MongoDB.Driver.MongoClient(connection); _database = _client.GetDatabase("local", null); _alertTypes = _database.GetCollection<AlertType>("alerttypes"); var filter = new MongoDB.Bson.BsonDocument(); long count = _alertTypes.Count(filter); // AddTestData(); }
public void TestWMIDiskSpace() { DataAccess.DatabaseFacade.DatabaseManager.InitializeDatabaseConnection("mongodb://localhost", "HomeAutomation"); var refDocument = new MongoDB.Bson.BsonDocument { { "$ref", "Component" }, { "$id", new MongoDB.Bson.ObjectId("53fc96c0f59e1008ace5649d") } }; var query = Query.EQ("ComponentId", refDocument); var test = query.ToString(); var values = DataAccess.DatabaseFacade.DatabaseManager.ComponentValueHistory.Find(query); foreach (var item in values) { Console.WriteLine(item.Value); } }
/// <summary> /// 将类转换为BsonDocument以放入MongoDB,类中每个字段都可转换为BsonValue /// </summary> /// <param name="obj">待转换的对象</param> /// <returns>转换后的BsonDocument对象</returns> public static MongoDB.Bson.BsonDocument ToMongoDocument(object obj) { MongoDB.Bson.BsonDocument document = new MongoDB.Bson.BsonDocument(); foreach (PropertyInfo property in obj.GetType().GetProperties()) { object propertyValue = property.GetValue(obj, null); if (propertyValue == null) { document.Add(property.Name, MongoDB.Bson.BsonNull.Value); } else { document.Add(property.Name, MongoDB.Bson.BsonValue.Create(propertyValue)); } } return(document); }
public String GetDataTableJson(String id) { DataTable dt = new DataTable(); var bSonId = new MongoDB.Bson.ObjectId(id); var query = Query <HomeAutomation.DataAccess.Entity.Component> .EQ(e => e.Id, bSonId); var model = DataAccess.DatabaseFacade.DatabaseManager.Components.FindOne(query); //Act ----------------- dt.AddColumn(new Column(ColumnType.Datetime, "Date", "Date")); dt.AddColumn(new Column(ColumnType.Number, "Value", model.Name)); // var bSonId = new MongoDB.Driver.MongoDBRef("Component",new MongoDB.Bson.ObjectId( id)); var refDocument = new MongoDB.Bson.BsonDocument { { "$ref", "Component" }, { "$id", new MongoDB.Bson.ObjectId(id) } }; var queryHist = Query.EQ("ComponentId", refDocument); var values = DataAccess.DatabaseFacade.DatabaseManager.ComponentValueHistory.Find(queryHist); foreach (var value in values) { var row = dt.NewRow(); row.AddCellRange(new[] { new Cell(value.TimeStamp), new Cell(value.Value) }); dt.AddRow(row); } var rowCur = dt.NewRow(); rowCur.AddCellRange(new[] { new Cell(model.LastContact), new Cell(model.CurrentValue) }); dt.AddRow(rowCur); //row1.AddCellRange(new[] { new Cell(2012), new Cell(150) }); //row2.AddCellRange(new[] { new Cell(2013), new Cell(100) }); //dt.AddRow(row1); //dt.AddRow(row2); return(dt.GetJson()); }
static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <MongoDB.Bson.BsonDocument>(L, 3)) { string _code = LuaAPI.lua_tostring(L, 2); MongoDB.Bson.BsonDocument _scope = (MongoDB.Bson.BsonDocument)translator.GetObject(L, 3, typeof(MongoDB.Bson.BsonDocument)); MongoDB.Bson.BsonJavaScriptWithScope gen_ret = new MongoDB.Bson.BsonJavaScriptWithScope(_code, _scope); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.BsonJavaScriptWithScope constructor!")); }
static int _m_Set(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); MongoDB.Bson.MaterializedOnDemandBsonDocument gen_to_be_invoked = (MongoDB.Bson.MaterializedOnDemandBsonDocument)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 3 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && translator.Assignable <MongoDB.Bson.BsonValue>(L, 3)) { int _index = LuaAPI.xlua_tointeger(L, 2); MongoDB.Bson.BsonValue _value = (MongoDB.Bson.BsonValue)translator.GetObject(L, 3, typeof(MongoDB.Bson.BsonValue)); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.Set(_index, _value); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <MongoDB.Bson.BsonValue>(L, 3)) { string _name = LuaAPI.lua_tostring(L, 2); MongoDB.Bson.BsonValue _value = (MongoDB.Bson.BsonValue)translator.GetObject(L, 3, typeof(MongoDB.Bson.BsonValue)); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.Set(_name, _value); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.MaterializedOnDemandBsonDocument.Set!")); }
public MongoDB.Bson.BsonDocument Execute(MongoDB.Bson.BsonDocument _doc) { switch (Type) { case "NONE": return(_doc); break; case "AGGRIGATION": return(Aggrigate(_doc)); break; case "SWAP": return(Swap(_doc)); break; } return(_doc); }
async System.Threading.Tasks.Task FindAll(MongoDB.Driver.IMongoCollection<AlertType> collection, List<AlertType> results ) { results = new List<AlertType>(); var filter = new MongoDB.Bson.BsonDocument(); var count = 0; using (var cursor = await collection.FindAsync<AlertType>(filter,null)) { while (await cursor.MoveNextAsync()) { var batch = cursor.Current; foreach (var document in batch) { // process document count++; results.Add(document); } } } }
public List <FerroFTS.Data.last_location> GetLastLocations(string sOu, string sOuService, DateTime sStartDate) { MongoDB.Driver.FilterDefinition <FerroFTS.Data.last_location> oFilter; FerroData.Mongo.DataMongo <FerroFTS.Data.last_location> oData = new FerroData.Mongo.DataMongo <FerroFTS.Data.last_location>(); MongoDB.Driver.FindOptions <FerroFTS.Data.last_location> oOptions = new MongoDB.Driver.FindOptions <FerroFTS.Data.last_location>(); List <FerroFTS.Data.last_location> oList; try { oFilter = new MongoDB.Bson.BsonDocument("ou", sOu); oFilter = (oFilter & new MongoDB.Bson.BsonDocument("ou_service", sOuService)); oFilter = (oFilter & new MongoDB.Bson.BsonDocument("utc_datetime", new MongoDB.Bson.BsonDocument("$gte", sStartDate))); oData.Session = this._Session; oList = oData.Find(oFilter, oOptions); return(oList); } catch (Exception ex) { throw new Exception((ex.StackTrace.Substring((ex.StackTrace.LastIndexOf("\r\n") + 4)) + ("\r\n" + ex.Message))); } }
static int _m_SetElement(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); MongoDB.Bson.MaterializedOnDemandBsonDocument gen_to_be_invoked = (MongoDB.Bson.MaterializedOnDemandBsonDocument)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonElement>(L, 2)) { MongoDB.Bson.BsonElement _element; translator.Get(L, 2, out _element); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.SetElement(_element); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 3 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && translator.Assignable <MongoDB.Bson.BsonElement>(L, 3)) { int _index = LuaAPI.xlua_tointeger(L, 2); MongoDB.Bson.BsonElement _element; translator.Get(L, 3, out _element); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.SetElement(_index, _element); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.MaterializedOnDemandBsonDocument.SetElement!")); }
static int _m_Merge(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); MongoDB.Bson.MaterializedOnDemandBsonDocument gen_to_be_invoked = (MongoDB.Bson.MaterializedOnDemandBsonDocument)translator.FastGetCSObj(L, 1); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonDocument>(L, 2)) { MongoDB.Bson.BsonDocument _document = (MongoDB.Bson.BsonDocument)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonDocument)); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.Merge(_document); translator.Push(L, gen_ret); return(1); } if (gen_param_count == 3 && translator.Assignable <MongoDB.Bson.BsonDocument>(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3)) { MongoDB.Bson.BsonDocument _document = (MongoDB.Bson.BsonDocument)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonDocument)); bool _overwriteExistingElements = LuaAPI.lua_toboolean(L, 3); MongoDB.Bson.BsonDocument gen_ret = gen_to_be_invoked.Merge(_document, _overwriteExistingElements); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.MaterializedOnDemandBsonDocument.Merge!")); }
List<AlertType> FindAllSync() { List<AlertType> results = new List<AlertType>(); var count = 0; var filter = new MongoDB.Bson.BsonDocument(); using (var cursor = _alertTypes.FindSync<AlertType>(filter, null)) { while (cursor.MoveNext()) { var batch = cursor.Current; foreach (var document in batch) { // process document count++; results.Add(document); } } } return results; }
public async System.Threading.Tasks.Task<AlertType> GetAlertTypesAsync() { var filter = new MongoDB.Bson.BsonDocument(); return null; }
public void TestFractionBsonSerialization() { Fraction fIn = 3.0 / 2; Fraction fOut = Fraction.NaN; MongoDB.Bson.BsonDocument bd = new MongoDB.Bson.BsonDocument(); using (MongoDB.Bson.IO.BsonWriter bw = MongoDB.Bson.IO.BsonWriter.Create(bd)) { MongoDB.Bson.Serialization.BsonSerializer.Serialize<Fraction>(bw, fIn); } fOut = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<Fraction>(bd); Assert.IsNotNull(fOut); Assert.AreEqual(1.5, fOut); }