sync
This commit is contained in:
@ -16,6 +16,10 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Foresight.Standard;
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using Foresight.Fleet.Services.AssetHealth.WorkOrder;
|
||||
using IronIntel.Contractor.Site.Maintenance;
|
||||
using System.Drawing;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Asset
|
||||
{
|
||||
@ -34,6 +38,9 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
case "GETMACHINESBYCOMPANY":
|
||||
result = GetMachinesByCompany();
|
||||
break;
|
||||
case "GETMACHINESBYCOMPANY1":
|
||||
result = GetMachinesByCompany1();
|
||||
break;
|
||||
case "GETMACHINEINFO":
|
||||
result = GetMachineInfo();
|
||||
break;
|
||||
@ -79,6 +86,15 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
case "GETASSETDATASOURCES":
|
||||
result = GetAssetDatasources();
|
||||
break;
|
||||
case "GETASSETS":
|
||||
result = GetAssets();
|
||||
break;
|
||||
case "GETASSETHISTORYS":
|
||||
result = GetAssetHistorys();
|
||||
break;
|
||||
case "GETASSETDETAILINFO":
|
||||
result = GetAssetDetailInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,6 +107,33 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetAssetDetailInfo()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var custid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var assetidstr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long assetid = -1;
|
||||
long.TryParse(assetidstr, out assetid);
|
||||
if (string.IsNullOrWhiteSpace(custid))
|
||||
custid = SystemParams.CompanyID;
|
||||
|
||||
AssetDetailInfo info = CreateClient<AssetQueryClient>(custid).GetAssetDetailInfo(custid, assetid);
|
||||
return new { ID = info.ID, Name = info.DisplayName + " " + info.VIN };
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetMachinesByCompany()
|
||||
{
|
||||
try
|
||||
@ -114,7 +157,13 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
//GpsDeviceInfo[] devs = SystemParams.DeviceProvider.GetDeviceItems(contractorid, "");
|
||||
|
||||
AssetBasicInfo[] assets = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByUser(companyid, searchtxt, session.User.UID, att);
|
||||
List<AssetBasicItem> list = new List<AssetBasicItem>();
|
||||
|
||||
if (assets == null || assets.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
assets = assets.OrderBy((m) => m.VIN).ToArray();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var a in assets)
|
||||
{
|
||||
if (!showHidden && a.Hide) continue;
|
||||
@ -122,12 +171,17 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
Helper.CloneProperty(asset, a);
|
||||
asset.EngineHours = a.EngineHours == null ? 0 : a.EngineHours.Value;
|
||||
asset.Odometer = a.Odometer == null ? 0 : a.Odometer.Value;
|
||||
list.Add(asset);
|
||||
|
||||
sb.Append(SPLIT_CHAR180 + asset.ToString());
|
||||
}
|
||||
return list.OrderBy((m) => m.VIN).ToArray();
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
return sb.ToString().Substring(1);
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
else
|
||||
return new MachineItem[0];
|
||||
return string.Empty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -136,6 +190,38 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
}
|
||||
}
|
||||
|
||||
private object GetMachinesByCompany1()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string companyid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
AssetBasicInfo[] assets = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByUser(companyid, "", session.User.UID, 0);
|
||||
|
||||
if (assets == null || assets.Length == 0)
|
||||
return new AssetBasicInfo[0];
|
||||
|
||||
var items = assets.Select((a) => new { ID = a.ID, Name = a.DisplayName + (string.IsNullOrWhiteSpace(a.VIN) ? "" : ("----" + a.VIN)) });
|
||||
|
||||
items = items.OrderBy((m) => m.Name).ToArray();
|
||||
|
||||
return items;
|
||||
}
|
||||
else
|
||||
return new AssetBasicInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AssetBasePage.GetMachinesByCompany1", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetMachineInfo()
|
||||
{
|
||||
try
|
||||
@ -185,9 +271,6 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
// assetItem.MachineRental = rental;
|
||||
//}
|
||||
|
||||
if (assetItem.UnderCarriageHours != null)
|
||||
assetItem.UnderCarriageHours = Math.Round(assetItem.UnderCarriageHours.Value, 2);
|
||||
|
||||
return assetItem;
|
||||
}
|
||||
else
|
||||
@ -213,7 +296,7 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
AssetDetailItem2 asset = JsonConvert.DeserializeObject<AssetDetailItem2>(clientdata);
|
||||
|
||||
if (SystemParams.IsDealer && string.IsNullOrWhiteSpace(asset.ContractorID))
|
||||
return "Failed";
|
||||
return FailedResult;
|
||||
|
||||
string connectionStr = string.Empty;
|
||||
string customerid = string.Empty;
|
||||
@ -288,7 +371,7 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
return FailedResult;
|
||||
}
|
||||
}
|
||||
catch (BusinessException bex)
|
||||
@ -380,10 +463,10 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "OK";
|
||||
return OkResult;
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
return FailedResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -633,9 +716,11 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
custid = SystemParams.CompanyID;
|
||||
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = SystemParams.GetStringParam("CustomerTimeZone", false, db);
|
||||
TimeZoneInfo tz = SystemParams.GetTimeZoneInfo(custid);
|
||||
DateTime time = SystemParams.ConvertToUserTimeFromUtc(session.User, DateTime.Now.ToUniversalTime());
|
||||
|
||||
//kv.Key = CreateClient<CustomerProvider>(custid).GetCustomerTimeZone(custid);
|
||||
kv.Key = SystemParams.GetUserTimeZoneId(session.User);
|
||||
//TimeZoneInfo tz = SystemParams.GetTimeZoneInfo(custid);
|
||||
DateTime time = SystemParams.ConvertToUserTimeFromUtc(session.User, DateTime.UtcNow);
|
||||
kv.Value = time.ToString("MM/dd/yyyy HH:mm:ss");//此处格式不能修改
|
||||
return kv;
|
||||
}
|
||||
@ -674,9 +759,9 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
}
|
||||
MachineManagement.ChangeMachineIconFile(Convert.ToInt64(kv.Value), uploadFile == null ? "" : uploadFile.FileName, iconfilebyte, db);
|
||||
|
||||
return "OK";
|
||||
return OkResult;
|
||||
}
|
||||
return "Failed";
|
||||
return FailedResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -731,7 +816,7 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
client.GenerateMissedPMAlert(SystemParams.CompanyID, p.SelectedIntervalID, pmAsset.AssetId);
|
||||
}
|
||||
}
|
||||
return "OK";
|
||||
return OkResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -754,7 +839,7 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
|
||||
CreateClient<PMClient>().DeleteAssetsFromSchedule(SystemParams.CompanyID, ps[1], new long[] { assetid }, session.User.UID);
|
||||
}
|
||||
return "OK";
|
||||
return OkResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -788,7 +873,7 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
return FailedResult;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -820,7 +905,7 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
return FailedResult;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -865,6 +950,98 @@ namespace IronIntel.Contractor.Site.Asset
|
||||
}
|
||||
}
|
||||
|
||||
#region Asset History
|
||||
private object GetAssets()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
var items = CreateClient<AssetQueryClient>(companyid).GetAssetListItemsByUser(companyid, session.User.UID, string.Empty, true, 0, false, null, null, null);
|
||||
return items.OrderBy(g => g.VIN).Select(i => new
|
||||
{
|
||||
i.Id,
|
||||
DisplayName = GetDisplayName(i),
|
||||
}).ToArray();
|
||||
}
|
||||
else
|
||||
return new AssetGroupInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "MachineDeviceBasePage.GetAssetList", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssetHistorys()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string clientdata = Request.Params["ClientData"];
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
|
||||
var companyid = ps[0];
|
||||
long assetid = Convert.ToInt64(ps[1]);
|
||||
DateTime beginDate = Helper.DBMinDateTime;
|
||||
DateTime endDate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(ps[2], out beginDate))
|
||||
beginDate = Helper.DBMinDateTime;
|
||||
if (!DateTime.TryParse(ps[3], out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
AssetHistoryInfo[] items = CreateClient<AssetQueryClient>(companyid).GetAssetHistorys(companyid, assetid, beginDate, endDate, "");
|
||||
if (items == null || items.Length == 0)
|
||||
return new AssetHistoryItem[0];
|
||||
|
||||
List<AssetHistoryItem> ls = new List<AssetHistoryItem>();
|
||||
foreach (AssetHistoryInfo item in items)
|
||||
{
|
||||
AssetHistoryItem his = new AssetHistoryItem();
|
||||
Helper.CloneProperty(his, item);
|
||||
ls.Add(his);
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
else
|
||||
return new AssetHistoryItem[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private string GetDisplayName(AssetListItemInfo a)
|
||||
{
|
||||
//Name取值顺序为Name2,Name,VIN,ID用于前端显示
|
||||
string name = a.Name2;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = a.Name;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = a.VIN;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = a.Id.ToString();
|
||||
return name;
|
||||
}
|
||||
class AssetHistoryItem : AssetHistoryInfo
|
||||
{
|
||||
public string DateTimeStr { get { return DateTime == null ? "" : DateTime.Value.ToString(); } }
|
||||
}
|
||||
#endregion
|
||||
|
||||
class PMScheduleAssetItem
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
|
Reference in New Issue
Block a user