Esempio n. 1
0
 public void AddLocation(GpsLocation location)
 {
     // serialize location
     BsonDocument doc = location.ToBsonDocument();
     // Add extra data (in case we have)
     Utilities.AddExtraData(doc, location);
     // insert into database
     DB.GetCollection<BsonDocument>(_locationColection).Insert<BsonDocument>(doc);
 }
Esempio n. 2
0
 /// <summary>
 /// constructs a GpsLocation object from a generic BsonDocument
 /// </summary>
 /// <param name="loc">BsonDocument</param>
 /// <returns>GpsLocation created</returns>
 public static GpsLocation GetLocationFromDoc(BsonDocument loc, bool includeExtraData)
 {
     GpsLocation _loc = new GpsLocation();
     // set properties
     _loc.CreatedDate = loc["CreatedDate"].AsDateTime;
     _loc.Key = loc["_id"].AsGuid;
     _loc.SessionKey = loc["SessionKey"].AsGuid;
     BsonDocument _coord = loc["Coordinates"].AsBsonDocument;
     _loc.Coordinates = new GpsPoint() { Latitude = _coord["Latitude"].AsDouble, Longitude = _coord["Longitude"].AsDouble };
     if (includeExtraData)
     {
         BsonValue ExtraDataValue;
         loc.TryGetValue(extraData.ToLower(), out ExtraDataValue);
         if (ExtraDataValue != null)
             _loc.Data = ExtraDataValue.AsBsonDocument.ToJson();
     }
     return _loc;
 }
 //public override void EndSession(Guid sessionKey)
 //{
 //    throw new NotImplementedException();
 //}
 public virtual void AddLocation(GpsLocation location)
 {
     dataProvider.AddLocation(location);
 }