initial version with inspection edition
This commit is contained in:
94
IronIntelContractorBusiness/OTRConfig/HarshDrivingItem.cs
Normal file
94
IronIntelContractorBusiness/OTRConfig/HarshDrivingItem.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.OTRConfig
|
||||
{
|
||||
public class HarshDrivingItem
|
||||
{
|
||||
public long LogID { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name2 { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public int MakeID { get; set; }
|
||||
public int TypeID { get; set; }
|
||||
public int ModelID { get; set; }
|
||||
public string MakeName { get; set; }
|
||||
public string ModelName { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
|
||||
public DateTime AsofTime { get; set; }
|
||||
public string AsofTimeStr { get { return AsofTime == DateTime.MinValue ? "" : AsofTime.ToString(); } }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public string AsofTimeLocalStr { get { return AsofTimeLocal == DateTime.MinValue ? "" : AsofTimeLocal.ToString(); } }
|
||||
public string EventType { get; set; }
|
||||
public string Street { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
public double StartingSpeed { get; set; }
|
||||
public string SpeedUnits { get; set; }
|
||||
public double Duration { get; set; }
|
||||
public string DurationUnits { get; set; }
|
||||
public double Magnitude { get; set; }
|
||||
public string MagnitudeUnits { get; set; }
|
||||
public bool Excluded { get; set; }
|
||||
|
||||
public HarshDrivingEvents HarshDringEvent { get; set; }
|
||||
public SpeedingBehaviors SpeedingBehavior { get; set; }
|
||||
public string ShowName
|
||||
{
|
||||
get
|
||||
{
|
||||
string name = Name2;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = Name;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = VIN;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = AssetID.ToString();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
public string EventDesc
|
||||
{
|
||||
get
|
||||
{
|
||||
string desc = EventType;
|
||||
if (string.Compare(desc, "ACCEL", true) == 0)
|
||||
desc = "Hard Acceleration";
|
||||
else if (string.Compare(desc, "DECEL", true) == 0)
|
||||
desc = "Hard Brake";
|
||||
else if (string.Compare(desc, "HARD_CORNERING_LEFT", true) == 0 || string.Compare(EventType, "HARD_CORNERING_RIGHT", true) == 0)
|
||||
desc = "Hard Turn";
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class HarshDrivintClient
|
||||
{
|
||||
public long LogID { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public bool Excluded { get; set; }
|
||||
public string Notes { get; set; }
|
||||
}
|
||||
|
||||
public enum HarshDrivingEvents
|
||||
{
|
||||
None = 0,
|
||||
HardAccelerationEvent = 1,
|
||||
HardBrakeEvent = 2,
|
||||
HardTurnEvent = 3
|
||||
}
|
||||
|
||||
public enum SpeedingBehaviors
|
||||
{
|
||||
None = 0,
|
||||
MinorSpeeding = 1,
|
||||
SevereSpeeding = 2
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.OTRConfig;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.OTRConfig
|
||||
{
|
||||
public class HarshDrivingManagement
|
||||
{
|
||||
public static HarshDrivingItem[] GetHarshDrivingEvents(string sessionid, DateTime startdate, DateTime enddate, string searchtxt, string useriid)
|
||||
{
|
||||
HarshDrivingInfo[] hds = FleetServiceClientHelper.CreateClient<OTRConfigClient>(sessionid).GetHarshDrivingEvents(SystemParams.CompanyID, startdate, enddate);
|
||||
if (hds == null || hds.Length == 0)
|
||||
return new HarshDrivingItem[0];
|
||||
|
||||
long[] availableAssetsids = null;
|
||||
var user = Users.UserManagement.GetUserByIID(useriid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(sessionid).GetAvailableAssetsForUsers(SystemParams.CompanyID, useriid);
|
||||
|
||||
List<HarshDrivingItem> list = new List<HarshDrivingItem>();
|
||||
foreach (HarshDrivingInfo hd in hds)
|
||||
{
|
||||
if (user.UserType < Users.UserTypes.Admin && !availableAssetsids.Contains(hd.AssetID))
|
||||
continue;
|
||||
HarshDrivingItem item = new HarshDrivingItem();
|
||||
Helper.CloneProperty(item, hd);
|
||||
|
||||
if (!string.IsNullOrEmpty(searchtxt))
|
||||
{
|
||||
if (Helper.Contains(item.VIN, searchtxt)
|
||||
|| Helper.Contains(item.AssetID.ToString(), searchtxt)
|
||||
|| Helper.Contains(item.Name, searchtxt)
|
||||
|| Helper.Contains(item.Name2, searchtxt)
|
||||
|| Helper.Contains(item.MakeName, searchtxt)
|
||||
|| Helper.Contains(item.TypeName, searchtxt)
|
||||
|| Helper.Contains(item.ModelName, searchtxt)
|
||||
|| Helper.Contains(item.Street, searchtxt)
|
||||
|| Helper.Contains(item.City, searchtxt)
|
||||
|| Helper.Contains(item.State, searchtxt)
|
||||
|| Helper.Contains(item.PostalCode, searchtxt))
|
||||
{
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static void ExcludedHarshDrivingEvents(string sessionid, HarshDrivintClient hd, string useriid)
|
||||
{
|
||||
long[] logids = new long[] { hd.LogID };
|
||||
var client = FleetServiceClientHelper.CreateClient<OTRConfigClient>(sessionid);
|
||||
if (hd.Excluded)
|
||||
client.IncludedHarshDrivingEvents(SystemParams.CompanyID, hd.AssetID, logids, useriid, hd.Notes);
|
||||
else
|
||||
client.ExcludedHarshDrivingEvents(SystemParams.CompanyID, hd.AssetID, logids, useriid, hd.Notes);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
27
IronIntelContractorBusiness/OTRConfig/SpeedingItem.cs
Normal file
27
IronIntelContractorBusiness/OTRConfig/SpeedingItem.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.OTRConfig
|
||||
{
|
||||
public class SpeedingItem
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public string AssetName { get; set; }
|
||||
public string Make { get; set; }
|
||||
public string Model { get; set; }
|
||||
public DateTime EventTime { get; set; }
|
||||
public string EventTimeStr { get { return EventTime == DateTime.MinValue ? "" : EventTime.ToString(); } }
|
||||
public string Street { get; set; }
|
||||
public string City { get; set; }
|
||||
public string State { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Country { get; set; }
|
||||
public double TopSpeed { get; set; }
|
||||
public double PostedSpeedLimit { get; set; }
|
||||
public double SpeedingOverage { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user