This commit is contained in:
2023-04-28 12:21:24 +08:00
parent 156d145a48
commit 88e0a25ecd
162 changed files with 26324 additions and 7519 deletions

View File

@ -3,8 +3,8 @@ using Foresight.Fleet.Services;
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.AssetHealth;
using Foresight.Fleet.Services.Device;
using Foresight.Fleet.Services.JobSite;
using Foresight.Fleet.Services.User;
using Foresight.ServiceModel;
using IronIntel.Contractor.Machines;
using IronIntel.Contractor.Maintenance;
using IronIntel.Contractor.Users;
@ -15,6 +15,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Foresight.Standard;
namespace IronIntel.Contractor.Site.Asset
{
@ -66,6 +67,18 @@ namespace IronIntel.Contractor.Site.Asset
case "CHANGEASSETPROPERTY":
result = ChangeAssetProperty();
break;
case "GETASSETATTACHMENTINFO":
result = GetAssetAttachmentInfo();
break;
case "DELETEASSETS":
result = DeleteAssets();
break;
case "MERGEASSET":
result = MergeAsset();
break;
case "GETASSETDATASOURCES":
result = GetAssetDatasources();
break;
}
}
}
@ -89,6 +102,8 @@ namespace IronIntel.Contractor.Site.Asset
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
bool showHidden = HttpUtility.HtmlDecode(clientdata[1]) == "1";
var searchtxt = HttpUtility.HtmlDecode(clientdata[2]);
bool attachment = HttpUtility.HtmlDecode(clientdata[3]) == "1";
int att = attachment ? 0 : 2;
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
@ -98,13 +113,15 @@ namespace IronIntel.Contractor.Site.Asset
//GpsDeviceInfo[] devs = SystemParams.DeviceProvider.GetDeviceItems(contractorid, "");
AssetBasicInfo[] assets = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByUser(companyid, searchtxt, session.User.UID);
AssetBasicInfo[] assets = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByUser(companyid, searchtxt, session.User.UID, att);
List<AssetBasicItem> list = new List<AssetBasicItem>();
foreach (var a in assets)
{
if (!showHidden && a.Hide) continue;
AssetBasicItem asset = new AssetBasicItem();
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);
}
return list.OrderBy((m) => m.VIN).ToArray();
@ -150,7 +167,7 @@ namespace IronIntel.Contractor.Site.Asset
AssetDetailItem2 assetItem = new AssetDetailItem2();
Helper.CloneProperty(assetItem, assetDetail);
assetItem.OnSiteJobsiteID = mother.JobSiteID;
assetItem.JobSites = mother.JobSites;
assetItem.ContactIDs = string.IsNullOrEmpty(mother.ContactIDs) ? new string[0] : mother.ContactIDs.Split(',');
assetItem.MachineGroupIDs = string.IsNullOrEmpty(mother.GroupIDs) ? new string[0] : mother.GroupIDs.Split(',');
@ -190,7 +207,7 @@ namespace IronIntel.Contractor.Site.Asset
var session = GetCurrentLoginSession();
if (session != null)
{
if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_ASSETS))
if (!CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.MANAGE_ASSETS, Permissions.FullControl))
return "";
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
AssetDetailItem2 asset = JsonConvert.DeserializeObject<AssetDetailItem2>(clientdata);
@ -215,20 +232,13 @@ namespace IronIntel.Contractor.Site.Asset
AssetDataAdjustClient client = CreateClient<AssetDataAdjustClient>(customerid);
if (asset.ID > 0)
{
//没有权限修改的,保持原来的值
var oldMachine = client.GetAssetDetailInfo2(customerid, asset.ID);
asset.EngineHours = oldMachine.EngineHours;//EngineHours单独保存
var user = UserManagement.GetUserByIID(session.User.UID);
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
if (!permission)
if (oldMachine.ShareStatus == AssetShareStatus.Child)
{
asset.VIN = oldMachine.VIN;
asset.VIN = oldMachine.VIN;//共享机器不能修改VIN/Make/Model/Type
asset.MakeID = oldMachine.MakeID;
asset.MakeName = oldMachine.MakeName;
asset.ModelID = oldMachine.ModelID;
asset.ModelName = oldMachine.ModelName;
asset.Odometer = oldMachine.Odometer;
asset.OdometerUnits = oldMachine.OdometerUnits;
asset.TypeID = oldMachine.TypeID;
}
}
else if (!asset.IgnoreDuplicate)
@ -247,26 +257,29 @@ namespace IronIntel.Contractor.Site.Asset
AssetDetailInfo2 a = new AssetDetailInfo2();
Helper.CloneProperty(a, asset);
a.ID = client.UpdateAssetInfo(customerid, a, asset.ContactIDs, asset.MachineGroupIDs, (int)asset.OnSiteJobsiteID, session.User.UID);
a.ID = client.UpdateAssetInfo(customerid, a, asset.ContactIDs, asset.MachineGroupIDs, session.User.UID);
CreateClient<JobSiteProvider>(customerid).AddAssetToJobSites(customerid, asset.OnSiteJobsiteIDs, a.ID, a.VIN);
UpdateMachineAttributes(a.ID, asset.ContractorID, asset.MachineAttributes, session.User.UID);
if (asset.VisibleOnWorkOrders != null)
{
foreach (StringKeyValue kv in asset.VisibleOnWorkOrders)
{
CreateClient<AssetAttachmentProvider>(customerid).ChangeVisibleOnWorkOrder(customerid, Convert.ToInt32(kv.Key), Helper.IsTrue(kv.Value));
}
}
long rentalID = -1;
if (asset.MachineRental != null)
if (a.ShareStatus != AssetShareStatus.Child)
{
asset.MachineRental.MachineID = a.ID;
AssetRentalInfo rentalinfo = new AssetRentalInfo();
Helper.CloneProperty(rentalinfo, asset.MachineRental);
rentalinfo.RentalRate = (double)asset.MachineRental.RentalRate;
rentalID = CreateClient<AssetQueryClient>(customerid).SaveAssetRental(customerid, rentalinfo, session.User.UID);
UpdateMachineAttributes(a.ID, asset.ContractorID, asset.MachineAttributes, session.User.UID);
if (asset.MachineRental != null)
{
asset.MachineRental.MachineID = a.ID;
AssetRentalInfo rentalinfo = new AssetRentalInfo();
Helper.CloneProperty(rentalinfo, asset.MachineRental);
rentalinfo.RentalRate = (double)asset.MachineRental.RentalRate;
rentalID = CreateClient<AssetQueryClient>(customerid).SaveAssetRental(customerid, rentalinfo, session.User.UID);
}
if (asset.AttachmentInfo != null)
{
asset.AttachmentInfo.AssetId = a.ID;
client.UpdateAssetAttachmentAttribute(customerid, asset.AttachmentInfo, session.User.UID);
}
}
return new
{
Result = 1,
@ -289,6 +302,47 @@ namespace IronIntel.Contractor.Site.Asset
}
}
private object GetAssetAttachmentInfo()
{
try
{
if (GetCurrentLoginSession() != null)
{
var clientdata = Request.Form["ClientData"].Split((char)170);
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
var mid = HttpUtility.HtmlDecode(clientdata[1]);
long machineid = -1;
long.TryParse(mid, out machineid);
var client = CreateClient<AssetDataAdjustClient>(companyid);
AttachmentAttributeItem attaitem = null;
AttachmentAttributeInfo attainfo = client.GetAssetAttachmentAttribute(companyid, machineid);
if (attainfo != null)
{
attaitem = new AttachmentAttributeItem();
Helper.CloneProperty(attaitem, attainfo);
if (attaitem.AttachedtoAssetId != null && attaitem.AttachedtoAssetId.Value > 0)
{
var asset = CreateClient<AssetQueryClient>(companyid).GetAssetBasicInfoByID(companyid, attaitem.AttachedtoAssetId.Value);
if (asset != null)
attaitem.AttachedtoAssetName = asset.DisplayName;
}
}
return attaitem;
}
else
return new AttachmentAttributeItem();
}
catch (Exception ex)
{
SystemParams.WriteLog("error", "AssetBasePage.GetAssetAttachmentInfo", ex.Message, ex.ToString());
return ex.Message;
}
}
private string ChangeAssetProperty()
{
try
@ -317,6 +371,12 @@ namespace IronIntel.Contractor.Site.Asset
case "TelematicsEnabled":
CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetTelematicsProperty(contractorid, assetid, value, "", user.IID);
break;
case "Attachment":
CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetAttachmentProperty(contractorid, assetid, value, "", user.IID);
break;
case "Preloaded":
CreateClient<AssetDataAdjustClient>(contractorid).ChangeAssetPreloadedProperty(contractorid, assetid, value, "", user.IID);
break;
default:
break;
}
@ -475,9 +535,8 @@ namespace IronIntel.Contractor.Site.Asset
if (!DateTime.TryParse(edate, out endtime))
endtime = DateTime.MaxValue;
else
endtime = endtime.Date.AddDays(1).AddSeconds(-1);
AssetBasicInfo asset = CreateClient<AssetQueryClient>(customerid).GetAssetBasicInfoByID(customerid, Convert.ToInt64(assetid));
AssetOdometerAdjustInfo[] odos = CreateClient<AssetDataAdjustClient>(customerid).GetOdometerAdjustmentHistory(customerid, Convert.ToInt64(assetid), starttime, endtime);
if (odos == null || odos.Length == 0)
return new AssetOdometerAdjustItem[0];
@ -487,6 +546,8 @@ namespace IronIntel.Contractor.Site.Asset
{
AssetOdometerAdjustItem item = new AssetOdometerAdjustItem();
Helper.CloneProperty(item, odo);
item.DisplayName = asset.DisplayName;
item.VIN = asset.VIN;
list.Add(item);
}
return list.ToArray();
@ -525,9 +586,8 @@ namespace IronIntel.Contractor.Site.Asset
if (!DateTime.TryParse(edate, out endtime))
endtime = DateTime.MaxValue;
else
endtime = endtime.Date.AddDays(1).AddSeconds(-1);
AssetBasicInfo asset = CreateClient<AssetQueryClient>(customerid).GetAssetBasicInfoByID(customerid, Convert.ToInt64(assetid));
AssetEngineHoursAdjustInfo[] hours = CreateClient<AssetDataAdjustClient>(customerid).GetEngineHoursAdjustmentHistory(customerid, Convert.ToInt64(assetid), starttime, endtime);
if (hours == null || hours.Length == 0)
return new AssetEngineHoursAdjustItem[0];
@ -537,6 +597,8 @@ namespace IronIntel.Contractor.Site.Asset
{
AssetEngineHoursAdjustItem item = new AssetEngineHoursAdjustItem();
Helper.CloneProperty(item, hour);
item.DisplayName = asset.DisplayName;
item.VIN = asset.VIN;
list.Add(item);
}
return list.ToArray();
@ -572,9 +634,9 @@ namespace IronIntel.Contractor.Site.Asset
StringKeyValue kv = new StringKeyValue();
kv.Key = SystemParams.GetStringParam("CustomerTimeZone", false, db);
TimeZoneInfo tz = SystemParams.GetTimeZoneInfo(custid, db);
DateTime time = TimeZoneInfo.ConvertTimeFromUtc(DateTime.Now.ToUniversalTime(), tz);
kv.Value = time.ToString("MM/dd/yyyy HH:mm:ss");
TimeZoneInfo tz = SystemParams.GetTimeZoneInfo(custid);
DateTime time = SystemParams.ConvertToUserTimeFromUtc(session.User, DateTime.Now.ToUniversalTime());
kv.Value = time.ToString("MM/dd/yyyy HH:mm:ss");//此处格式不能修改
return kv;
}
else
@ -632,7 +694,7 @@ namespace IronIntel.Contractor.Site.Asset
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
long assetid = 0;
long.TryParse(clientdata, out assetid);
return MaintenanceManagement.GetPmScheduleByAsset(session.SessionID, assetid);
return MaintenanceManagement.GetPmScheduleByAsset(session.SessionID, assetid, true);
}
else
return new PmScheduleInfo[0];
@ -701,6 +763,108 @@ namespace IronIntel.Contractor.Site.Asset
}
}
private object DeleteAssets()
{
try
{
var session = GetCurrentLoginSession();
if (session != null && session.User.UserType == Foresight.Fleet.Services.User.UserTypes.SupperAdmin)
{
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
string custid = ps[0];
long[] assetids = JsonConvert.DeserializeObject<long[]>(ps[1]);
string notes = ps[2];
if (string.IsNullOrEmpty(custid))
custid = SystemParams.CompanyID;
var client = CreateClient<AssetDataAdjustClient>(custid);
foreach (long assetid in assetids)
{
client.DeleteAsset(custid, Convert.ToInt64(assetid), notes);
}
return "";
}
else
{
return "Failed";
}
}
catch (Exception ex)
{
SystemParams.WriteLog("error", "AssetBasePage.DeleteAsset", ex.Message, ex.ToString());
return ex.Message;
}
}
private object MergeAsset()
{
try
{
var session = GetCurrentLoginSession();
if (session != null && session.User.UserType == Foresight.Fleet.Services.User.UserTypes.SupperAdmin)
{
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
string custid = ps[0];
string fromassetid = ps[1];
string toassetid = ps[2];
string notes = ps[3];
if (string.IsNullOrEmpty(custid))
custid = SystemParams.CompanyID;
CreateClient<AssetDataAdjustClient>(custid).MergeAsset(custid, Convert.ToInt64(fromassetid), Convert.ToInt64(toassetid), notes);
return "";
}
else
{
return "Failed";
}
}
catch (Exception ex)
{
SystemParams.WriteLog("error", "AssetBasePage.MergeAsset", ex.Message, ex.ToString());
return ex.Message;
}
}
private object GetAssetDatasources()
{
try
{
if (GetCurrentLoginSession() != null)
{
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
var companyid = HttpUtility.HtmlDecode(ps[0]);
var mid = HttpUtility.HtmlDecode(ps[1]);
long machineid = -1;
long.TryParse(mid, out machineid);
if (!SystemParams.IsDealer)
{
companyid = SystemParams.CompanyID;
}
var client = CreateClient<AssetDataAdjustClient>(companyid);
string[] datasources = client.GetAssetDatasources(companyid, machineid);
if (datasources == null)
return new string[0];
return datasources;
}
else
return new string[0];
}
catch (Exception ex)
{
SystemParams.WriteLog("error", "AssetBasePage.GetAssetDatasources", ex.Message, ex.ToString());
return ex.Message;
}
}
class PMScheduleAssetItem
{
public long AssetId { get; set; }
@ -711,5 +875,15 @@ namespace IronIntel.Contractor.Site.Asset
public int? StartIntervalValue { get; set; }
public string SelectedIntervalID { get; set; }
}
class AttachmentAttributeItem : AttachmentAttributeInfo
{
public string AttachedtoAssetName { get; set; }
}
class AssetMergeItem : AssetMergeInfo
{
public string CompletedOnStr { get { return CompletedOn == DateTime.MinValue ? "" : CompletedOn.ToString(); } }
public string MergeOnStr { get { return MergeOn == DateTime.MinValue ? "" : MergeOn.ToString(); } }
}
}
}

