add openhack files

This commit is contained in:
Ryan Peters
2022-11-03 16:41:13 -04:00
commit b2c9f7e29f
920 changed files with 118861 additions and 0 deletions

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace DeviceSim.Helpers
{
public class ConnectionStringHelper
{
private string connectionString;
public string ConnectionString
{
get => connectionString;
private set => connectionString = value;
}
private void ConnectionStringBuilder(DBConnectionInfo dBConnectionInfo)
{
ConnectionString = $"Server=tcp:{dBConnectionInfo.DBServer},1433;Initial Catalog={dBConnectionInfo.DBCatalog};Persist Security Info=False;User ID={dBConnectionInfo.DBUserName};Password={dBConnectionInfo.DBPassword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=60";
}
public ConnectionStringHelper(DBConnectionInfo dBConnectionInfo)
{
ConnectionStringBuilder(dBConnectionInfo);
}
}
public struct DBConnectionInfo
{
public string DBServer;
public string DBCatalog;
public string DBUserName;
public string DBPassword;
}
}

View File

@ -0,0 +1,51 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Collections.Generic;
using System.Reflection;
namespace DeviceSim.Model
{
public class CustomContractResolver : DefaultContractResolver
{
public CustomContractResolver()
{
PropertyMappings = new Dictionary<string, string>
{
["Longitude"] = "Lon",
["Latitude"] = "Lat",
["ShortTermFuelBank"] = "ShortTermFuelBank1",
["LongTermFuelBank"] = "LongTermFuelBank1",
["MassFlowRate"] = "MAFFlowRate",
["RPM"] = "EngineRPM",
["Id"] = "TripPointId",
["DistanceWithMalfunctionLight"] = "DistancewithMIL",
["HasSimulatedOBDData"] = "IsSimulated",
};
IgnoreProperties = new List<string> { "HasOBDData" };
}
private Dictionary<string, string> PropertyMappings { get; }
private List<string> IgnoreProperties { get; }
protected override string ResolvePropertyName(string propertyName)
{
string resolvedName;
var resolved = PropertyMappings.TryGetValue(propertyName, out resolvedName);
return resolved ? resolvedName : base.ResolvePropertyName(propertyName);
}
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
{
JsonProperty property = base.CreateProperty(member, memberSerialization);
if (IgnoreProperties.Contains(property.PropertyName))
{
property.ShouldSerialize = p => false;
}
return property;
}
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using DeviceSim.Interfaces;
namespace DeviceSim.Helpers
{
public class Logger : ILogger
{
public void Report(Exception exception, LogCategory category)
{
throw new NotImplementedException();
}
public void WriteMessage( LogLevel level, string message)
{
throw new NotImplementedException();
}
}
}