public async Task <string> SaveRoundEndAsync(TerrestrialRoundMessage message) { var filter = Builders <TerrestrialRound> .Filter.Eq(s => s._id, message.RoundId); var update = Builders <TerrestrialRound> .Update.Set(s => s.RoundEndUtc, message.RoundEndUtc); await _MongoCollectionRounds.UpdateOneAsync(filter, update); return(message.RoundId); }
public async Task <string> SaveStationRecordAsync(TerrestrialRoundMessage message) { var filter = Builders <TerrestrialRound> .Filter.Eq(s => s._id, message.RoundId); if (!(await _MongoCollectionRounds.CountDocumentsAsync(filter) > 0)) { TerrestrialRound document = new TerrestrialRound { }; document = MapRound(message); await _MongoCollectionRounds.InsertOneAsync(document); return(message.RoundId); } return(null); }
private TerrestrialRound MapRound(TerrestrialRoundMessage message) { TerrestrialRound round = new TerrestrialRound { _id = message.RoundId, DeviceId = message.DeviceId, StationId = message.StationId, RoundStartUtc = message.RoundStartUtc, RoundEndUtc = message.RoundEndUtc, Station = message.Station }; round.Results = new Results() { LocalCoordinates = new Dictionary <string, LocalPoint>(), ProjectCoordinates = new Dictionary <string, ProjectCoordinates>(), }; return(round); }
public async Task <string> SaveObservationAsync(TerrestrialRoundMessage message) { var filter = Builders <TerrestrialRound> .Filter.Eq(s => s._id, message.RoundId); TerrestrialRound round = await _MongoCollectionRounds.Find(filter).SingleAsync(); foreach (var obj in message.Observations) { if (round.Observations == null) { Dictionary <string, Target> dict = new Dictionary <string, Target>(); Target target = new Target { }; dict.Add(obj.PointId, target); switch (obj.ObservationType) { case "Face1": if (obj.EdmDistance != 0) { dict[obj.PointId].Face1 = obj; } else { dict[obj.PointId].Face1 = null; } break; case "Face2": if (obj.EdmDistance != 0) { dict[obj.PointId].Face2 = obj; } else { dict[obj.PointId].Face2 = null; } break; default: Console.WriteLine("unknown ObservationType: " + obj.ObservationType); break; } round.Observations = dict; } else { if (round.Observations.ContainsKey(obj.PointId)) { switch (obj.ObservationType) { case "Face1": round.Observations[obj.PointId].Face1 = obj; break; case "Face2": round.Observations[obj.PointId].Face2 = obj; break; default: Console.WriteLine("unknown ObservationType: " + obj.ObservationType); break; } round.Observations[obj.PointId].MeanF1F2 = null; } else { Target target = new Target { }; round.Observations.Add(obj.PointId, target); switch (obj.ObservationType) { case "Face1": round.Observations[obj.PointId].Face1 = obj; break; case "Face2": round.Observations[obj.PointId].Face2 = obj; break; default: Console.WriteLine("unknown ObservationType: " + obj.ObservationType); break; } } } } var update = Builders <TerrestrialRound> .Update.Set(s => s.Observations, round.Observations); await _MongoCollectionRounds.UpdateOneAsync(filter, update); return(message.RoundId); }