View File

@ -0,0 +1,346 @@
using Foresight.Data;
using Foresight.Fleet.Services;
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.AssetHealth;
using Foresight.Fleet.Services.Device;
using Foresight.Fleet.Services.JobSite;
using Foresight.Fleet.Services.User;
using IronIntel.Contractor.Machines;
using IronIntel.Contractor.Maintenance;
using IronIntel.Contractor.Users;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Foresight.Standard;
namespace IronIntel.Contractor.Site.Asset
{
public class ShareAssetBasePage : ContractorBasePage
{
protected void ProcessRequest(string method)
{
object result = null;
string methodName = Request.Params["MethodName"];
try
{
if (methodName != null)
{
switch (methodName.ToUpper())
{
case "GETSHAREWITHCUSTOMERS":
result = GetShareWithCustomers();
break;
case "SETSHAREWITHCUSTOMERS":
result = SetShareWithCustomers();
break;
case "GETASSETSHAREINFOS":
result = GetAssetShareInfos();
break;
case "GETSHAREASSETLIST":
result = GetShareAssetList();
break;
case "SAVESHAREASSET":
result = SaveShareAsset();
break;
case "UNSHAREASSET":
result = UnShareAsset();
break;
}
}
}
catch (Exception ex)
{
SystemParams.WriteLog("error", "ShareAssetBasePage", ex.Message, ex.ToString());
throw ex;
}
string json = JsonConvert.SerializeObject(result);
Response.Write(json);
Response.End();
}
private object GetShareWithCustomers()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
var companyid = ps[0];
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
bool sharableonly = Helper.IsTrue(ps[1]);
var custs = CreateClient<ShareAssetsProvider>(companyid).GetSharableCustomers(companyid, sharableonly);
return custs.OrderBy((c) => c.CustomerName).ToArray();
}
else
return new MachineItem[0];
}
catch (Exception ex)
{
AddLog("ERROR", "ShareAssetBasePage.GetShareWithCustomers", ex.Message, ex.ToString());
return ex.Message;
}
}
private object GetAssetShareInfos()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
var companyid = ps[0];
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
long asstid = -1;
long.TryParse(ps[1], out asstid);
AssetShareInfo[] assets = CreateClient<ShareAssetsProvider>(companyid).GetAssetShareInfos(companyid, asstid);
if (assets == null || assets.Length == 0)
return new AssetShareItem[0];
List<AssetShareItem> ls = new List<AssetShareItem>();
foreach (AssetShareInfo item in assets)
{
AssetShareItem ai = new AssetShareItem();
Helper.CloneProperty(ai, item);
ls.Add(ai);
}
return ls.ToArray();
}
else
return new AssetShareItem[0];
}
catch (Exception ex)
{
AddLog("ERROR", "ShareAssetBasePage.GetAssetShareInfos", ex.Message, ex.ToString());
return ex.Message;
}
}
private object GetShareAssetList()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
ShareAssetQueryItem q = JsonConvert.DeserializeObject<ShareAssetQueryItem>(clientdata);
if (string.IsNullOrEmpty(q.CustomerId))
q.CustomerId = SystemParams.CompanyID;
ShareAssetItem[] assets = CreateClient<ShareAssetsProvider>(q.CustomerId).GetShareAssetList(q.CustomerId, q.Shared, q.OnRoad, q.IncludeHidden, q.Filter);
List<ShareAssetInfo> ls = new List<ShareAssetInfo>();
foreach (ShareAssetItem item in assets)
{
ShareAssetInfo ai = new ShareAssetInfo();
Helper.CloneProperty(ai, item);
if (ai.ShareInfo != null)
{
ai.ChildId = ai.ShareInfo.ChildId;
ai.ChildName = ai.ShareInfo.ChildName;
ai.StartDate = ai.ShareInfo.StartDate;
ai.ExpectedRetrievalDate = ai.ShareInfo.ExpectedRetrievalDate;
ai.RetrievalDate = ai.ShareInfo.RetrievalDate;
}
ls.Add(ai);
}
return ls.OrderBy(a => a.VIN).ToArray();
}
else
return new ShareAssetItem[0];
}
catch (Exception ex)
{
AddLog("ERROR", "ShareAssetBasePage.GetShareAssetList", ex.Message, ex.ToString());
return ex.Message;
}
}
private object SaveShareAsset()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
var q = JsonConvert.DeserializeObject<SaveShareAssetParam>(clientdata);
if (string.IsNullOrEmpty(q.CustomerId))
q.CustomerId = SystemParams.CompanyID;
DateTime? expected = DateTime.TryParse(q.EndDate, out DateTime dt) ? dt : default(DateTime?);
ShareAssetsProvider provider = CreateClient<ShareAssetsProvider>(q.CustomerId);
string[] results = new string[q.SharedIds.Length];
Task[] tasks = new Task[q.SharedIds.Length];
for (var i = 0; i < tasks.Length; i++)
{
var index = i;
var id = q.SharedIds[i];
tasks[i] = Task.Run(() =>
{
try
{
provider.SetShareAsset(q.CustomerId, new AssetShareInfo
{
ChildId = q.SharedWith,
AssetId = id,
ExpectedRetrievalDate = expected,
HideAssetOnThisSite = q.HideAsset
});
}
catch (Exception ex)
{
results[index] = ex.Message;
}
});
}
Task.WaitAll(tasks);
return results;
}
else
{
return null;
}
}
catch (Exception ex)
{
AddLog("ERROR", "ShareAssetBasePage.SaveShareAsset", ex.Message, ex.ToString());
return ex.Message;
}
}
private object UnShareAsset()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
var q = JsonConvert.DeserializeObject<SaveShareAssetParam>(clientdata);
if (string.IsNullOrEmpty(q.CustomerId))
q.CustomerId = SystemParams.CompanyID;
ShareAssetsProvider provider = CreateClient<ShareAssetsProvider>(q.CustomerId);
string[] results = new string[q.SharedIds.Length];
Task[] tasks = new Task[q.SharedIds.Length];
for (var i = 0; i < tasks.Length; i++)
{
var index = i;
var id = q.SharedIds[i];
tasks[i] = Task.Run(() =>
{
try
{
provider.UnShareAsset(q.CustomerId, id);
}
catch (Exception ex)
{
results[index] = ex.Message;
}
});
}
Task.WaitAll(tasks);
return results;
}
else
{
return null;
}
}
catch (Exception ex)
{
AddLog("ERROR", "ShareAssetBasePage.UnShareAsset", ex.Message, ex.ToString());
return ex.Message;
}
}
private object SetShareWithCustomers()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
var companyid = ps[0];
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
string[] ids = JsonConvert.DeserializeObject<string[]>(ps[1]);
string[] delids = JsonConvert.DeserializeObject<string[]>(ps[2]);
var client = CreateClient<ShareAssetsProvider>(companyid);
client.SetSharableCustomers(companyid, ids, true);
client.SetSharableCustomers(companyid, delids, false);
}
return "";
}
catch (Exception ex)
{
AddLog("ERROR", "ShareAssetBasePage.SetShareWithCustomers", ex.Message, ex.ToString());
return ex.Message;
}
}
}
class ShareAssetInfo : ShareAssetItem
{
public string ChildId { get; set; }
public string ChildName { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? ExpectedRetrievalDate { get; set; }
public DateTime? RetrievalDate { get; set; }
public string StartDateStr { get { return Helper.IsNullDateTime(StartDate) ? "" : StartDate.Value.ToShortDateString(); } }
public string ExpectedRetrievalDateStr { get { return Helper.IsNullDateTime(ExpectedRetrievalDate) ? "" : ExpectedRetrievalDate.Value.ToShortDateString(); } }
public string RetrievalDateStr { get { return Helper.IsNullDateTime(RetrievalDate) ? "" : RetrievalDate.Value.ToShortDateString(); } }
public double EngineHoursValue => EngineHours == null ? 0 : EngineHours.Value;
}
class AssetShareItem : AssetShareInfo
{
public string StartDateStr { get { return Helper.IsNullDateTime(StartDate) ? "" : StartDate.Value.ToShortDateString(); } }
public string ExpectedRetrievalDateStr { get { return Helper.IsNullDateTime(ExpectedRetrievalDate) ? "" : ExpectedRetrievalDate.Value.ToShortDateString(); } }
public string RetrievalDateStr { get { return Helper.IsNullDateTime(RetrievalDate) ? "" : RetrievalDate.Value.ToShortDateString(); } }
}
class ShareAssetQueryItem
{
public string CustomerId { get; set; }
public int Shared { get; set; }
public int OnRoad { get; set; }
public bool IncludeHidden { get; set; }
public string Filter { get; set; }
}
class SaveShareAssetParam
{
public string CustomerId { get; set; }
public long[] SharedIds { get; set; }
public string SharedWith { get; set; }
public string EndDate { get; set; }
public bool HideAsset { get; set; }
}
}