add openhack files
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Simulator.DataObjects
|
||||
{
|
||||
public interface IBaseDataObject
|
||||
{
|
||||
string Id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class BaseDataObject : IBaseDataObject
|
||||
{
|
||||
public BaseDataObject() { Id = Guid.NewGuid().ToString(); }
|
||||
|
||||
public string Id { get ; set ; }
|
||||
}
|
||||
}
|
39
support/simulator/Simulator.DataStore.API/DataObjects/Poi.cs
Normal file
39
support/simulator/Simulator.DataStore.API/DataObjects/Poi.cs
Normal file
@ -0,0 +1,39 @@
|
||||
namespace Simulator.DataObjects
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
public partial class Poi //: BaseDataObject
|
||||
{
|
||||
[JsonProperty("tripId")]
|
||||
public Guid TripId { get; set; }
|
||||
|
||||
[JsonProperty("latitude")]
|
||||
public double Latitude { get; set; }
|
||||
|
||||
[JsonProperty("longitude")]
|
||||
public double Longitude { get; set; }
|
||||
|
||||
[JsonProperty("poiType")]
|
||||
public long PoiType { get; set; }
|
||||
|
||||
[JsonProperty("timestamp")]
|
||||
public DateTime Timestamp { get; set; }
|
||||
|
||||
[JsonProperty("deleted")]
|
||||
public bool Deleted { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
||||
public partial class Poi
|
||||
{
|
||||
public static Poi FromJson(string json) => JsonConvert.DeserializeObject<Poi>(json, Converter.Settings);
|
||||
}
|
||||
|
||||
public static class PoiSerializer
|
||||
{
|
||||
public static string ToJson(this Poi self) => JsonConvert.SerializeObject(self, Converter.Settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
namespace Simulator.DataObjects
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
public partial class Trip // : BaseDataObject
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("Name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("UserId")]
|
||||
public string UserId { get; set; }
|
||||
|
||||
[JsonProperty("RecordedTimeStamp")]
|
||||
public DateTime RecordedTimeStamp { get; set; }
|
||||
|
||||
[JsonProperty("EndTimeStamp")]
|
||||
public DateTime EndTimeStamp { get; set; }
|
||||
|
||||
[JsonProperty("Rating")]
|
||||
public long Rating { get; set; }
|
||||
|
||||
[JsonProperty("IsComplete")]
|
||||
public bool IsComplete { get; set; }
|
||||
|
||||
[JsonProperty("HasSimulatedOBDData")]
|
||||
public bool HasSimulatedObdData { get; set; }
|
||||
|
||||
[JsonProperty("AverageSpeed")]
|
||||
public long AverageSpeed { get; set; }
|
||||
|
||||
[JsonProperty("FuelUsed")]
|
||||
public long FuelUsed { get; set; }
|
||||
|
||||
[JsonProperty("HardStops")]
|
||||
public long HardStops { get; set; }
|
||||
|
||||
[JsonProperty("HardAccelerations")]
|
||||
public long HardAccelerations { get; set; }
|
||||
|
||||
[JsonProperty("Distance")]
|
||||
public double Distance { get; set; }
|
||||
|
||||
[JsonProperty("Created")]
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
[JsonProperty("UpdatedAt")]
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
public partial class Trip
|
||||
{
|
||||
public static Trip FromJson(string json) => JsonConvert.DeserializeObject<Trip>(json, Converter.Settings);
|
||||
}
|
||||
|
||||
public static class TripSerializer
|
||||
{
|
||||
public static string ToJson(this Trip self) => JsonConvert.SerializeObject(self, Converter.Settings);
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
namespace Simulator.DataObjects
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
|
||||
public partial class TripPoint//: BaseDataObject
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("TripId")]
|
||||
public Guid TripId { get; set; }
|
||||
|
||||
[JsonProperty("Latitude")]
|
||||
public double Latitude { get; set; }
|
||||
|
||||
[JsonProperty("Longitude")]
|
||||
public double Longitude { get; set; }
|
||||
|
||||
[JsonProperty("Speed")]
|
||||
public double Speed { get; set; }
|
||||
|
||||
[JsonProperty("RecordedTimeStamp")]
|
||||
public DateTime RecordedTimeStamp { get; set; }
|
||||
|
||||
[JsonProperty("Sequence")]
|
||||
public int Sequence { get; set; }
|
||||
|
||||
[JsonProperty("RPM")]
|
||||
public double Rpm { get; set; }
|
||||
|
||||
[JsonProperty("ShortTermFuelBank")]
|
||||
public double ShortTermFuelBank { get; set; }
|
||||
|
||||
[JsonProperty("LongTermFuelBank")]
|
||||
public double LongTermFuelBank { get; set; }
|
||||
|
||||
[JsonProperty("ThrottlePosition")]
|
||||
public double ThrottlePosition { get; set; }
|
||||
|
||||
[JsonProperty("RelativeThrottlePosition")]
|
||||
public double RelativeThrottlePosition { get; set; }
|
||||
|
||||
[JsonProperty("Runtime")]
|
||||
public double Runtime { get; set; }
|
||||
|
||||
[JsonProperty("DistanceWithMalfunctionLight")]
|
||||
public double DistanceWithMalfunctionLight { get; set; }
|
||||
|
||||
[JsonProperty("EngineLoad")]
|
||||
public double EngineLoad { get; set; }
|
||||
|
||||
[JsonProperty("EngineFuelRate")]
|
||||
public double EngineFuelRate { get; set; }
|
||||
|
||||
[JsonProperty("VIN")]
|
||||
public Vin Vin { get; set; }
|
||||
|
||||
[JsonProperty("CreatedAt")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[JsonProperty("UpdatedAt")]
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
public partial class Vin
|
||||
{
|
||||
[JsonProperty("String")]
|
||||
public string String { get; set; }
|
||||
|
||||
[JsonProperty("Valid")]
|
||||
public bool Valid { get; set; }
|
||||
}
|
||||
|
||||
public partial class TripPoint
|
||||
{
|
||||
public static TripPoint FromJson(string json) => JsonConvert.DeserializeObject<TripPoint>(json, Converter.Settings);
|
||||
}
|
||||
|
||||
public static class TripPointSerializer
|
||||
{
|
||||
public static string ToJson(this TripPoint self) => JsonConvert.SerializeObject(self, Converter.Settings);
|
||||
}
|
||||
|
||||
internal static class Converter
|
||||
{
|
||||
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
|
||||
{
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
||||
//DateParseHandling = DateParseHandling.None,
|
||||
//Converters = {new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.None } },
|
||||
};
|
||||
}
|
||||
}
|
104
support/simulator/Simulator.DataStore.API/DataObjects/User.cs
Normal file
104
support/simulator/Simulator.DataStore.API/DataObjects/User.cs
Normal file
@ -0,0 +1,104 @@
|
||||
namespace Simulator.DataObjects
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
public partial class User //: BaseDataObject
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[JsonProperty("firstName")]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
[JsonProperty("lastName")]
|
||||
[JsonConverter(typeof(ParseStringConverter))]
|
||||
public long LastName { get; set; }
|
||||
|
||||
[JsonProperty("userId")]
|
||||
public string UserId { get; set; }
|
||||
|
||||
[JsonProperty("profilePictureUri")]
|
||||
public string ProfilePictureUri { get; set; }
|
||||
|
||||
[JsonProperty("rating")]
|
||||
public long Rating { get; set; }
|
||||
|
||||
[JsonProperty("ranking")]
|
||||
public long Ranking { get; set; }
|
||||
|
||||
[JsonProperty("totalDistance")]
|
||||
public double TotalDistance { get; set; }
|
||||
|
||||
[JsonProperty("totalTrips")]
|
||||
public long TotalTrips { get; set; }
|
||||
|
||||
[JsonProperty("totalTime")]
|
||||
public long TotalTime { get; set; }
|
||||
|
||||
[JsonProperty("hardStops")]
|
||||
public long HardStops { get; set; }
|
||||
|
||||
[JsonProperty("hardAccelerations")]
|
||||
public long HardAccelerations { get; set; }
|
||||
|
||||
[JsonProperty("fuelConsumption")]
|
||||
public long FuelConsumption { get; set; }
|
||||
|
||||
[JsonProperty("maxSpeed")]
|
||||
public long MaxSpeed { get; set; }
|
||||
|
||||
[JsonProperty("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
[JsonProperty("createdAt")]
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
[JsonProperty("updatedAt")]
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
[JsonProperty("deleted")]
|
||||
public bool Deleted { get; set; }
|
||||
}
|
||||
|
||||
public partial class User
|
||||
{
|
||||
public static User FromJson(string json) => JsonConvert.DeserializeObject<User>(json, Converter.Settings);
|
||||
}
|
||||
|
||||
public static class UserSerializer
|
||||
{
|
||||
public static string ToJson(this User self) => JsonConvert.SerializeObject(self, Converter.Settings);
|
||||
}
|
||||
|
||||
internal class ParseStringConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type t) => t == typeof(long) || t == typeof(long?);
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null) return null;
|
||||
var value = serializer.Deserialize<string>(reader);
|
||||
long l;
|
||||
if (Int64.TryParse(value, out l))
|
||||
{
|
||||
return l;
|
||||
}
|
||||
throw new Exception("Cannot unmarshal type long");
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
|
||||
{
|
||||
if (untypedValue == null)
|
||||
{
|
||||
serializer.Serialize(writer, null);
|
||||
return;
|
||||
}
|
||||
var value = (long)untypedValue;
|
||||
serializer.Serialize(writer, value.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
public static readonly ParseStringConverter Singleton = new ParseStringConverter();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user