initial version with inspection edition
This commit is contained in:
155
IronIntelContractorBusiness/Machines/EngineHoursInfo.cs
Normal file
155
IronIntelContractorBusiness/Machines/EngineHoursInfo.cs
Normal file
@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class EngineHoursInfo
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string DataSourceName { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
|
||||
public double Hours { get; set; }
|
||||
public string UOM { get; set; }
|
||||
|
||||
private double _Corrected;
|
||||
public double Corrected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Corrected;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Corrected = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public string ReceivedDateStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTimeLocal.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AdjustEngineHoursInfo
|
||||
{
|
||||
public string CustomerID { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public DateTime EngineHoursDate { get; set; }
|
||||
|
||||
private double _EngineHours;
|
||||
public double EngineHours
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EngineHours;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_EngineHours = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public string Notes { get; set; }
|
||||
/// <summary>
|
||||
/// 前端选择的时区的分钟偏移
|
||||
/// </summary>
|
||||
public int OffsetMinute { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class CalampEngineHoursInfo
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
public string DeviceAirId { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public double Gps { get; set; }
|
||||
public double Gps_Calc { get; set; }
|
||||
public double VBUS { get; set; }
|
||||
public double VBUS_Calc { get; set; }
|
||||
public string EventTimeText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("MM/dd/yyyy HH:mm");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTime_Local { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime_Local.ToString("MM/dd/yyyy HH:mm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class PedigreeEngineHoursInfo
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
public string DeviceSN { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public double VBUS { get; set; }
|
||||
public double VBUS_Calc { get; set; }
|
||||
public string EventTimeText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("MM/dd/yyyy HH:mm");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTime_Local { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime_Local.ToString("MM/dd/yyyy HH:mm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AssetEngineHoursAdjustItem
|
||||
{
|
||||
public long LogId { get; set; }
|
||||
public long AssetId { get; set; }
|
||||
public DateTime AdjustmentTime { get; set; }
|
||||
public string AdjustmentTimeText { get { return AdjustmentTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public DateTime EngineHoursTime { get; set; }
|
||||
public string EngineHoursTimeText { get { return EngineHoursTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public DateTime AdjustmentLocalTime { get; set; }
|
||||
public string AdjustmentLocalTimeText { get { return AdjustmentLocalTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public DateTime EngineHoursLocalTime { get; set; }
|
||||
public string EngineHoursLocalTimeText { get { return EngineHoursLocalTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
|
||||
private double _EngineHours;
|
||||
public double EngineHours
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EngineHours;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_EngineHours = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public string Notes { get; set; }
|
||||
public string UserName { get; set; }
|
||||
|
||||
}
|
||||
}
|
31
IronIntelContractorBusiness/Machines/FuelusedInfo.cs
Normal file
31
IronIntelContractorBusiness/Machines/FuelusedInfo.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class FuelusedInfo
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string DataSourceName { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
|
||||
public double Amount { get; set; }
|
||||
public double Percent { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public string ReceivedDateStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTimeLocal.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
30
IronIntelContractorBusiness/Machines/IdlehoursInfo.cs
Normal file
30
IronIntelContractorBusiness/Machines/IdlehoursInfo.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class IdlehoursInfo
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string DataSourceName { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
|
||||
public double Hours { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public string ReceivedDateStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTimeLocal.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
43
IronIntelContractorBusiness/Machines/LocationInfo.cs
Normal file
43
IronIntelContractorBusiness/Machines/LocationInfo.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class LocationInfo
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string DataSourceName { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
|
||||
public string SpeedUnits { get; set; }
|
||||
public double AccelerationMagnitude { get; set; }
|
||||
public double Duration { get; set; }
|
||||
public SpeedingBehaviors SpeedingBehavior { get; set; }
|
||||
public HarshDrivingEvents HarshDringEvent { get; set; }
|
||||
public string Street { get; set; }
|
||||
public string SpeedLimitUnits { get; set; }
|
||||
public double PostedSpeedLimit { get; set; }
|
||||
public double Speed { get; set; }
|
||||
public AssetMoveStatus MoveStatus { get; set; }
|
||||
public string EventType { get; set; }
|
||||
public int Heading { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public double Latitude { get; set; }
|
||||
|
||||
public string ReceivedDateStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTimeLocal.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
412
IronIntelContractorBusiness/Machines/MachineItem.cs
Normal file
412
IronIntelContractorBusiness/Machines/MachineItem.cs
Normal file
@ -0,0 +1,412 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class AssetBasicItem
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name2 { get; set; }
|
||||
public string MakeName { get; set; }
|
||||
public string ModelName { get; set; }
|
||||
|
||||
private double _EngineHours;
|
||||
public double EngineHours
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EngineHours;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_EngineHours = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public string CalampDeviceAirID { get; set; }
|
||||
public bool TelematicsEnabled { get; set; }
|
||||
public bool Hide { get; set; }
|
||||
public bool OnRoad { get; set; }
|
||||
public int MakeYear { get; set; }
|
||||
public string DealerID { get; set; }
|
||||
public string Dealer { get; set; }
|
||||
public string ContractorID { get; set; }
|
||||
public string Contractor { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public int ModelID { get; set; }
|
||||
public int TypeID { get; set; }
|
||||
public int MakeID { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public DateTime? EngineHoursDate { get; set; }
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
//DisplayName取值顺序为Name2,Name,VIN,ID用于前端显示
|
||||
string name = Name2;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = Name;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = VIN;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = ID.ToString();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
public string EngineHoursDateStr { get { return EngineHoursDate == null ? "" : EngineHoursDate.Value.ToShortDateString(); } }
|
||||
public string EngineHoursDateTimeStr { get { return EngineHoursDate == null ? "" : EngineHoursDate.Value.ToString(); } }
|
||||
}
|
||||
|
||||
|
||||
public class AssetDetailItem2
|
||||
{
|
||||
public bool IgnoreDuplicate { get; set; }//忽略重复
|
||||
public long ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name2 { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public int MakeID { get; set; }
|
||||
public string MakeName { get; set; }
|
||||
public int ModelID { get; set; }
|
||||
public string ModelName { get; set; }
|
||||
public int TypeID { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public int MakeYear { get; set; }
|
||||
|
||||
private double? _EngineHours;
|
||||
public double? EngineHours
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EngineHours;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
_EngineHours = Math.Round(value.Value, 2);
|
||||
else
|
||||
_EngineHours = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? EngineHoursLocalTime { get; set; }
|
||||
|
||||
private double? _Odometer;
|
||||
public double? Odometer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Odometer;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
_Odometer = Math.Round(value.Value, 2);
|
||||
else
|
||||
_Odometer = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime? OdometerLocalTime { get; set; }
|
||||
public string OdometerUnits { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string PairedDeviceSN { get; set; }
|
||||
public double? UnderCarriageHours { get; set; }
|
||||
public bool TelematicsEnabled { get; set; }
|
||||
public bool Hidden { get; set; }
|
||||
public bool OnRoad { get; set; }
|
||||
public string EQClass { get; set; }
|
||||
public string CostCenter { get; set; }
|
||||
public string AquisitionType { get; set; }
|
||||
public DateTime? AddedLocalTime { get; set; }
|
||||
public DateTime? AddedTime { get; set; }
|
||||
public string AddedByUserName { get; set; }
|
||||
public string IconFileName { get; set; }
|
||||
|
||||
public string ContractorID { get; set; }
|
||||
|
||||
public long OnSiteJobsiteID { get; set; }
|
||||
public string[] ContactIDs { get; set; }
|
||||
public string[] MachineGroupIDs { get; set; }
|
||||
public MachineRentalInfo MachineRental { get; set; }
|
||||
public MachineAttributeClient[] MachineAttributes { get; set; }
|
||||
public StringKeyValue[] VisibleOnWorkOrders { get; set; }
|
||||
|
||||
|
||||
public string AddedOnStr
|
||||
{
|
||||
get { return AddedLocalTime == null ? "" : AddedLocalTime.Value.ToString("MM/dd/yyyy"); }
|
||||
}
|
||||
public string EngineHoursDateTimeStr
|
||||
{
|
||||
get { return EngineHoursLocalTime == null ? "" : EngineHoursLocalTime.Value.ToString("MM/dd/yyyy"); }
|
||||
}
|
||||
public string OdometerDateTimeStr
|
||||
{
|
||||
get { return OdometerLocalTime == null ? "" : OdometerLocalTime.Value.ToString("MM/dd/yyyy"); }
|
||||
}
|
||||
}
|
||||
|
||||
public class MachineItem
|
||||
{
|
||||
public Int64 MachineID { get; set; }
|
||||
public int TypeID { get; set; }
|
||||
public string MachineType { get; set; }
|
||||
public int ModelID { get; set; }
|
||||
public string Model { get; set; }
|
||||
public int MakeID { get; set; }
|
||||
public string Make { get; set; }
|
||||
public string MakeIconColor { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name2 { get; set; }
|
||||
public int MakeYear { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string ContractorID { get; set; }
|
||||
public string Contractor { get; set; }
|
||||
public string DealerID { get; set; }
|
||||
public string Dealer { get; set; }
|
||||
public int Status { get; set; }
|
||||
public Int64 GpsDeviceID { get; set; } //空 -1
|
||||
public string GpsDeviceSN { get; set; } = string.Empty; //空 -1
|
||||
|
||||
public double StartingEngineHours { get; set; }
|
||||
|
||||
private double _EngineHours;
|
||||
public double EngineHours
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EngineHours;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_EngineHours = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public DateTime EngineHoursDate { get; set; }
|
||||
public string EngineHoursDateStr { get { return EngineHoursDate == DateTime.MinValue ? "" : EngineHoursDate.ToShortDateString(); } }
|
||||
public string EngineHoursDateTimeStr { get { return EngineHoursDate == DateTime.MinValue ? "" : EngineHoursDate.ToString(); } }
|
||||
public bool Hide { get; set; }
|
||||
public double ODOStart2 { get; set; }
|
||||
|
||||
private double _ODOMeter;
|
||||
public double ODOMeter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ODOMeter;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_ODOMeter = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public DateTime ODOMeterDate { get; set; }
|
||||
public string ODOMeterDateStr { get { return ODOMeterDate == DateTime.MinValue ? "" : ODOMeterDate.ToShortDateString(); } }
|
||||
public string ODOMeterDateTimeStr { get { return ODOMeterDate == DateTime.MinValue ? "" : ODOMeterDate.ToString(); } }
|
||||
public string ODOMeterUom { get; set; }
|
||||
public double FuelCost { get; set; }
|
||||
public string FuelCostUom { get; set; }
|
||||
public double MachineRate { get; set; }
|
||||
public string WorkType { get; set; }
|
||||
public double RetirementHours { get; set; }
|
||||
public double RetirementOdo { get; set; }
|
||||
public bool OnRoad { get; set; }
|
||||
public DateTime LeaseStart { get; set; }
|
||||
public string LeaseStartStr { get { return LeaseStart == DateTime.MinValue ? "" : LeaseStart.ToShortDateString(); } }
|
||||
public DateTime LeaseEnd { get; set; }
|
||||
public string LeaseEndStr { get { return LeaseEnd == DateTime.MinValue ? "" : LeaseEnd.ToShortDateString(); } }
|
||||
public double LeaseTerm { get; set; }
|
||||
public double UndercarriageHours { get; set; }
|
||||
public string AquisitionType { get; set; }
|
||||
|
||||
public int OnSiteJobsiteID { get; set; }
|
||||
public string[] ContactIDs { get; set; }
|
||||
public MachineAttributeClient[] MachineAttributes { get; set; }
|
||||
public string MachineIconFileName { get; set; }
|
||||
public string DistanceCalcBy { get; set; }
|
||||
public bool TelematicsEnabled { get; set; }
|
||||
public string CostCenter { get; set; }
|
||||
public string EqClass { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string[] MachineGroupIDs { get; set; }
|
||||
public MachineRentalInfo MachineRental { get; set; }
|
||||
public StringKeyValue[] VisibleOnWorkOrders { get; set; }
|
||||
public DateTime AddedOn { get; set; }
|
||||
public string AddedOnStr { get { return AddedOn == DateTime.MinValue ? "" : AddedOn.ToShortDateString(); } }
|
||||
public string AddedBy { get; set; }
|
||||
public string AddedByName { get; set; }
|
||||
public string ShowName
|
||||
{
|
||||
get
|
||||
{
|
||||
//Name取值顺序为Name2,Name,VIN,ID用于前端显示
|
||||
string name = Name2;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = Name;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = VIN;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = MachineID.ToString();
|
||||
return name;
|
||||
}
|
||||
}//由于地图显示及排序的名称
|
||||
}
|
||||
|
||||
public class MachineOffsetItem
|
||||
{
|
||||
public Int64 MachineID { get; set; }
|
||||
public double Value { get; set; }
|
||||
public double Offset { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public OffsetTypes Type { get; set; }
|
||||
}
|
||||
|
||||
public class DeviceItem
|
||||
{
|
||||
public string ContractorID { get; set; }
|
||||
|
||||
public string DeviceType { get; set; }
|
||||
public int Status { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public DateTime? ServiceStartDate { get; set; }
|
||||
public DateTime? InvoiceDate { get; set; }
|
||||
public DateTime? AddLocalDate { get; set; }
|
||||
public DateTime? AddDate { get; set; }
|
||||
public string InvoiceNumber { get; set; }
|
||||
public PairedAssetItem PairedAsset { get; set; }
|
||||
public string SourceName { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string SourceDeviceId { get; set; }
|
||||
public string AlternativeSerialNumber { get; set; }
|
||||
public string SerialNumber { get; set; }
|
||||
public long Id { get; set; }
|
||||
public bool Active { get; }
|
||||
public long DeviceID { get; set; }
|
||||
public string AddDateStr { get { return AddLocalDate == null ? "" : AddLocalDate.Value.ToShortDateString(); } }
|
||||
public string InvoiceDateStr { get { return InvoiceDate == null ? "" : InvoiceDate.Value.ToShortDateString(); } }
|
||||
public string ServiceStartDateStr { get { return ServiceStartDate == null ? "" : ServiceStartDate.Value.ToShortDateString(); } }
|
||||
}
|
||||
|
||||
public class PairedAssetItem
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Year { get; set; }
|
||||
public string MakeName { get; set; }
|
||||
public string ModelName { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public double? EngineHours { get; set; }
|
||||
public DateTime? EngineHoursDate { get; set; }
|
||||
public DateTime? EngineHoursLocalDate { get; set; }
|
||||
public string EngineHoursDateStr { get { return EngineHoursLocalDate == null ? "" : EngineHoursLocalDate.Value.ToShortDateString(); } }
|
||||
}
|
||||
public class CommentItem
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime SubmitLocalDate { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Comment { get; set; }
|
||||
public string SubmitDateStr { get { return SubmitLocalDate == DateTime.MinValue ? "" : SubmitLocalDate.ToString(); } }
|
||||
}
|
||||
|
||||
public class MachineGroup
|
||||
{
|
||||
public string GroupID { get; set; }
|
||||
public string GroupName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Code { get; set; }
|
||||
|
||||
public long[] MachineIDs { get; set; }
|
||||
}
|
||||
|
||||
public class AssetMakeItem
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string IconColor { get; set; }
|
||||
public string AlterActiveName { get; set; }
|
||||
public string AddedBy { get; set; }//companyid
|
||||
public DateTime AddedDate { get; set; }
|
||||
public string Synonyms { get; set; }
|
||||
public bool CanEdit
|
||||
{
|
||||
get
|
||||
{
|
||||
return SystemParams.CompanyID.Equals(AddedBy, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AssetModelItem
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string AddedBy { get; set; }//companyid
|
||||
public int MakeID { get; set; }
|
||||
public string MakeName { get; set; }
|
||||
public int TypeID { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
public string Synonyms { get; set; }
|
||||
|
||||
public bool CanEdit
|
||||
{
|
||||
get
|
||||
{
|
||||
return SystemParams.CompanyID.Equals(AddedBy, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MachineAttributeCategoryClient
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string DisplayText { get; set; }
|
||||
public int TabID { get; set; }
|
||||
public string TabName { get; set; }
|
||||
public int OrderIndex { get; set; }
|
||||
public List<MachineAttributeClient> MachineAttributes { get; set; }
|
||||
}
|
||||
|
||||
public class MachineAttributeClient
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string DisplayText { get; set; }
|
||||
public string Format { get; set; }
|
||||
public string Description { get; set; }
|
||||
public MachineAttributeDataTypes DataType { get; set; }
|
||||
public bool Multiline { get; set; }
|
||||
public int Length { get; set; }
|
||||
public int Precision { get; set; }
|
||||
public string Value { get; set; }
|
||||
public bool Dropdown { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class AssetAttachmentItem
|
||||
{
|
||||
public long ID { get; set; }
|
||||
public long AssetId { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string AddedByUserIID { get; set; }
|
||||
public string AddedByUserName { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public bool VisibleOnWorkOrder { get; set; }
|
||||
public DateTime AddedOn { get; set; }
|
||||
public string AddedOnStr { get { return AddedOn.ToString(); } }
|
||||
public byte[] FileData { get; set; }
|
||||
}
|
||||
}
|
866
IronIntelContractorBusiness/Machines/MachineManagement.cs
Normal file
866
IronIntelContractorBusiness/Machines/MachineManagement.cs
Normal file
@ -0,0 +1,866 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using Foresight.Data;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using IronIntel.Services.MapView;
|
||||
using IronIntel.Services.Customers;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
|
||||
namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class MachineManagement
|
||||
{
|
||||
private static List<MachineMake> _Makes = new List<MachineMake>();
|
||||
private static object _sycmakes = new object();
|
||||
|
||||
private static List<MachineType> _MachineTypes = new List<MachineType>();
|
||||
private static object _syctypes = new object();
|
||||
|
||||
private static List<MachineModel> _MachineModels = new List<MachineModel>();
|
||||
private static object _sycmodels = new object();
|
||||
|
||||
private const string MachineFields = "{0}MACHINEID,{0}MACHINENAME,{0}MAKEID,{0}MODELID,{0}TYPEID,{0}MACHINEICONID,{0}DEVICEID,{0}VIN,{0}MAKEYEAR,{0}NOTES,{0}STATUS,{0}CONTRACTORID,{0}DEALERID,{0}UID,{0}ADDEDON,{0}CUR_LONGITUDE,{0}CUR_LATITUDE,{0}LOCDATE_UTC,{0}ENGINEHOURS,{0}HOURSDATE_UTC,{0}DATASOURCE,{0}HIDE,{0}FUEL_CONSUMED,{0}FUEL_UNITS,{0}FUEL_DATE,{0}ODOMETER,{0}ODODATE_UTC,{0}ODOMETERUOM,{0}FUELCOST,{0}FUELCOSTUOM,{0}MACHINERATE,{0}WORKTYPE,{0}RETIREMENTHOURS,{0}RETIREMENTODO,{0}ALTITUDE,{0}ALTITUDEUNITS,{0}IDLEHOURSUTC,{0}IDLEHOURS,{0}LOADCOUNTUTC,{0}LOADCOUNT,{0}PAYLOADTOTALUTC,{0}PAYLOADTOTAL,{0}PAYLOADTOTALUNITS,{0}DEFREMAININGUTC,{0}DEFREMAINING,{0}FUELREMAININGUTC,{0}FUELREMAININGPERCENT,{0}MACHINENAME2,{0}ONROAD,{0}LEASESTART,{0}LEASEEND,{0}LEASEHOURS,{0}UNDERCARRIAGEHOURS,{0}ODOSTART2,{0}ISDELETED,{0}DELETEDDATE,{0}ODOSTART2DATASOURCE,{0}LOCDATASOURCE,{0}HOURSDATASOURCE,{0}FUELDATASOURCE,{0}AQUISITIONTYPE,{0}ICONFILENAME,{0}STARTINGENGINEHOURS,{0}DISTANCECALCBY,{0}TELEMATICSENABLED,{0}COSTCENTER,{0}EQCLASS,{0}DESCRIPTION,{0}ADDEDBY";
|
||||
|
||||
static MachineManagement()
|
||||
{
|
||||
RefreshBaseData();
|
||||
}
|
||||
|
||||
public static void RefreshBaseData()
|
||||
{
|
||||
RefreshMakes();
|
||||
RefreshModels();
|
||||
RefreshMachineTypes();
|
||||
}
|
||||
|
||||
public static void RefreshMakes()
|
||||
{
|
||||
MachineMake[] mks = null;
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
try
|
||||
{
|
||||
mks = mc.GetMachineMakes();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (mks != null)
|
||||
{
|
||||
lock (_sycmakes)
|
||||
{
|
||||
_Makes.Clear();
|
||||
_Makes.AddRange(mks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RefreshMachineTypes()
|
||||
{
|
||||
MachineType[] mks = null;
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
try
|
||||
{
|
||||
mks = mc.GetMachineTypes();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (mks != null)
|
||||
{
|
||||
lock (_syctypes)
|
||||
{
|
||||
_MachineTypes.Clear();
|
||||
_MachineTypes.AddRange(mks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void RefreshModels()
|
||||
{
|
||||
MachineModel[] mks = null;
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
try
|
||||
{
|
||||
mks = mc.GetMachineModels();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (mks != null)
|
||||
{
|
||||
lock (_sycmodels)
|
||||
{
|
||||
_MachineModels.Clear();
|
||||
_MachineModels.AddRange(mks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineMake[] GetMachineMakes()
|
||||
{
|
||||
lock (_sycmakes)
|
||||
{
|
||||
return _Makes.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineType[] GetMachineTypes()
|
||||
{
|
||||
lock (_syctypes)
|
||||
{
|
||||
return _MachineTypes.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineModel[] GetMachineModels()
|
||||
{
|
||||
lock (_sycmodels)
|
||||
{
|
||||
return _MachineModels.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineMake GetMachineMake(int makeid)
|
||||
{
|
||||
var makes = GetMachineMakes();
|
||||
foreach (var make in makes)
|
||||
{
|
||||
if (makeid == make.ID)
|
||||
{
|
||||
return make;
|
||||
}
|
||||
}
|
||||
RefreshMakes();
|
||||
var makes2 = GetMachineMakes();
|
||||
foreach (var make in makes2)
|
||||
{
|
||||
if (makeid == make.ID)
|
||||
{
|
||||
return make;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetMachineMakeName(int makeid)
|
||||
{
|
||||
var make = GetMachineMake(makeid);
|
||||
return make == null ? string.Empty : make.Name;
|
||||
}
|
||||
|
||||
public static MachineModel GetMachineModel(int modelid)
|
||||
{
|
||||
var models = GetMachineModels();
|
||||
foreach (var model in models)
|
||||
{
|
||||
if (model.ID == modelid)
|
||||
{
|
||||
return model;
|
||||
}
|
||||
}
|
||||
RefreshModels();
|
||||
var models2 = GetMachineModels();
|
||||
foreach (var model in models2)
|
||||
{
|
||||
if (model.ID == modelid)
|
||||
{
|
||||
return model;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetMachineModelName(int modelid)
|
||||
{
|
||||
var model = GetMachineModel(modelid);
|
||||
return model == null ? string.Empty : model.Name;
|
||||
}
|
||||
|
||||
public static MachineType GetMachineType(int typeid)
|
||||
{
|
||||
var types = GetMachineTypes();
|
||||
foreach (var mtype in types)
|
||||
{
|
||||
if (mtype.ID == typeid)
|
||||
{
|
||||
return mtype;
|
||||
}
|
||||
}
|
||||
RefreshMachineTypes();
|
||||
var types2 = GetMachineTypes();
|
||||
foreach (var mtype in types2)
|
||||
{
|
||||
if (mtype.ID == typeid)
|
||||
{
|
||||
return mtype;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetMachineTypeName(int typeid)
|
||||
{
|
||||
var mtype = GetMachineType(typeid);
|
||||
return mtype == null ? string.Empty : mtype.Name;
|
||||
}
|
||||
|
||||
public static MachineMake GetMachineMake(IEnumerable<MachineMake> makes, int id)
|
||||
{
|
||||
foreach (MachineMake mk in makes)
|
||||
{
|
||||
if (id == mk.ID)
|
||||
{
|
||||
return mk;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MachineType GetMachineType(IEnumerable<MachineType> types, int id)
|
||||
{
|
||||
foreach (MachineType mk in types)
|
||||
{
|
||||
if (id == mk.ID)
|
||||
{
|
||||
return mk;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MachineModel GetMachineModel(IEnumerable<MachineModel> models, int id)
|
||||
{
|
||||
foreach (MachineModel mk in models)
|
||||
{
|
||||
if (id == mk.ID)
|
||||
{
|
||||
return mk;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static string _DefaultMachineTypeIconUrl = string.Empty;
|
||||
|
||||
public static string DefaultMachineTypeIconUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_DefaultMachineTypeIconUrl))
|
||||
{
|
||||
try
|
||||
{
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
_DefaultMachineTypeIconUrl = mc.GetDefaultMachineTypeIconUrl();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return _DefaultMachineTypeIconUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineAlertViewClient GetMachineAlertViewClient()
|
||||
{
|
||||
string[] address = SystemParams.SystemServiceAddresses;
|
||||
MachineAlertViewClient ic = new MachineAlertViewClient(address[0]);
|
||||
return ic;
|
||||
}
|
||||
|
||||
public static bool Contains(string text, string val)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
return text.IndexOf(val, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateMachineHideStatus(IEnumerable<Tuple<long, bool>> machines)
|
||||
{
|
||||
const string SQL = "update MACHINES set HIDE={1} where MACHINEID={0}";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
foreach (Tuple<long, bool> mac in machines)
|
||||
{
|
||||
db.ExecSQL(SQL, mac.Item1, mac.Item2 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static MachineItem GetMachineByID(string sessionid, long machineid, FIDbAccess db = null)
|
||||
{
|
||||
string SQL = "select " + string.Format(MachineFields, "") + " from MACHINES where MACHINEID={0}";
|
||||
|
||||
if (db == null)
|
||||
{
|
||||
db = SystemParams.GetDbInstance();
|
||||
}
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, machineid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
MachineItem mi = null;
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
mi = ConvertToMachineItem(tb.Rows[0], makes, models, types);
|
||||
mi.AddedOn = FIDbAccess.GetFieldDateTime(tb.Rows[0]["ADDEDON"], DateTime.MinValue).AddHours(SystemParams.GetHoursOffset());
|
||||
mi.AddedBy = FIDbAccess.GetFieldString(tb.Rows[0]["ADDEDBY"], string.Empty);
|
||||
if (!string.IsNullOrEmpty(mi.AddedBy))
|
||||
{
|
||||
var user = Users.UserManagement.GetUserByIID(mi.AddedBy);
|
||||
mi.AddedByName = user == null ? mi.AddedBy : user.DisplayName;
|
||||
}
|
||||
}
|
||||
return mi;
|
||||
}
|
||||
|
||||
public static MachineItem[] GetMachines(string sessionid, string useriid, string searchtxt, string companyid = null)
|
||||
{
|
||||
string SQL = "select " + string.Format(MachineFields, "") + " from MACHINES order by MACHINENAME";
|
||||
|
||||
FIDbAccess db = null;
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
db = SystemParams.GetDbInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(companyid);
|
||||
db = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
DataTable tb = db.GetDataTableBySQL(SQL);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new MachineItem[0];
|
||||
}
|
||||
long[] availableAssetsids = null;
|
||||
IronIntel.Contractor.Users.UserInfo user = null;
|
||||
if (!string.IsNullOrWhiteSpace(useriid))
|
||||
{
|
||||
user = Users.UserManagement.GetUserByIID(useriid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetAvailableAssetsForUsers(companyid, useriid);
|
||||
}
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
List<MachineItem> ls = new List<MachineItem>();
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
long mid = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
if (!string.IsNullOrWhiteSpace(useriid) && user.UserType < Users.UserTypes.Admin && !availableAssetsids.Contains(mid))
|
||||
continue;
|
||||
|
||||
MachineItem mi = ConvertToMachineItem(dr, makes, models, types);
|
||||
if (!string.IsNullOrWhiteSpace(searchtxt))
|
||||
{
|
||||
if (Helper.Contains(mi.VIN, searchtxt)
|
||||
|| Helper.Contains(mi.MachineID.ToString(), searchtxt)
|
||||
|| Helper.Contains(mi.Name, searchtxt)
|
||||
|| Helper.Contains(mi.Name2, searchtxt)
|
||||
|| Helper.Contains(mi.Make, searchtxt)
|
||||
|| Helper.Contains(mi.MachineType, searchtxt)
|
||||
|| Helper.Contains(mi.Model, searchtxt))
|
||||
{
|
||||
ls.Add(mi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ls.Add(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public static MachineItem[] GetSelectMachinesByRental(string sessionid, string useriid, string searchtxt, string companyid = null)
|
||||
{
|
||||
string SQL = "select " + string.Format(MachineFields, "") + " from MACHINES where AQUISITIONTYPE in ('Rental','Rerent','RPO') order by MACHINENAME";
|
||||
|
||||
FIDbAccess db = null;
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
db = SystemParams.GetDbInstance();
|
||||
}
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(companyid);
|
||||
db = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
DataTable tb = db.GetDataTableBySQL(SQL);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new MachineItem[0];
|
||||
}
|
||||
|
||||
long[] availableAssetsids = null;
|
||||
var user = Users.UserManagement.GetUserByIID(useriid);
|
||||
if (user.UserType < Users.UserTypes.Admin)
|
||||
availableAssetsids = FleetServiceClientHelper.CreateClient<AssetQueryClient>(companyid, sessionid).GetAvailableAssetsForUsers(companyid, useriid);
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
List<MachineItem> ls = new List<MachineItem>();
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
long mid = FIDbAccess.GetFieldInt64(dr["MACHINEID"], 0);
|
||||
if (user.UserType < Users.UserTypes.Admin && !availableAssetsids.Contains(mid))
|
||||
continue;
|
||||
MachineItem mi = ConvertToMachineItem(dr, makes, models, types);
|
||||
if (!string.IsNullOrWhiteSpace(searchtxt))
|
||||
{
|
||||
if (Helper.Contains(mi.VIN, searchtxt)
|
||||
|| Helper.Contains(mi.MachineID.ToString(), searchtxt)
|
||||
|| Helper.Contains(mi.Name, searchtxt)
|
||||
|| Helper.Contains(mi.Name2, searchtxt)
|
||||
|| Helper.Contains(mi.Make, searchtxt)
|
||||
|| Helper.Contains(mi.MachineType, searchtxt)
|
||||
|| Helper.Contains(mi.Model, searchtxt))
|
||||
{
|
||||
ls.Add(mi);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ls.Add(mi);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
private static MachineItem ConvertToMachineItem(DataRow dr, MachineMake[] makes, MachineModel[] models, MachineType[] types)
|
||||
{
|
||||
MachineItem mi = new MachineItem();
|
||||
mi.MachineID = FIDbAccess.GetFieldInt(dr["MACHINEID"], 0);
|
||||
mi.Name = FIDbAccess.GetFieldString(dr["MACHINENAME"], string.Empty);
|
||||
mi.Name2 = FIDbAccess.GetFieldString(dr["MACHINENAME2"], string.Empty);
|
||||
mi.VIN = FIDbAccess.GetFieldString(dr["VIN"], string.Empty);
|
||||
mi.Notes = FIDbAccess.GetFieldString(dr["NOTES"], string.Empty);
|
||||
mi.MakeYear = FIDbAccess.GetFieldInt(dr["MAKEYEAR"], 0);
|
||||
mi.ContractorID = FIDbAccess.GetFieldString(dr["CONTRACTORID"], string.Empty);
|
||||
mi.DealerID = FIDbAccess.GetFieldString(dr["DEALERID"], string.Empty);
|
||||
mi.Status = FIDbAccess.GetFieldInt(dr["STATUS"], 0);
|
||||
mi.StartingEngineHours = FIDbAccess.GetFieldDouble(dr["STARTINGENGINEHOURS"], 0);
|
||||
mi.EngineHours = FIDbAccess.GetFieldDouble(dr["ENGINEHOURS"], 0);
|
||||
mi.EngineHoursDate = FIDbAccess.GetFieldDateTime(dr["HOURSDATE_UTC"], DateTime.MinValue);
|
||||
mi.Hide = FIDbAccess.GetFieldInt(dr["HIDE"], 0) == 1;
|
||||
mi.ODOStart2 = FIDbAccess.GetFieldDouble(dr["ODOSTART2"], 0);
|
||||
mi.ODOMeter = FIDbAccess.GetFieldDouble(dr["ODOMETER"], 0);
|
||||
mi.ODOMeterDate = FIDbAccess.GetFieldDateTime(dr["ODODATE_UTC"], DateTime.MinValue);
|
||||
mi.ODOMeterUom = FIDbAccess.GetFieldString(dr["ODOMETERUOM"], string.Empty);
|
||||
mi.FuelCost = FIDbAccess.GetFieldDouble(dr["FUELCOST"], 0);
|
||||
mi.FuelCostUom = FIDbAccess.GetFieldString(dr["FUELCOSTUOM"], string.Empty);
|
||||
mi.MachineRate = FIDbAccess.GetFieldDouble(dr["MACHINERATE"], 0);
|
||||
mi.WorkType = FIDbAccess.GetFieldString(dr["WORKTYPE"], string.Empty);
|
||||
mi.RetirementHours = FIDbAccess.GetFieldDouble(dr["RETIREMENTHOURS"], 0);
|
||||
mi.RetirementOdo = FIDbAccess.GetFieldDouble(dr["RETIREMENTODO"], 0);
|
||||
|
||||
mi.MakeID = FIDbAccess.GetFieldInt(dr["MAKEID"], 0);
|
||||
MachineMake make = MachineManagement.GetMachineMake(makes, mi.MakeID);
|
||||
mi.Make = make == null ? string.Empty : make.Name;
|
||||
|
||||
mi.ModelID = FIDbAccess.GetFieldInt(dr["MODELID"], 0);
|
||||
MachineModel model = MachineManagement.GetMachineModel(models, mi.ModelID);
|
||||
mi.Model = model == null ? string.Empty : model.Name;
|
||||
|
||||
mi.TypeID = FIDbAccess.GetFieldInt(dr["TYPEID"], 0);
|
||||
MachineType mtype = MachineManagement.GetMachineType(types, mi.TypeID);
|
||||
mi.MachineType = mtype == null ? string.Empty : mtype.Name;
|
||||
mi.OnRoad = FIDbAccess.GetFieldInt(dr["ONROAD"], 0) == 1;
|
||||
mi.LeaseStart = FIDbAccess.GetFieldDateTime(dr["LEASESTART"], DateTime.MinValue);
|
||||
mi.LeaseEnd = FIDbAccess.GetFieldDateTime(dr["LEASEEND"], DateTime.MinValue);
|
||||
mi.LeaseTerm = FIDbAccess.GetFieldDouble(dr["LEASEHOURS"], 0);
|
||||
mi.UndercarriageHours = FIDbAccess.GetFieldDouble(dr["UNDERCARRIAGEHOURS"], 0);
|
||||
mi.AquisitionType = FIDbAccess.GetFieldString(dr["AQUISITIONTYPE"], "");
|
||||
|
||||
mi.GpsDeviceID = FIDbAccess.GetFieldInt(dr["DEVICEID"], -1);
|
||||
mi.MachineIconFileName = FIDbAccess.GetFieldString(dr["ICONFILENAME"], "");
|
||||
mi.DistanceCalcBy = FIDbAccess.GetFieldString(dr["DISTANCECALCBY"], "");
|
||||
|
||||
mi.TelematicsEnabled = FIDbAccess.GetFieldInt(dr["TELEMATICSENABLED"], 0) == 1;
|
||||
mi.CostCenter = FIDbAccess.GetFieldString(dr["COSTCENTER"], "");
|
||||
mi.EqClass = FIDbAccess.GetFieldString(dr["EQCLASS"], "");
|
||||
mi.Description = FIDbAccess.GetFieldString(dr["DESCRIPTION"], "");
|
||||
|
||||
return mi;
|
||||
}
|
||||
|
||||
public static int SaveMachineGroup(MachineGroup mg)
|
||||
{
|
||||
const string SQL_Insert = "insert into MACHINEGROUPS (GROUPID,GROUPNAME,DESCRIPTION,CODE) values ({0},{1},{2},{3})";
|
||||
const string SQL_Update = "update MACHINEGROUPS set GROUPNAME={1},DESCRIPTION={2},CODE={3} where GROUPID={0} ";
|
||||
const string SQL_Exists = "select Count(1) from MACHINEGROUPS where GROUPNAME={0} and GROUPID<>{1}";
|
||||
const string SQL_DeleteDetail = "delete MACHINEGROUPMAP where GROUPID={0}";
|
||||
const string SQL_InsertDetail = "insert MACHINEGROUPMAP(MACHINEID,GROUPID) values({0},{1})";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
|
||||
int count = FIDbAccess.GetFieldInt(db.GetRC1BySQL(SQL_Exists, mg.GroupName, mg.GroupID ?? ""), 0);
|
||||
if (count > 0)
|
||||
return -1;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(mg.GroupID))
|
||||
{
|
||||
mg.GroupID = Guid.NewGuid().ToString();
|
||||
db.ExecSQL(SQL_Insert, mg.GroupID, mg.GroupName, mg.Description, mg.Code);
|
||||
if (mg.MachineIDs != null && mg.MachineIDs.Length > 0)
|
||||
{
|
||||
foreach (long mid in mg.MachineIDs)
|
||||
db.ExecSQL(SQL_InsertDetail, mid, mg.GroupID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
db.ExecSQL(SQL_Update, mg.GroupID, mg.GroupName, mg.Description, mg.Code);
|
||||
db.ExecSQL(SQL_DeleteDetail, mg.GroupID);
|
||||
if (mg.MachineIDs != null && mg.MachineIDs.Length > 0)
|
||||
{
|
||||
foreach (long mid in mg.MachineIDs)
|
||||
db.ExecSQL(SQL_InsertDetail, mid, mg.GroupID);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void SaveMachineToMachineGroups(FISqlConnection db, long machineid, string[] groupids)
|
||||
{
|
||||
const string SQL = "insert into MACHINEGROUPMAP(MACHINEID,GROUPID) values({0},{1})";
|
||||
const string SQL_DEL = "delete from MACHINEGROUPMAP where MACHINEID={0}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
db.ExecSQL(SQL_DEL, machineid);
|
||||
if (groupids != null && groupids.Length > 0)
|
||||
{
|
||||
foreach (var groupid in groupids)
|
||||
{
|
||||
db.ExecSQL(SQL, machineid, groupid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int DeleteMachineGroup(string groupID)
|
||||
{
|
||||
const string SQL_Delete = "delete from MACHINEGROUPS where GROUPID={0} delete from MACHINEGROUPMAP where GROUPID={0} ";
|
||||
const string SQL_Exists = "select Count(1) from USERMACHINEGROUPMAP where GROUPID={0}";
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
int count = FIDbAccess.GetFieldInt(db.GetRC1BySQL(SQL_Exists, groupID ?? ""), 0);
|
||||
if (count > 0)
|
||||
return -1;
|
||||
|
||||
db.ExecSQL(SQL_Delete, groupID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static MachineGroup[] GetMachineGroups(string searchtext, FISqlConnection db = null)
|
||||
{
|
||||
string SQL = "select GROUPID,GROUPNAME,DESCRIPTION,CODE from MACHINEGROUPS ";
|
||||
if (!string.IsNullOrEmpty(searchtext))
|
||||
SQL += " where GROUPNAME like {0} or DESCRIPTION like {0} or CODE like {0}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL, "%" + searchtext + "%");
|
||||
|
||||
List<MachineGroup> result = new List<MachineGroup>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
MachineGroup mg = new MachineGroup();
|
||||
mg.GroupID = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
mg.GroupName = FIDbAccess.GetFieldString(dr["GROUPNAME"], "");
|
||||
mg.Description = FIDbAccess.GetFieldString(dr["DESCRIPTION"], "");
|
||||
mg.Code = FIDbAccess.GetFieldString(dr["CODE"], "");
|
||||
result.Add(mg);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public static MachineGroup[] GetMachineGroupsByUser(string useriid, FISqlConnection db = null)
|
||||
{
|
||||
string SQL = @"select GROUPID,GROUPNAME,DESCRIPTION from MACHINEGROUPS mg where (select case when not exists(select 1 from USERMACHINEGROUPMAP where USERIID={0}) then 1
|
||||
when exists(select 1 from USERMACHINEGROUPMAP g where USERIID={0} and mg.GROUPID=g.GROUPID) then 1 else 0 end) = 1";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL, useriid);
|
||||
|
||||
List<MachineGroup> result = new List<MachineGroup>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
MachineGroup mg = new MachineGroup();
|
||||
mg.GroupID = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
mg.GroupName = FIDbAccess.GetFieldString(dr["GROUPNAME"], "");
|
||||
mg.Description = FIDbAccess.GetFieldString(dr["DESCRIPTION"], "");
|
||||
result.Add(mg);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public static MachineItem[] GetMachineByGroup(string groupid)
|
||||
{
|
||||
string SQL = "select " + string.Format(MachineFields, "b.") + " from MACHINEGROUPMAP a left join MACHINES b on a.MACHINEID=b.MACHINEID where a.GROUPID={0} order by MACHINENAME";
|
||||
|
||||
FIDbAccess db = SystemParams.GetDbInstance();
|
||||
if (db == null)
|
||||
{
|
||||
return new MachineItem[0];
|
||||
}
|
||||
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, groupid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new MachineItem[0];
|
||||
}
|
||||
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
|
||||
List<MachineItem> ls = new List<MachineItem>();
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
MachineItem mi = ConvertToMachineItem(dr, makes, models, types);
|
||||
ls.Add(mi);
|
||||
}
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
|
||||
public static MachineGroup[] GetMachineGroupByUser(string useriid, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL = "select b.* from USERMACHINEGROUPMAP a left join MACHINEGROUPS b on a.GROUPID=b.GROUPID where a.USERIID={0} order by GROUPNAME";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable dt = db.GetDataTableBySQL(SQL, useriid);
|
||||
|
||||
List<MachineGroup> result = new List<MachineGroup>();
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
MachineGroup mg = new MachineGroup();
|
||||
mg.GroupID = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
mg.GroupName = FIDbAccess.GetFieldString(dr["GROUPNAME"], "");
|
||||
mg.Description = FIDbAccess.GetFieldString(dr["DESCRIPTION"], "");
|
||||
result.Add(mg);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public static void SaveUserMachineGroup(string useriid, string[] groupids)
|
||||
{
|
||||
const string SQL_DeleteDetail = "delete USERMACHINEGROUPMAP where USERIID={0}";
|
||||
const string SQL_InsertDetail = "insert USERMACHINEGROUPMAP(USERIID,GROUPID) values({0},{1})";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
|
||||
db.ExecSQL(SQL_DeleteDetail, useriid);
|
||||
if (groupids != null && groupids.Length > 0)
|
||||
{
|
||||
foreach (string gid in groupids)
|
||||
db.ExecSQL(SQL_InsertDetail, useriid, gid);
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<int, List<StringKeyValue>> GetGroupsAssets(FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_C = "select mgm.MACHINEID,mgm.GROUPID,mg.GROUPNAME from MACHINEGROUPMAP mgm left join MACHINEGROUPS mg on mgm.GROUPID=mg.GROUPID";
|
||||
|
||||
Dictionary<int, List<StringKeyValue>> result = new Dictionary<int, List<StringKeyValue>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C);
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
int machineid = FIDbAccess.GetFieldInt(dr["MACHINEID"], -1);
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
kv.Value = FIDbAccess.GetFieldString(dr["GROUPNAME"], ""); ;
|
||||
if (!result.ContainsKey(machineid))
|
||||
result[machineid] = new List<StringKeyValue>();
|
||||
result[machineid].Add(kv);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器组和机器的对应关系
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<int, List<string>> GetGroupMachines(FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_C = "select MACHINEID,GROUPID from MACHINEGROUPMAP";
|
||||
|
||||
Dictionary<int, List<string>> result = new Dictionary<int, List<string>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C);
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
int machineid = FIDbAccess.GetFieldInt(dr["MACHINEID"], -1);
|
||||
string groupid = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
if (!result.ContainsKey(machineid))
|
||||
result[machineid] = new List<string>();
|
||||
result[machineid].Add(groupid);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器组和机器的对应关系
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static long[] GetGroupMachines(string[] groupids, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_C = "select distinct MACHINEID from MACHINEGROUPMAP where GROUPID in ({0})";
|
||||
|
||||
List<long> result = new List<long>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(string.Format(SQL_C, "'" + string.Join("','", groupids) + "'"));
|
||||
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
int machineid = FIDbAccess.GetFieldInt(dr["MACHINEID"], -1);
|
||||
result.Add(machineid);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器组
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string[] GetGroupByMachineID(FISqlConnection db, long machineid)
|
||||
{
|
||||
const string SQL_C = "select GROUPID from MACHINEGROUPMAP where MACHINEID={0}";
|
||||
|
||||
Dictionary<int, List<string>> result = new Dictionary<int, List<string>>();
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL_C, machineid);
|
||||
if (tb.Rows.Count == 0)
|
||||
return new string[0];
|
||||
|
||||
List<string> list = new List<string>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
string groupid = FIDbAccess.GetFieldString(dr["GROUPID"], "");
|
||||
list.Add(groupid);
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public static void ChangeMachineIconFile(long machineid, string filename, byte[] filebyte, FISqlConnection db = null)
|
||||
{
|
||||
const string SQL_NULL = "update MACHINES set ICONFILENAME=null,ICONDATA=null where MACHINEID={0}";
|
||||
const string SQL_ICON = "update MACHINES set ICONFILENAME={1},ICONDATA={2} where MACHINEID={0}";
|
||||
|
||||
if (db == null)
|
||||
db = SystemParams.GetDbInstance();
|
||||
if (filebyte == null)
|
||||
db.ExecSQL(SQL_NULL, machineid);
|
||||
else
|
||||
db.ExecSQL(SQL_ICON, machineid, filename, filebyte);
|
||||
}
|
||||
|
||||
public static byte[] GetMachineIconFile(string companyid, long machineid)
|
||||
{
|
||||
const string SQL = "select ICONDATA from MACHINES where MACHINEID={0}";
|
||||
FISqlConnection db = null;
|
||||
if (SystemParams.IsDealer)
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(companyid);
|
||||
db = new FISqlConnection(connetionstring);
|
||||
}
|
||||
else
|
||||
db = SystemParams.GetDbInstance();
|
||||
|
||||
object obj = db.GetRC1BySQL(SQL, machineid);
|
||||
return FIDbAccess.GetFieldBytes(obj);
|
||||
}
|
||||
|
||||
public static MachineInfo2 GetMachineByVIN(string vin)
|
||||
{
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
return mc.GetMachineInfoByVIN(vin);
|
||||
}
|
||||
|
||||
public static MachineInfo2 GetMachineByID(long machineid)
|
||||
{
|
||||
MachineServiceClient2 mc = SystemParams.GetMachineServiceClient();
|
||||
return mc.GetMachineInfoByMachineID(machineid);
|
||||
}
|
||||
|
||||
public static string GetMachineIDByVIN(string vin)
|
||||
{
|
||||
const string SQL = "select MACHINEID from MACHINES where VIN={0} and isnull(HIDE,0)=0";
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
|
||||
object obj = db.GetRC1BySQL(SQL, vin);
|
||||
return FIDbAccess.GetFieldString(obj, string.Empty);
|
||||
}
|
||||
|
||||
public static MaintenanceMachineInfo[] GetContactMachinesByID(string contactid)
|
||||
{
|
||||
const string SQL = @"select a.MACHINEID,b.MACHINENAME,b.MACHINENAME2,b.VIN,b.MAKEID,b.MODELID,b.TYPEID,b.HIDE,ISNULL(b.ENGINEHOURS,0) as ENGINEHOURS,
|
||||
ISNULL(b.ODOMETER,0) as ODOMETER,ISNULL(b.ODOMETERUOM,'Mile') AS ODOMETERUOM from USERMACHINEMAP a,MACHINES b
|
||||
where a.MACHINEID=b.MACHINEID and a.USERIID={0}";
|
||||
|
||||
FISqlConnection db = SystemParams.GetDbInstance();
|
||||
DataTable tb = db.GetDataTableBySQL(SQL, contactid);
|
||||
if (tb.Rows.Count == 0)
|
||||
{
|
||||
return new MaintenanceMachineInfo[0];
|
||||
}
|
||||
MachineManagement.RefreshBaseData();
|
||||
MachineMake[] makes = MachineManagement.GetMachineMakes();
|
||||
MachineModel[] models = MachineManagement.GetMachineModels();
|
||||
MachineType[] types = MachineManagement.GetMachineTypes();
|
||||
List<MaintenanceMachineInfo> ls = new List<MaintenanceMachineInfo>();
|
||||
foreach (DataRow dr in tb.Rows)
|
||||
{
|
||||
MaintenanceMachineInfo mi = MaintenanceManagement.ConvertToMaintenanceMachineInfo(dr, makes, models, types);
|
||||
ls.Add(mi);
|
||||
}
|
||||
return ls.ToArray();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
89
IronIntelContractorBusiness/Machines/MachineRentalInfo.cs
Normal file
89
IronIntelContractorBusiness/Machines/MachineRentalInfo.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class MachineRentalInfo
|
||||
{
|
||||
public long RentalID { get; set; }
|
||||
public long MachineID { get; set; }
|
||||
public string MachineName { get; set; }
|
||||
public string VIN { get; set; }
|
||||
public string AquisitionType { get; set; }
|
||||
public string AssetID { get; set; }
|
||||
public string Division { get; set; }
|
||||
public string EQClass { get; set; }
|
||||
public string Outside { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Vendor { get; set; }
|
||||
public int Term { get; set; }
|
||||
public string TermUnit { get; set; }
|
||||
public decimal RentalRate { get; set; }
|
||||
public DateTime? RentalDate { get; set; }
|
||||
public string RentalDateStr { get { return RentalDate == null ? "" : RentalDate.Value.ToShortDateString(); } }
|
||||
public DateTime? ProjectReturnDate { get; set; }
|
||||
public string ProjectReturnDateStr { get { return ProjectReturnDate == null ? "" : ProjectReturnDate.Value.ToShortDateString(); } }
|
||||
public DateTime? ReturnDate { get; set; }
|
||||
public string ReturnDateStr { get { return ReturnDate == null ? "" : ReturnDate.Value.ToShortDateString(); } }
|
||||
public string PONumber { get; set; }
|
||||
public string Comments { get; set; }
|
||||
|
||||
public DateTime? RentalTermBillingDate { get; set; }
|
||||
public string RentalTermBillingDateStr { get { return RentalTermBillingDate == null ? "" : RentalTermBillingDate.Value.ToShortDateString(); } }
|
||||
public int BillingCycleDays { get; set; }
|
||||
|
||||
public bool Selected { get; set; }
|
||||
|
||||
public string ShowName
|
||||
{
|
||||
get
|
||||
{
|
||||
//Name取值顺序为Name2,Name,VIN,ID用于前端显示
|
||||
string name = MachineName;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = VIN;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = MachineID.ToString();
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public string RentalStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
//5.Can we add a rental status to Rental Information section:
|
||||
//a.Rental Information: ON RENT(if we are past the Start Date and the return date is blank or a future date and the Proj Return Date is blank or today or greater)
|
||||
//b.Rental Information: OVERDUE(if we are past the Start Date and the Proj Return Date is past and Return Date is Blank)
|
||||
//c.Rental Information: RETURNED(if Return Date is populated today or less).
|
||||
|
||||
DateTime today = DateTime.Now.Date;
|
||||
if (RentalDate < today
|
||||
&& (ReturnDate == null || ReturnDate > today)
|
||||
&& (ProjectReturnDate == null || ProjectReturnDate >= today))
|
||||
return "ON RENT";
|
||||
if (RentalDate < today
|
||||
&& (ProjectReturnDate != null && ProjectReturnDate < today)
|
||||
&& ReturnDate == null)
|
||||
return "OVERDUE";
|
||||
if (ReturnDate <= today)
|
||||
return "RETURNED";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class RentalChangeHistoryInfo : MachineRentalInfo
|
||||
{
|
||||
public string OperateType { get; set; }
|
||||
public string LastUpdateUserName { get; set; }
|
||||
public string LastUpdatedBy { get; set; }
|
||||
public DateTime? LastUpdateDate { get; set; }
|
||||
public string LastUpdateDateStr { get { return LastUpdateDate == null ? "" : LastUpdateDate.Value.ToShortDateString(); } }
|
||||
|
||||
}
|
||||
}
|
179
IronIntelContractorBusiness/Machines/OdometerInfo.cs
Normal file
179
IronIntelContractorBusiness/Machines/OdometerInfo.cs
Normal file
@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Machines
|
||||
{
|
||||
public class OdometerInfo
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string DataSourceName { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public DateTime AsofTimeLocal { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
|
||||
public string UOM { get; set; }
|
||||
|
||||
private double _Odometer;
|
||||
public double Odometer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Odometer;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Odometer = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private double _Corrected;
|
||||
public double Corrected
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Corrected;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Corrected = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public string ReceivedDateStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTimeLocal.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AdjustOdometerInfo
|
||||
{
|
||||
public string CustomerID { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public DateTime OdometerDate { get; set; }
|
||||
public string UOM { get; set; }
|
||||
|
||||
private double _Odometer;
|
||||
public double Odometer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Odometer;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Odometer = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public string Notes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 前端选择的时区的分钟偏移
|
||||
/// </summary>
|
||||
public int OffsetMinute { get; set; }
|
||||
}
|
||||
public class CalampOdometerInfo
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
public string DeviceAirId { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public double Gps { get; set; }
|
||||
public double Gps_Calc { get; set; }
|
||||
public double VBUS { get; set; }
|
||||
public double VBUS_Calc { get; set; }
|
||||
public string EventTimeText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("MM/dd/yyyy HH:mm");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTime_Local { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime_Local.ToString("MM/dd/yyyy HH:mm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class PedigreeOdometerInfo
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
public string DeviceSN { get; set; }
|
||||
public DateTime AsofTime { get; set; }
|
||||
public string UOM { get; set; }
|
||||
public double Gps { get; set; }
|
||||
public double Gps_Calc { get; set; }
|
||||
public double VBUS { get; set; }
|
||||
public double VBUS_Calc { get; set; }
|
||||
public string EventTimeText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime.ToString("MM/dd/yyyy HH:mm");
|
||||
}
|
||||
}
|
||||
public DateTime AsofTime_Local { get; set; }
|
||||
public string EventTimeLocalText
|
||||
{
|
||||
get
|
||||
{
|
||||
return AsofTime_Local.ToString("MM/dd/yyyy HH:mm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PrimaryDataSourceInfo
|
||||
{
|
||||
public int Type { get; set; } //Odometer:0,EngineHours:1
|
||||
public string CustomerID { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string Notes { get; set; }
|
||||
}
|
||||
|
||||
public class AssetOdometerAdjustItem
|
||||
{
|
||||
public long LogId { get; set; }
|
||||
public long AssetId { get; set; }
|
||||
public DateTime AdjustmentTime { get; set; }
|
||||
public string AdjustmentTimeText { get { return AdjustmentTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public DateTime OdometerTime { get; set; }
|
||||
public string OdometerTimeText { get { return OdometerTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public DateTime AdjustmentLocalTime { get; set; }
|
||||
public string AdjustmentLocalTimeText { get { return AdjustmentLocalTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
public DateTime OdometerLocalTime { get; set; }
|
||||
public string OdometerLocalTimeText { get { return OdometerLocalTime.ToString("MM/dd/yyyy HH:mm"); } }
|
||||
|
||||
private double _Odometer;
|
||||
public double Odometer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Odometer;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Odometer = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public string UOM { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user