sync
This commit is contained in:
@ -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(); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
346
IronIntelContractorSiteLib/Asset/ShareAssetBasePage.cs
Normal file
346
IronIntelContractorSiteLib/Asset/ShareAssetBasePage.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Users;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -48,7 +45,7 @@ namespace IronIntel.Contractor.Site
|
||||
client.SessionID = session.SessionID;
|
||||
client.ClientHost = Request.UserHostName;
|
||||
client.ChangePassword(session.User.UID, oldpass, newpass, session.SessionID);
|
||||
Response.Write(string.Empty);
|
||||
Response.Write("\"\"");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
97
IronIntelContractorSiteLib/CommBase.cs
Normal file
97
IronIntelContractorSiteLib/CommBase.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using FI.FIC;
|
||||
using Foresight.Fleet.Services.Styles;
|
||||
using IronIntel.Contractor.iisitebase;
|
||||
using IronIntel.Contractor.Users;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class CommonBase : MasterPage
|
||||
{
|
||||
protected string CanExportFile = "false";
|
||||
protected string StyleVariables = "";
|
||||
|
||||
protected virtual bool ExportModule => false;
|
||||
|
||||
protected virtual StyleInfo GetUIStyle()
|
||||
{
|
||||
var sessionid = IronIntelBasePage.GetLoginSessionID(Request);
|
||||
var user = UserManagement.GetUserBySessionID(sessionid);
|
||||
CustUIStyle style = null;
|
||||
if (user != null)
|
||||
{
|
||||
if (ExportModule)
|
||||
{
|
||||
CanExportFile = FICHostEnvironment.CanExportToFile(user.IID).ToString().ToLower();
|
||||
}
|
||||
style = SystemParams.GetUIStyle(user.IID);
|
||||
string color;
|
||||
if (style != null)
|
||||
{
|
||||
color = style.TitleBarColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = "#f78e1e";
|
||||
}
|
||||
string opacity;
|
||||
string fore;
|
||||
try
|
||||
{
|
||||
var c = ColorTranslator.FromHtml(color);
|
||||
opacity = string.Format("rgb({0} {1} {2}/60%)", c.R, c.G, c.B);
|
||||
fore = (.299 * c.R + .587 * c.G + .114 * c.B) < 127.5 ? "#f0f0f0" : "#0f0f0f";
|
||||
}
|
||||
catch
|
||||
{
|
||||
opacity = "rgb(247 142 30/60%)";
|
||||
fore = "#0f0f0f";
|
||||
}
|
||||
StyleVariables = $"--title-color: {fore}; --title-bg-color: {color}; --title-bg-opacity-color: {opacity}";
|
||||
}
|
||||
return new StyleInfo
|
||||
{
|
||||
User = user,
|
||||
Style = style
|
||||
};
|
||||
}
|
||||
|
||||
protected string GetUrl(string file)
|
||||
{
|
||||
string url;
|
||||
Page page = HttpContext.Current.Handler as Page;
|
||||
if (page != null)
|
||||
{
|
||||
// Use page instance.
|
||||
url = page.ResolveUrl("~/") + file;
|
||||
}
|
||||
else
|
||||
{
|
||||
// avoid duplicate operation
|
||||
url = HttpContext.Current.Request.ApplicationPath + "/" + file;
|
||||
}
|
||||
try
|
||||
{
|
||||
var path = System.IO.Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, file);
|
||||
if (System.IO.File.Exists(path))
|
||||
{
|
||||
url += "?t=" + System.IO.File.GetLastWriteTimeUtc(path).Ticks;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// cant read file
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
public class StyleInfo
|
||||
{
|
||||
public UserInfo User { get; set; }
|
||||
public CustUIStyle Style { get; set; }
|
||||
}
|
||||
}
|
@ -6,10 +6,11 @@ using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Site;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Customers;
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using IronIntel.Contractor.iisitebase;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.Fleet.Services;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
@ -19,7 +20,7 @@ namespace IronIntel.Contractor.Site
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(companyid))
|
||||
{
|
||||
return SystemParams.GetCompanyLOGO(CompanyInfo.FORESIGHT);
|
||||
return SystemParams.GetCompanyLOGO(CustomerInfo.FORESIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -43,12 +44,8 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
public static byte[] GetCustomerLocationLOGO(int locationid)
|
||||
{
|
||||
CustomerProvider ic = SystemParams.GetCustomerProvider();
|
||||
return ic.GetCustomerLocationLOGO(locationid);
|
||||
}
|
||||
public override string GetIronSystemServiceAddress()
|
||||
{
|
||||
return SystemParams.SystemServiceAddresses[0];
|
||||
CustomerProvider ic = FleetServiceClientHelper.CreateClient<CustomerProvider>(SystemParams.CompanyID);
|
||||
return ic.GetLocationLOGO(SystemParams.CompanyID, locationid, true);
|
||||
}
|
||||
|
||||
public CommonHttpRequestHandler(HttpContext context)
|
||||
@ -62,6 +59,7 @@ namespace IronIntel.Contractor.Site
|
||||
if (string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
Context.Response.StatusCode = 204;
|
||||
Context.Response.Write(JsonConvert.SerializeObject(null));
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
@ -73,12 +71,14 @@ namespace IronIntel.Contractor.Site
|
||||
catch
|
||||
{
|
||||
Context.Response.StatusCode = 400;
|
||||
Context.Response.Write(JsonConvert.SerializeObject(null));
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
if (req == null)
|
||||
{
|
||||
Context.Response.StatusCode = 204;
|
||||
Context.Response.Write(JsonConvert.SerializeObject(null));
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
@ -101,8 +101,39 @@ namespace IronIntel.Contractor.Site
|
||||
case CommonRequestMethods.AddLog:
|
||||
AddLog(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.GetLanguageResVersion:
|
||||
GetLanguageResVersion(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.GetGridLayout:
|
||||
GetGridLayout(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.SetGridLayout:
|
||||
SetGridLayout(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.DeleteGridLayout:
|
||||
DeleteGridLayout(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.GetUserMessages:
|
||||
GetUserMessages(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.ReadUserMessages:
|
||||
ReadUserMessages(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.DeleteUserMessages:
|
||||
DeleteUserMessages(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.GetUnreadCount:
|
||||
GetUnreadCount(req.ClientData);
|
||||
return;
|
||||
case CommonRequestMethods.GetCurrentDate:
|
||||
GetCurrentDate();
|
||||
return;
|
||||
case CommonRequestMethods.GetGridLayouts:
|
||||
GetGridLayouts(req.ClientData);
|
||||
return;
|
||||
default:
|
||||
Context.Response.StatusCode = 204;
|
||||
Context.Response.Write(JsonConvert.SerializeObject(null));
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
@ -112,6 +143,7 @@ namespace IronIntel.Contractor.Site
|
||||
{
|
||||
if (LoginSession == null)
|
||||
{
|
||||
Context.Response.Write(JsonConvert.SerializeObject(null));
|
||||
Context.Response.StatusCode = 401;
|
||||
}
|
||||
else
|
||||
@ -122,11 +154,24 @@ namespace IronIntel.Contractor.Site
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetCurrentDate()
|
||||
{
|
||||
string s = string.Empty;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
DateTime dt = SystemParams.ConvertToUserTimeFromUtc(LoginSession.User, DateTime.UtcNow);
|
||||
s = dt.ToString("M/d/yyyy h:mm tt");
|
||||
}
|
||||
Context.Response.Write(JsonConvert.SerializeObject(s));
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetAppModules()
|
||||
{
|
||||
if (LoginSession == null)
|
||||
{
|
||||
Context.Response.StatusCode = 401;
|
||||
Context.Response.Write(JsonConvert.SerializeObject(null));
|
||||
Context.Response.End();
|
||||
return;
|
||||
}
|
||||
@ -140,7 +185,7 @@ namespace IronIntel.Contractor.Site
|
||||
{
|
||||
string s = LoginSession == null ? string.Empty : LoginSession.User.Name;
|
||||
|
||||
Context.Response.Write(s);
|
||||
Context.Response.Write(JsonConvert.SerializeObject(s));
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
@ -151,8 +196,185 @@ namespace IronIntel.Contractor.Site
|
||||
Context.Response.StatusCode = 200;
|
||||
try
|
||||
{
|
||||
string logininfo = "";
|
||||
if (LoginSession != null)
|
||||
{
|
||||
logininfo = LoginSession.SessionID;
|
||||
if (LoginSession.User != null)
|
||||
logininfo += "/" + LoginSession.User.ID;
|
||||
}
|
||||
string[] s = clientdata.Split(new char[] { SPLITCHAR });
|
||||
SystemParams.WriteLog(s[0], s[1], s[2], s[3]);
|
||||
SystemParams.WriteLog_Ext(s[0], s[1], s[2], s[3], logininfo);
|
||||
Context.Response.Write("\"OK\"");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetLanguageResVersion(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(clientdata))
|
||||
clientdata = "en-us";
|
||||
string file = clientdata + ".json";
|
||||
var path = System.IO.Path.Combine(System.Web.HttpContext.Current.Request.PhysicalApplicationPath, "Languages\\" + file);
|
||||
var ticks = System.IO.File.GetLastWriteTimeUtc(path).Ticks;
|
||||
string json = JsonConvert.SerializeObject(ticks);
|
||||
Context.Response.Write(json);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetGridLayout(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
string objid = clientdata;
|
||||
if (!string.IsNullOrEmpty(objid) && LoginSession != null)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<UserProfileProvider>(LoginSession.SessionID);
|
||||
var layout = client.GetGridLayout(SystemParams.CompanyID, LoginSession.User.UID, objid);
|
||||
Context.Response.Write(JsonConvert.SerializeObject(layout));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetGridLayouts(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
string objid = clientdata;
|
||||
if (!string.IsNullOrEmpty(objid) && LoginSession != null)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<UserProfileProvider>(LoginSession.SessionID);
|
||||
UserGridLayoutInfo[] layouts = client.GetGridLayouts(SystemParams.CompanyID, LoginSession.User.UID, objid);
|
||||
Context.Response.Write(JsonConvert.SerializeObject(layouts));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void SetGridLayout(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
var layoutinfo = JsonConvert.DeserializeObject<UserGridLayoutInfo>(ps[0]);
|
||||
if (layoutinfo.IsPublic && LoginSession.User.UserType < Foresight.Fleet.Services.User.UserTypes.Admin)
|
||||
Context.Response.Write("\"-1\"");
|
||||
|
||||
layoutinfo.UserIID = LoginSession.User.UID;
|
||||
bool overwrite = ps[1] == "1";
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<UserProfileProvider>(LoginSession.SessionID);
|
||||
int r = client.SetGridLayout(SystemParams.CompanyID, layoutinfo, overwrite);
|
||||
Context.Response.Write(JsonConvert.SerializeObject(r));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void DeleteGridLayout(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
string layoutid = clientdata;
|
||||
if (!string.IsNullOrEmpty(layoutid) && LoginSession != null)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<UserProfileProvider>(LoginSession.SessionID);
|
||||
//client.DeleteGridLayout(SystemParams.CompanyID, LoginSession.User.UID, int.Parse(objid));
|
||||
client.DeleteGridLayout(SystemParams.CompanyID, int.Parse(layoutid));
|
||||
Context.Response.Write("\"OK\"");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetUserMessages(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
int startid = 0;
|
||||
int.TryParse(clientdata, out startid);
|
||||
if (int.TryParse(clientdata, out startid) && LoginSession != null)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<MessageProvider>(LoginSession.SessionID);
|
||||
var msgs = client.GetMessages(SystemParams.CompanyID, startid);
|
||||
List<MessageInfoClient> msgls = new List<MessageInfoClient>();
|
||||
foreach (var msg in msgs)
|
||||
{
|
||||
MessageInfoClient mc = new MessageInfoClient();
|
||||
Helper.CloneProperty(mc, msg);
|
||||
msgls.Add(mc);
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(msgls);
|
||||
Context.Response.Write(json);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void ReadUserMessages(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
long[] msgids = JsonConvert.DeserializeObject<long[]>(clientdata);
|
||||
if (msgids.Length > 0 && LoginSession != null)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<MessageProvider>(LoginSession.SessionID);
|
||||
client.MarkReaded(SystemParams.CompanyID, msgids);
|
||||
Context.Response.Write("\"OK\"");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void DeleteUserMessages(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
long[] msgids = JsonConvert.DeserializeObject<long[]>(clientdata);
|
||||
if (msgids.Length > 0 && LoginSession != null)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<MessageProvider>(LoginSession.SessionID);
|
||||
client.DeleteMessage(SystemParams.CompanyID, msgids);
|
||||
Context.Response.Write("\"OK\"");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
Context.Response.End();
|
||||
}
|
||||
|
||||
private void GetUnreadCount(string clientdata)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<MessageProvider>(LoginSession.SessionID);
|
||||
int count = client.GetNewMessageNumber(SystemParams.CompanyID);
|
||||
Context.Response.Write(JsonConvert.SerializeObject(count));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@ -177,6 +399,21 @@ namespace IronIntel.Contractor.Site
|
||||
GetCurrentLoginName = 2,
|
||||
AddLog = 3,
|
||||
GetMachineMapPinItem = 4,
|
||||
GetJobSiteMapItem = 5
|
||||
GetJobSiteMapItem = 5,
|
||||
GetLanguageResVersion = 6,
|
||||
GetGridLayout = 7,
|
||||
SetGridLayout = 8,
|
||||
DeleteGridLayout = 9,
|
||||
GetUserMessages = 10,
|
||||
ReadUserMessages = 11,
|
||||
DeleteUserMessages = 12,
|
||||
GetUnreadCount = 13,
|
||||
GetCurrentDate = 14,
|
||||
GetGridLayouts = 15
|
||||
}
|
||||
|
||||
public class MessageInfoClient : MessageInfo
|
||||
{
|
||||
public string CreatedTimeStr { get { return CreatedTime < new DateTime(2000, 1, 1) ? "" : CreatedTime.ToString(); } }
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ namespace IronIntel.Contractor.Site.Contact
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.UrlDecode(s);
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", false);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
@ -243,7 +243,7 @@ namespace IronIntel.Contractor.Site.Contact
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var contactid = Request.Form["ClientData"];
|
||||
contactid = HttpUtility.UrlDecode(contactid);
|
||||
contactid = HttpUtility.HtmlDecode(contactid);
|
||||
|
||||
items = ContactManagement.GetContactJobsitesByID(contactid);
|
||||
}
|
||||
|
@ -2,15 +2,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Users;
|
||||
using IronIntel.Site;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Customers;
|
||||
using System.Web;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.Fleet.Services.Style;
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Contractor.iisitebase;
|
||||
using Foresight.Standard;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
@ -47,7 +47,7 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
}
|
||||
|
||||
protected IronIntel.Contractor.Users.UserInfo GetCurrentUser()
|
||||
protected Users.UserInfo GetCurrentUser()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null)
|
||||
@ -69,10 +69,23 @@ namespace IronIntel.Contractor.Site
|
||||
return (user.UserType == Users.UserTypes.Admin || user.UserType == Users.UserTypes.SupperAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetIronSystemServiceAddress()
|
||||
protected virtual bool AllowCurrentLoginSessionEnter(LoginSession session)
|
||||
{
|
||||
return SystemParams.SystemServiceAddresses[0];
|
||||
if (session == null)
|
||||
session = GetCurrentLoginSession();
|
||||
if (session == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Compare(session.User.CompanyID, SystemParams.CompanyID, true) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (string.Compare(session.User.CompanyID, CustomerInfo.FORESIGHT, true) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return CreateClient<UserQueryClient>().CanEnterSite(session.SessionID, SystemParams.CompanyID);
|
||||
}
|
||||
|
||||
protected virtual bool AllowCurrentLoginSessionEnter()
|
||||
@ -86,11 +99,11 @@ namespace IronIntel.Contractor.Site
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (string.Compare(session.User.CompanyID, CompanyInfo.FORESIGHT, true) == 0)
|
||||
if (string.Compare(session.User.CompanyID, CustomerInfo.FORESIGHT, true) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return CreateClient<Foresight.Fleet.Services.User.UserQueryClient>().CanEnterSite(session.SessionID, SystemParams.CompanyID);
|
||||
return CreateClient<UserQueryClient>().CanEnterSite(session.SessionID, SystemParams.CompanyID);
|
||||
}
|
||||
|
||||
protected virtual bool ThrowIfNotAllowed { get { return false; } }
|
||||
@ -152,7 +165,12 @@ namespace IronIntel.Contractor.Site
|
||||
RedirectToLoginPage();
|
||||
return false;
|
||||
}
|
||||
if (!AllowCurrentLoginSessionEnter() || !CheckRight(FeatureID))
|
||||
if (!session.User.AllowLoginIntoPC)
|
||||
{
|
||||
RedirectToErrorPage();
|
||||
return false;
|
||||
}
|
||||
if (!AllowCurrentLoginSessionEnter(session) || !CheckRight(FeatureID))
|
||||
{
|
||||
if (ThrowIfNotAllowed)
|
||||
{
|
||||
@ -160,7 +178,7 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
else
|
||||
{
|
||||
RedirectToEntryPage();
|
||||
RedirectToErrorPage();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -193,6 +211,13 @@ namespace IronIntel.Contractor.Site
|
||||
Response.Redirect(LoginPageUrl, true);
|
||||
}
|
||||
|
||||
protected void RedirectToErrorPage()
|
||||
{
|
||||
var url = Request.Url;
|
||||
var addr = string.Format("{0}://{1}:{2}{3}/ErrorPage.aspx?code=403", url.Scheme, url.Host, url.Port, Request.ApplicationPath);
|
||||
Response.Redirect(addr, true);
|
||||
}
|
||||
|
||||
protected void DoLogout()
|
||||
{
|
||||
string sid = null;
|
||||
@ -222,7 +247,14 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
}
|
||||
|
||||
RedirectToLoginPage();
|
||||
//RedirectToLoginPage();
|
||||
RedirectToLoginPageAndClearCookie();
|
||||
}
|
||||
|
||||
protected void RedirectToLoginPageAndClearCookie()
|
||||
{//由于登录站点和Contractor站得Webconfig的sessioncookiedomain配置不一样导致ClearLoginSessionCookie无法清除Sessionid的cookie
|
||||
//增加tp=c,在登录页面清除Sessionid的cookie
|
||||
Response.Redirect(LoginPageUrl + "?tp=c");
|
||||
}
|
||||
|
||||
protected void AddLog(string type, string source, string message, string detail)
|
||||
@ -277,13 +309,15 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
public virtual string JQueryVersion
|
||||
{
|
||||
get { return "1.8.0"; }
|
||||
get { return "3.6.0"; }
|
||||
}
|
||||
|
||||
protected T CreateClient<T>(string companyid = null) where T : RemoteClientBase
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
return FleetServiceClientHelper.CreateClient<T>(companyid, session == null ? "" : session.SessionID);
|
||||
var client = FleetServiceClientHelper.CreateClient<T>(string.IsNullOrEmpty(companyid) ? SystemParams.CompanyID : companyid, session == null ? "" : session.SessionID);
|
||||
client.Timeout = 300;
|
||||
return client;
|
||||
}
|
||||
protected bool CheckRight(int featureid)
|
||||
{
|
||||
@ -292,7 +326,7 @@ namespace IronIntel.Contractor.Site
|
||||
return CheckRight(SystemParams.CompanyID, featureid);
|
||||
}
|
||||
|
||||
protected bool CheckRight(string custid, int featureid)
|
||||
protected bool CheckRight(string custid, int featureid, Permissions per = Permissions.ReadOnly)
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user == null)
|
||||
@ -308,7 +342,53 @@ namespace IronIntel.Contractor.Site
|
||||
if (pmss.Length > 0)
|
||||
{
|
||||
Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid);
|
||||
if (permission != null)
|
||||
if (permission != null && permission.Item2 >= per)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool CheckReadonly(string custid, int featureid)
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user == null)
|
||||
return false;
|
||||
|
||||
if (user.UserType == Users.UserTypes.SupperAdmin || user.UserType == Users.UserTypes.Admin)
|
||||
return false;
|
||||
|
||||
if (user.UserType == Users.UserTypes.Common)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<PermissionProvider>();
|
||||
Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(custid, user.IID);
|
||||
if (pmss.Length > 0)
|
||||
{
|
||||
Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid);
|
||||
if (permission != null && permission.Item2 == Permissions.ReadOnly)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool CanEdit(string custid, int featureid, Permissions per = Permissions.FullControl)
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user == null)
|
||||
return false;
|
||||
|
||||
if (user.UserType == Users.UserTypes.SupperAdmin || user.UserType == Users.UserTypes.Admin)
|
||||
return true;
|
||||
|
||||
if (user.UserType == Users.UserTypes.Common)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<PermissionProvider>();
|
||||
Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(custid, user.IID);
|
||||
if (pmss.Length > 0)
|
||||
{
|
||||
Tuple<Feature, Permissions> permission = pmss.FirstOrDefault(m => m.Item1.Id == featureid);
|
||||
if (permission != null && permission.Item2 >= per)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,331 +0,0 @@
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.CredentialObjects;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class CredentialEntryBasePage : ContractorBasePage
|
||||
{
|
||||
private const string AEMP = "AEMPFLEET";
|
||||
private const string JDAPI = "JDAPI";
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetCredentials":
|
||||
GetCredentials();
|
||||
break;
|
||||
case "SaveCredential":
|
||||
SaveCredential(true);
|
||||
break;
|
||||
case "DeleteCredential":
|
||||
DeleteCredential();
|
||||
break;
|
||||
case "GetAEMPSources":
|
||||
GetAEMPSources();
|
||||
break;
|
||||
case "GetJDLinkCredentials":
|
||||
GetJDLinkCredentials();
|
||||
break;
|
||||
case "AuthorizeRequestToken":
|
||||
AuthorizeRequestToken();
|
||||
break;
|
||||
case "FinishJDLinkOAuthRequest":
|
||||
FinishJDLinkOAuthRequest();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
private void GetCredentials()
|
||||
{
|
||||
string type = Request.Form["ClientData"];
|
||||
string creType = "";
|
||||
switch (type)
|
||||
{
|
||||
case "AEMP":
|
||||
creType = AEMP;
|
||||
break;
|
||||
}
|
||||
CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
CredentialInfo[] creInfos = crd.GetCredentialByCompanyID(SystemParams.CompanyID, creType);
|
||||
|
||||
List<CredentialObj> creObjs = new List<CredentialObj>();
|
||||
foreach (var cre in creInfos)
|
||||
{
|
||||
creObjs.Add(ConvertFromAEMP(cre));
|
||||
}
|
||||
var items = creObjs.OrderBy((c) => c.UserName).ToArray();
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void SaveCredential(bool adduser)
|
||||
{
|
||||
var content = Request.Form["ClientData"];
|
||||
content = HttpUtility.HtmlDecode(content);
|
||||
var item = JsonConvert.DeserializeObject<CredentialObj>(content);
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.ID))
|
||||
item.ID = Guid.NewGuid().ToString();
|
||||
CredentialInfo creInfo = null;
|
||||
switch (item.CredentialType)
|
||||
{
|
||||
case "AEMP":
|
||||
creInfo = ConvertToAEMP(item);
|
||||
break;
|
||||
}
|
||||
if (creInfo != null)
|
||||
{
|
||||
CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
crd.UpdateCredential(creInfo);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
return;
|
||||
}
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
private void DeleteCredential()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
Guid guid;
|
||||
if (!Guid.TryParse(iid, out guid))
|
||||
{
|
||||
throw new ArgumentException("Credential IID is not valid.");
|
||||
}
|
||||
CredentialManagementClient crd = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
crd.DeleteCredential(iid);
|
||||
}
|
||||
|
||||
private void GetAEMPSources()
|
||||
{
|
||||
IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient();
|
||||
AEMPSourceInfo[] sources = ic.GetAEMPSourceInfo();
|
||||
|
||||
List<AEMPSourceItem> list = new List<AEMPSourceItem>();
|
||||
foreach (var source in sources)
|
||||
{
|
||||
AEMPSourceItem item = new AEMPSourceItem();
|
||||
Helper.CloneProperty(item, source);
|
||||
list.Add(item);
|
||||
}
|
||||
var items = list.OrderBy((c) => c.ManufactureName).ToArray();
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
#region AEMP
|
||||
|
||||
private CredentialObj ConvertFromAEMP(CredentialInfo cre)
|
||||
{
|
||||
CredentialObj result = new CredentialObj();
|
||||
result.ID = cre.ID;
|
||||
result.CredentialType = cre.CredentialType;
|
||||
|
||||
AEMPCredential aemp = new AEMPCredential();
|
||||
aemp.FillFromXml(cre.Credential);
|
||||
if (aemp != null)
|
||||
{
|
||||
result.Manufacture = aemp.ManufactureID;
|
||||
result.UserName = aemp.UserName;
|
||||
result.Password = aemp.Password;
|
||||
result.Enabled = aemp.Enabled;
|
||||
result.UrlKey = aemp.UrlKey;
|
||||
result.OrgnizationID = aemp.OrgnizationID;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private CredentialInfo ConvertToAEMP(CredentialObj cre)
|
||||
{
|
||||
CredentialInfo result = new CredentialInfo();
|
||||
result.ID = cre.ID;
|
||||
result.CredentialType = AEMP;
|
||||
result.CompanyID = SystemParams.CompanyID;
|
||||
|
||||
AEMPCredential aemp = new AEMPCredential();
|
||||
aemp.ManufactureID = cre.Manufacture;
|
||||
aemp.UserName = cre.UserName;
|
||||
aemp.Password = cre.Password;
|
||||
aemp.Enabled = cre.Enabled;
|
||||
aemp.UrlKey = cre.UrlKey;
|
||||
aemp.OrgnizationID = cre.OrgnizationID;
|
||||
|
||||
result.Credential = aemp.ToString();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JDLink credential
|
||||
private void GetJDLinkCredentials()
|
||||
{
|
||||
CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
JDCredential[] jds = client.GetJDLinkCredentials(SystemParams.CompanyID);
|
||||
List<JDCredentialObj> list = new List<JDCredentialObj>();
|
||||
foreach (var jd in jds)
|
||||
{
|
||||
JDCredentialObj item = new JDCredentialObj();
|
||||
item.ID = jd.ID;
|
||||
item.UserName = jd.Credential.UserName;
|
||||
item.ExpirationDateUtc = jd.Credential.ExpirationDateUtc;
|
||||
item.ConsumerKey = jd.Credential.ConsumerKey;
|
||||
item.AuthorityUrl = jd.Credential.AuthorityUrl;
|
||||
list.Add(item);
|
||||
}
|
||||
var items = list.OrderBy(m => m.UserName).ToArray();
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void AuthorizeRequestToken()
|
||||
{
|
||||
string username = Request.Form["ClientData"];
|
||||
username = HttpUtility.HtmlDecode(username);
|
||||
CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
JDCredential[] jds = client.GetJDLinkCredentials(SystemParams.CompanyID);
|
||||
JDCredential jd = jds.FirstOrDefault(m => m.Credential.UserName == username);
|
||||
if (jd != null)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject("User name already exists."));
|
||||
Response.End();
|
||||
}
|
||||
StringKeyValue kv = GetJDLinkApiKey();
|
||||
if (kv == null)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject("The JDLink Key does not exist,Please contact the administrator."));
|
||||
Response.End();
|
||||
}
|
||||
JDOAuthData data = client.GetJDLinkAuthorizeRequestOAuth(kv.Key, kv.Value);
|
||||
string json = JsonConvert.SerializeObject(data);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
public void FinishJDLinkOAuthRequest()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var authordata = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
string virifier = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
JDOAuthData oriauthdata = JsonConvert.DeserializeObject<JDOAuthData>(authordata);
|
||||
CredentialManagementClient client = SystemParams.GetServiceClient<CredentialManagementClient>();
|
||||
JDOAuthData data = client.FinishJDLinkOAuthRequest(oriauthdata, virifier);
|
||||
CredentialInfo ci = new CredentialInfo();
|
||||
ci.ID = Guid.NewGuid().ToString().ToUpper();
|
||||
ci.CompanyID = SystemParams.CompanyID;
|
||||
ci.CredentialType = "JDLINK";
|
||||
JDCredential jd = new JDCredential();
|
||||
jd.Credential = data;
|
||||
jd.Enabled = true;
|
||||
ci.Credential = jd.ToString();
|
||||
client.UpdateCredential(ci);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
return;
|
||||
}
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
private StringKeyValue GetJDLinkApiKey()
|
||||
{
|
||||
string key = SystemParams.GetStringParam("JDAPIConsumerKey");
|
||||
if (string.IsNullOrWhiteSpace(key))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string sec = SystemParams.GetStringParam("JDAPIConsumerSecret");
|
||||
if (string.IsNullOrWhiteSpace(sec))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = key;
|
||||
kv.Value = sec;
|
||||
return kv;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 用于传输的临时Credential类
|
||||
/// </summary>
|
||||
public class CredentialObj
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string CredentialType { get; set; }
|
||||
public string Manufacture { get; set; }
|
||||
public string UrlKey { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public string OrgnizationID { get; set; }
|
||||
}
|
||||
|
||||
public class AEMPSourceItem
|
||||
{
|
||||
public string ManufactureID { get; set; }
|
||||
public string ManufactureName { get; set; }
|
||||
public string FleetUrl { get; set; }
|
||||
public string AutoServiceClass { get; set; }
|
||||
}
|
||||
|
||||
public class JDCredentialObj
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string ConsumerKey { get; set; }
|
||||
public string AuthorityUrl { get; set; }
|
||||
public DateTime ExpirationDateUtc { get; set; }
|
||||
public string ExpirationDateUtcStr { get { return ExpirationDateUtc == DateTime.MinValue ? "" : ExpirationDateUtc.ToShortDateString(); } }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,424 @@
|
||||
using FI.FIC.Contracts.DataObjects.BaseObject;
|
||||
using Foresight.Fleet.Services.Credentials;
|
||||
using Foresight.Fleet.Services.Credentials.JDAPI;
|
||||
using Foresight.Service.Credential.Common;
|
||||
using Foresight.Service.Credential.JDAPI;
|
||||
using Foresight.ServiceModel;
|
||||
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;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Credentials
|
||||
{
|
||||
public class CredentialEntryBasePage : ContractorBasePage
|
||||
{
|
||||
private const string AEMP = "AEMPFLEET";
|
||||
private const string JDAPI = "JDAPI";
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetAEMPCredentials":
|
||||
GetAEMPCredentials();
|
||||
break;
|
||||
case "UpdateAEMPCredential":
|
||||
UpdateAEMPCredential();
|
||||
break;
|
||||
case "DeleteAEMPCredential":
|
||||
DeleteAEMPCredential();
|
||||
break;
|
||||
case "DeleteToken":
|
||||
DeleteToken();
|
||||
break;
|
||||
case "GetJDLinkTokenItems":
|
||||
GetJDLinkTokenItems();
|
||||
break;
|
||||
case "CreateJDLinkAuthUrl":
|
||||
CreateJDLinkAuthUrl();
|
||||
break;
|
||||
case "GetAPIDictionaries":
|
||||
GetAPIDictionaries();
|
||||
break;
|
||||
case "GetAPICredentialDefs":
|
||||
GetAPICredentialDefs();
|
||||
break;
|
||||
case "UpdateApiCredentialDefs":
|
||||
UpdateApiCredentialDefs();
|
||||
break;
|
||||
case "DeleteApiCredential":
|
||||
DeleteApiCredential();
|
||||
break;
|
||||
case "GetNotificationSubscriptions":
|
||||
GetNotificationSubscriptions();
|
||||
break;
|
||||
case "CreateJDSubPubAuthUrl":
|
||||
CreateJDSubPubAuthUrl();
|
||||
break;
|
||||
case "DeleteNotificationSubscription":
|
||||
DeleteNotificationSubscription();
|
||||
break;
|
||||
case "GetMyJDAPITokenItems":
|
||||
GetMyJDAPITokenItems();
|
||||
break;
|
||||
case "CreateMyJDAPIAuthUrl":
|
||||
CreateMyJDAPIAuthUrl();
|
||||
break;
|
||||
case "GetOrganizations":
|
||||
GetOrganizations();
|
||||
break;
|
||||
case "GetJDOrganizationUrl":
|
||||
GetJDOrganizationUrl();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
#region AEMP credential
|
||||
private void GetAEMPCredentials()
|
||||
{
|
||||
CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>();
|
||||
AEMPInfo[] items = crd.GetAEMPCredentials(SystemParams.CompanyID);
|
||||
if (items == null)
|
||||
items = new AEMPInfo[0];
|
||||
|
||||
items = items.OrderBy((c) => c.UserName).ToArray();
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void UpdateAEMPCredential()
|
||||
{
|
||||
var content = Request.Form["ClientData"];
|
||||
content = HttpUtility.HtmlDecode(content);
|
||||
var aempinfo = JsonConvert.DeserializeObject<AEMPInfo>(content);
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(aempinfo.ID))
|
||||
aempinfo.ID = Guid.NewGuid().ToString();
|
||||
|
||||
CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>();
|
||||
crd.UpdateAEMPCredential(SystemParams.CompanyID, aempinfo);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
return;
|
||||
}
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
private void DeleteAEMPCredential()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
Guid guid;
|
||||
if (!Guid.TryParse(iid, out guid))
|
||||
{
|
||||
throw new ArgumentException("Credential IID is not valid.");
|
||||
}
|
||||
CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>();
|
||||
crd.DeleteAEMPCredential(SystemParams.CompanyID, iid);
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region JDLink credential
|
||||
private void GetJDLinkTokenItems()
|
||||
{
|
||||
var user = GetCurrentLoginSession().User;
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
AuthTokenItem[] items = client.GetJDLinkTokenItems(SystemParams.CompanyID);
|
||||
List<AuthTokenInfo> ls = new List<AuthTokenInfo>();
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
foreach (AuthTokenItem item in items)
|
||||
{
|
||||
AuthTokenInfo ai = new AuthTokenInfo();
|
||||
Helper.CloneProperty(ai, item);
|
||||
ai.RequestTime = SystemParams.ConvertToUserTimeFromUtc(user, item.RequestTimeUtc);
|
||||
ls.Add(ai);
|
||||
}
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(ls);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void CreateJDLinkAuthUrl()
|
||||
{
|
||||
string absuri = Request.Url.AbsoluteUri;
|
||||
string url = absuri.Substring(0, absuri.LastIndexOf('/'));
|
||||
string redirecturl = url + "/Credentials.aspx?isjdlink=true";
|
||||
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
string result = client.CreateJDLinkAuthUrl(SystemParams.CompanyID, redirecturl);
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void DeleteToken()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
client.DeleteToken(SystemParams.CompanyID, iid, GetCurrentUser().IID, string.Empty);
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MyJohnDeere
|
||||
private void GetMyJDAPITokenItems()
|
||||
{
|
||||
var user = GetCurrentLoginSession().User;
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
AuthTokenItem[] items = client.GetMyJDAPITokenItems(SystemParams.CompanyID);
|
||||
List<AuthTokenInfo> ls = new List<AuthTokenInfo>();
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
foreach (AuthTokenItem item in items)
|
||||
{
|
||||
AuthTokenInfo ai = new AuthTokenInfo();
|
||||
Helper.CloneProperty(ai, item);
|
||||
ai.RequestTime = SystemParams.ConvertToUserTimeFromUtc(user, item.RequestTimeUtc);
|
||||
ls.Add(ai);
|
||||
}
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(ls);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void CreateMyJDAPIAuthUrl()
|
||||
{
|
||||
string absuri = Request.Url.AbsoluteUri;
|
||||
string url = absuri.Substring(0, absuri.LastIndexOf('/'));
|
||||
string redirecturl = url + "/Credentials.aspx?ismyjd=true";
|
||||
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
string result = client.CreateMyJDAPIAuthUrl(SystemParams.CompanyID, redirecturl);
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region JDNotification credential
|
||||
|
||||
private void GetNotificationSubscriptions()
|
||||
{
|
||||
var user = GetCurrentLoginSession().User;
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
SubscriptionItem[] items = client.GetNotificationSubscriptions(SystemParams.CompanyID);
|
||||
List<SubscriptionInfo> ls = new List<SubscriptionInfo>();
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
foreach (SubscriptionItem item in items)
|
||||
{
|
||||
SubscriptionInfo ai = new SubscriptionInfo();
|
||||
Helper.CloneProperty(ai, item);
|
||||
ai.CreateTime = SystemParams.ConvertToUserTimeFromUtc(user, item.CreateTimeUtc);
|
||||
ls.Add(ai);
|
||||
}
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(ls);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void CreateJDSubPubAuthUrl()
|
||||
{
|
||||
var name = Request.Form["ClientData"];
|
||||
string absuri = Request.Url.AbsoluteUri;
|
||||
string url = absuri.Substring(0, absuri.LastIndexOf('/'));
|
||||
string redirecturl = url + "/Credentials.aspx?isjdsub=true";
|
||||
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
string result = client.CreateJDSubPubAuthUrl(SystemParams.CompanyID, redirecturl, name);
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void DeleteNotificationSubscription()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
client.DeleteNotificationSubscription(SystemParams.CompanyID, iid);
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region API Credential
|
||||
|
||||
private void GetAPIDictionaries()
|
||||
{
|
||||
CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>();
|
||||
APIDictionary[] items = crd.GetAPIDictionaries(SystemParams.CompanyID);
|
||||
items = items.Where(m => m.IsEnabled == true).ToArray();
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void GetAPICredentialDefs()
|
||||
{
|
||||
CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>();
|
||||
APICredentialDef[] items = crd.GetAPICredentialDefs(SystemParams.CompanyID);
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void UpdateApiCredentialDefs()
|
||||
{
|
||||
var content = Request.Form["ClientData"];
|
||||
content = HttpUtility.HtmlDecode(content);
|
||||
var item = JsonConvert.DeserializeObject<APICredentialDef>(content);
|
||||
|
||||
try
|
||||
{
|
||||
CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>();
|
||||
crd.UpdateApiCredentialDefs(SystemParams.CompanyID, item, GetCurrentUser().IID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Response.Write(JsonConvert.SerializeObject(ex.Message));
|
||||
return;
|
||||
}
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
private void DeleteApiCredential()
|
||||
{
|
||||
var id = Request.Form["ClientData"];
|
||||
CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>();
|
||||
crd.DeleteApiCredential(SystemParams.CompanyID, Convert.ToInt32(id), GetCurrentUser().IID);
|
||||
|
||||
Response.Write("\"OK\"");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void GetOrganizations()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
JDOrganizationInfo[] items = client.GetOrganizations(SystemParams.CompanyID, iid);
|
||||
if (items == null)
|
||||
items = new JDOrganizationInfo[0];
|
||||
|
||||
string json = JsonConvert.SerializeObject(items);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void GetJDOrganizationUrl()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
JDAPICredentialProvider client = FleetServiceClientHelper.CreateClient<JDAPICredentialProvider>();
|
||||
string url = client.GetJDOrganizationUrl(SystemParams.CompanyID, iid);
|
||||
string json = JsonConvert.SerializeObject(url);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用于传输的临时Credential类
|
||||
/// </summary>
|
||||
public class CredentialObj
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string CredentialType { get; set; }
|
||||
public string Manufacture { get; set; }
|
||||
public string UrlKey { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public string OrgnizationID { get; set; }
|
||||
public string Notes { get; set; }
|
||||
}
|
||||
|
||||
public class AEMPSourceItem
|
||||
{
|
||||
public string ManufactureID { get; set; }
|
||||
public string ManufactureName { get; set; }
|
||||
public string FleetUrl { get; set; }
|
||||
public string AutoServiceClass { get; set; }
|
||||
}
|
||||
|
||||
public class JDCredentialObj
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string ConsumerKey { get; set; }
|
||||
public string AuthorityUrl { get; set; }
|
||||
public DateTime ExpirationDateUtc { get; set; }
|
||||
public string ExpirationDateUtcStr { get { return ExpirationDateUtc == DateTime.MinValue ? "" : ExpirationDateUtc.ToShortDateString(); } }
|
||||
}
|
||||
public class JDNotifySubItem
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public DateTime ExpireDate { get; set; }
|
||||
public string ExpireDateStr { get { return ExpireDate == DateTime.MinValue ? "" : ExpireDate.ToShortDateString(); } }
|
||||
}
|
||||
|
||||
public class AuthTokenInfo : AuthTokenItem
|
||||
{
|
||||
public DateTime RequestTime { get; set; }
|
||||
public string RequestTimeStr { get { return RequestTime == DateTime.MinValue ? "" : RequestTime.ToString(); } }
|
||||
}
|
||||
|
||||
public class SubscriptionInfo : SubscriptionItem
|
||||
{
|
||||
public DateTime CreateTime { get; set; }
|
||||
public string CreateTimeStr { get { return CreateTime == DateTime.MinValue ? "" : CreateTime.ToString(); } }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Credentials
|
||||
{
|
||||
public class CredentialsBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETNAVS":
|
||||
result = GetNavigations();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private CredentialNavigateItem[] GetNavigations()
|
||||
{
|
||||
List<CredentialNavigateItem> list = GetNavigateItems();
|
||||
LicenseInfo license = SystemParams.GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
var jdn = license.Items.FirstOrDefault(m => m.Key == "JohnDeereNotifications");
|
||||
if (jdn == null || !Helper.IsTrue(jdn.Value))
|
||||
{
|
||||
CredentialNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_jdnotification");
|
||||
list.Remove(item);
|
||||
}
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
|
||||
public static List<CredentialNavigateItem> GetNavigateItems()
|
||||
{
|
||||
List<CredentialNavigateItem> list = new List<CredentialNavigateItem>();
|
||||
|
||||
CredentialNavigateItem item1 = new CredentialNavigateItem();
|
||||
item1.ID = "nav_credential";
|
||||
item1.Title = "Credentials";
|
||||
item1.Url = "ManageCredential.aspx";
|
||||
item1.IconPath = "img/credential.png";
|
||||
list.Add(item1);
|
||||
|
||||
CredentialNavigateItem item2 = new CredentialNavigateItem();
|
||||
item2.ID = "nav_jdlink";
|
||||
item2.Title = "JD Link";
|
||||
item2.Url = "ManageJDLink.aspx";
|
||||
item2.IconPath = "img/jdlink.png";
|
||||
list.Add(item2);
|
||||
|
||||
//CredentialNavigateItem item3 = new CredentialNavigateItem();
|
||||
//item3.ID = "nav_jdnotification";
|
||||
//item3.Title = "JohnDeere Notifications";
|
||||
//item3.Url = "ManageJDNotifications.aspx";
|
||||
//item3.IconPath = "img/jdnotifications.png";
|
||||
//list.Add(item3);
|
||||
|
||||
CredentialNavigateItem item4 = new CredentialNavigateItem();
|
||||
item4.ID = "nav_apicredential";
|
||||
item4.Title = "API Credentials";
|
||||
item4.Url = "ManageAPICredential.aspx";
|
||||
item4.IconPath = "img/apicredential.png";
|
||||
list.Add(item4);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
594
IronIntelContractorSiteLib/Customer/CustomerRecordBasePage.cs
Normal file
594
IronIntelContractorSiteLib/Customer/CustomerRecordBasePage.cs
Normal file
@ -0,0 +1,594 @@
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Foresight.Fleet.Services.Partner;
|
||||
using Foresight.Fleet.Services;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Customer
|
||||
{
|
||||
public class CustomerRecordBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest()
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
string methodName = Request.Params["MethodName"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetPartners":
|
||||
result = GetPartners();
|
||||
break;
|
||||
case "GetCustomerRecordInfo":
|
||||
result = GetPartner();
|
||||
break;
|
||||
case "SaveCustomerRecord":
|
||||
result = SavePartner();
|
||||
break;
|
||||
case "DeletePartner":
|
||||
result = DeletePartner();
|
||||
break;
|
||||
case "GetContacts":
|
||||
result = GetContacts();
|
||||
break;
|
||||
case "SaveContact":
|
||||
result = SaveContact();
|
||||
break;
|
||||
case "DeleteContact":
|
||||
result = DeleteContact();
|
||||
break;
|
||||
case "GetCustomerComments":
|
||||
result = GetComments();
|
||||
break;
|
||||
case "SubmitComment":
|
||||
result = SubmitComment();
|
||||
break;
|
||||
case "GetAssignedMachines":
|
||||
result = GetAssignedMachines();
|
||||
break;
|
||||
case "AssignMachines":
|
||||
result = AssignMachines();
|
||||
break;
|
||||
case "RemoveAssignedMachines":
|
||||
result = RemoveAssignedMachines();
|
||||
break;
|
||||
case "GetAssignedPartnersByMachine":
|
||||
result = GetAssignedPartnersByMachine();
|
||||
break;
|
||||
case "GetSalespersons":
|
||||
result = GetSalespersons();
|
||||
break;
|
||||
case "GetAllFollowers":
|
||||
result = GetAllFollowers();
|
||||
break;
|
||||
case "GetFollowers":
|
||||
result = GetFollowers();
|
||||
break;
|
||||
case "AddFollowers":
|
||||
result = AddFollowers();
|
||||
break;
|
||||
case "DeleteFollower":
|
||||
result = DeleteFollower();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "CustomerRecordBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetPartners()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
BusinessPartnerInfo[] partners = CreateClient<BusinessPartnerProvider>().GetPartners(SystemParams.CompanyID, clientdata);
|
||||
return partners;
|
||||
}
|
||||
else
|
||||
return new BusinessPartnerInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetPartner()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var id = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
BusinessPartnerInfo partner = CreateClient<BusinessPartnerProvider>().GetPartner(SystemParams.CompanyID, Convert.ToInt32(id));
|
||||
if (partner == null)
|
||||
return new BusinessPartnerInfo();
|
||||
|
||||
return partner;
|
||||
}
|
||||
else
|
||||
return new BusinessPartnerInfo();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetAssignedPartnersByMachine()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var assetid = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
BusinessPartnerInfo[] partners = CreateClient<BusinessPartnerProvider>().GetAssignedPartnersByMachine(SystemParams.CompanyID, Convert.ToInt64(assetid));
|
||||
return partners;
|
||||
}
|
||||
else
|
||||
return new BusinessPartnerInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SavePartner()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var data = HttpUtility.HtmlDecode(clientdata);
|
||||
BusinessPartnerInfo partner = JsonConvert.DeserializeObject<BusinessPartnerInfo>(data);
|
||||
if (partner.Id > 0)
|
||||
CreateClient<BusinessPartnerProvider>().UpdatePartner(SystemParams.CompanyID, partner);
|
||||
else
|
||||
partner.Id = CreateClient<BusinessPartnerProvider>().AddNewPartner(SystemParams.CompanyID, partner);
|
||||
return partner.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeletePartner()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var id = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
CreateClient<BusinessPartnerProvider>().DeletePartner(SystemParams.CompanyID, Convert.ToInt32(id));
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetContacts()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string custid = Request.Form["ClientData"];
|
||||
custid = HttpUtility.HtmlDecode(custid);
|
||||
|
||||
ContactInfo[] contacts = CreateClient<BusinessPartnerProvider>().GetContacts(SystemParams.CompanyID, int.Parse(custid));
|
||||
if (contacts == null || contacts.Length == 0)
|
||||
return new ContactInfo[0];
|
||||
|
||||
var lang = GetLanguageCookie();
|
||||
List<ContactInfoClient> ls = new List<ContactInfoClient>();
|
||||
foreach (var pa in contacts)
|
||||
{
|
||||
ContactInfoClient item = new ContactInfoClient();
|
||||
Helper.CloneProperty(item, pa);
|
||||
if ((int)item.ContactPreference == 0)
|
||||
item.ContactPreferenceStr = SystemParams.GetTextByKey(lang, "P_CR_TEXT", "Text");
|
||||
else if ((int)item.ContactPreference == 1)
|
||||
item.ContactPreferenceStr = SystemParams.GetTextByKey(lang, "P_CR_EMAIL", "Email");
|
||||
else if ((int)item.ContactPreference == 2)
|
||||
item.ContactPreferenceStr = SystemParams.GetTextByKey(lang, "P_CR_PHONE", "Phone");
|
||||
ls.Add(item);
|
||||
}
|
||||
return ls.ToArray(); ;
|
||||
}
|
||||
else
|
||||
return new ContactInfoClient[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private object SaveContact()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
int custid = int.Parse(ps[0]);
|
||||
var data = HttpUtility.HtmlDecode(ps[1]);
|
||||
ContactInfo contact = JsonConvert.DeserializeObject<ContactInfo>(data);
|
||||
if (contact.Id > 0)
|
||||
CreateClient<BusinessPartnerProvider>().UpdateContact(SystemParams.CompanyID, custid, contact);
|
||||
else
|
||||
contact.Id = CreateClient<BusinessPartnerProvider>().AddContact(SystemParams.CompanyID, custid, contact);
|
||||
return contact.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteContact()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var id = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
CreateClient<BusinessPartnerProvider>().DeleteContact(SystemParams.CompanyID, Convert.ToInt32(id));
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAllFollowers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var users = UserManagement.GetActiveUsers(session.SessionID);
|
||||
return users.Where(u => u.IsUser).ToArray();
|
||||
}
|
||||
else
|
||||
return new UserInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "CustomerRecordBasePage.GetAllFollowers", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetFollowers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string custid = Request.Form["ClientData"];
|
||||
custid = HttpUtility.HtmlDecode(custid);
|
||||
|
||||
FollowerInfo[] followers = CreateClient<BusinessPartnerProvider>().GetFollowers(SystemParams.CompanyID, int.Parse(custid));
|
||||
if (followers == null || followers.Length == 0)
|
||||
return new FollowerInfo[0];
|
||||
return followers;
|
||||
}
|
||||
else
|
||||
return new FollowerInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private object AddFollowers()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
int custid = int.Parse(ps[0]);
|
||||
var data = HttpUtility.HtmlDecode(ps[1]);
|
||||
FollowerInfo[] followers = JsonConvert.DeserializeObject<FollowerInfo[]>(data);
|
||||
CreateClient<BusinessPartnerProvider>().AddFollowers(SystemParams.CompanyID, custid, followers);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteFollower()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var id = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
CreateClient<BusinessPartnerProvider>().DeleteFollower(SystemParams.CompanyID, Convert.ToInt32(id));
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetComments()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var id = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
CommentInfo[] comments = CreateClient<BusinessPartnerProvider>().GetComments(SystemParams.CompanyID, Convert.ToInt32(id));
|
||||
if (comments == null || comments.Length == 0)
|
||||
return new CommentItem[0];
|
||||
|
||||
List<CommentItem> ls = new List<CommentItem>();
|
||||
foreach (CommentInfo com in comments)
|
||||
{
|
||||
CommentItem item = new CommentItem();
|
||||
Helper.CloneProperty(item, com);
|
||||
ls.Add(item);
|
||||
}
|
||||
|
||||
return ls.OrderBy(r => r.SubmitLocalDate).ToArray();
|
||||
}
|
||||
else
|
||||
return new CommentItem[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string SubmitComment()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
string[] p = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
int id = Convert.ToInt32(p[0]);
|
||||
bool isprivate = Helper.IsTrue(p[1]);
|
||||
|
||||
CreateClient<BusinessPartnerProvider>().SubmitComment(SystemParams.CompanyID, id, p[2], isprivate);
|
||||
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssignedMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var id = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
var machines = CreateClient<BusinessPartnerProvider>().GetAssignedMachines(SystemParams.CompanyID, Convert.ToInt32(id)); if (session.User.UserType < Foresight.Fleet.Services.User.UserTypes.Admin)
|
||||
{
|
||||
AssetBasicInfo[] allassets = CreateClient<AssetQueryClient>(SystemParams.CompanyID).GetAssetBasicInfoByUser(SystemParams.CompanyID, "", session.User.UID, 0);
|
||||
var allassetids = allassets.Select(a => a.ID).ToList();
|
||||
machines = machines.Where(a => allassetids.Contains(a.Id)).ToArray();
|
||||
}
|
||||
return machines.OrderBy(m => m.VIN).Select(m => new
|
||||
{
|
||||
ID = m.Id,
|
||||
Name = m.Name,
|
||||
m.VIN,
|
||||
m.MakeName,
|
||||
m.ModelName,
|
||||
m.TypeName
|
||||
}).ToArray();
|
||||
}
|
||||
else
|
||||
return new BusinessPartnerInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object AssignMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
int id = Convert.ToInt32(ps[0]);
|
||||
long[] assetids = JsonConvert.DeserializeObject<long[]>(ps[1]);
|
||||
|
||||
CreateClient<BusinessPartnerProvider>().AssignMachines(SystemParams.CompanyID, id, assetids);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object RemoveAssignedMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
int id = Convert.ToInt32(ps[0]);
|
||||
long[] assetids = JsonConvert.DeserializeObject<long[]>(ps[1]);
|
||||
|
||||
CreateClient<BusinessPartnerProvider>().RemoveAssignedMachines(SystemParams.CompanyID, id, assetids);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetSalespersons()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
string searchtxt = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
var users = UserManagement.GetSalespersons(session.SessionID, SystemParams.CompanyID, searchtxt);
|
||||
users = users.Where(m => !string.IsNullOrWhiteSpace(m.FOB)).OrderBy(m => m.FOB).ToArray();
|
||||
return users;
|
||||
}
|
||||
else
|
||||
return new UserInfo[0];
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CommentItem : CommentInfo
|
||||
{
|
||||
public string SubmitLocalDateStr { get { return SubmitLocalDate == null ? "" : SubmitLocalDate.ToString("M/d/yyyy h:m:s tt"); } }
|
||||
|
||||
}
|
||||
|
||||
public class ContactInfoClient : ContactInfo
|
||||
{
|
||||
public string ContactPreferenceStr { get; set; }
|
||||
}
|
||||
}
|
@ -3,8 +3,6 @@ using Foresight.Fleet.Services.JobSite;
|
||||
using IronIntel.Contractor.FITracker;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -96,13 +94,12 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
List<TrackerChatMessage> result = new List<TrackerChatMessage>();
|
||||
var msgs = FITrackerManagement.GetMessages(session.SessionID, deviceid, lastmsgid);
|
||||
double hourOffset = SystemParams.GetHoursOffset();
|
||||
foreach (ChatMessageInfo msginfo in msgs)
|
||||
{
|
||||
TrackerChatMessage msg = new TrackerChatMessage();
|
||||
Helper.CloneProperty(msg, msginfo);
|
||||
if (msg.Time != DateTime.MinValue)
|
||||
msg.Time = msg.Time.AddHours(hourOffset);
|
||||
msg.Time = SystemParams.ConvertToUserTimeFromUtc(session.User, msg.Time);
|
||||
msg.IsSelf = session.User.UID.Equals(msg.SenderID, StringComparison.OrdinalIgnoreCase);
|
||||
result.Add(msg);
|
||||
}
|
||||
@ -122,12 +119,9 @@ namespace IronIntel.Contractor.Site
|
||||
int type = 0;
|
||||
int.TryParse(obj[2], out type);
|
||||
var msginfo = FITrackerManagement.PostMessage(session.SessionID, obj[0], session.User.UID, session.User.Name, obj[1], type);
|
||||
double hourOffset = SystemParams.GetHoursOffset();
|
||||
|
||||
TrackerChatMessage msg = new TrackerChatMessage();
|
||||
Helper.CloneProperty(msg, msginfo);
|
||||
if (msg.Time != DateTime.MinValue)
|
||||
msg.Time = msg.Time.AddHours(hourOffset);
|
||||
msg.IsSelf = session.User.UID.Equals(msg.SenderID, StringComparison.OrdinalIgnoreCase);
|
||||
return msg;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,49 +37,18 @@
|
||||
<AssemblyOriginatorKeyFile>LHBIS.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FICBLC">
|
||||
<HintPath>..\Reflib\FIC\FICBLC.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICIntf, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b006d6021b5c4397, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Reflib\FIC\FICIntf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICIntfAdv, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b006d6021b5c4397, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Reflib\FIC\FICIntfAdv.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICore">
|
||||
<HintPath>..\Reflib\FICore.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FICore.std">
|
||||
<Reference Include="FICore.std, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c0ebbbf33888075, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Reflib\FICore.std.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FIWinLib">
|
||||
<HintPath>..\Reflib\FIWinLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FleetClientBase">
|
||||
<HintPath>..\Reflib\FleetClientBase.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FleetServiceClient">
|
||||
<HintPath>..\Reflib\FleetServiceClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iisitebase">
|
||||
<HintPath>..\Reflib\iisitebase.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iisyslib">
|
||||
<HintPath>..\Reflib\iisyslib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ironcontractorwinlib">
|
||||
<HintPath>..\Reflib\ironcontractorwinlib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntel.Services.Contractor">
|
||||
<HintPath>..\Site\Bin\IronIntel.Services.Contractor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntel.Services.CredentialObjects">
|
||||
<HintPath>..\Reflib\IronIntel.Services.CredentialObjects.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="IronIntelServiceModel">
|
||||
<HintPath>..\Reflib\IronIntelServiceModel.dll</HintPath>
|
||||
<Reference Include="ForesightCredentialClient">
|
||||
<HintPath>..\Reflib\ForesightCredentialClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\Reflib\Newtonsoft.Json.dll</HintPath>
|
||||
@ -99,9 +68,15 @@
|
||||
<Compile Include="Asset\AssetBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Asset\ShareAssetBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ChangePasswordBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CommBase.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CommonHttpRequestHandler.cs" />
|
||||
<Compile Include="Contact\ContactBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
@ -109,7 +84,13 @@
|
||||
<Compile Include="ContractorBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CredentialEntryBasePage.cs">
|
||||
<Compile Include="Credentials\CredentialEntryBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Credentials\CredentialsBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Customer\CustomerRecordBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FITrackerBasePage.cs">
|
||||
@ -118,10 +99,13 @@
|
||||
<Compile Include="InspectionBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="JobSitesBasePage.cs">
|
||||
<Compile Include="FilterQBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FilterQBasePage.cs">
|
||||
<Compile Include="JobSite\JobSiteRequirementsBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="JobSite\JobSitesBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MachineDeviceBasePage.cs">
|
||||
@ -165,15 +149,9 @@
|
||||
<Compile Include="Security\CurfewBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\FilterBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\SecurityBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\DataTablePermissionBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Security\UserGroupBasePage.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
@ -197,14 +175,39 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="LHBIS.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\FI_G3\FICG5Core\Service\FICBLC\FICBLC.csproj">
|
||||
<Project>{39e2a8c6-f58f-4839-b7c1-82d44153fc3a}</Project>
|
||||
<Name>FICBLC</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\FI_G3\FICG5Core\Service\FICIntf\FICIntfAdv\FICIntfAdv.csproj">
|
||||
<Project>{3ffa4093-4325-4fbb-a874-f288bfdcf7ba}</Project>
|
||||
<Name>FICIntfAdv</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\FI_G3\FICG5Core\Service\FICIntf\FICIntf\FICIntf.csproj">
|
||||
<Project>{4963deb2-f0e3-44a3-b5e1-e13e191a8de8}</Project>
|
||||
<Name>FICIntf</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\..\FI_G3\FICG5Core\Service\FICModels\FICModels.csproj">
|
||||
<Project>{f47ebf77-eed3-44e2-9983-ef556372a648}</Project>
|
||||
<Name>FICModels</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Service\DataModel\FleetClientBase\FleetClientBase.csproj">
|
||||
<Project>{b0110465-8537-4fe7-bee6-b10faa0ba92d}</Project>
|
||||
<Name>FleetClientBase</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Service\DataModel\FleetServiceClient\FleetServiceClient.csproj">
|
||||
<Project>{a872b915-d7f0-4e7f-81e7-742dbb4dbbba}</Project>
|
||||
<Name>FleetServiceClient</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\IronIntelContractorBusiness\IronIntelContractorBusiness.csproj">
|
||||
<Project>{515fb61f-f032-4a48-8f32-93b59b9d37f8}</Project>
|
||||
<Name>IronIntelContractorBusiness</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LHBIS.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
1387
IronIntelContractorSiteLib/JobSite/JobSiteRequirementsBasePage.cs
Normal file
1387
IronIntelContractorSiteLib/JobSite/JobSiteRequirementsBasePage.cs
Normal file
File diff suppressed because it is too large
Load Diff
1136
IronIntelContractorSiteLib/JobSite/JobSitesBasePage.cs
Normal file
1136
IronIntelContractorSiteLib/JobSite/JobSitesBasePage.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,498 +0,0 @@
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.MapView;
|
||||
using Foresight.Standard;
|
||||
using IronIntel.Contractor.FilterQ;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
public class JobSitesBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest()
|
||||
{
|
||||
object result = null;
|
||||
try
|
||||
{
|
||||
string methodName = Request.Params["MethodName"];
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName)
|
||||
{
|
||||
case "GetJobSites":
|
||||
result = GetJobSites();
|
||||
break;
|
||||
case "SaveJobSite":
|
||||
result = SaveJobSite();
|
||||
break;
|
||||
case "DeleteJobSite":
|
||||
result = DeleteJobSite();
|
||||
break;
|
||||
case "SaveJobSiteMachines":
|
||||
result = SaveJobSiteMachines();
|
||||
break;
|
||||
case "GetMachines":
|
||||
result = GetMachines();
|
||||
break;
|
||||
case "GetSelectedAssets":
|
||||
result = GetSelectedAssets();
|
||||
break;
|
||||
case "AddAssetToJobSite":
|
||||
result = AddAssetToJobSite();
|
||||
break;
|
||||
case "RemoveAssetFromJobSite":
|
||||
result = RemoveAssetFromJobSite();
|
||||
break;
|
||||
case "ChangeAssetOnSiteState":
|
||||
result = ChangeAssetOnSiteState();
|
||||
break;
|
||||
case "GetMachineTypes":
|
||||
result = GetMachineTypes();
|
||||
break;
|
||||
case "GetMachinesByType":
|
||||
result = GetMachinesByType();
|
||||
break;
|
||||
case "GetBindingMachines":
|
||||
result = GetBindingMachines();
|
||||
break;
|
||||
case "ImportJobsitePolygon":
|
||||
result = ImportJobsitePolygon();
|
||||
break;
|
||||
case "GetJobSiteUsers":
|
||||
result = GetJobSiteUsers();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "JobSitesBasePage", ex.Message, ex.ToString());
|
||||
throw ex;
|
||||
}
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private object GetJobSites()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, s);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
|
||||
foreach (var js in jss)
|
||||
{
|
||||
JobSiteViewItem item = new JobSiteViewItem();
|
||||
item.ID = js.ID;
|
||||
item.Name = js.Name;
|
||||
item.BaseOnMachineID = js.BaseonMachineID;
|
||||
item.Code = js.Code;
|
||||
item.Types = new string[] { js.JobSiteTypes };
|
||||
item.ColorString = js.Color;
|
||||
System.Drawing.Color color = System.Drawing.Color.Orange;
|
||||
try
|
||||
{
|
||||
color = System.Drawing.ColorTranslator.FromHtml(item.ColorString);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
item.Color = new IIColor() { Alpha = color.A, Red = color.R, Green = color.G, Blue = color.B };
|
||||
|
||||
item.Latitude = js.Latitude;
|
||||
item.Longitude = js.Longitude;
|
||||
item.StartDate = js.StartDate == null ? DateTime.MinValue : js.StartDate.Value;
|
||||
item.EndDate = js.EndDate == null ? DateTime.MinValue : js.EndDate.Value;
|
||||
item.Radius = js.Radius;
|
||||
item.Radius_UOM = js.RadiusUOM;
|
||||
if (js.Polygon != null && js.Polygon.Length > 0)
|
||||
{
|
||||
List<PostionItem> temps = new List<PostionItem>();
|
||||
foreach (var p in js.Polygon)
|
||||
{
|
||||
temps.Add(new PostionItem(p.Latitude, p.Longtitude));
|
||||
}
|
||||
item.Polygon = temps.ToArray();
|
||||
}
|
||||
|
||||
list.Add(item);
|
||||
}
|
||||
items = list.ToArray();
|
||||
//items = JobSitesManagement.GetJobSite(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteViewItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveJobSite()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
var js = JsonConvert.DeserializeObject<JobSiteViewItem>(s);
|
||||
JobSiteItem jobsite = new JobSiteItem();
|
||||
Helper.CloneProperty(jobsite, js);
|
||||
jobsite.RadiusUOM = js.Radius_UOM;
|
||||
jobsite.BaseonMachineID = js.BaseOnMachineID;
|
||||
jobsite.Color = js.ColorString;
|
||||
jobsite.JobSiteTypes = string.Join(",", js.Types);
|
||||
if (js.StartDate > Helper.DBMinDateTime)
|
||||
jobsite.StartDate = js.StartDate;
|
||||
if (js.EndDate > Helper.DBMinDateTime)
|
||||
jobsite.EndDate = js.EndDate;
|
||||
if (js.Polygon != null && js.Polygon.Length > 0)
|
||||
{
|
||||
List<Position> list = new List<Position>();
|
||||
foreach (PostionItem pi in js.Polygon)
|
||||
{
|
||||
Position p = new Position(pi.Latitude, pi.Longitude);
|
||||
list.Add(p);
|
||||
}
|
||||
jobsite.Polygon = list.ToArray();
|
||||
}
|
||||
|
||||
long jobsiteid = CreateClient<JobSiteProvider>().SaveJobSite(SystemParams.CompanyID, jobsite, GetCurrentLoginSession().User.UID);
|
||||
|
||||
JobSitesManagement.RefreshJobsiteAssets(session.SessionID, jobsiteid);
|
||||
|
||||
return new string[] { jobsiteid.ToString(), "Saved successfully." };
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteJobSite()
|
||||
{
|
||||
try
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
if (user != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var s = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
long jsid = Convert.ToInt64(s);
|
||||
var notes = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
CreateClient<JobSiteProvider>().DeleteJobSite(SystemParams.CompanyID, jsid, notes, user.IID);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private string SaveJobSiteMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
var jobsite = JsonConvert.DeserializeObject<JobSiteViewItem>(s);
|
||||
|
||||
JobSitesManagement.AddMachinesToJobSite(jobsite);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private AssetMapViewPinItem[] GetMachines()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
AssetMapViewPinItem[] items = AssetMapViewManagement.GetAssets(session.SessionID, SystemParams.CompanyID, session.User.UID, "", -1, null, false);
|
||||
return items;
|
||||
}
|
||||
return new AssetMapViewPinItem[0];
|
||||
}
|
||||
|
||||
private object[] GetSelectedAssets()
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
}
|
||||
var jobsiteid = long.Parse(clientdata[1]);
|
||||
var jobsites = CreateClient<JobSiteProvider>(companyid).GetAssetsCurrentInJobSite(companyid, jobsiteid);
|
||||
return jobsites.Select(i => new
|
||||
{
|
||||
i.AssetId,
|
||||
i.OnSite,
|
||||
Name = string.IsNullOrEmpty(i.AssetName2) ? i.AssetName : i.AssetName2,
|
||||
i.VIN,
|
||||
i.MakeName,
|
||||
i.ModelName,
|
||||
i.TypeName
|
||||
}).ToArray();
|
||||
}
|
||||
return new object[0];
|
||||
}
|
||||
|
||||
private string AddAssetToJobSite()
|
||||
{
|
||||
try
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var jobsiteid = long.Parse(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<long[]>(machineids);
|
||||
|
||||
var client = CreateClient<JobSiteProvider>(companyId);
|
||||
foreach (var id in ids)
|
||||
{
|
||||
client.AddAssetToJobSite(companyId, jobsiteid, id, false, u.IID);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "JobSitesBasePage.AddAssetToJobSite", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string RemoveAssetFromJobSite()
|
||||
{
|
||||
try
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var jobsiteid = long.Parse(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
var ids = JsonConvert.DeserializeObject<long[]>(machineids);
|
||||
|
||||
var client = CreateClient<JobSiteProvider>(companyId);
|
||||
foreach (var id in ids)
|
||||
{
|
||||
client.RemoveAssetFromJobSite(companyId, jobsiteid, id, u.IID);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "JobSitesBasePage.RemoveAssetFromJobSite", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string ChangeAssetOnSiteState()
|
||||
{
|
||||
try
|
||||
{
|
||||
var u = GetCurrentUser();
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyId = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyId))
|
||||
{
|
||||
companyId = SystemParams.CompanyID;
|
||||
}
|
||||
var jobsiteid = long.Parse(clientdata[1]);
|
||||
var assetid = long.Parse(clientdata[2]);
|
||||
var onsite = (clientdata[3] == "1");
|
||||
|
||||
CreateClient<JobSiteProvider>(companyId).ChangeAssetOnSiteState(companyId, jobsiteid, assetid, onsite, u.IID);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "JobSitesBasePage.ChangeAssetOnSiteState", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private MachineViewItem[] GetBindingMachines()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
MachineViewItem[] items = JobSitesManagement.GetBindingMachines(session.SessionID, session.User.UID);
|
||||
if (items != null)
|
||||
{
|
||||
items = items.OrderBy((m) => m.DisplayName).ToArray();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private MachineTypeItem[] GetMachineTypes()
|
||||
{
|
||||
MachineTypeItem[] types = JobSitesManagement.GetMachineTypes();
|
||||
if (types != null)
|
||||
{
|
||||
types = types.OrderBy((t) => t.Name).ToArray();
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
private AvailableMachines GetMachinesByType()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
var p = Request.Form["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
var param = JsonConvert.DeserializeObject<JobSiteMahcineQueryItem>(p);
|
||||
|
||||
AvailableMachines machines = JobSitesManagement.GetMachineViewItemByType(session.SessionID, param.JobSiteID, param.MachineTypeID, param.SearchText, session.User.UID);
|
||||
return machines;
|
||||
}
|
||||
|
||||
private object ImportJobsitePolygon()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
string fileName = clientdata;
|
||||
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] buffer = null;
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
uploadFile = Request.Files[0];
|
||||
buffer = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
return JobSitesManagement.ImportJobsitePolygon(fileName, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetJobSiteUsers()
|
||||
{
|
||||
try
|
||||
{
|
||||
UserNameInfoItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var data = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
var jobsiteid = long.Parse(data);
|
||||
var users = CreateClient<JobSiteProvider>().GetJobisteUserNamesList(SystemParams.CompanyID, jobsiteid);
|
||||
|
||||
List<UserNameInfoItem> list = new List<UserNameInfoItem>();
|
||||
foreach (var user in users)
|
||||
{
|
||||
UserNameInfoItem ui = new UserNameInfoItem();
|
||||
Helper.CloneProperty(ui, user);
|
||||
list.Add(ui);
|
||||
}
|
||||
items = list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new UserNameInfoItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private class JobSiteMahcineQueryItem
|
||||
{
|
||||
public string JobSiteID { get; set; }
|
||||
public string MachineTypeID { get; set; }
|
||||
public string SearchText { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,10 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Foresight;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Contractor.Users;
|
||||
using System.Web;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.Fleet.Services.FIC;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
@ -17,8 +19,8 @@ namespace IronIntel.Contractor.Site
|
||||
string methidName = Request.Params["MethodName"];
|
||||
switch (methidName)
|
||||
{
|
||||
case "GetUserName":
|
||||
GetUserName();
|
||||
case "GetUserData":
|
||||
GetUserData();
|
||||
break;
|
||||
case "GetAppModules":
|
||||
GetAppModules();
|
||||
@ -29,23 +31,60 @@ namespace IronIntel.Contractor.Site
|
||||
case "GetSiteHeaderNote":
|
||||
GetSiteHeaderNote();
|
||||
break;
|
||||
case "SetFavorites":
|
||||
SetFavorites();
|
||||
break;
|
||||
case "GetFavoriteItems":
|
||||
GetFavoriteItems();
|
||||
break;
|
||||
case "GetDashboardList":
|
||||
GetDashboardList();
|
||||
break;
|
||||
case "SetRecentOpenedDashboard":
|
||||
SetRecentOpenedDashboard();
|
||||
break;
|
||||
case "UploadUserAvatar":
|
||||
UploadUserAvatar();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//TODO
|
||||
}
|
||||
|
||||
private void GetUserName()
|
||||
private void GetUserData()
|
||||
{
|
||||
string userName = "";
|
||||
string userdata = "";
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
userName = session.User.Name;
|
||||
var data = new
|
||||
{
|
||||
UserName = session.User.Name,
|
||||
};
|
||||
|
||||
userdata = JsonConvert.SerializeObject(data);
|
||||
}
|
||||
|
||||
userName = JsonConvert.SerializeObject(userName);
|
||||
Response.Write(userName);
|
||||
Response.Write(userdata);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void UploadUserAvatar()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
byte[] avadarBytes = null;
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
HttpPostedFile uploadFile = Request.Files[0];
|
||||
avadarBytes = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
UserManagement.SetUserAvatar(session.SessionID, session.User.UID, avadarBytes);
|
||||
}
|
||||
|
||||
Response.Write(JsonConvert.SerializeObject("OK"));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
@ -126,5 +165,147 @@ namespace IronIntel.Contractor.Site
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void GetFavoriteItems()
|
||||
{
|
||||
string value = string.Empty;
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
value = UserParams.GetStringParameter(session.User.UID, "FavoriteSites");
|
||||
}
|
||||
|
||||
string json = string.IsNullOrEmpty(value) ? JsonConvert.SerializeObject(new FavoriteInfo[0]) : value;
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
|
||||
private void SetFavorites()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var data = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
UserParams.SetStringParameter(session.User.UID, "FavoriteSites", data);
|
||||
}
|
||||
Response.Write(JsonConvert.SerializeObject("OK"));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void GetDashboardList()
|
||||
{
|
||||
List<DashboardInfo> ls = new List<DashboardInfo>();
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
var ps = JsonConvert.DeserializeObject<string[]>(Request.Form["ClientData"]);
|
||||
var filter = HttpUtility.HtmlDecode(ps[0]);
|
||||
int flag;
|
||||
if (!int.TryParse(ps[1], out flag))
|
||||
{
|
||||
flag = 0;
|
||||
}
|
||||
|
||||
var ficprovider = FleetServiceClientHelper.CreateClient<FICObjectProvider>();
|
||||
WorkSpaceInfo[] wsps = ficprovider.GetWorkSpaces(SystemParams.CompanyID, filter, false, flag);
|
||||
ChartInfo[] charts = ficprovider.GetCharts(SystemParams.CompanyID, filter, flag);
|
||||
foreach (WorkSpaceInfo wsp in wsps)
|
||||
{
|
||||
DashboardInfo item = new DashboardInfo();
|
||||
Helper.CloneProperty(item, wsp);
|
||||
item.IsChart = false;
|
||||
item.Notes = wsp.Description;
|
||||
ls.Add(item);
|
||||
}
|
||||
foreach (ChartInfo chart in charts)
|
||||
{
|
||||
DashboardInfo item = new DashboardInfo();
|
||||
Helper.CloneProperty(item, chart);
|
||||
item.IsChart = true;
|
||||
item.Notes = chart.ChartNotes;
|
||||
ls.Add(item);
|
||||
}
|
||||
|
||||
List<RecentOpenedDashboardItem> lsrencent = GetRecentOpenedDashboards(session.User.UID);
|
||||
foreach (RecentOpenedDashboardItem item in lsrencent)
|
||||
{
|
||||
DashboardInfo dab = ls.FirstOrDefault(m => m.ID == item.ID);
|
||||
if (dab != null)
|
||||
{
|
||||
ls.Remove(dab);
|
||||
ls.Insert(0, dab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(ls.ToArray());
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private void SetRecentOpenedDashboard()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null && session.User != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var id = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
List<RecentOpenedDashboardItem> lsrencent = GetRecentOpenedDashboards(session.User.UID);
|
||||
RecentOpenedDashboardItem ritem = lsrencent.FirstOrDefault(m => m.ID == id);
|
||||
if (ritem == null)
|
||||
{
|
||||
RecentOpenedDashboardItem item = new RecentOpenedDashboardItem();
|
||||
item.ID = id;
|
||||
item.Time = DateTime.UtcNow;
|
||||
lsrencent.Add(item);
|
||||
}
|
||||
else
|
||||
ritem.Time = DateTime.UtcNow;
|
||||
|
||||
lsrencent = lsrencent.OrderBy(m => m.Time).ToList();
|
||||
string newdata = JsonConvert.SerializeObject(lsrencent);
|
||||
UserParams.SetStringParameter(session.User.UID, "RecentOpenedDashboard", newdata);
|
||||
}
|
||||
Response.Write(JsonConvert.SerializeObject("OK"));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private List<RecentOpenedDashboardItem> GetRecentOpenedDashboards(string uid)
|
||||
{
|
||||
string data = UserParams.GetStringParameter(uid, "RecentOpenedDashboard");
|
||||
List<RecentOpenedDashboardItem> ls = JsonConvert.DeserializeObject<List<RecentOpenedDashboardItem>>(data);
|
||||
if (ls == null)
|
||||
return new List<RecentOpenedDashboardItem>();
|
||||
return ls.OrderBy(m => m.Time).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class FavoriteInfo
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int FavoriteType { get; set; }
|
||||
}
|
||||
|
||||
public class DashboardInfo
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public bool IsChart { get; set; }
|
||||
}
|
||||
|
||||
public class RecentOpenedDashboardItem
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.AssetHealth.WorkOrder;
|
||||
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;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -33,15 +34,15 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
case "GETMACHINEALERTS":
|
||||
result = GetMachineAlerts();
|
||||
break;
|
||||
case "GETPMALERTSERVICEDESCRIPTIONS":
|
||||
result = GetPMAlertServiceDescriptions();
|
||||
break;
|
||||
case "SAVEACKNOWLEDGEALERT":
|
||||
result = SaveAcknowledgeAlert();
|
||||
break;
|
||||
case "ASSIGNEDALERTSTOWORKORDER":
|
||||
result = AssignedAlertsToWorkOrder();
|
||||
break;
|
||||
case "GETALERTSBYWORKORDER":
|
||||
result = GetAlertsByWorkOrder();
|
||||
break;
|
||||
case "GETALERTSLISENCE":
|
||||
result = GetAlertsLisence();
|
||||
break;
|
||||
@ -60,6 +61,30 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
case "GETACKNOWLEDGEDALERTS":
|
||||
result = GetAcknowledgedAlerts();
|
||||
break;
|
||||
case "GETJOBSITES":
|
||||
result = GetJobsites();
|
||||
break;
|
||||
case "SAVEAUTOACKNOWLEDGEALERTTYPES":
|
||||
result = SaveAutoAcknowledgeAlertTypes();
|
||||
break;
|
||||
case "GETAUTOACKNOWLEDGEALERTTYPES":
|
||||
result = GetAutoAcknowledgeAlertTypes();
|
||||
break;
|
||||
case "GETAUTOACKNOWLEDGEALERTTYPESHISTORY":
|
||||
result = GetAutoAcknowledgeAlertTypesHistory();
|
||||
break;
|
||||
case "GETWORKORDERGENERATORS":
|
||||
result = GetWorkOrderGenerators();
|
||||
break;
|
||||
case "SAVEWORKORDERGENERATOR":
|
||||
result = SaveWorkOrderGenerator();
|
||||
break;
|
||||
case "DELETEWORKORDERGENERATOR":
|
||||
result = DeleteWorkOrderGenerator();
|
||||
break;
|
||||
case "GETASSIGNTOS":
|
||||
result = GetAssignTos();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -90,11 +115,6 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
// beginDate = beginDate.ToUniversalTime();
|
||||
if (!DateTime.TryParse(alertparam.EndDate, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
else
|
||||
endDate = endDate.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
beginDate = SystemParams.CustomerDetail.CustomerTimeToUtc(beginDate);
|
||||
endDate = SystemParams.CustomerDetail.CustomerTimeToUtc(endDate);
|
||||
|
||||
int assigned = -1;
|
||||
int completed = -1;
|
||||
@ -106,18 +126,23 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
assigned = 1;
|
||||
|
||||
if (alertparam.AlertStatus.Contains("Completed") && !alertparam.AlertStatus.Contains("Uncompleted"))
|
||||
assigned = 1;
|
||||
completed = 1;
|
||||
if (!alertparam.AlertStatus.Contains("Completed") && alertparam.AlertStatus.Contains("Uncompleted"))
|
||||
assigned = 0;
|
||||
completed = 0;
|
||||
}
|
||||
AssetAlertGridViewItem[] assetalerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, assigned, completed, alertparam.SearchText, session.User.UID);
|
||||
|
||||
AssetAlertGridViewItem[] assetalerts = null;
|
||||
if (alertparam.AssetID > 0)
|
||||
assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted);
|
||||
else
|
||||
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted);
|
||||
|
||||
if (assetalerts == null || assetalerts.Length == 0)
|
||||
return new AlertInfo[0];
|
||||
List<AlertInfo> list = new List<AlertInfo>();
|
||||
foreach (AssetAlertGridViewItem item in assetalerts)
|
||||
{
|
||||
AlertInfo ai = ConvertAlertObj(item);
|
||||
ai.AlertTime_UTC = item.LastAlertLocalTime;
|
||||
list.Add(ai);
|
||||
}
|
||||
return list.ToArray();
|
||||
@ -149,11 +174,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
// beginDate = beginDate.ToUniversalTime();
|
||||
if (!DateTime.TryParse(alertparam.EndDate, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
else
|
||||
endDate = endDate.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
beginDate = SystemParams.CustomerDetail.CustomerTimeToUtc(beginDate);
|
||||
endDate = SystemParams.CustomerDetail.CustomerTimeToUtc(endDate);
|
||||
|
||||
int assigned = -1;
|
||||
int completed = -1;
|
||||
@ -165,12 +186,16 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
assigned = 1;
|
||||
|
||||
if (alertparam.AlertStatus.Contains("Completed") && !alertparam.AlertStatus.Contains("Uncompleted"))
|
||||
assigned = 1;
|
||||
completed = 1;
|
||||
if (!alertparam.AlertStatus.Contains("Completed") && alertparam.AlertStatus.Contains("Uncompleted"))
|
||||
assigned = 0;
|
||||
completed = 0;
|
||||
}
|
||||
|
||||
AssetAlertGridViewItem[] assetalerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, assigned, completed, alertparam.SearchText, session.User.UID);
|
||||
AssetAlertGridViewItem[] assetalerts = null;
|
||||
if (alertparam.AssetID > 0)
|
||||
assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted);
|
||||
else
|
||||
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted);
|
||||
|
||||
if (assetalerts == null || assetalerts.Length == 0)
|
||||
return new MachineInfoForAlert[0];
|
||||
@ -205,8 +230,8 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
mi.InspectAlertCount += count;
|
||||
else
|
||||
mi.DTCAlertCount += count;
|
||||
if (ai.AlertTime_UTC > mi.LatestAlertDateTime)
|
||||
mi.LatestAlertDateTime = ai.AlertTime_UTC;
|
||||
if (ai.AlertLocalTime > mi.LatestAlertDateTime)
|
||||
mi.LatestAlertDateTime = ai.AlertLocalTime;
|
||||
}
|
||||
|
||||
return machinealerts.ToArray();
|
||||
@ -221,6 +246,53 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
}
|
||||
}
|
||||
|
||||
private object GetPMAlertServiceDescriptions()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
long[] alertids = JsonConvert.DeserializeObject<long[]>(clientdata);
|
||||
|
||||
return CreateClient<AlertProvider>().GetAlertServiceDescriptions(SystemParams.CompanyID, alertids);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetPMAlertServiceDescriptions", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private AlertInfo ConvertAlertObj1(AssetAlertItem item)
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
ai.AlertID = item.ID;
|
||||
ai.AlertType = item.AlertType;
|
||||
ai.AlertLocalTime = item.AlertLocalTime;
|
||||
ai.Completed = item.Completed;
|
||||
ai.MachineID = item.AssetID;
|
||||
ai.Model = item.ModelName;
|
||||
ai.Make = item.MakeName;
|
||||
ai.VIN = item.VIN;
|
||||
ai.MachineName = item.AssetName;
|
||||
ai.EngineHours = item.EngineHours;
|
||||
ai.Description = item.Description;
|
||||
ai.Description = ai.FormatDescription(ai.Description);
|
||||
ai.ServiceDescription = item.ServiceDescription;
|
||||
ai.RepeatedAlerts = item.RepeatedAlerts;
|
||||
ai.AlertCount = item.RepeatedAlerts.Count + 1;
|
||||
ai.ScheduleID = item.ScheduleID;
|
||||
ai.IntervalID = item.IntervalID;
|
||||
ai.Recurring = item.Recurring;
|
||||
ai.Priority = item.Priority;
|
||||
ai.ExpectedCost = item.ExpectedCost;
|
||||
|
||||
return ai;
|
||||
}
|
||||
|
||||
private AlertInfo ConvertAlertObj(AssetAlertGridViewItem item)
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
@ -229,6 +301,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
ai.WorkOrderStatus = item.WorkOrderStatus;
|
||||
ai.AlertType = item.AlertType;
|
||||
ai.AlertTime_UTC = item.LastAlertTime;
|
||||
ai.AlertLocalTime = item.AlertLocalTime;
|
||||
ai.Completed = item.Completed;
|
||||
ai.MachineID = item.AssetID;
|
||||
//ai.ModelID = item.ModelName;
|
||||
@ -240,10 +313,42 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
ai.EngineHours = item.EngineHours;
|
||||
ai.CurrentHours = item.CurrentEngineHours;
|
||||
ai.Description = item.Description;
|
||||
ai.ServiceDescription = item.ServiceDescription;
|
||||
ai.Description = ai.FormatDescription(ai.Description);
|
||||
//ai.ServiceDescription = item.ServiceDescription;
|
||||
ai.RepeatedAlerts = item.RepeatedAlerts;
|
||||
ai.AlertCount = item.RepeatedAlerts.Count + 1;
|
||||
ai.OpenWorkOrderCount = item.OpenWorkOrderCount;
|
||||
//ai.ScheduleID = item.ScheduleID;
|
||||
//ai.IntervalID = item.IntervalID;
|
||||
//ai.Recurring = item.Recurring;
|
||||
//ai.Priority = item.Priority;
|
||||
//ai.ExpectedCost = item.ExpectedCost;
|
||||
|
||||
return ai;
|
||||
}
|
||||
private AlertInfo ConvertAlertObj2(AcknowledgedAlertItem item)
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
ai.AlertID = item.ID;
|
||||
ai.WorkOrderID = item.WorkOrderId;
|
||||
ai.AlertType = item.AlertType;
|
||||
ai.AlertTime_UTC = item.LastAlertTime;
|
||||
ai.AlertLocalTime = item.AlertLocalTime;
|
||||
ai.MachineID = item.AssetID;
|
||||
ai.Model = item.ModelName;
|
||||
ai.Make = item.MakeName;
|
||||
ai.VIN = item.VIN;
|
||||
ai.MachineName = item.AssetName;
|
||||
ai.EngineHours = item.EngineHours;
|
||||
ai.Description = item.Description;
|
||||
ai.Description = ai.FormatDescription(ai.Description);
|
||||
ai.RepeatedAlerts = item.RepeatedAlerts;
|
||||
ai.AlertCount = item.RepeatedAlerts.Count + 1;
|
||||
ai.OpenWorkOrderCount = item.OpenWorkOrderCount;
|
||||
ai.AcknowledgedByName = item.AcknowledgedBy;
|
||||
ai.AcknowledgedTime_UTC = item.AcknowledgedTime;
|
||||
ai.AcknowledgedTime_Local = item.AcknowledgedLocalTime;
|
||||
ai.AcknowledgedComment = item.AcknowledgedComment;
|
||||
|
||||
return ai;
|
||||
}
|
||||
@ -265,15 +370,23 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
// beginDate = beginDate.ToUniversalTime();
|
||||
if (!DateTime.TryParse(alertparam.EndDate, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
else
|
||||
endDate = endDate.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
|
||||
alertparam.AlertStatus = new string[0];
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
AlertInfo[] alerts = am.SearchAcknowledgedAlerts(session.SessionID, alertparam.SearchText, alertparam.AlertStatus, alertparam.AlertTypes, alertparam.AssetGroups, beginDate, endDate, session.User.UID);
|
||||
if (alerts == null)
|
||||
AcknowledgedAlertItem[] ackalerts = CreateClient<AlertProvider>().GetAcknowledgedAlerts(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.SearchText);
|
||||
if (ackalerts == null || ackalerts.Length == 0)
|
||||
return new AlertInfo[0];
|
||||
return alerts.ToArray();
|
||||
List<AlertInfo> list = new List<AlertInfo>();
|
||||
foreach (AcknowledgedAlertItem item in ackalerts)
|
||||
{
|
||||
AlertInfo ai = ConvertAlertObj2(item);
|
||||
list.Add(ai);
|
||||
}
|
||||
if (list == null)
|
||||
return new AlertInfo[0];
|
||||
if (alertparam.AssetID > 0)
|
||||
list = list.Where(m => m.MachineID == alertparam.AssetID).ToList();
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new AlertInfo[0];
|
||||
@ -292,7 +405,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
AlertsLisenceItem result = new AlertsLisenceItem();
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
LicenseInfo license = SystemParams.GetLicense();
|
||||
Foresight.Fleet.Services.Customer.LicenseInfo license = SystemParams.GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
var woitem = license.Items.FirstOrDefault(m => m.Key == "WorkOrder");
|
||||
@ -314,7 +427,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
try
|
||||
{
|
||||
Services.Users.LoginSession se = GetCurrentLoginSession();
|
||||
LoginSession se = GetCurrentLoginSession();
|
||||
if (se != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
@ -344,10 +457,17 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
var ids = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
long workorderid = Convert.ToInt64(id);
|
||||
long[] alertids = JsonConvert.DeserializeObject<long[]>(ids);
|
||||
if (alertids != null && alertids.Length == 0)
|
||||
alertids = null;
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
am.AssignedAlertsToWorkOrder(workorderid, alertids);
|
||||
if (alertids == null)
|
||||
alertids = new long[0];
|
||||
|
||||
var wp = CreateClient<WorkOrderProvider>();
|
||||
var existsalerts = wp.GetWorkOrderAlerts(SystemParams.CompanyID, workorderid).Select(a => a.ID);
|
||||
var added = alertids.Except(existsalerts).ToArray();
|
||||
var deleted = existsalerts.Except(alertids).ToArray();
|
||||
if (added.Length > 0)
|
||||
wp.AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, workorderid, added, true);
|
||||
if (deleted.Length > 0)
|
||||
wp.AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, workorderid, deleted, false);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
@ -359,85 +479,26 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAlertsByWorkOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var woid = Request.Form["ClientData"];
|
||||
long workorderid = Convert.ToInt64(woid);
|
||||
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
|
||||
AlertInfo[] alerts = am.GetAlertsByWorkOrder(workorderid);
|
||||
if (alerts == null)
|
||||
return new AlertInfo[0];
|
||||
return alerts;
|
||||
}
|
||||
else
|
||||
return new AlertInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAlertsByWorkOrder", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetWorkOrderAlerts()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
|
||||
long workorderid = 0;
|
||||
long.TryParse(clientdata, out workorderid);
|
||||
|
||||
AssetAlertItem[] alerts = CreateClient<WorkOrderClient>().GetAssignedAlerts(SystemParams.CompanyID, workorderid);
|
||||
AlertItems items = WorkOrderManager.GetWorkOrderAlerts(workorderid, session.SessionID);
|
||||
if (items == null)
|
||||
return new AlertItems();
|
||||
|
||||
AlertItems items = new AlertItems();
|
||||
if (alerts != null)
|
||||
{
|
||||
var dtcalerts = new List<AlertInfo>();
|
||||
var pmaalerts = new List<AlertInfo>();
|
||||
var inspectalerts = new List<AlertInfo>();
|
||||
var oilalerts = new List<AlertInfo>();
|
||||
foreach (AssetAlertItem alertitem in alerts.OrderByDescending(ai => ai.AlertTime))
|
||||
{
|
||||
List<AlertInfo> tempList = null;
|
||||
if (alertitem.Category == AssetAlertCategory.PMAlert)
|
||||
tempList = pmaalerts;
|
||||
else if (alertitem.Category == AssetAlertCategory.InspectAlert)
|
||||
tempList = inspectalerts;
|
||||
else if (alertitem.Category == AssetAlertCategory.OilSampleAlert)
|
||||
tempList = oilalerts;
|
||||
else
|
||||
tempList = dtcalerts;
|
||||
|
||||
var existalert = tempList.FirstOrDefault((ai) => ai.Description == alertitem.Description);
|
||||
if (existalert != null)
|
||||
{
|
||||
existalert.AlertCount++;
|
||||
if (existalert.RepeatedAlerts == null)
|
||||
existalert.RepeatedAlerts = new List<long>();
|
||||
existalert.RepeatedAlerts.Add(alertitem.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
var a = ConvertAlert(alertitem);
|
||||
a.AlertCount = 1;
|
||||
tempList.Add(a);
|
||||
}
|
||||
}
|
||||
items.DTCAlerts = dtcalerts.ToArray();
|
||||
items.PMAlerts = pmaalerts.ToArray();
|
||||
items.InspectAlerts = inspectalerts.ToArray();
|
||||
items.OilAlerts = oilalerts.ToArray();
|
||||
}
|
||||
return items;
|
||||
}
|
||||
else
|
||||
return new AlertInfo[0];
|
||||
return new AlertItems();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -461,7 +522,8 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
|
||||
long[] alertids = JsonConvert.DeserializeObject<long[]>(ids);
|
||||
|
||||
AssetAlertGridViewItem[] alerts = CreateClient<WorkOrderClient>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, machineid, Helper.DBMinDateTime, DateTime.MaxValue, null, -1, -1, "");
|
||||
AssetAlertItem[] alerts = CreateClient<WorkOrderProvider>().GetNoneAssignedAlerts(SystemParams.CompanyID, machineid);
|
||||
//AssetAlertGridViewItem[] alerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, machineid, Helper.DBMinDateTime, DateTime.MaxValue, null, null, -1, -1, "", false);
|
||||
AlertItems items = new AlertItems();
|
||||
if (alerts != null)
|
||||
{
|
||||
@ -469,12 +531,11 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
var pmaalerts = new List<AlertInfo>();
|
||||
var inspectalerts = new List<AlertInfo>();
|
||||
var oilalerts = new List<AlertInfo>();
|
||||
foreach (AssetAlertGridViewItem alertitem in alerts.OrderByDescending(ai => ai.AlertTime))
|
||||
Dictionary<string, List<AlertInfo>> pmalertdic = new Dictionary<string, List<AlertInfo>>();
|
||||
foreach (var alertitem in alerts.OrderByDescending(ai => ai.AlertTime))
|
||||
{
|
||||
if (alertids != null && alertids.Length > 0 && !alertids.Contains(alertitem.ID))
|
||||
continue;
|
||||
if (alertitem.Completed || alertitem.Acknowledged || alertitem.WorkOrderId > 0)
|
||||
continue;
|
||||
|
||||
List<AlertInfo> tempList = null;
|
||||
var category = DetermineAlertCategory(alertitem.AlertType);
|
||||
@ -487,15 +548,33 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
else
|
||||
tempList = dtcalerts;
|
||||
|
||||
var a = ConvertAlertObj(alertitem);
|
||||
var a = ConvertAlertObj1(alertitem);
|
||||
a.RepeatedAlerts = alertitem.RepeatedAlerts;
|
||||
a.AlertCount = alertitem.RepeatedAlerts.Count + 1;
|
||||
tempList.Add(a);
|
||||
|
||||
if (category == AssetAlertCategory.PMAlert)
|
||||
{
|
||||
if (!pmalertdic.ContainsKey(a.ScheduleID))
|
||||
pmalertdic[a.ScheduleID] = new List<AlertInfo>();
|
||||
pmalertdic[a.ScheduleID].Add(a);
|
||||
}
|
||||
}
|
||||
items.DTCAlerts = dtcalerts.ToArray();
|
||||
items.PMAlerts = pmaalerts.ToArray();
|
||||
items.InspectAlerts = inspectalerts.ToArray();
|
||||
items.OilAlerts = oilalerts.ToArray();
|
||||
items.AllExpectedCost = 0;
|
||||
|
||||
foreach (var dic in pmalertdic)
|
||||
{
|
||||
items.AllExpectedCost += dic.Value.Where(m => !m.Recurring).Sum(m => m.ExpectedCost);
|
||||
|
||||
int minPriority = dic.Value.Select(m => m.Priority).Min();
|
||||
var recalerts = dic.Value.Where(m => m.Priority == minPriority && m.Recurring && m.ExpectedCost > 0);
|
||||
if (recalerts != null && recalerts.Count() > 0)
|
||||
items.AllExpectedCost += recalerts.Sum(m => m.ExpectedCost);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@ -509,6 +588,77 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
}
|
||||
}
|
||||
|
||||
private string SaveAutoAcknowledgeAlertTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
LoginSession session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
string[] alerttypes = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
CreateClient<WorkOrderProvider>().SaveAutoAcknowledgeAlertTypes(SystemParams.CompanyID, alerttypes, session.User.UID);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAutoAcknowledgeAlertTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string[] alerttypes = CreateClient<WorkOrderProvider>().GetAutoAcknowledgeAlertTypes(SystemParams.CompanyID, GetCurrentLoginSession().User.UID);
|
||||
return alerttypes;
|
||||
}
|
||||
else
|
||||
return new string[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAutoAcknowledgeAlertTypes", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAutoAcknowledgeAlertTypesHistory()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
AutoAcknowledgeItem[] items = CreateClient<WorkOrderProvider>().GetAutoAcknowledgeAlertTypesHistory(SystemParams.CompanyID, GetCurrentLoginSession().User.UID);
|
||||
if (items == null || items.Length == 0)
|
||||
return new AutoAcknowledgeInfo[0];
|
||||
|
||||
List<AutoAcknowledgeInfo> ls = new List<AutoAcknowledgeInfo>();
|
||||
foreach (AutoAcknowledgeItem item in items)
|
||||
{
|
||||
AutoAcknowledgeInfo ai = new AutoAcknowledgeInfo();
|
||||
Helper.CloneProperty(ai, item);
|
||||
ai.LocalUpdatedOn = ai.UpdatedOnLocal;
|
||||
ls.Add(ai);
|
||||
}
|
||||
return ls.OrderBy(m => m.LocalUpdatedOn).ToArray();
|
||||
}
|
||||
else
|
||||
return new AutoAcknowledgeInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAutoAcknowledgeAlertTypesHistory", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly string[] PMALERTS = new string[] { "Preventative Maintenance" };
|
||||
private static readonly string[] INSPECT = new string[] { "Red-Inspect", "Yellow-Inspect", "Green-Inspect", "Info-Inspect" };
|
||||
private static readonly string[] OILSAMPLE = new string[] { "Oil Sample Result" };
|
||||
@ -559,6 +709,67 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssignTos()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var users = Users.UserManagement.GetActiveUsers(session.SessionID, SystemParams.CompanyID);
|
||||
List<StringKeyValue> list = new List<StringKeyValue>();
|
||||
foreach (var u in users)
|
||||
{
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = u.IID;
|
||||
kv.Value = u.DisplayName;
|
||||
list.Add(kv);
|
||||
}
|
||||
|
||||
list = list.OrderBy((m) => m.Value).ToList();
|
||||
list.Insert(0, new StringKeyValue() { Key = "1", Value = "Alert Creator" });
|
||||
list.Insert(1, new StringKeyValue() { Key = "2", Value = "First Assigned Contact in Managed Assets" });
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
else
|
||||
return new StringKeyValue[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAssignTos", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
JobSiteItem[] jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, string.Empty, false);
|
||||
List<StringKeyValue> list = new List<StringKeyValue>();
|
||||
foreach (JobSiteItem js in jss)
|
||||
{
|
||||
StringKeyValue kv = new StringKeyValue();
|
||||
kv.Key = js.ID.ToString();
|
||||
kv.Value = js.Name;
|
||||
list.Add(kv);
|
||||
}
|
||||
|
||||
return list.OrderBy((m) => m.Value).ToArray();
|
||||
}
|
||||
else
|
||||
return new StringKeyValue[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetAssetGroups", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAlertTypes()
|
||||
{
|
||||
try
|
||||
@ -578,35 +789,83 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
}
|
||||
}
|
||||
|
||||
#region Work Order Generators
|
||||
|
||||
private AlertInfo ConvertAlert(AssetAlertItem alertitem)
|
||||
private object GetWorkOrderGenerators()
|
||||
{
|
||||
AlertInfo ai = new AlertInfo();
|
||||
ai.AlertID = alertitem.ID;
|
||||
ai.MachineID = alertitem.AssetID;
|
||||
ai.AlertType = alertitem.AlertType;
|
||||
ai.Description = alertitem.Description;
|
||||
ai.AlertTime_UTC = alertitem.AlertTime;
|
||||
ai.EngineHours = alertitem.EngineHours;
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
WorkOrderGeneratorInfo[] generators = CreateClient<WorkOrderProvider>().GetWorkOrderGenerators(SystemParams.CompanyID);
|
||||
if (generators == null)
|
||||
return new WorkOrderGeneratorInfo[0];
|
||||
|
||||
return ai;
|
||||
return generators;
|
||||
}
|
||||
else
|
||||
return new WorkOrderGeneratorInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "AlertsBasePage.GetWorkOrderGenerators", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class AlertItems
|
||||
{
|
||||
public AlertInfo[] DTCAlerts { get; set; }
|
||||
public AlertInfo[] PMAlerts { get; set; }
|
||||
public AlertInfo[] InspectAlerts { get; set; }
|
||||
public AlertInfo[] OilAlerts { get; set; }
|
||||
}
|
||||
public class AlertQueryParams
|
||||
{
|
||||
public string SearchText { get; set; }
|
||||
public string[] AlertStatus { get; set; }
|
||||
public string[] AssetGroups { get; set; }
|
||||
public string[] AlertTypes { get; set; }
|
||||
public string BeginDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
|
||||
private object SaveWorkOrderGenerator()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
WorkOrderGeneratorInfo generator = JsonConvert.DeserializeObject<WorkOrderGeneratorInfo>(clientdata);
|
||||
|
||||
if (generator.Id > 0)
|
||||
{
|
||||
CreateClient<WorkOrderProvider>().UpdateWorkOrderGenerator(SystemParams.CompanyID, generator);
|
||||
}
|
||||
else
|
||||
{
|
||||
generator.Id = CreateClient<WorkOrderProvider>().AddNewWorkOrderGenerator(SystemParams.CompanyID, generator);
|
||||
}
|
||||
|
||||
return new string[] { generator.Id.ToString(), "" };
|
||||
}
|
||||
else
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeleteWorkOrderGenerator()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string id = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
CreateClient<WorkOrderProvider>().DeleteWorkOrderGenerator(SystemParams.CompanyID, Convert.ToInt32(id));
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
return "Failed";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public class AlertsLisenceItem
|
||||
|
@ -6,15 +6,10 @@ using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System.Web;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.Device;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using IronIntel.Contractor.Attachment;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
@ -89,23 +84,26 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
var sdatestr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var edatestr = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
var searchtxt = HttpUtility.HtmlDecode(clientdata[3]);
|
||||
long assetid = 0;
|
||||
long.TryParse(HttpUtility.HtmlDecode(clientdata[4]), out assetid);
|
||||
|
||||
DateTime beginDate = DateTime.MinValue;
|
||||
DateTime beginDate = Helper.DBMinDateTime;
|
||||
DateTime endDate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(sdatestr, out beginDate))
|
||||
beginDate = DateTime.MinValue;
|
||||
beginDate = Helper.DBMinDateTime;
|
||||
if (!DateTime.TryParse(edatestr, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
|
||||
FuelRecord[] fuels = CreateClient<FuelManagementClient>().GetFuelRecords(SystemParams.CompanyID, Convert.ToInt64(type), beginDate, endDate, searchtxt);
|
||||
if (assetid > 0)
|
||||
fuels = fuels.Where(m => m.AssetID == assetid).ToArray();
|
||||
|
||||
List<FuelRecordInfo> list = new List<FuelRecordInfo>();
|
||||
foreach (FuelRecord fuel in fuels)
|
||||
{
|
||||
FuelRecordInfo fi = new FuelRecordInfo();
|
||||
Helper.CloneProperty(fi, fuel);
|
||||
//fi.TransactionDate = fi.TransactionDate.ToLocalTime();
|
||||
fi.TransactionDate = SystemParams.CustomerDetail.UtcToCustomerTime(fi.TransactionDate);
|
||||
fi.TransactionLocalDate = fuel.TransactionLocalDate;
|
||||
list.Add(fi);
|
||||
}
|
||||
|
||||
@ -140,9 +138,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
FuelRecordAuditItem fi = new FuelRecordAuditItem();
|
||||
Helper.CloneProperty(fi, fuel);
|
||||
//fi.TransactionDate = fi.TransactionDate.ToLocalTime();
|
||||
fi.TransactionDate=SystemParams.CustomerDetail.UtcToCustomerTime(fi.TransactionDate);
|
||||
fi.AddedOn = fi.AddedOn.ToLocalTime();
|
||||
fi.LastUpdatedOn = fi.LastUpdatedOn.ToLocalTime();
|
||||
fi.TransactionLocalDate = fuel.TransactionLocalDate;
|
||||
list.Add(fi);
|
||||
}
|
||||
|
||||
@ -171,8 +167,6 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
|
||||
FuelRecord record = new FuelRecord();
|
||||
Helper.CloneProperty(record, fuelrecord);
|
||||
//record.TransactionDate = record.TransactionDate.ToUniversalTime();
|
||||
record.TransactionDate = SystemParams.CustomerDetail.CustomerTimeToUtc(record.TransactionDate);
|
||||
long fuleid = record.FuelID;
|
||||
if (record.FuelID == -1)
|
||||
{
|
||||
@ -308,22 +302,21 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
string fuleid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
AttachmentInfo[] atts = CreateClient<AttachmentClient>().GetAttachments(SystemParams.CompanyID, "FuelRecord", fuleid);
|
||||
AttachmentItem[] atts = CreateClient<AttachmentProvider>().GetAttachmentItems(SystemParams.CompanyID, "FuelRecord", fuleid);
|
||||
if (atts == null || atts.Length <= 0)
|
||||
return new AttachmentItem[0];
|
||||
return new AttachmentItemClient[0];
|
||||
|
||||
List<AttachmentItem> list = new List<AttachmentItem>();
|
||||
foreach (AttachmentInfo att in atts)
|
||||
List<AttachmentItemClient> list = new List<AttachmentItemClient>();
|
||||
foreach (Foresight.Fleet.Services.AttachmentItem att in atts)
|
||||
{
|
||||
AttachmentItem item = new AttachmentItem();
|
||||
AttachmentItemClient item = new AttachmentItemClient();
|
||||
Helper.CloneProperty(item, att);
|
||||
item.AddedOn = item.AddedOn.AddHours(SystemParams.GetHoursOffset());
|
||||
list.Add(item);
|
||||
}
|
||||
return list.OrderBy(m => m.AddedOn).ToArray();
|
||||
}
|
||||
else
|
||||
return new AttachmentItem[0];
|
||||
return new AttachmentItemClient[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -348,15 +341,8 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
iconfilebyte = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
AttachmentInfo attachment = new AttachmentInfo();
|
||||
attachment.StringID = Guid.NewGuid().ToString().ToUpper();
|
||||
attachment.FileName = uploadFile == null ? "" : uploadFile.FileName;
|
||||
attachment.Source = "FuelRecord";
|
||||
attachment.SourceID = fuleid;
|
||||
attachment.FileData = iconfilebyte;
|
||||
attachment.AddedByUserIID = session.User.UID;
|
||||
|
||||
string attid = CreateClient<AttachmentClient>().AddAttachmentLegacy(SystemParams.CompanyID, attachment);
|
||||
string FileName = uploadFile == null ? "" : uploadFile.FileName;
|
||||
long attid = CreateClient<AttachmentProvider>().AddAttachment(SystemParams.CompanyID, "FuelRecord", fuleid, FileName, "", iconfilebyte);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -377,7 +363,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
CreateClient<AttachmentClient>().DeleteAttachmentLegacy(SystemParams.CompanyID, attachid, session.User.UID);
|
||||
CreateClient<AttachmentProvider>().DeleteAttachment(SystemParams.CompanyID, long.Parse(attachid));
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
@ -391,4 +377,9 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
#endregion
|
||||
|
||||
}
|
||||
public class AttachmentItemClient : AttachmentItem
|
||||
{
|
||||
public string AddedOnStr { get { return AddedOn.ToString(); } }
|
||||
public byte[] FileData { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,13 @@
|
||||
using System;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.ServiceModel;
|
||||
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 Newtonsoft.Json;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using System.Web;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using IronIntel.Contractor.Attachment;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
@ -33,9 +29,6 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
case "GETRECORDS":
|
||||
GetRecords();
|
||||
break;
|
||||
case "GETMACHINES":
|
||||
Getmachines();
|
||||
break;
|
||||
case "GETMACHINEINFO":
|
||||
GetmachineInfo();
|
||||
break;
|
||||
@ -91,9 +84,8 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
string json = "";
|
||||
List<KeyValuePair<int, string>> typeskeypair = new List<KeyValuePair<int, string>>();
|
||||
MachineServiceClient2 mc = new MachineServiceClient2(SystemParams.SystemServiceAddresses[0]);
|
||||
MachineType[] types = mc.GetMachineTypes();
|
||||
foreach (MachineType item in types)
|
||||
AssetType[] types = CreateClient<AssetClassProvider>().GetAssetTypes(SystemParams.CompanyID);
|
||||
foreach (AssetType item in types)
|
||||
{
|
||||
typeskeypair.Add(new KeyValuePair<int, string>(item.ID, item.Name));
|
||||
}
|
||||
@ -117,7 +109,17 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]);
|
||||
string sortype = HttpUtility.UrlDecode(Request.Params["sortype"]);
|
||||
string sortdata = HttpUtility.UrlDecode(Request.Params["sortdata"]);
|
||||
MaintenanceLogInfo[] logs = MaintenanceManagement.GetMaintenanceLog(session.SessionID, assetid, maintenanceType, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID);
|
||||
string sdatestr = HttpUtility.UrlDecode(Request.Params["startdate"]);
|
||||
string edatestr = HttpUtility.UrlDecode(Request.Params["enddate"]);
|
||||
|
||||
DateTime beginDate = Helper.DBMinDateTime;
|
||||
DateTime endDate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(sdatestr, out beginDate))
|
||||
beginDate = Helper.DBMinDateTime;
|
||||
if (!DateTime.TryParse(edatestr, out endDate))
|
||||
endDate = DateTime.MaxValue;
|
||||
|
||||
MaintenanceLogInfo[] logs = MaintenanceManagement.GetMaintenanceLog(session.SessionID, assetid, maintenanceType, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, beginDate, endDate, session.User.UID);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sortype))
|
||||
{
|
||||
@ -190,19 +192,19 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
string json = "";
|
||||
long mid = -1;
|
||||
long.TryParse(Request.Params["machineID"].ToString(), out mid);
|
||||
MaintenanceMachineInfo machine = MaintenanceManagement.GetmachineByMachineID(mid);
|
||||
json += JsonConvert.SerializeObject(machine);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
private void Getmachines()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
string json = "";
|
||||
string mtype = Request.Params["type"];
|
||||
string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]);
|
||||
MaintenanceMachineInfo[] machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID).OrderBy(t => t.VIN).ToArray();
|
||||
json += JsonConvert.SerializeObject(machines);
|
||||
AssetBasicInfo asset = CreateClient<AssetQueryClient>().GetAssetBasicInfoByID(SystemParams.CompanyID, mid);
|
||||
|
||||
MaintenanceMachineInfo mi = new MaintenanceMachineInfo();
|
||||
mi.MachineID = asset.ID;
|
||||
mi.MachineName = asset.Name;
|
||||
mi.MachineName2 = asset.Name2;
|
||||
mi.VIN = asset.VIN;
|
||||
mi.EngineHours = asset.EngineHours == null ? 0 : asset.EngineHours.Value;
|
||||
mi.Make = asset.MakeName;
|
||||
mi.Model = asset.ModelName;
|
||||
mi.TypeID = asset.TypeID;
|
||||
mi.MachineType = asset.TypeName;
|
||||
json += JsonConvert.SerializeObject(mi);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
@ -211,7 +213,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
var session = GetCurrentLoginSession();
|
||||
string json = "";
|
||||
string mtype = Request.Params["type"];
|
||||
string searchtxt = HttpUtility.UrlDecode(Request.Params["searchtxt"]);
|
||||
string searchtxt = HttpUtility.HtmlDecode(Request.Params["searchtxt"]);
|
||||
|
||||
MaintenanceMachineInfo[] machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, string.IsNullOrWhiteSpace(mtype) ? -1 : Convert.ToInt32(mtype), searchtxt, session.User.UID);
|
||||
if (machines.Length > 0)
|
||||
@ -230,6 +232,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
if (u != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
clientdata = HttpUtility.HtmlDecode(clientdata);
|
||||
MaintenanceLogInfo m = JsonConvert.DeserializeObject<MaintenanceLogInfo>(clientdata);
|
||||
|
||||
MaintenanceLogInfo oldinfo = null;
|
||||
@ -247,7 +250,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
oldinfo.MaintenanceHours = m.MaintenanceHours;
|
||||
oldinfo.ODOMeter = m.ODOMeter;
|
||||
oldinfo.ODOMemterUOM = m.ODOMemterUOM;
|
||||
oldinfo.Notes = HttpUtility.UrlDecode(m.Notes);
|
||||
oldinfo.Notes = HttpUtility.HtmlDecode(m.Notes);
|
||||
oldinfo.LogType = m.LogType;
|
||||
oldinfo.Cost = m.Cost;
|
||||
oldinfo.InvoiceNumber = m.InvoiceNumber;
|
||||
@ -371,16 +374,15 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var woid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
|
||||
AttachmentInfo[] atts = CreateClient<AttachmentClient>().GetAttachments(SystemParams.CompanyID, "MaintenanceLog", woid);
|
||||
AttachmentItem[] atts = CreateClient<AttachmentProvider>().GetAttachmentItems(SystemParams.CompanyID, "MaintenanceLog", woid);
|
||||
if (atts == null || atts.Length <= 0)
|
||||
return new AttachmentItem[0];
|
||||
|
||||
List<AttachmentItem> list = new List<AttachmentItem>();
|
||||
foreach (AttachmentInfo att in atts)
|
||||
foreach (AttachmentItem att in atts)
|
||||
{
|
||||
AttachmentItem item = new AttachmentItem();
|
||||
Helper.CloneProperty(item, att);
|
||||
item.AddedOn = item.AddedOn.ToLocalTime();
|
||||
list.Add(item);
|
||||
}
|
||||
return list.OrderBy(m => m.AddedOn).ToArray();
|
||||
@ -411,15 +413,8 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
iconfilebyte = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
AttachmentInfo attachment = new AttachmentInfo();
|
||||
attachment.StringID = Guid.NewGuid().ToString().ToUpper();
|
||||
attachment.FileName = uploadFile == null ? "" : uploadFile.FileName;
|
||||
attachment.Source = "MaintenanceLog";
|
||||
attachment.SourceID = woid;
|
||||
attachment.FileData = iconfilebyte;
|
||||
attachment.AddedByUserIID = session.User.UID;
|
||||
|
||||
string attid = CreateClient<AttachmentClient>().AddAttachmentLegacy(SystemParams.CompanyID, attachment);
|
||||
string FileName = uploadFile == null ? "" : uploadFile.FileName;
|
||||
long attid = CreateClient<AttachmentProvider>().AddAttachment(SystemParams.CompanyID, "MaintenanceLog", woid, FileName, "", iconfilebyte);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -440,7 +435,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
|
||||
|
||||
CreateClient<AttachmentClient>().DeleteAttachmentLegacy(SystemParams.CompanyID, attachid, session.User.UID);
|
||||
CreateClient<AttachmentProvider>().DeleteAttachment(SystemParams.CompanyID, long.Parse(attachid));
|
||||
return "OK";
|
||||
}
|
||||
return "Failed";
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -8,6 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class MaintenanceBasePage : ContractorBasePage
|
||||
@ -33,20 +33,22 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
private MaintenanceNavigateItem[] GetNavigations()
|
||||
{
|
||||
List<MaintenanceNavigateItem> list = GetNavigateItems();
|
||||
LicenseInfo license = SystemParams.GetLicense();
|
||||
Foresight.Fleet.Services.Customer.LicenseInfo license = SystemParams.GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
var alitem = license.Items.FirstOrDefault(m => m.Key == "AlertsManagement");
|
||||
if (alitem == null || !Helper.IsTrue(alitem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
|
||||
list.Remove(item);
|
||||
}
|
||||
var woitem = license.Items.FirstOrDefault(m => m.Key == "WorkOrder");
|
||||
if (woitem == null || !Helper.IsTrue(woitem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_workorder");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_workorderhis");
|
||||
list.Remove(item);
|
||||
}
|
||||
var alitem = license.Items.FirstOrDefault(m => m.Key == "AlertsManagement");
|
||||
if (alitem == null || !Helper.IsTrue(alitem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
|
||||
list.Remove(item);
|
||||
}
|
||||
var fuelitem = license.Items.FirstOrDefault(m => m.Key == "FuelRecords");
|
||||
if (fuelitem == null || !Helper.IsTrue(fuelitem.Value))
|
||||
@ -54,42 +56,66 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_fuelrecord");
|
||||
list.Remove(item);
|
||||
}
|
||||
var critem = license.Items.FirstOrDefault(m => m.Key == "CustomerRecord");
|
||||
if (critem == null || !Helper.IsTrue(critem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_customerrecord");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_customersatisfactionsurveys");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_surveymanagementresult");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_wosurveytemplate");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_wosurveytemplatereport");
|
||||
list.Remove(item);
|
||||
}
|
||||
var pmitem = license.Items.FirstOrDefault(m => m.Key == "PreventativeMaintenance");
|
||||
if (pmitem == null || !Helper.IsTrue(pmitem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_maintenanceschedule");
|
||||
list.Remove(item);
|
||||
}
|
||||
var mritem = license.Items.FirstOrDefault(m => m.Key == "MaintenanceRecord");
|
||||
if (mritem == null || !Helper.IsTrue(mritem.Value))
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_record");
|
||||
list.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
var user = GetCurrentUser();
|
||||
if (user.UserType == Users.UserTypes.Common)
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<PermissionProvider>();
|
||||
var client = CreateClient<PermissionProvider>();
|
||||
Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID);
|
||||
if (pmss.Length > 0)
|
||||
{
|
||||
Tuple<Feature, Permissions> alertpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.ALERTS_MANAGEMENT);
|
||||
if (alertpm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
|
||||
list.Remove(item);
|
||||
}
|
||||
Tuple<Feature, Permissions> wopm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORK_ORDER);
|
||||
if (wopm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_workorder");
|
||||
list.Remove(item);
|
||||
}
|
||||
Tuple<Feature, Permissions> wohispm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORKORDERHISTORY);
|
||||
if (wohispm == null)
|
||||
{
|
||||
MaintenanceNavigateItem itemhis = list.FirstOrDefault(m => m.ID == "nav_workorderhis");
|
||||
list.Remove(itemhis);
|
||||
}
|
||||
Tuple<Feature, Permissions> alertpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.ALERTS_MANAGEMENT);
|
||||
if (alertpm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
|
||||
list.Remove(item);
|
||||
}
|
||||
Tuple<Feature, Permissions> pmpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE);
|
||||
if (pmpm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item1 = list.FirstOrDefault(m => m.ID == "nav_preventative");
|
||||
list.Remove(item1);
|
||||
MaintenanceNavigateItem item2 = list.FirstOrDefault(m => m.ID == "nav_timebased");
|
||||
list.Remove(item2);
|
||||
MaintenanceNavigateItem item3 = list.FirstOrDefault(m => m.ID == "nav_hours");
|
||||
list.Remove(item3);
|
||||
MaintenanceNavigateItem item4 = list.FirstOrDefault(m => m.ID == "nav_absolutedistance");
|
||||
list.Remove(item4);
|
||||
MaintenanceNavigateItem item5 = list.FirstOrDefault(m => m.ID == "nav_relativedistance");
|
||||
list.Remove(item5);
|
||||
MaintenanceNavigateItem item6 = list.FirstOrDefault(m => m.ID == "nav_record");
|
||||
list.Remove(item6);
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_maintenanceschedule");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_record");
|
||||
list.Remove(item);
|
||||
}
|
||||
Tuple<Feature, Permissions> fuelpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.FUEL_RECORDS);
|
||||
if (fuelpm == null)
|
||||
@ -97,9 +123,29 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_fuelrecord");
|
||||
list.Remove(item);
|
||||
}
|
||||
Tuple<Feature, Permissions> crpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.CUSTOMER_RECORD);
|
||||
if (crpm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_customerrecord");
|
||||
list.Remove(item);
|
||||
}
|
||||
Tuple<Feature, Permissions> wosurpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORKORDERSURVEYS);
|
||||
if (crpm == null || wosurpm == null)
|
||||
{
|
||||
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_customersatisfactionsurveys");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_surveymanagementresult");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_wosurveytemplate");
|
||||
list.Remove(item);
|
||||
item = list.FirstOrDefault(m => m.ID == "nav_wosurveytemplatereport");
|
||||
list.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (user.UserType == Users.UserTypes.Readonly)
|
||||
list.Clear();
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
@ -108,68 +154,80 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
List<MaintenanceNavigateItem> list = new List<MaintenanceNavigateItem>();
|
||||
|
||||
MaintenanceNavigateItem item2 = new MaintenanceNavigateItem();
|
||||
item2.ID = "nav_workorder";
|
||||
item2.Title = "Work Order";
|
||||
item2.Url = "WorkOrderMaintenance.aspx";
|
||||
item2.IconPath = "img/workorder.png";
|
||||
list.Add(item2);
|
||||
|
||||
MaintenanceNavigateItem itemhis = new MaintenanceNavigateItem();
|
||||
itemhis.ID = "nav_workorderhis";
|
||||
itemhis.Title = "Work Order History";
|
||||
itemhis.Url = "WorkOrderHistory.aspx";
|
||||
itemhis.IconPath = "img/workorder.png";
|
||||
list.Add(itemhis);
|
||||
|
||||
MaintenanceNavigateItem item1 = new MaintenanceNavigateItem();
|
||||
item1.ID = "nav_alertsmanagement";
|
||||
item1.Title = "Alerts Management **New**";
|
||||
item1.Title = "Alerts Management";
|
||||
item1.Url = "AlertsManagement.aspx";
|
||||
item1.IconPath = "img/alert.png";
|
||||
list.Add(item1);
|
||||
|
||||
MaintenanceNavigateItem item6 = new MaintenanceNavigateItem();
|
||||
item6.ID = "nav_workorder";
|
||||
item6.Title = "Work Order **New**";
|
||||
item6.Url = "WorkOrderMaintenance.aspx";
|
||||
item6.IconPath = "img/workorder.png";
|
||||
list.Add(item6);
|
||||
|
||||
MaintenanceNavigateItem item3 = new MaintenanceNavigateItem();
|
||||
item3.ID = "nav_preventative";
|
||||
item3.Title = "Absolute Hours Maintenance";
|
||||
item3.Url = "PreventativeMaintenance.aspx";
|
||||
item3.ID = "nav_maintenanceschedule";
|
||||
item3.Title = "Maintenance Schedules";
|
||||
item3.Url = "MaintenanceSchedulesManagement.aspx";
|
||||
item3.IconPath = "img/preventative.png";
|
||||
list.Add(item3);
|
||||
|
||||
MaintenanceNavigateItem item4 = new MaintenanceNavigateItem();
|
||||
item4.ID = "nav_timebased";
|
||||
item4.Title = "Relative Time Maintenance";
|
||||
item4.Url = "TimeBasedMaintenance.aspx";
|
||||
item4.IconPath = "img/timebased.png";
|
||||
item4.ID = "nav_record";
|
||||
item4.Title = "Maintenance Record";
|
||||
item4.Url = "MaintanceRecordsManagement.aspx";
|
||||
item4.IconPath = "img/record.png";
|
||||
list.Add(item4);
|
||||
|
||||
MaintenanceNavigateItem item7 = new MaintenanceNavigateItem();
|
||||
item7.ID = "nav_hours";
|
||||
item7.Title = "Relative Hours Maintenance";
|
||||
item7.Url = "HoursMaintenance.aspx";
|
||||
item7.IconPath = "img/hours.png";
|
||||
list.Add(item7);
|
||||
|
||||
MaintenanceNavigateItem item5 = new MaintenanceNavigateItem();
|
||||
item5.ID = "nav_absolutedistance";
|
||||
item5.Title = "Absolute Distance Maintenance";
|
||||
item5.Url = "AbsoluteDistanceMaintenance.aspx";
|
||||
item5.IconPath = "img/preventative.png";
|
||||
item5.ID = "nav_fuelrecord";
|
||||
item5.Title = "Fuel Records";
|
||||
item5.Url = "FuelRecordManagement.aspx";
|
||||
item5.IconPath = "img/fuelrecord.png";
|
||||
list.Add(item5);
|
||||
|
||||
MaintenanceNavigateItem item6 = new MaintenanceNavigateItem();
|
||||
item6.ID = "nav_customerrecord";
|
||||
item6.Title = "Customer Record";
|
||||
item6.Url = "CustomerRecordManagement.aspx";
|
||||
item6.IconPath = "img/customerrecord.png";
|
||||
list.Add(item6);
|
||||
|
||||
MaintenanceNavigateItem item7 = new MaintenanceNavigateItem();
|
||||
item7.ID = "nav_customersatisfactionsurveys";
|
||||
item7.Title = "Customer Satisfaction Surveys";
|
||||
//item7.Url = "SurveyTemplateManagement.aspx";
|
||||
item7.IconPath = "img/customerrecord.png";
|
||||
list.Add(item7);
|
||||
|
||||
MaintenanceNavigateItem item8 = new MaintenanceNavigateItem();
|
||||
item8.ID = "nav_relativedistance";
|
||||
item8.Title = "Relative Distance Maintenance";
|
||||
item8.Url = "RelativeDistanceMaintenance.aspx";
|
||||
item8.IconPath = "img/hours.png";
|
||||
item8.ID = "nav_surveymanagementresult";
|
||||
item8.Title = "Survey Management/Result";
|
||||
item8.Url = "SurveyManagement.aspx";
|
||||
list.Add(item8);
|
||||
|
||||
MaintenanceNavigateItem item2 = new MaintenanceNavigateItem();
|
||||
item2.ID = "nav_record";
|
||||
item2.Title = "Maintenance Record **Legacy**";
|
||||
item2.Url = "MaintanceRecordsManagement.aspx";
|
||||
item2.IconPath = "img/record.png";
|
||||
list.Add(item2);
|
||||
|
||||
MaintenanceNavigateItem item9 = new MaintenanceNavigateItem();
|
||||
item9.ID = "nav_fuelrecord";
|
||||
item9.Title = "Fuel Records";
|
||||
item9.Url = "FuelRecordManagement.aspx";
|
||||
item9.IconPath = "img/fuelrecord.png";
|
||||
item9.ID = "nav_wosurveytemplate";
|
||||
item9.Title = "Templates";
|
||||
item9.Url = "SurveyTemplateManagement.aspx";
|
||||
list.Add(item9);
|
||||
|
||||
MaintenanceNavigateItem item10 = new MaintenanceNavigateItem();
|
||||
item10.ID = "nav_wosurveytemplatereport";
|
||||
item10.Title = "Reports";
|
||||
item10.Url = "SurveyTemplateReport.aspx";
|
||||
list.Add(item10);
|
||||
|
||||
return list;
|
||||
}
|
||||
public class MaintenanceNavigateItem
|
||||
|
@ -1,26 +0,0 @@
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public class ScheduleSaveArgs
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ScheduleUom { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Notes { get; set; }
|
||||
|
||||
public PmIntervalItem[] Intervals { get; set; }
|
||||
}
|
||||
|
||||
public class ScheduleMachineArgs
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public MaintenanceMachineInfo[] Machines { get; set; }
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -69,6 +69,9 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
case "GETPMSCHEDULEBYID":
|
||||
result = GetPMScheduleByID();
|
||||
break;
|
||||
case "GETMAINTENANCESCHEDULES":
|
||||
result = GetMaintenanceSchedules();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,7 +119,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
if (string.IsNullOrWhiteSpace(pmtype))
|
||||
pmtype = "PM";
|
||||
|
||||
return MaintenanceManagement.GetPmSchedule(session.SessionID, pmtype);
|
||||
return MaintenanceManagement.GetPmSchedule(session.SessionID, pmtype, string.Empty, string.Empty);
|
||||
}
|
||||
else
|
||||
return new PmScheduleInfo[0];
|
||||
@ -127,6 +130,32 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetMaintenanceSchedules()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
string[] param = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
var pmtype = param[0];
|
||||
var pmid = param[1];
|
||||
var filter = HttpUtility.HtmlDecode(param[2]);
|
||||
|
||||
return MaintenanceManagement.GetPmSchedule(session.SessionID, pmtype, pmid, filter);
|
||||
}
|
||||
else
|
||||
return new PmScheduleInfo[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "PreventativeMaintenanceBasePage.GetPmSchedule", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetPMScheduleByID()
|
||||
{
|
||||
try
|
||||
@ -316,17 +345,7 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
var s = Request.Form["ClientData"];
|
||||
var type = JsonConvert.DeserializeObject<MachineItem>(s);
|
||||
|
||||
//MaintenanceMachineInfo[] selected;
|
||||
//if (!string.IsNullOrWhiteSpace(type.VIN))
|
||||
//{
|
||||
// selected = MaintenanceManagement.GetPmMachinesByScheduleId(type.VIN);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// selected = new MaintenanceMachineInfo[0];
|
||||
//}
|
||||
|
||||
var machines = MaintenanceManagement.GetMaintenanceMachines1(session.SessionID, (int)type.MachineID, type.Name, session.User.UID)
|
||||
var machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, (int)type.MachineID, type.Name, session.User.UID)
|
||||
//.Where(m => !selected.Any(t => t.MachineID == m.MachineID))
|
||||
.OrderBy(m => m.VIN)
|
||||
.ToArray();
|
||||
@ -336,18 +355,38 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
|
||||
private PMAssetItem[] GetSelectedMachines()
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
List<PMAssetItem> result = new List<PMAssetItem>();
|
||||
var assets = CreateClient<PMClient>().GetPMAssets(SystemParams.CompanyID, iid);
|
||||
foreach (var asset in assets)
|
||||
try
|
||||
{
|
||||
PMAssetItem a = new PMAssetItem();
|
||||
Helper.CloneProperty(a, asset);
|
||||
a.EngineHours = asset.CurrentEngineHours;
|
||||
a.Odometer = asset.CurrentOdometer;
|
||||
result.Add(a);
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var iid = Request.Form["ClientData"];
|
||||
List<PMAssetItem> result = new List<PMAssetItem>();
|
||||
var assets = CreateClient<PMClient>().GetPMAssets(SystemParams.CompanyID, iid);
|
||||
if (session.User.UserType < Foresight.Fleet.Services.User.UserTypes.Admin)
|
||||
{
|
||||
AssetBasicInfo[] allassets = CreateClient<AssetQueryClient>(SystemParams.CompanyID).GetAssetBasicInfoByUser(SystemParams.CompanyID, "", session.User.UID, 0);
|
||||
var allassetids = allassets.Select(a => a.ID).ToList();
|
||||
assets = assets.Where(a => allassetids.Contains(a.AssetId)).ToArray();
|
||||
}
|
||||
foreach (var asset in assets)
|
||||
{
|
||||
PMAssetItem a = new PMAssetItem();
|
||||
Helper.CloneProperty(a, asset);
|
||||
a.EngineHours = asset.CurrentEngineHours;
|
||||
a.Odometer = asset.CurrentOdometer;
|
||||
result.Add(a);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
private string SaveMachines()
|
||||
@ -409,7 +448,21 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
{
|
||||
public string ModelName { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public double? StartOdometer { get; set; }
|
||||
private double? _StartOdometer;
|
||||
public double? StartOdometer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _StartOdometer;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
_StartOdometer = Math.Round(value.Value, 2);
|
||||
else
|
||||
_StartOdometer = value;
|
||||
}
|
||||
}
|
||||
public double? StartHours { get; set; }
|
||||
public DateTime? StartDate { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
@ -420,7 +473,22 @@ namespace IronIntel.Contractor.Site.Maintenance
|
||||
public string VIN { get; set; }
|
||||
public long AssetId { get; set; }
|
||||
public double? EngineHours { get; set; }
|
||||
public double? Odometer { 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 string PMScheduleId { get; set; }
|
||||
public int? StartIntervalValue { get; set; }
|
||||
public string StartDateString
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,24 +6,21 @@ using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using Newtonsoft.Json;
|
||||
using IronIntel.Site;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
using IronIntel.Contractor.Contact;
|
||||
using Foresight.Fleet.Services.Attachment;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.MapView;
|
||||
using System.Net;
|
||||
using IronIntel.Contractor.iisitebase;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace IronIntel.Contractor.Site.MapView
|
||||
{
|
||||
public class MapViewHandler : IronIntelHttpHandlerBase
|
||||
{
|
||||
public override string GetIronSystemServiceAddress()
|
||||
{
|
||||
return SystemParams.SystemServiceAddresses[0];
|
||||
}
|
||||
|
||||
public MapViewHandler(HttpContext context)
|
||||
: base(context)
|
||||
{
|
||||
@ -67,11 +64,17 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
case "GetServerVersion":
|
||||
result = GetServerVersion();
|
||||
break;
|
||||
case "GetContacts":
|
||||
result = GetContacts();
|
||||
break;
|
||||
case "GetMachineContacts":
|
||||
result = GetMachineContacts();
|
||||
break;
|
||||
case "SendLocation":
|
||||
result = SendLocation();
|
||||
case "GetJobsiteContacts":
|
||||
result = GetJobsiteContacts();
|
||||
break;
|
||||
case "SendEmails":
|
||||
result = SendEmails();
|
||||
break;
|
||||
case "SaveMapViewSearch":
|
||||
result = SaveMapViewSearch();
|
||||
@ -97,6 +100,21 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
case "GetAssetByID":
|
||||
result = GetAssetByID();
|
||||
break;
|
||||
case "RequestVideo":
|
||||
result = RequestVideo();
|
||||
break;
|
||||
case "GetAssetTripLins":
|
||||
result = GetAssetTripLins();
|
||||
break;
|
||||
case "GetLocationPrimaryDataSource":
|
||||
result = GetLocationPrimaryDataSource();
|
||||
break;
|
||||
case "GetAssetMapAttachments":
|
||||
result = GetAssetMapAttachments();
|
||||
break;
|
||||
case "GetNowFormatDate":
|
||||
result = GetNowFormatDate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -116,6 +134,9 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
string serverVersion = SystemParams.GetVersion();
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
const char SPLITCHAR170 = (char)170;
|
||||
const char SPLITCHAR171 = (char)171;
|
||||
private object GetAssets()
|
||||
{
|
||||
AssetMapViewPinItem[] assets = null;
|
||||
@ -132,7 +153,11 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
viewqueryparam = ConvertToMachineAlertViewQueryParameter(p);
|
||||
}
|
||||
|
||||
assets = AssetMapViewManagement.GetAssets(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText, p.Onroad, viewqueryparam, !p.ExcludeNoLocation);
|
||||
if (!SystemParams.IsDealer)
|
||||
assets = AssetMapViewManagement.GetAssets(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText, p.Onroad, viewqueryparam, !p.ExcludeNoLocation, p.Attachment);
|
||||
else
|
||||
assets = AssetMapViewManagement.GetDealerAssets(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText, p.Onroad, viewqueryparam, !p.ExcludeNoLocation, p.Attachment);
|
||||
|
||||
SystemParams.WriteRefreshLog(LoginSession.User.UID, UserHostAddress, "Assets", p.IsAutoRefresh ? "Auto" : "Manual");
|
||||
}
|
||||
else
|
||||
@ -141,13 +166,14 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
List<string> results = new List<string>();
|
||||
foreach (var r in assets)
|
||||
{
|
||||
//if (sb.Length > 0)
|
||||
//{
|
||||
// sb.Append((char)171);
|
||||
//}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
r.ToFormatedString(sb, (char)170);
|
||||
results.Add(sb.ToString());
|
||||
if (r is AssetMapViewPinItemClient)
|
||||
{
|
||||
AssetMapViewPinItemClient rc = r as AssetMapViewPinItemClient;
|
||||
var companyinfo = rc.CompanyID + SPLITCHAR170 + rc.CompanyName;
|
||||
results.Add(companyinfo + SPLITCHAR171 + r.ToString());
|
||||
}
|
||||
else
|
||||
results.Add(r.ToString());
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
@ -170,11 +196,13 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
List<AssetGroupViewItem> temp = new List<AssetGroupViewItem>();
|
||||
groups = AssetMapViewManagement.GetAssetGroups(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText);
|
||||
if (!SystemParams.IsDealer)
|
||||
groups = AssetMapViewManagement.GetAssetGroups(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText);
|
||||
else
|
||||
groups = AssetMapViewManagement.GetDealerAssetGroups(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText);
|
||||
temp.AddRange(groups);
|
||||
|
||||
AssetGroupViewItem eg = new AssetGroupViewItem() { ID = "-1", Name = "No Asset Group Assigned" };
|
||||
//eg.Assets = AssetMapViewManagement.GetNoGroupAssets(companyid);
|
||||
AssetGroupViewItem eg = new AssetGroupViewItem() { ID = "-1", Name = SystemParams.GetTextByKey(GetLanguageCookie(), "P_MV_NOASSETGROUPASSIGNED", "No Asset Group Assigned") };
|
||||
temp.Add(eg);
|
||||
groups = temp.ToArray();
|
||||
}
|
||||
@ -274,6 +302,67 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
return item;
|
||||
}
|
||||
|
||||
private AssetTripItem[] GetAssetTripLins()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
string[] ps = p.Split(';');
|
||||
//if (ps.Length != 6) return item;
|
||||
DateTime dtFrom = DateTime.Now;
|
||||
DateTime dtTo = DateTime.Now;
|
||||
if (!DateTime.TryParse(ps[1], out dtFrom) || !DateTime.TryParse(ps[2], out dtTo))
|
||||
return new AssetTripItem[0];
|
||||
string companyid = ps[3].Trim();//companyid
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, LoginSession.SessionID);
|
||||
AssetTripInfo[] trips = client.GetAssetTripLins(companyid, long.Parse(ps[0]), dtFrom, dtTo);
|
||||
trips = trips.Where(m => m.TripOn != null || m.TripOff != null).ToArray();
|
||||
|
||||
List<AssetTripItem> ls = new List<AssetTripItem>();
|
||||
TripColor[] colors = Enum.GetValues(typeof(TripColor)) as TripColor[];
|
||||
Random random = new Random();
|
||||
foreach (AssetTripInfo trip in trips)
|
||||
{
|
||||
AssetTripItem item = new AssetTripItem();
|
||||
Helper.CloneProperty(item, trip);
|
||||
|
||||
TripColor color = colors[random.Next(0, colors.Length)];
|
||||
item.Color = color;
|
||||
|
||||
ls.Add(item);
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new AssetTripItem[0];
|
||||
}
|
||||
}
|
||||
|
||||
private Tuple<string, string> GetLocationPrimaryDataSource()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
string[] ps = p.Split(';');
|
||||
string companyid = ps[1].Trim();//companyid
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, LoginSession.SessionID);
|
||||
Tuple<string, string> datasource = client.GetLocationPrimaryDataSource(companyid, long.Parse(ps[0]));
|
||||
|
||||
return datasource;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Tuple<string, string>(string.Empty, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private JobSiteViewItem[] GetJobSites()
|
||||
{
|
||||
JobSiteViewItem[] items = null;
|
||||
@ -284,18 +373,14 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
GetJobsiteParameterItem p = JsonConvert.DeserializeObject<GetJobsiteParameterItem>(clientdata);
|
||||
p.SearchText = HttpUtility.HtmlDecode(p.SearchText);
|
||||
|
||||
string companyid = p.ContractorID;
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
items = AssetMapViewManagement.GetJobsites(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText);
|
||||
|
||||
|
||||
List<JobSiteViewItem> temp = new List<JobSiteViewItem>();
|
||||
items = AssetMapViewManagement.GetJobsites(LoginSession.SessionID, companyid, LoginSession.User.UID, p.SearchText);
|
||||
if (!SystemParams.IsDealer)
|
||||
items = AssetMapViewManagement.GetJobsites(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText);
|
||||
else
|
||||
items = AssetMapViewManagement.GetDealerJobsites(LoginSession.SessionID, p.ContractorID, LoginSession.User.UID, p.SearchText);
|
||||
temp.AddRange(items);
|
||||
|
||||
JobSiteViewItem js = new JobSiteViewItem() { ID = -1, Name = "No Jobsite Assigned" };
|
||||
JobSiteViewItem js = new JobSiteViewItem() { ID = -1, Name = SystemParams.GetTextByKey(GetLanguageCookie(), "P_MV_NOJOBSITEASSIGNED", "No Jobsite Assigned") };
|
||||
temp.Add(js);
|
||||
items = temp.ToArray();
|
||||
}
|
||||
@ -316,23 +401,11 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, LoginSession.SessionID);
|
||||
CustomerLocation[] locs = client.GetContractorAndDealerLocations(companyid);
|
||||
List<CompanyLocationViewItem> temps = new List<CompanyLocationViewItem>();
|
||||
foreach (var loc in locs)
|
||||
{
|
||||
CompanyLocationViewItem l = new CompanyLocationViewItem();
|
||||
l.ID = loc.ID;
|
||||
l.Latitude = loc.Latitude;
|
||||
l.Longitude = loc.Longitude;
|
||||
l.LocationName = loc.Name;
|
||||
l.Notes = loc.Notes;
|
||||
l.IconUrl = loc.IconUrl;
|
||||
temps.Add(l);
|
||||
}
|
||||
items = temps.ToArray();
|
||||
|
||||
//items = LocationManagement.GetCompanyLocations("");
|
||||
if (!SystemParams.IsDealer)
|
||||
items = AssetMapViewManagement.GetLocations(LoginSession.SessionID, companyid);
|
||||
else
|
||||
items = AssetMapViewManagement.GetDealerLocations(LoginSession.SessionID, companyid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -352,7 +425,10 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
string companyid = p.Substring(0, index);
|
||||
string selectedViewID = p.Substring(index + 1);
|
||||
|
||||
items = AssetMapViewManagement.GetMapAlertViews(LoginSession.SessionID, companyid, selectedViewID);
|
||||
if (!SystemParams.IsDealer)
|
||||
items = AssetMapViewManagement.GetMapAlertViews(LoginSession.SessionID, companyid, selectedViewID);
|
||||
else
|
||||
items = AssetMapViewManagement.GetDealerMapAlertViews(LoginSession.SessionID, companyid, selectedViewID);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -409,7 +485,77 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
return new MapViewSearchItem[0];
|
||||
}
|
||||
|
||||
private object GetAssetMapAttachments()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
string companyid = ps[0];
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
long assetid = 0;
|
||||
if (!long.TryParse(ps[1], out assetid))
|
||||
return null;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, LoginSession.SessionID);
|
||||
return client.GetAssetDocumentsOnMap(companyid, assetid);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private object RequestVideo()
|
||||
{
|
||||
if (LoginSession != null && SystemParams.HasLicense("SmartWitness"))
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(p);
|
||||
string companyid = ps[0];
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
long aid = 0;
|
||||
DateTime dt = DateTime.MinValue;
|
||||
if (long.TryParse(ps[1], out aid))
|
||||
{
|
||||
bool isCustomerTime = ps[2] == "1";
|
||||
if (DateTime.TryParse(ps[3], out dt))
|
||||
{
|
||||
var cust = SystemParams.GetCustomerDetail(companyid);
|
||||
dt = cust.CustomerTimeToUtc(dt);
|
||||
}
|
||||
int seconds = ps[4] == "1" ? 30 : 120;
|
||||
|
||||
long logid = 0;
|
||||
if (!long.TryParse(ps[5], out logid))
|
||||
logid = -1;
|
||||
string src = ps[6];
|
||||
string subsrc = ps[7];
|
||||
string et = ps[8];
|
||||
string msguid = ps[9];
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, LoginSession.SessionID);
|
||||
var result = client.SendSmartWitnessVideoRequestWithTime(companyid, LoginSession.User.UID, aid, isCustomerTime, dt, seconds, logid, src, subsrc, et, msguid);
|
||||
//var result = client.SendSmartWitnessVideoRequest(companyid, logid, LoginSession.User.UID);
|
||||
return string.IsNullOrEmpty(result) ? "OK" : result;
|
||||
}
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
#region Send Location
|
||||
private UserInfo[] GetContacts()
|
||||
{
|
||||
UserInfo[] users;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
users = UserManagement.GetUsers().Where(u => u.Active).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
users = new UserInfo[0];
|
||||
}
|
||||
return users;
|
||||
}
|
||||
private UserInfo[] GetMachineContacts()
|
||||
{
|
||||
UserInfo[] items = null;
|
||||
@ -429,51 +575,104 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
}
|
||||
return items;
|
||||
}
|
||||
private string SendLocation()
|
||||
private UserInfo[] GetJobsiteContacts()
|
||||
{
|
||||
UserInfo[] items = null;
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
int index = p.IndexOf(";");
|
||||
string contractorid = p.Substring(0, index);
|
||||
string jsid = p.Substring(index + 1);
|
||||
|
||||
items = UserManagement.GetUsersByJobsiteID(LoginSession.SessionID, Convert.ToInt64(jsid), contractorid);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new UserInfo[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
private string SendEmails()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
string p = Context.Request.Params["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
|
||||
SendLocationInfo si = JsonConvert.DeserializeObject<SendLocationInfo>(p);
|
||||
SendEmailsInfo si = JsonConvert.DeserializeObject<SendEmailsInfo>(p);
|
||||
if (string.IsNullOrEmpty(si.CompanyID))
|
||||
si.CompanyID = SystemParams.CompanyID;
|
||||
|
||||
AssetDetailViewItem asset = AssetMapViewManagement.GetAssetDetailItem(LoginSession.SessionID, si.CompanyID, si.AssetID);
|
||||
SendMail(asset, si);
|
||||
if (si.Type == 0)
|
||||
{//SendLocation
|
||||
AssetDetailViewItem asset = AssetMapViewManagement.GetAssetDetailItem(LoginSession.SessionID, si.CompanyID, si.ObjectID);
|
||||
SendAssetLocation(asset, si);
|
||||
}
|
||||
else if (si.Type == 1)
|
||||
{//Send Jobsite
|
||||
JobSiteItem jobsite = FleetServiceClientHelper.CreateClient<JobSiteProvider>().GetJobSiteItem(si.CompanyID, si.ObjectID);
|
||||
SendJobsite(jobsite, si);
|
||||
}
|
||||
else if (si.Type == 3)
|
||||
{
|
||||
// Send Route
|
||||
SendRoute(si);
|
||||
}
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
private void SendMail(AssetDetailViewItem asset, SendLocationInfo si)
|
||||
|
||||
private void SendAssetLocation(AssetDetailViewItem asset, SendEmailsInfo si)
|
||||
{
|
||||
string[] emailaddress = si.EmailAddress;
|
||||
string[] textaddress = si.TextAddress;
|
||||
string Subject = "Location of Asset: " + asset.Name2 + " " + asset.Name + " " + asset.Make + " " + asset.Model + " " + asset.VIN + " " + (asset.MakeYear > 0 ? asset.MakeYear.ToString() : "");
|
||||
StringKeyValue[] emailaddress = si.EmailAddress;
|
||||
StringKeyValue[] textaddress = si.TextAddress;
|
||||
var alllangs = GetUserLanguages(emailaddress, textaddress);
|
||||
var useriid = LoginSession.User.UID;
|
||||
var client = FleetServiceClientHelper.CreateClient<AttachmentClient>();
|
||||
if (emailaddress != null && emailaddress.Length > 0)
|
||||
{
|
||||
string Body = OrdinaryEmailFormat(asset, si.Description);
|
||||
FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationEmail(si.CompanyID, si.AssetID, Subject, Body, emailaddress.ToArray(), useriid);
|
||||
foreach (var item in emailaddress)
|
||||
{
|
||||
string lang = GetUserLanguage(alllangs, item.Key);
|
||||
string Subject = SystemParams.GetTextByKey(lang, "P_MV_LOCATIONOFASSET_COLON", "Location of Asset:") + " " + asset.Name2 + " " + asset.Name + " " + asset.Make + " " + asset.Model + " " + asset.VIN + " " + (asset.MakeYear > 0 ? asset.MakeYear.ToString() : "");
|
||||
|
||||
string Body = OrdinaryEmailFormat(lang, asset, si.Description, LoginSession.User.Name);
|
||||
client.SendAssetLoationEmail(si.CompanyID, si.ObjectID, Subject, Body, new string[] { item.Value }, useriid);
|
||||
}
|
||||
}
|
||||
if (textaddress != null && textaddress.Length > 0)
|
||||
{
|
||||
string Body = OrdinaryTextFormat(asset, si.Description);
|
||||
Subject = "";//短信暂时不发Subject 8897反馈
|
||||
FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationEmail(si.CompanyID, si.AssetID, Subject, Body, textaddress.ToArray(), useriid);
|
||||
foreach (var item in textaddress)
|
||||
{
|
||||
string lang = GetUserLanguage(alllangs, item.Key);
|
||||
string Body = OrdinaryTextFormat(lang, asset, si.Description, LoginSession.User.Name);
|
||||
string Subject = "";//短信暂时不发Subject 8897反馈
|
||||
client.SendAssetLoationText(si.CompanyID, si.ObjectID, Subject, Body, new string[] { item.Value }, useriid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string OrdinaryEmailFormat(AssetDetailViewItem asset, string desc)
|
||||
private string OrdinaryEmailFormat(string lang, AssetDetailViewItem asset, string desc, string username)
|
||||
{
|
||||
string EmailFormat = "Location of Asset: {0} {1} {2} {3} {4} {5}</br></br>";
|
||||
EmailFormat += "Description:</br>";
|
||||
EmailFormat += "{6}</br><br/>";
|
||||
EmailFormat += "Click the link below to view directions to this asset:</br>";
|
||||
EmailFormat += "<a href=\"{7}\">{7}</a>";
|
||||
string EmailFormat = SystemParams.GetTextByKey(lang, "P_MV_LOCATIONOFASSET_COLON", "Location of Asset:") + " {0} {1} {2} {3} {4} {5}<br/><br/>";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_DESCRIPTION_COLON", "Description:") + "<br/>";
|
||||
EmailFormat += "{6}<br/><br/>";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_CLICKTHELINKBELOWTOVIEWDIRECTIONSTOTHISASSET", "Click the link below to view directions to this asset:") + "<br/>";
|
||||
EmailFormat += "<a href=\"{7}\">" + SystemParams.GetTextByKey(lang, "P_MV_VIEWDIRECTIONS", "View Directions") + "</a>";
|
||||
|
||||
if (asset.Location == null)
|
||||
asset.Location = new LocationViewItem();
|
||||
|
||||
if (!string.IsNullOrEmpty(desc))
|
||||
{
|
||||
desc = Regex.Replace(desc, "\\[site name\\]", SystemParams.CustomerDetail.Name, RegexOptions.IgnoreCase);
|
||||
desc = Regex.Replace(desc, "\\[User Name\\]", username, RegexOptions.IgnoreCase);
|
||||
desc = Regex.Replace(desc, "\\[asset name\\]", asset.DisplayName, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
return string.Format(EmailFormat,
|
||||
HttpUtility.HtmlEncode(asset.Name2),
|
||||
HttpUtility.HtmlEncode(asset.Name),
|
||||
@ -485,24 +684,309 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
"https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude + "&travelmode=driving");
|
||||
}
|
||||
|
||||
private string OrdinaryTextFormat(AssetDetailViewItem asset, string desc)
|
||||
private string OrdinaryTextFormat(string lang, AssetDetailViewItem asset, string desc, string username)
|
||||
{
|
||||
string EmailFormat = "Location of Asset: {0} {1} {2} {3} {4} {5}</br></br>";
|
||||
EmailFormat += "Description:</br>";
|
||||
EmailFormat += "{6}</br><br/>";
|
||||
EmailFormat += "Click the link below to view directions to this asset:</br>";
|
||||
EmailFormat += "<a href=\"{7}\">View Directions</a>";
|
||||
if (asset.Location == null)
|
||||
asset.Location = new LocationViewItem();
|
||||
//string EmailFormat = SystemParams.GetTextByKey(lang, "P_MV_LOCATIONOFASSET_COLON", "Location of Asset:") + " {0}. ";
|
||||
////string EmailFormat = "Location of Asset: {0} {1} {2} {3} {4} {5}. ";
|
||||
////EmailFormat += "Description: ";
|
||||
////EmailFormat += "{6}. ";
|
||||
//EmailFormat += "<a href=\"{1}\">" + SystemParams.GetTextByKey(lang, "P_MV_VIEWDIRECTIONS", "View Directions") + "</a>";
|
||||
//if (asset.Location == null)
|
||||
// asset.Location = new LocationViewItem();
|
||||
//return string.Format(EmailFormat,
|
||||
// HttpUtility.HtmlEncode(asset.DisplayName),
|
||||
// //HttpUtility.HtmlEncode(asset.Name),
|
||||
// //HttpUtility.HtmlEncode(asset.Make),
|
||||
// //HttpUtility.HtmlEncode(asset.Model),
|
||||
// //HttpUtility.HtmlEncode(asset.VIN),
|
||||
// //HttpUtility.HtmlEncode(asset.MakeYear > 0 ? asset.MakeYear.ToString() : ""),
|
||||
// //HttpUtility.HtmlEncode(desc ?? ""),
|
||||
// "https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude /*+ "&travelmode=driving"*/);
|
||||
|
||||
if (!string.IsNullOrEmpty(desc))
|
||||
{
|
||||
desc = Regex.Replace(desc, "\\[site name\\]", SystemParams.CustomerDetail.Name, RegexOptions.IgnoreCase);
|
||||
desc = Regex.Replace(desc, "\\[User Name\\]", username, RegexOptions.IgnoreCase);
|
||||
desc = Regex.Replace(desc, "\\[asset name\\]", asset.DisplayName, RegexOptions.IgnoreCase);
|
||||
}
|
||||
return desc + Environment.NewLine + Environment.NewLine + "https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude;
|
||||
}
|
||||
|
||||
private void SendJobsite(JobSiteItem jobsite, SendEmailsInfo si)
|
||||
{
|
||||
StringKeyValue[] emailaddress = si.EmailAddress;
|
||||
StringKeyValue[] textaddress = si.TextAddress;
|
||||
var alllangs = GetUserLanguages(emailaddress, textaddress);
|
||||
string Subject = jobsite.Name;
|
||||
if (!string.IsNullOrEmpty(jobsite.Code))
|
||||
Subject += "/" + jobsite.Code;
|
||||
if (!string.IsNullOrEmpty(jobsite.Number))
|
||||
Subject += "/" + jobsite.Number;
|
||||
|
||||
var useriid = LoginSession.User.UID;
|
||||
|
||||
if (emailaddress != null && emailaddress.Length > 0)
|
||||
{
|
||||
foreach (var item in emailaddress)
|
||||
{
|
||||
string lang = GetUserLanguage(alllangs, item.Key);
|
||||
string Body = OrdinaryJobsiteEmailFormat(lang, jobsite, si.Description, LoginSession.User.Name);
|
||||
FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationEmail(si.CompanyID, si.ObjectID, Subject, Body, new string[] { item.Value }, useriid);
|
||||
}
|
||||
}
|
||||
|
||||
if (textaddress != null && textaddress.Length > 0)
|
||||
{
|
||||
foreach (var item in textaddress)
|
||||
{
|
||||
string lang = GetUserLanguage(alllangs, item.Key);
|
||||
string Body = OrdinaryJobsiteTextFormat(lang, jobsite, si.Description, LoginSession.User.Name);
|
||||
FleetServiceClientHelper.CreateClient<AttachmentClient>().SendAssetLoationText(si.CompanyID, si.ObjectID, Subject, Body, new string[] { item.Value }, useriid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SendRoute(SendEmailsInfo si)
|
||||
{
|
||||
var emailaddress = si.EmailAddress;
|
||||
var subject = si.Title;
|
||||
|
||||
var useriid = LoginSession.User.UID;
|
||||
if (emailaddress != null && emailaddress.Length > 0)
|
||||
{
|
||||
var body = @"<!doctype html>
|
||||
<html lang=""en""><head><style type=""text/css"">
|
||||
.fa {
|
||||
display: none;
|
||||
font: normal normal normal 14px/1 FontAwesome;
|
||||
font-size: inherit;
|
||||
text-rendering: auto;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
.routeSummary {
|
||||
line-height: 30px;
|
||||
padding: 0 20px 10px 20px;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.routeSummary > .routeSummaryTitle {
|
||||
font-size: 1.6em;
|
||||
font-weight: 500;
|
||||
}
|
||||
.routeSummary > .routeSummaryDetail {
|
||||
font-size: 1.2em;
|
||||
color: gray;
|
||||
}
|
||||
.routeSummary .fa-car {
|
||||
font-size: 1.2em;
|
||||
padding-right: 6px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.routeSummary .fa-car::before { content: '\f1b9'; }
|
||||
.routeSummary .routeSummaryDistance { margin-left: 10px; }
|
||||
.routeFeature {
|
||||
line-height: 30px;
|
||||
padding: 0 20px 0 40px;
|
||||
position: relative;
|
||||
}
|
||||
.routeFeature > .fa {
|
||||
position: absolute;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
left: 10px;
|
||||
top: 3px;
|
||||
line-height: 24px;
|
||||
text-align: center;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
.routeFeature > .fa::before { content: '\f054'; }
|
||||
.routeFeature > .fa-ship::before { content: '\f21a'; }
|
||||
.routeFeature > .fa-merge-right { transform: scaleX(-1); }
|
||||
.routeFeature > .fa-merge-right::before,
|
||||
.routeFeature > .fa-merge::before { content: '\f387'; }
|
||||
.routeFeature > .fa-up::before { content: '\f176'; }
|
||||
.routeFeature > .fa-left::before,
|
||||
.routeFeature > .fa-right::before { content: '\f148'; }
|
||||
.routeFeature > .fa-back::before { content: '\f175'; }
|
||||
.routeFeature > .fa-left { transform: rotate(-90deg); }
|
||||
.routeFeature > .fa-right { transform: scaleX(-1) rotate(-90deg); }
|
||||
.routeFeature > .fa-back { transform: rotate(180deg); }
|
||||
.routeFeature > .routeFeatureMessage { font-size: 1.2em; }
|
||||
.routeFeature > .routeFeatureDetail {
|
||||
color: #aaa;
|
||||
position: relative;
|
||||
height: 30px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.routeFeature > .routeFeatureDetail > .routeFeatureDetailBorder {
|
||||
border-bottom: 1px solid #ccc;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
top: 50%;
|
||||
}
|
||||
.routeFeature > .routeFeatureDetail > span {
|
||||
background-color: white;
|
||||
position: absolute;
|
||||
padding-right: 10px;
|
||||
}
|
||||
</style></head><body>";
|
||||
body += "<p>" + (si.Description ?? "").Replace("\n", "<br>") + "</p>";
|
||||
body += si.HtmlBody + "</body></html>";
|
||||
string[] address = emailaddress.Select(m => m.Value).ToArray();
|
||||
FleetServiceClientHelper.CreateClient<AttachmentClient>().SendRoutesEmail(si.CompanyID, subject, body, address, useriid);
|
||||
}
|
||||
}
|
||||
|
||||
private string OrdinaryJobsiteEmailFormat(string lang, JobSiteItem jobsite, string desc, string username)
|
||||
{
|
||||
string EmailFormat = "{7}";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_LATLONG_COLON", "Lat/Long:") + " {0},{1}<br/>";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_DELIVERYADDRESS_COLON", "Delivery Address:") + " {2}<br/<br/>";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_FOREMAN_COLON", "Foreman:") + " {3}<br/><br/>";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_STATDATE_COLON", "Start Date:") + " {4}<br/>";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_ENDDATE_COLON", "End Date:") + " {5}<br/><br/>";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_MA_NOTES_COLON", "Notes:") + " {6}<br/>";
|
||||
|
||||
if (!string.IsNullOrEmpty(desc))
|
||||
{
|
||||
desc = Regex.Replace(desc, "\\[site name\\]", SystemParams.CustomerDetail.Name, RegexOptions.IgnoreCase);
|
||||
desc = Regex.Replace(desc, "\\[User Name\\]", username, RegexOptions.IgnoreCase);
|
||||
desc = Regex.Replace(desc, "\\[jobsite\\]", jobsite.Name, RegexOptions.IgnoreCase);
|
||||
desc = HttpUtility.HtmlEncode(desc);
|
||||
}
|
||||
|
||||
return string.Format(EmailFormat,
|
||||
HttpUtility.HtmlEncode(asset.Name2),
|
||||
HttpUtility.HtmlEncode(asset.Name),
|
||||
HttpUtility.HtmlEncode(asset.Make),
|
||||
HttpUtility.HtmlEncode(asset.Model),
|
||||
HttpUtility.HtmlEncode(asset.VIN),
|
||||
HttpUtility.HtmlEncode(asset.MakeYear > 0 ? asset.MakeYear.ToString() : ""),
|
||||
HttpUtility.HtmlEncode(desc ?? "").Replace("\n", "<br>"),
|
||||
"https://www.google.com/maps/dir/?api=1&destination=" + asset.Location.Latitude + "," + asset.Location.Longitude + "&travelmode=driving");
|
||||
HttpUtility.HtmlEncode(jobsite.Latitude),
|
||||
HttpUtility.HtmlEncode(jobsite.Longitude),
|
||||
HttpUtility.HtmlEncode(jobsite.Address1),
|
||||
HttpUtility.HtmlEncode(jobsite.Foreman),
|
||||
HttpUtility.HtmlEncode(jobsite.StartDate == null ? "" : jobsite.StartDate.Value.ToShortDateString()),
|
||||
HttpUtility.HtmlEncode(jobsite.EndDate == null ? "" : jobsite.EndDate.Value.ToShortDateString()),
|
||||
HttpUtility.HtmlEncode(jobsite.Notes ?? "").Replace("\n", "<br/>"),
|
||||
string.IsNullOrWhiteSpace(desc) ? "" : desc.Replace("\n", "<br/>") + "<br/><br/>");
|
||||
}
|
||||
|
||||
private string OrdinaryJobsiteTextFormat(string lang, JobSiteItem jobsite, string desc, string username)
|
||||
{
|
||||
string EmailFormat = "{7}";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_LATLONG_COLON", "Lat/Long:") + " {0},{1} ";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_MV_DELIVERYADDRESS_COLON", "Delivery Address:") + " {2} ";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_FOREMAN_COLON", "Foreman:") + " {3} ";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_STATDATE_COLON", "Start Date:") + " {4} ";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_JS_ENDDATE_COLON", "End Date:") + " {5} ";
|
||||
EmailFormat += SystemParams.GetTextByKey(lang, "P_MA_NOTES_COLON", "Notes:") + " {6}";
|
||||
|
||||
if (!string.IsNullOrEmpty(desc))
|
||||
{
|
||||
desc = Regex.Replace(desc, "\\[site name\\]", SystemParams.CustomerDetail.Name, RegexOptions.IgnoreCase);
|
||||
desc = Regex.Replace(desc, "\\[User Name\\]", username, RegexOptions.IgnoreCase);
|
||||
desc = Regex.Replace(desc, "\\[jobsite\\]", jobsite.Name, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
return string.Format(EmailFormat, jobsite.Latitude,
|
||||
jobsite.Longitude,
|
||||
jobsite.Address1,
|
||||
jobsite.Foreman,
|
||||
jobsite.StartDate == null ? "" : jobsite.StartDate.Value.ToShortDateString(),
|
||||
jobsite.EndDate == null ? "" : jobsite.EndDate.Value.ToShortDateString(),
|
||||
jobsite.Notes ?? "",
|
||||
string.IsNullOrWhiteSpace(desc) ? "" : desc + "\r\n\r\n");
|
||||
}
|
||||
|
||||
public static Foresight.Standard.StringKeyValue[] GetUserLanguages(StringKeyValue[] emailaddress, StringKeyValue[] textaddress)
|
||||
{
|
||||
List<string> uids = new List<string>();
|
||||
if (emailaddress != null && emailaddress.Length > 0)
|
||||
{
|
||||
List<string> ids = emailaddress.Where(m => !string.IsNullOrEmpty(m.Key)).Select(m => m.Key).ToList();
|
||||
if (ids != null && ids.Count > 0)
|
||||
uids.AddRange(ids);
|
||||
}
|
||||
|
||||
if (textaddress != null && textaddress.Length > 0)
|
||||
{
|
||||
List<string> ids = textaddress.Where(m => !string.IsNullOrEmpty(m.Key)).Select(m => m.Key).ToList();
|
||||
if (ids != null && ids.Count > 0)
|
||||
uids.AddRange(ids);
|
||||
}
|
||||
|
||||
Foresight.Standard.StringKeyValue[] alllangs = null;
|
||||
if (uids.Count > 0)
|
||||
{
|
||||
alllangs = FleetServiceClientHelper.CreateClient<Foresight.Fleet.Services.User.UserQueryClient>().GetUserLanguages();
|
||||
}
|
||||
return alllangs;
|
||||
}
|
||||
|
||||
public static string GetUserLanguage(Foresight.Standard.StringKeyValue[] alllangs, string uid)
|
||||
{
|
||||
var lang = "en-us";
|
||||
if (alllangs != null)
|
||||
{
|
||||
var item = alllangs.FirstOrDefault(m => m.Key == uid);
|
||||
if (item != null)
|
||||
lang = item.Value;
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
|
||||
private string GetShotLink(string longurl)
|
||||
{
|
||||
string serverurl = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=AIzaSyBzQFCgFK-ytQGGfMKePtvMyb1kSqvJ7_E";
|
||||
|
||||
string result = longurl;
|
||||
try
|
||||
{
|
||||
//string dl = string.Format("https://foresight.page.link/?link={0}", longurl);
|
||||
var obj = new
|
||||
{
|
||||
dynamicLinkInfo = new
|
||||
{
|
||||
domainUriPrefix = "https://foresight.page.link",
|
||||
link = longurl
|
||||
},
|
||||
suffix = new
|
||||
{
|
||||
option = "SHORT"
|
||||
}
|
||||
};
|
||||
string json = JsonConvert.SerializeObject(obj);
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serverurl);
|
||||
request.Method = "POST";
|
||||
request.Accept = "application/json";
|
||||
//request.Accept = "*/*";
|
||||
request.ContentType = "application/json";
|
||||
|
||||
byte[] byteRequest = Encoding.Default.GetBytes(json);
|
||||
using (Stream rs = request.GetRequestStream())
|
||||
{
|
||||
rs.Write(byteRequest, 0, byteRequest.Length);
|
||||
//rs.Close();
|
||||
}
|
||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
Stream resultStream = response.GetResponseStream();
|
||||
StreamReader sr = new StreamReader(resultStream, Encoding.UTF8);
|
||||
string rjson = sr.ReadToEnd();
|
||||
Newtonsoft.Json.Linq.JObject robj = JsonConvert.DeserializeObject(rjson) as Newtonsoft.Json.Linq.JObject;
|
||||
|
||||
if (robj != null)
|
||||
{
|
||||
result = robj["shortLink"].ToString();
|
||||
}
|
||||
|
||||
sr.Close();
|
||||
resultStream.Close();
|
||||
response.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("error", "GetShotLink", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -517,21 +1001,14 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
string clientdata = HttpUtility.HtmlDecode(Context.Request.Params["ClientData"]);
|
||||
StringKeyValue kv = JsonConvert.DeserializeObject<StringKeyValue>(clientdata);
|
||||
string customerid = kv.Key;
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
|
||||
ShapeFileInfo[] files = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).GetShapeFileInfos(customerid, kv.Value);
|
||||
if (files == null || files.Length == 0)
|
||||
return new ShapeFileItem[0];
|
||||
ShapeFileItem[] files = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
files = AssetMapViewManagement.GetShapes(LoginSession.SessionID, customerid, kv.Value);
|
||||
else
|
||||
files = AssetMapViewManagement.GetDealerShapes(LoginSession.SessionID, customerid, kv.Value);
|
||||
|
||||
List<ShapeFileItem> list = new List<ShapeFileItem>();
|
||||
foreach (ShapeFileInfo fi in files)
|
||||
{
|
||||
ShapeFileItem item = new ShapeFileItem();
|
||||
Helper.CloneProperty(item, fi);
|
||||
list.Add(item);
|
||||
}
|
||||
return list.OrderBy(m => m.Name).ToArray();
|
||||
return files.OrderBy(m => m.Name).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -558,13 +1035,15 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] iconfilebyte = null;
|
||||
string filename = "";
|
||||
if (Context.Request.Files.Count > 0)
|
||||
{
|
||||
uploadFile = Context.Request.Files[0];
|
||||
iconfilebyte = ConvertFile2bytes(uploadFile);
|
||||
filename = uploadFile.FileName;
|
||||
}
|
||||
|
||||
FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).ImportShape(customerid, kv.Value, kv.Tag1, LoginSession.User.UID, iconfilebyte);
|
||||
FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).ImportShape(customerid, kv.Value, kv.Tag1, LoginSession.User.UID, filename, iconfilebyte);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -587,13 +1066,24 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
string customerid = kv.Key;
|
||||
if (string.IsNullOrEmpty(customerid))
|
||||
customerid = SystemParams.CompanyID;
|
||||
string fileName = kv.Tag1 ?? "";
|
||||
|
||||
byte[] buffer = FleetServiceClientHelper.CreateClient<ShapeFileProvider>(customerid, LoginSession.SessionID).GetShapeData(customerid, Convert.ToInt64(kv.Value));
|
||||
Shape.Shape shape = new Shape.Shape();
|
||||
Shape.ShapeFileParser.ParseFromShapeFile(buffer, shape);
|
||||
|
||||
if (fileName == "" || fileName.EndsWith(".shp", StringComparison.OrdinalIgnoreCase))
|
||||
Shape.ShapeFileParser.ParseFromShapeFile(buffer, shape);
|
||||
else if (fileName.EndsWith(".kml", StringComparison.OrdinalIgnoreCase))
|
||||
Shape.ShapeFileParser.ParseFromKMLFile(buffer, shape);
|
||||
else if (fileName.EndsWith(".kmz", StringComparison.OrdinalIgnoreCase))
|
||||
Shape.ShapeFileParser.ParseFromKMZFile(buffer, shape);
|
||||
|
||||
Shape.SimpleShape ss = new Shape.SimpleShape();
|
||||
ss.FromShapeObj(shape);
|
||||
|
||||
//#if DEBUG
|
||||
// if (Convert.ToInt64(kv.Value) == 12d)
|
||||
// ss = AutoJobsitesCreator.DoTest(GetCurrentLoginSession().SessionID);
|
||||
//#endif
|
||||
return ss;
|
||||
}
|
||||
else
|
||||
@ -668,13 +1158,28 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
|
||||
#endregion
|
||||
|
||||
public class SendLocationInfo
|
||||
|
||||
private string GetNowFormatDate()
|
||||
{
|
||||
if (LoginSession != null)
|
||||
{
|
||||
return SystemParams.ConvertToUserTimeFromUtc(LoginSession.User, DateTime.UtcNow).ToString("M/d/yyyy h:m:s tt");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public class SendEmailsInfo
|
||||
{
|
||||
public int Type { get; set; }
|
||||
public string CompanyID { get; set; }
|
||||
public long AssetID { get; set; }
|
||||
public long ObjectID { get; set; }
|
||||
public long[] ObjectIDs { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string[] EmailAddress { get; set; }
|
||||
public string[] TextAddress { get; set; }
|
||||
public StringKeyValue[] EmailAddress { get; set; }
|
||||
public StringKeyValue[] TextAddress { get; set; }
|
||||
public string HtmlBody { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string AssignTo { get; set; }
|
||||
}
|
||||
|
||||
public class GetMachineParameterItem
|
||||
@ -687,6 +1192,7 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
public MapAlertLayerDefinitionItem[] Layers { get; set; }
|
||||
public string MachineIDs { get; set; }
|
||||
public bool ExcludeNoLocation { get; set; }
|
||||
public int Attachment { get; set; }
|
||||
}
|
||||
|
||||
public class GetJobsiteParameterItem
|
||||
@ -697,16 +1203,56 @@ namespace IronIntel.Contractor.Site.MapView
|
||||
public string SearchText { get; set; }
|
||||
}
|
||||
|
||||
public class MachineQueryResult
|
||||
public class AssetTripItem : AssetTripInfo
|
||||
{
|
||||
public MachineViewItem[] Machines { get; set; }
|
||||
public AssetGroupViewItem[] Groups { get; set; }
|
||||
public TripColor Color { get; set; }
|
||||
public string TripTimeStr { get { return TripTime == null ? "" : TripTime.Value.ToString(); } }
|
||||
public string TripOnLocalAsofTimeStr { get { return TripOn == null ? "" : TripOn.LocalAsofTime.ToString("MM/dd/yyyy hh:mm:ss tt"); } }
|
||||
public string TripOffLocalAsofTimeStr { get { return TripOff == null ? "" : TripOff.LocalAsofTime.ToString("MM/dd/yyyy hh:mm:ss tt"); } }
|
||||
public string TripOnAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
var address = "";
|
||||
if (TripOn != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(TripOn.Street))
|
||||
address = TripOn.Street;
|
||||
if (!string.IsNullOrEmpty(TripOn.City))
|
||||
address += ", " + TripOn.City;
|
||||
if (!string.IsNullOrEmpty(TripOn.State))
|
||||
address += ", " + TripOn.State;
|
||||
}
|
||||
return address;
|
||||
}
|
||||
}
|
||||
public string TripOffAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
var address = "";
|
||||
if (TripOff != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(TripOff.Street))
|
||||
address = TripOff.Street;
|
||||
if (!string.IsNullOrEmpty(TripOff.City))
|
||||
address += ", " + TripOff.City;
|
||||
if (!string.IsNullOrEmpty(TripOff.State))
|
||||
address += ", " + TripOff.State;
|
||||
}
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class MapViewSearchClient
|
||||
|
||||
public enum TripColor
|
||||
{
|
||||
public string SearchName { get; set; }
|
||||
public bool IsDefault { get; set; }
|
||||
public int Type { get; set; }
|
||||
Blue,
|
||||
Green,
|
||||
Purple,
|
||||
Yellow,
|
||||
Pink,
|
||||
Red,
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
|
@ -110,18 +110,12 @@ namespace IronIntel.Contractor.Site.OTRConfig
|
||||
var edatestr = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var searchtxt = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
DateTime startdate = DateTime.MinValue;
|
||||
DateTime startdate = Helper.DBMinDateTime;
|
||||
DateTime enddate = DateTime.MaxValue;
|
||||
if (!DateTime.TryParse(sdatestr, out startdate))
|
||||
startdate = DateTime.MinValue;
|
||||
startdate = Helper.DBMinDateTime;
|
||||
if (!DateTime.TryParse(edatestr, out enddate))
|
||||
enddate = DateTime.MaxValue;
|
||||
else
|
||||
enddate = enddate.Date.AddDays(1).AddSeconds(-1);
|
||||
|
||||
double timeOffset = SystemParams.GetHoursOffset();
|
||||
startdate = startdate.AddHours(-timeOffset);
|
||||
enddate = enddate.AddHours(-timeOffset);
|
||||
|
||||
return HarshDrivingManagement.GetHarshDrivingEvents(session.SessionID, startdate, enddate, searchtxt, session.User.UID);
|
||||
}
|
||||
|
@ -1,12 +1,20 @@
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using FI.FIC;
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.AssetHealth.WorkOrder;
|
||||
using Foresight.Fleet.Services.Inspection;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using IronIntel.Contractor.FilterQ;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.Site.JobSite;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static IronIntel.Contractor.Site.JobSite.JobSiteRequirementsBasePage;
|
||||
|
||||
namespace IronIntel.Contractor.Site
|
||||
{
|
||||
@ -25,11 +33,98 @@ namespace IronIntel.Contractor.Site
|
||||
case (int)PrintType.WorkOrder:
|
||||
result = PrintWorkOrder();
|
||||
break;
|
||||
case (int)PrintType.DispatchRequest:
|
||||
result = PrintDispatchRequest();
|
||||
break;
|
||||
case (int)PrintType.Attachment:
|
||||
PrintAttachment();
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void PrintAttachment()
|
||||
{
|
||||
string at = Request.Params["at"];
|
||||
string attaid = Request.Params["id"];
|
||||
|
||||
byte[] content = null;
|
||||
string ext = "";
|
||||
string contentType = "application/octet-stream";
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (at == "1" || at == "2")
|
||||
{
|
||||
long aid = 0;
|
||||
if (!long.TryParse(attaid, out aid))
|
||||
return;
|
||||
var client = FleetServiceClientHelper.CreateClient<WorkOrderProvider>(SystemParams.CompanyID, GetCurrentLoginSession().SessionID);
|
||||
Tuple<string, byte[]> atta = null;
|
||||
if (at == "1")
|
||||
{
|
||||
atta = client.GetAssetAttachmentData(SystemParams.CompanyID, aid);
|
||||
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "AssetAttachment", "", "Print", atta.Item1, "", atta.Item2);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
atta = client.GetWorkOrderAttachmentData(SystemParams.CompanyID, aid);
|
||||
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "WorkOrderAttachment", "", "Print", atta.Item1, "", atta.Item2);
|
||||
}
|
||||
|
||||
if (atta != null)
|
||||
{
|
||||
content = atta.Item2;
|
||||
ext = atta.Item1;
|
||||
}
|
||||
}
|
||||
else if (at == "3")
|
||||
{
|
||||
var client = FleetServiceClientHelper.CreateClient<AssetInspectClient>(SystemParams.CompanyID, GetCurrentLoginSession().SessionID);
|
||||
var atta = client.DownloadMediaContent(SystemParams.CompanyID, attaid);
|
||||
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "MediaContent", "", "DownLoad", "", atta.FileType, atta.Content);
|
||||
if (atta != null)
|
||||
{
|
||||
content = atta.Content;
|
||||
ext = atta.FileType;
|
||||
}
|
||||
}
|
||||
if (!Helper.FileTypes.TryGetValue(ext, out contentType))
|
||||
ext = Helper.GetFileExtention(ext);
|
||||
if (!Helper.FileTypes.TryGetValue(ext, out contentType))
|
||||
contentType = "application/octet-stream";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemParams.WriteLog("Error", "PrintAttachment", ex.Message, ex.ToString());
|
||||
}
|
||||
Response.ContentType = contentType;
|
||||
Response.BinaryWrite(content);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
private string DownloadString(string url)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
return DownloadString(request);
|
||||
}
|
||||
|
||||
private string DownloadString(HttpWebRequest request)
|
||||
{
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
using (Stream str = response.GetResponseStream())
|
||||
{
|
||||
using (StreamReader r = new StreamReader(str))
|
||||
{
|
||||
string s = r.ReadToEnd();
|
||||
response.Close();
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string PrintWorkOrder()
|
||||
{
|
||||
string woidstr = Request.Params["wo"];
|
||||
@ -37,12 +132,64 @@ namespace IronIntel.Contractor.Site
|
||||
if (!long.TryParse(woidstr, out woid) || woid <= 0)
|
||||
return "";
|
||||
|
||||
return WorkOrderManager.GenerateWorkOrderPrintHtml(GetCurrentLoginSession().SessionID, SystemParams.CompanyID, woid);
|
||||
var session = GetCurrentLoginSession();
|
||||
string html = WorkOrderManager.GenerateWorkOrderPrintHtml(GetCurrentLoginSession().SessionID, SystemParams.CompanyID, woid, GetLanguageCookie());
|
||||
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "WorkOrder", "", "Print", "", "", null);
|
||||
return html;
|
||||
}
|
||||
|
||||
private string PrintDispatchRequest()
|
||||
{
|
||||
int type = -1;
|
||||
string pt = Request.Params["t"];
|
||||
if (!int.TryParse(pt, out type))
|
||||
return "";
|
||||
|
||||
string data = Request.Params["ids"];
|
||||
long[] ids = JsonConvert.DeserializeObject<long[]>(data);
|
||||
if (ids == null || ids.Length == 0)
|
||||
return "";
|
||||
|
||||
string assignto = System.Web.HttpUtility.HtmlDecode(Request.Params["assignto"]);
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<JobSiteDispatchProvider>(SystemParams.CompanyID, GetCurrentLoginSession().SessionID);
|
||||
|
||||
JobSiteAssetDispatchInfo[] items = null;
|
||||
if (type == 0)//create requiremetn
|
||||
{
|
||||
items = client.GetAssetDispatchsByRequirementIds(SystemParams.CompanyID, ids);
|
||||
}
|
||||
else//dispatch
|
||||
{
|
||||
items = client.GetAssetDispatchsByIds(SystemParams.CompanyID, ids);
|
||||
}
|
||||
|
||||
if (items == null || items.Length == 0)
|
||||
return "";
|
||||
|
||||
string html = GenerateDispatchPrintHtml(GetLanguageCookie(), items, assignto);
|
||||
var session = GetCurrentLoginSession();
|
||||
FICHostEnvironment.WriteExportAuditTrail(session.User.UID, "Dispatch", "", "Print", "", "", null);
|
||||
return html;
|
||||
}
|
||||
|
||||
public static string GenerateDispatchPrintHtml(string lang, JobSiteAssetDispatchInfo[] dispatchs, string assignto)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.AppendLine("<H1 style='text-align:center;'>" + SystemParams.GetTextByKey(lang, "P_JS_DISPATCHREQUESTS", "Dispatch Requests") + "</H1>");
|
||||
if (!string.IsNullOrEmpty(assignto))
|
||||
str.AppendLine("<H2 style='text-align:center;'>" + SystemParams.GetTextByKey(lang, "P_JS_FORASSET_COLON", "For Asset:") + " " + assignto + "</H2>");
|
||||
|
||||
str.Append(GenerateDispatchHtml(lang, dispatchs, string.Empty, string.Empty));
|
||||
|
||||
return str.ToString();
|
||||
}
|
||||
|
||||
protected enum PrintType
|
||||
{
|
||||
WorkOrder = 1
|
||||
WorkOrder = 1,
|
||||
DispatchRequest = 2,
|
||||
Attachment = 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.20.609")]
|
||||
[assembly: AssemblyFileVersion("23.4.26")]
|
||||
|
@ -2,12 +2,10 @@
|
||||
using Foresight.Fleet.Services.AssetHealth;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.SystemOption;
|
||||
using IronIntel.Contractor.JobSites;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Security;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Customers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -42,12 +40,6 @@ namespace IronIntel.Contractor.Site.Security
|
||||
case "DeleteCurfew":
|
||||
result = DeleteCurfew();
|
||||
break;
|
||||
case "GetSelectedMachines":
|
||||
result = GetSelectedMachines();
|
||||
break;
|
||||
case "SaveCurfewMachines":
|
||||
result = SaveCurfewMachines();
|
||||
break;
|
||||
case "GetSelectedAssets":
|
||||
result = GetSelectedAssets();
|
||||
break;
|
||||
@ -66,9 +58,6 @@ namespace IronIntel.Contractor.Site.Security
|
||||
case "SaveCurfewJobsites":
|
||||
result = SaveCurfewJobsites();
|
||||
break;
|
||||
case "GetMachineList":
|
||||
result = GetMachineList();
|
||||
break;
|
||||
case "GetCurfewMovementTolerance":
|
||||
result = GetCurfewMovementTolerance();
|
||||
break;
|
||||
@ -101,16 +90,10 @@ namespace IronIntel.Contractor.Site.Security
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var searchtext = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
items = CurfewManagement.GetCurfews(session.SessionID, searchtext, contractordb);
|
||||
items = CreateClient<CurfewClient>(contractorid).GetCurfews(contractorid, searchtext);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -133,16 +116,10 @@ namespace IronIntel.Contractor.Site.Security
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
return CurfewManagement.GetCurfewInfo(curfewid, contractordb);
|
||||
return CreateClient<CurfewClient>(contractorid).GetCurfewInfo(contractorid, curfewid);
|
||||
}
|
||||
else
|
||||
return new CurfewInfo();
|
||||
@ -164,23 +141,14 @@ namespace IronIntel.Contractor.Site.Security
|
||||
var data = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
var ci = JsonConvert.DeserializeObject<CurfewInfo>(data);
|
||||
if (string.IsNullOrWhiteSpace(ci.CurfewID))
|
||||
{
|
||||
ci.CurfewID = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
CurfewManagement.SaveCurfew(ci, GetCurrentLoginSession().User.UID, contractordb);
|
||||
|
||||
return new string[] { ci.CurfewID, "OK" };
|
||||
ci.Id = CreateClient<CurfewClient>(contractorid).SaveCurfew(contractorid, ci);
|
||||
|
||||
return new string[] { ci.Id, "OK" };
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -224,74 +192,10 @@ namespace IronIntel.Contractor.Site.Security
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
CurfewManagement.DeleteCurfew(curfewid, contractordb);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Failed";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private MaintenanceMachineInfo[] GetSelectedMachines()
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
var machines = CurfewManagement.GetCurfewMachinesByID(curfewid, contractordb);
|
||||
|
||||
return machines.OrderBy(m => m.VIN).ToArray();
|
||||
}
|
||||
|
||||
private string SaveCurfewMachines()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var machineids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
if (string.IsNullOrWhiteSpace(contractorid))
|
||||
contractorid = SystemParams.CompanyID;
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(machineids);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
CurfewManagement.SaveCurfewMachines(curfewid, contractorid, ids, contractordb);
|
||||
CreateClient<CurfewClient>(contractorid).DeleteCurfew(contractorid, curfewid);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -393,32 +297,6 @@ namespace IronIntel.Contractor.Site.Security
|
||||
}
|
||||
}
|
||||
|
||||
private MaintenanceMachineInfo[] GetMachineList()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
string contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
string type = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
string searchtxt = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
int typeid = 0;
|
||||
int.TryParse(type, out typeid);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
var machines = MaintenanceManagement.GetMaintenanceMachines(session.SessionID, typeid, searchtxt, session.User.UID, contractorid)
|
||||
.OrderBy(m => m.VIN)
|
||||
.ToArray();
|
||||
|
||||
return machines;
|
||||
}
|
||||
|
||||
private object GetJobsiteList()
|
||||
{
|
||||
@ -431,14 +309,8 @@ namespace IronIntel.Contractor.Site.Security
|
||||
string contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
string searchtxt = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
var jss = CreateClient<JobSiteProvider>(contractorid).GetJobSiteItems(contractorid, "", false);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
@ -474,16 +346,19 @@ namespace IronIntel.Contractor.Site.Security
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
JobSiteItem[] jss = CreateClient<CurfewClient>(contractorid).GetJobSitesAssignedToCurfew(contractorid, curfewid);
|
||||
List<JobSiteViewItem> list = new List<JobSiteViewItem>();
|
||||
foreach (var js in jss)
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
JobSiteViewItem item = new JobSiteViewItem();
|
||||
item.ID = js.ID;
|
||||
item.Name = js.Name;
|
||||
|
||||
items = CurfewManagement.GetCurfewJobsitesByID(curfewid, contractordb);
|
||||
list.Add(item);
|
||||
}
|
||||
items = list.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -507,21 +382,16 @@ namespace IronIntel.Contractor.Site.Security
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var curfewid = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
var jobsiteids = HttpUtility.HtmlDecode(clientdata[2]);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(contractorid))
|
||||
contractorid = SystemParams.CompanyID;
|
||||
|
||||
string[] ids = JsonConvert.DeserializeObject<string[]>(jobsiteids);
|
||||
long[] ids = JsonConvert.DeserializeObject<long[]>(jobsiteids);
|
||||
|
||||
FISqlConnection contractordb = null;
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
else
|
||||
{
|
||||
string connetionstring = SystemParams.GetDbStringByCompany(contractorid);
|
||||
contractordb = new FISqlConnection(connetionstring);
|
||||
}
|
||||
|
||||
CurfewManagement.SaveCurfewJobsites(curfewid, contractorid, ids, contractordb);
|
||||
CreateClient<CurfewClient>(contractorid).AssignJobSitesToCurfew(contractorid, curfewid, ids);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
@ -1,76 +0,0 @@
|
||||
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;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class DataTablePermissionBasePage : ContractorBasePage
|
||||
{
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETUSERS":
|
||||
result = GetUsers();
|
||||
break;
|
||||
case "GETUSERGROUPS":
|
||||
result = GetUserGroups();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = ex.Message;
|
||||
SystemParams.WriteLog("Error", "UserGroupBasePage.ProcessRequest", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed { get { return true; } }
|
||||
|
||||
private UserInfo[] GetUsers()
|
||||
{
|
||||
var users = UserManagement.GetUnmanagementUsers().OrderBy(u => u.DisplayName).ToArray();
|
||||
return users;
|
||||
}
|
||||
|
||||
private UserGroupInfo[] GetUserGroups()
|
||||
{
|
||||
var groups = UserManagement.GetGroups();
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,651 +0,0 @@
|
||||
using FI.FIC.Contracts.DataObjects.BLObject;
|
||||
using FI.FIC.Models;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
public class FilterBasePage : ContractorBasePage
|
||||
{
|
||||
private const string sqlIn = "In";
|
||||
private const string isnull = "Is Null";
|
||||
private const string isnotnull = "Is Not Null";
|
||||
private const string defaultLanageCode = "en-us";
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (methodName != null)
|
||||
{
|
||||
switch (methodName.ToUpper())
|
||||
{
|
||||
case "GETFILTEROBJECT":
|
||||
result = GetFilterObject();
|
||||
break;
|
||||
case "SAVEFILTER":
|
||||
result = SaveFilter();
|
||||
break;
|
||||
case "GETDATASOURCE":
|
||||
result = GetDataSource();
|
||||
break;
|
||||
case "GETTABLEFILTERS":
|
||||
result = GetTableFilters();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = ex.Message;
|
||||
SystemParams.WriteLog("Error", "FilterBasePage.ProcessRequest", ex.Message, ex.ToString());
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(result);
|
||||
Response.Write(json);
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected override bool AllowCurrentLoginSessionEnter()
|
||||
{
|
||||
var f = base.AllowCurrentLoginSessionEnter();
|
||||
if (!f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check whether you are admin.
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session == null || session.User == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var ui = UserManagement.GetUserByIID(session.User.UID);
|
||||
return ui != null && ui.UserType >= UserTypes.Admin;
|
||||
}
|
||||
|
||||
protected override bool ThrowIfNotAllowed { get { return true; } }
|
||||
|
||||
private FilterObject GetFilterObject()
|
||||
{
|
||||
var p = Request.Form["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
int index = p.IndexOf(";");
|
||||
string iid = p.Substring(0, index);
|
||||
string type = p.Substring(index + 1);//1为Group 2为User
|
||||
|
||||
GlobalFilterAuthorize[] globalFilters = null;
|
||||
List<DataTableInfo> tableList = null;
|
||||
TableFilterAuthorize[] tableFilters = null;
|
||||
List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList = PluginManager.GetPlugin();
|
||||
if (type == "1")
|
||||
{
|
||||
globalFilters = GlobalFilterManager.GetGlobalFilterAuthorizeForGroup(iid);
|
||||
tableList = DataTableManager.GetHaveTableFilterDataTableListForUserGroup(iid, defaultLanageCode);
|
||||
if (tableList != null && tableList.Count > 0)
|
||||
{
|
||||
tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForGroup(iid, tableList[0].IID);
|
||||
}
|
||||
}
|
||||
else if (type == "2")
|
||||
{
|
||||
globalFilters = GlobalFilterManager.GetGlobalFilterAuthorizeForUser(iid);
|
||||
tableList = DataTableManager.GetHaveTableFilterDataTableList(iid, defaultLanageCode);
|
||||
if (tableList != null && tableList.Count > 0)
|
||||
{
|
||||
tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForUser(iid, tableList[0].IID);
|
||||
}
|
||||
}
|
||||
|
||||
FilterObject filterObj = new FilterObject();
|
||||
|
||||
if (globalFilters != null)
|
||||
{
|
||||
List<Filter> gfs = new List<Filter>();
|
||||
foreach (var item in globalFilters)
|
||||
{
|
||||
Filter gf = new Filter();
|
||||
gf.FilterName = item.FilterName;
|
||||
gf.FilterCondition = item.FilterCondition ?? " ";
|
||||
gf.FilterDataType = (int)item.FilterDataType;
|
||||
gf.FilterType = (int)item.FilterType;
|
||||
if (gf.FilterType == 0)
|
||||
gf.FilterTypeString = "Single Value";
|
||||
else
|
||||
gf.FilterTypeString = getPluginName(item.PluginID, pluginList);
|
||||
gf.FilterValue = item.FilterValue;
|
||||
gf.IID = item.IID;
|
||||
gf.PluginID = item.PluginID;
|
||||
|
||||
gfs.Add(gf);
|
||||
}
|
||||
filterObj.GlobalFilters = gfs.ToArray();
|
||||
}
|
||||
|
||||
if (tableList != null)
|
||||
{
|
||||
List<KeyValuePair<string, string>> dts = new List<KeyValuePair<string, string>>();
|
||||
foreach (var item in tableList)
|
||||
{
|
||||
KeyValuePair<string, string> kv = new KeyValuePair<string, string>(item.IID, item.DataTableName);
|
||||
dts.Add(kv);
|
||||
}
|
||||
filterObj.DataTableList = dts.ToArray();
|
||||
}
|
||||
|
||||
if (tableFilters != null)
|
||||
{
|
||||
List<Filter> tfs = new List<Filter>();
|
||||
foreach (var item in tableFilters)
|
||||
{
|
||||
Filter tf = new Filter();
|
||||
tf.FieldName = item.FieldName;
|
||||
tf.FilterName = item.FilterName;
|
||||
tf.FilterCondition = item.FilterCondition ?? " ";
|
||||
tf.FilterDataType = (int)item.FilterDataType;
|
||||
tf.FilterType = (int)item.FilterType;
|
||||
if (tf.FilterType == 0)
|
||||
tf.FilterTypeString = "Single Value";
|
||||
else
|
||||
tf.FilterTypeString = getPluginName(item.PluginID, pluginList);
|
||||
tf.FilterValue = item.FilterValue;
|
||||
tf.IID = item.IID;
|
||||
tf.PluginID = item.PluginID;
|
||||
|
||||
tfs.Add(tf);
|
||||
}
|
||||
filterObj.FirstTableFilters = tfs.ToArray();
|
||||
}
|
||||
|
||||
return filterObj;
|
||||
}
|
||||
|
||||
private string getPluginName(string iid, List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList)
|
||||
{
|
||||
string result = "";
|
||||
if (pluginList != null)
|
||||
{
|
||||
var plugin = pluginList.FirstOrDefault((p) => p.IID.Equals(iid, StringComparison.OrdinalIgnoreCase));
|
||||
if (plugin != null)
|
||||
result = plugin.PluginName;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private object SaveFilter()
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
SaveFilterObject item = JsonConvert.DeserializeObject<SaveFilterObject>(s);
|
||||
|
||||
if (item.Type == 2)
|
||||
{
|
||||
var user = UserManagement.GetUserByIID(item.UserIID);
|
||||
if (user.UserType == UserTypes.Admin)//Admin用户不需要修改
|
||||
return "\"OK\"";
|
||||
}
|
||||
string error = "";
|
||||
if (!Validate(ref error, item))
|
||||
{
|
||||
return new ErrorObject() { ErrorCode = 1, ErrorMessage = error };
|
||||
}
|
||||
DoSaveFilter(item);
|
||||
return "\"OK\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "\"Failed\"";
|
||||
}
|
||||
}
|
||||
|
||||
private void DoSaveFilter(SaveFilterObject filterObject)
|
||||
{
|
||||
List<GlobalFilterAuthorize> globalFilter = new List<GlobalFilterAuthorize>();
|
||||
if (filterObject.GlobalFilter != null)
|
||||
{
|
||||
foreach (var item in filterObject.GlobalFilter)
|
||||
{
|
||||
GlobalFilterAuthorize gf = new GlobalFilterAuthorize();
|
||||
gf.FilterName = item.FilterName;
|
||||
gf.FilterCondition = item.FilterCondition;
|
||||
gf.FilterDataType = (FI.FIC.Contracts.DataObjects.Enumeration.DBDataType)item.FilterDataType;
|
||||
gf.FilterType = (FI.FIC.Contracts.DataObjects.Enumeration.FilterType)item.FilterType;
|
||||
gf.FilterValue = item.FilterValue;
|
||||
gf.IID = item.IID;
|
||||
gf.PluginID = item.PluginID;
|
||||
|
||||
globalFilter.Add(gf);
|
||||
}
|
||||
}
|
||||
|
||||
List<TableFilterAuthorize> tableFilter = new List<TableFilterAuthorize>();
|
||||
if (filterObject.TableFilters != null)
|
||||
{
|
||||
foreach (var tfobj in filterObject.TableFilters)
|
||||
{
|
||||
foreach (var item in tfobj.Filters)
|
||||
{
|
||||
TableFilterAuthorize tf = new TableFilterAuthorize();
|
||||
tf.FilterName = item.FilterName;
|
||||
tf.FilterCondition = item.FilterCondition;
|
||||
tf.FilterDataType = (FI.FIC.Contracts.DataObjects.Enumeration.DBDataType)item.FilterDataType;
|
||||
tf.FilterType = (FI.FIC.Contracts.DataObjects.Enumeration.FilterType)item.FilterType;
|
||||
tf.FilterValue = item.FilterValue;
|
||||
tf.IID = item.IID;
|
||||
tf.PluginID = item.PluginID;
|
||||
|
||||
tableFilter.Add(tf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filterObject.Type == 1)//1为Group,2为User
|
||||
{
|
||||
GlobalFilterManager.SaveGlobalFilterAuthorizeForGroup(filterObject.UserIID, globalFilter.ToArray(), tableFilter.ToArray());
|
||||
}
|
||||
else if (filterObject.Type == 2)
|
||||
{
|
||||
GlobalFilterManager.SaveGlobalFilterAuthorizeForUser(filterObject.UserIID, globalFilter.ToArray(), tableFilter.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
private DataSourceObject GetDataSource()
|
||||
{
|
||||
DataSourceObject result = new DataSourceObject();
|
||||
var s = Request.Form["ClientData"];
|
||||
string dsiid = HttpUtility.HtmlDecode(s);
|
||||
PluginStructure dsStructure = PluginManager.GetPluginStructure(dsiid);
|
||||
PluginManager pm = new PluginManager();
|
||||
DataTable dt = pm.GetSourceData(dsiid, null);
|
||||
|
||||
int indexOfName = dt.Columns.IndexOf(dsStructure.DataImport.DisplayField);
|
||||
int indexOfID = dt.Columns.IndexOf(dsStructure.DataImport.ValueField);
|
||||
int indexOfPID = dt.Columns.IndexOf(dsStructure.DataImport.ParentField);
|
||||
if (indexOfName < 0)
|
||||
indexOfName = dt.Columns.IndexOf("Name");
|
||||
if (indexOfID < 0)
|
||||
indexOfID = dt.Columns.IndexOf("ID");
|
||||
if (indexOfPID < 0)
|
||||
indexOfPID = dt.Columns.IndexOf("PID");
|
||||
|
||||
result.IID = dsStructure.IID;
|
||||
result.IsFlat = dsStructure.IsFlat == 1;
|
||||
if (!result.IsFlat)
|
||||
result.IsFlat = IsFlat(dt, indexOfPID);
|
||||
result.Name = dsStructure.PluginName;
|
||||
result.DisplayField = dsStructure.DataImport.DisplayField;
|
||||
result.ValueField = dsStructure.DataImport.ValueField;
|
||||
|
||||
List<DataSourceData> datas = new List<DataSourceData>();
|
||||
if (result.IsFlat)
|
||||
{
|
||||
foreach (DataRow dr in dt.Select("", dt.Columns[indexOfID].ColumnName + " asc"))
|
||||
{
|
||||
DataSourceData ds = new DataSourceData();
|
||||
ds.ID = dr[indexOfID].ToString();
|
||||
ds.Description = dr[indexOfName].ToString();
|
||||
if (indexOfPID >= 0)
|
||||
ds.PID = dr[indexOfPID].ToString();
|
||||
datas.Add(ds);
|
||||
}
|
||||
//datas = datas.OrderBy((d) => d.ID).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, DataSourceData> nodes = new Dictionary<string, DataSourceData>();
|
||||
foreach (DataRow dr in dt.Select("", dt.Columns[indexOfID].ColumnName + " asc"))
|
||||
{
|
||||
DataSourceData ds = new DataSourceData();
|
||||
ds.ID = dr[indexOfID].ToString();
|
||||
ds.Description = dr[indexOfName].ToString();
|
||||
if (indexOfPID >= 0)
|
||||
ds.PID = dr[indexOfPID].ToString();
|
||||
//if (nodes.ContainsKey(ds.PID))
|
||||
//{
|
||||
// DataSourceData pnode = nodes[ds.PID];
|
||||
// List<DataSourceData> subNodes = new List<DataSourceData>();
|
||||
// if (pnode.SubData != null)
|
||||
// subNodes.AddRange(pnode.SubData);
|
||||
// subNodes.Add(ds);
|
||||
// pnode.SubData = subNodes.ToArray();
|
||||
//}
|
||||
nodes[ds.ID] = ds;
|
||||
}
|
||||
|
||||
foreach (var kv in nodes)
|
||||
{
|
||||
if (nodes.ContainsKey(kv.Value.PID))
|
||||
{
|
||||
DataSourceData pnode = nodes[kv.Value.PID];
|
||||
List<DataSourceData> subNodes = new List<DataSourceData>();
|
||||
if (pnode.SubData != null)
|
||||
subNodes.AddRange(pnode.SubData);
|
||||
subNodes.Add(kv.Value);
|
||||
pnode.SubData = subNodes.ToArray();
|
||||
}
|
||||
else
|
||||
datas.Add(kv.Value);
|
||||
}
|
||||
}
|
||||
result.Data = datas.ToArray();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Filter[] GetTableFilters()
|
||||
{
|
||||
var p = Request.Form["ClientData"];
|
||||
p = HttpUtility.HtmlDecode(p);
|
||||
int index = p.IndexOf(";");
|
||||
string iid = p.Substring(0, index);
|
||||
int index1 = p.IndexOf(";", index + 1);
|
||||
string type = p.Substring(index + 1, index1 - index - 1);//1为Group 2为User
|
||||
string dtiid = p.Substring(index1 + 1);
|
||||
|
||||
TableFilterAuthorize[] tableFilters = null;
|
||||
List<FI.FIC.Contracts.DataObjects.BaseObject.Plugin> pluginList = PluginManager.GetPlugin();
|
||||
if (type == "1")
|
||||
{
|
||||
tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForGroup(iid, dtiid);
|
||||
}
|
||||
else if (type == "2")
|
||||
{
|
||||
tableFilters = GlobalFilterManager.GetTableFilterAuthorizeForUser(iid, dtiid);
|
||||
}
|
||||
|
||||
List<Filter> filters = new List<Filter>();
|
||||
|
||||
if (tableFilters != null)
|
||||
{
|
||||
foreach (var item in tableFilters)
|
||||
{
|
||||
Filter tf = new Filter();
|
||||
tf.FieldName = item.FieldName;
|
||||
tf.FilterName = item.FilterName;
|
||||
tf.FilterCondition = item.FilterCondition ?? " ";
|
||||
tf.FilterDataType = (int)item.FilterDataType;
|
||||
tf.FilterType = (int)item.FilterType;
|
||||
if (tf.FilterType == 0)
|
||||
tf.FilterTypeString = "Single Value";
|
||||
else
|
||||
tf.FilterTypeString = getPluginName(item.PluginID, pluginList);
|
||||
tf.FilterValue = item.FilterValue;
|
||||
tf.IID = item.IID;
|
||||
tf.PluginID = item.PluginID;
|
||||
|
||||
filters.Add(tf);
|
||||
}
|
||||
}
|
||||
return filters.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断数据源的数据是否是树形结构
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool IsFlat(DataTable dt, int pidIndex)
|
||||
{
|
||||
if (pidIndex < 0) return true;
|
||||
|
||||
List<string> ids = new List<string>();
|
||||
List<string> pids = new List<string>();
|
||||
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
string id = dr[pidIndex].ToString();
|
||||
if (pids.IndexOf(id) >= 0)
|
||||
return false;
|
||||
|
||||
string pid = dr[pidIndex].ToString();
|
||||
if (ids.IndexOf(pid) >= 0)
|
||||
return false;
|
||||
|
||||
ids.Add(id);
|
||||
pids.Add(pid);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool Validate(ref string error, SaveFilterObject FilterObj)
|
||||
{
|
||||
string msg = "";
|
||||
if (FilterObj.GlobalFilter != null && FilterObj.GlobalFilter.Length > 0)
|
||||
{
|
||||
Filter errorObj = null;
|
||||
if (!ValidateFilter(ref msg, FilterObj.GlobalFilter, out errorObj))
|
||||
{
|
||||
//string TableFilterError = CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A016") + "\n";
|
||||
error = "Filter '{0}' in global filter:" + "\n";
|
||||
error = string.Format(error, errorObj.FilterName);
|
||||
error = error + msg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (FilterObj.TableFilters != null && FilterObj.TableFilters.Length > 0)
|
||||
{
|
||||
foreach (var tf in FilterObj.TableFilters)
|
||||
{
|
||||
Filter errorObj = null;
|
||||
if (!ValidateFilter(ref msg, tf.Filters, out errorObj))
|
||||
{
|
||||
//string TableFilterError = CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A017") + "\n";
|
||||
error = "Filter '{0}' in the data Table '{1}':" + "\n";
|
||||
error = string.Format(error, errorObj.FilterName, tf.TableName);
|
||||
error = error + msg;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ValidateFilter(ref string error, Filter[] Filters, out Filter errorObj)
|
||||
{
|
||||
errorObj = null;
|
||||
for (int i = 0; i < Filters.Length; i++)
|
||||
{
|
||||
Filter item = Filters[i];
|
||||
if (!string.IsNullOrWhiteSpace(item.FilterCondition))
|
||||
{
|
||||
if ((item.FilterCondition == isnull) || (item.FilterCondition == isnotnull))
|
||||
{
|
||||
item.FilterValue = "";
|
||||
}
|
||||
else if (item.FilterCondition != sqlIn)
|
||||
{
|
||||
bool returnValue = true;
|
||||
switch (item.FilterDataType)
|
||||
{
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtBoolean:
|
||||
try
|
||||
{
|
||||
bool.Parse(item.FilterValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter value must be True/False.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A012");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtDate:
|
||||
try
|
||||
{
|
||||
//必须要满足(月日年)或(年月日)的格式
|
||||
DateTime t = DateTime.Now;
|
||||
try
|
||||
{
|
||||
t = DateTime.Parse(item.FilterValue, new System.Globalization.DateTimeFormatInfo());
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
string tFilterValue = item.FilterValue.Replace(".", "-").Replace("/", "-");
|
||||
if (!tFilterValue.StartsWith(t.ToString("MM-dd-yyyy"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("MM-d-yyyy"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("M-dd-yyyy"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("M-d-yyyy"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("yyyy-MM-dd"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("yyyy-MM-d"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("yyyy-M-dd"))
|
||||
&& !tFilterValue.StartsWith(t.ToString("yyyy-M-d")))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter value must be a date.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A013");
|
||||
error += " " + "Date format must be 'MM/dd/yyyy' or 'yyyy-MM-dd'";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Wizard.ChartWizardHelper.A286");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtFloat:
|
||||
try
|
||||
{
|
||||
float.Parse(item.FilterValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter value must be a floating point.";//CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A014");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtInteger:
|
||||
try
|
||||
{
|
||||
int.Parse(item.FilterValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter Value must be an integer.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A015");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
case (int)FI.FIC.Contracts.DataObjects.Enumeration.DBDataType.dtGuid:
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(item.FilterValue))
|
||||
item.FilterValue = Guid.Empty.ToString();
|
||||
else
|
||||
new Guid(item.FilterValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "The Filter Value must be a GUID.";// CommonHelper.GetLangauge("LHBIS.FIC.Client.Modules.FilterManagement.A018");
|
||||
returnValue = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (returnValue == false)
|
||||
{
|
||||
errorObj = item;
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.FilterValue.Length > 2000)
|
||||
{
|
||||
errorObj = item;
|
||||
error = "The length of the Filter Value must be less than 2000.";// 没有资源号
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#region Model
|
||||
public class Filter
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public string FilterName { get; set; }
|
||||
public int FilterType { get; set; }
|
||||
public string FilterTypeString { get; set; }
|
||||
public string FieldName { get; set; }
|
||||
public int FilterDataType { get; set; }
|
||||
public string FilterDataTypeString
|
||||
{
|
||||
get
|
||||
{
|
||||
string dataType = Enum.GetName(typeof(FI.FIC.Contracts.DataObjects.Enumeration.DBDataType), FilterDataType);
|
||||
if (dataType == null) return null;
|
||||
if (dataType.StartsWith("dt"))
|
||||
{
|
||||
return dataType.Substring(2, dataType.Length - 2);
|
||||
}
|
||||
return dataType;
|
||||
}
|
||||
}
|
||||
public string FilterCondition { get; set; }
|
||||
public string FilterValue { get; set; }
|
||||
public string PluginID { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 包含Global Filter, DataTable List和第一个DataTable的Filter
|
||||
/// </summary>
|
||||
public class FilterObject
|
||||
{
|
||||
public Filter[] GlobalFilters { get; set; }
|
||||
|
||||
public KeyValuePair<string, string>[] DataTableList { get; set; }//IID/Name
|
||||
|
||||
public Filter[] FirstTableFilters { get; set; }//第一个DataTable的Filter
|
||||
}
|
||||
|
||||
public class TableFilterObject
|
||||
{
|
||||
public string TableIID { get; set; }
|
||||
public string TableName { get; set; }
|
||||
public Filter[] Filters { get; set; }
|
||||
}
|
||||
|
||||
public class SaveFilterObject
|
||||
{
|
||||
public string UserIID { get; set; }//用户或用户组的IID
|
||||
public int Type { get; set; }//1
|
||||
public Filter[] GlobalFilter { get; set; }
|
||||
public TableFilterObject[] TableFilters { get; set; }
|
||||
}
|
||||
public class DataSourceObject
|
||||
{
|
||||
public string IID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsFlat { get; set; }
|
||||
|
||||
public string DisplayField { get; set; }
|
||||
public string ValueField { get; set; }
|
||||
|
||||
|
||||
public DataSourceData[] Data { get; set; }
|
||||
}
|
||||
|
||||
public class DataSourceData
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string PID { get; set; }
|
||||
public string Description { get; set; }
|
||||
public DataSourceData[] SubData { get; set; }
|
||||
}
|
||||
|
||||
public class ErrorObject
|
||||
{
|
||||
public int ErrorCode { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
using Foresight.Data;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.MapView;
|
||||
using IronIntel.Contractor.MapView;
|
||||
using IronIntel.Contractor.Security;
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services.Business.Admin;
|
||||
using IronIntel.Services.Customers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -59,20 +60,21 @@ namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var contractorid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
var searchtext = HttpUtility.HtmlDecode(clientdata[1]);
|
||||
|
||||
if (!SystemParams.IsDealer)
|
||||
contractorid = SystemParams.CompanyID;
|
||||
companyid = SystemParams.CompanyID;
|
||||
|
||||
JobSiteLimitItem[] items = CreateClient<JobSiteProvider>(contractorid).GetJobSiteLimitItems(contractorid, searchtext);
|
||||
JobSiteLimitItem[] items = CreateClient<JobSiteProvider>(companyid).GetJobSiteLimitItems(companyid, searchtext);
|
||||
if (items == null || items.Length == 0)
|
||||
return new JobsiteLimitInfo[0];
|
||||
|
||||
MachineType[] alltypes = Machines.MachineManagement.GetMachineTypes();
|
||||
AssetType[] alltypes = Machines.MachineManagement.GetMachineTypes();
|
||||
List<JobsiteLimitInfo> list = new List<JobsiteLimitInfo>();
|
||||
foreach (JobSiteLimitItem item in items)
|
||||
{
|
||||
@ -83,7 +85,7 @@ namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
foreach (string tyid in typeids)
|
||||
{
|
||||
MachineType type = alltypes.FirstOrDefault(m => m.ID == Convert.ToInt32(tyid));
|
||||
AssetType type = alltypes.FirstOrDefault(m => m.ID == Convert.ToInt32(tyid));
|
||||
if (type != null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(jl.AssetTypeNames))
|
||||
|
@ -1,5 +1,4 @@
|
||||
using IronIntel.Contractor.Users;
|
||||
using IronIntel.Services;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -34,10 +33,11 @@ namespace IronIntel.Contractor.Site.Security
|
||||
{
|
||||
var user = GetCurrentUser();
|
||||
List<SecurityNavigateItem> list = Acl.GetSecurityNavigateItems(user).ToList();
|
||||
LicenseInfo license = SystemParams.GetLicense();
|
||||
|
||||
Foresight.Fleet.Services.Customer.LicenseInfo license = SystemParams.GetLicense();
|
||||
if (license != null && license.Items.Count > 0)
|
||||
{
|
||||
LicenseItem li = license.Items.FirstOrDefault(m => m.Key == "CurfewConfiguration");
|
||||
Foresight.Fleet.Services.Customer.LicenseItem li = license.Items.FirstOrDefault(m => m.Key == "CurfewConfiguration");
|
||||
if (li == null || !Helper.IsTrue(li.Value))
|
||||
{
|
||||
SecurityNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_curfew");
|
||||
|
@ -91,7 +91,7 @@ namespace IronIntel.Contractor.Site.Security
|
||||
contractors[i] = HttpUtility.UrlDecode(contractors[i]);
|
||||
}
|
||||
UserManagement.AddUserToContractor(iid, contractors);
|
||||
Response.Write("Save contractors info successfully.");
|
||||
Response.Write(JsonConvert.SerializeObject("Save contractors info successfully."));
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using Foresight.Fleet.Services.MapView;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using IronIntel.Contractor.Maintenance;
|
||||
using Newtonsoft.Json;
|
||||
@ -38,9 +40,21 @@ namespace IronIntel.Contractor.Site
|
||||
case "GETASSETONOFFTIMELINE":
|
||||
result = GetAssetOnOffTimeline();
|
||||
break;
|
||||
case "GETASSETSONOFFTIMELINE":
|
||||
result = GetAssetsOnOffTimeline();
|
||||
break;
|
||||
case "ISCALAMPPRIMARYLOCATION":
|
||||
result = IsCalampPrimaryLocation();
|
||||
break;
|
||||
case "GETASSETEXTINFO":
|
||||
result = GetAssetExtInfo();
|
||||
break;
|
||||
case "GETASSETMAPATTACHMENTS":
|
||||
result = GetAssetMapAttachments();
|
||||
break;
|
||||
case "GETNOWFORMATDATE":
|
||||
result = GetNowFormatDate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,6 +87,7 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
AssetDetailItem assetdetail = new AssetDetailItem();
|
||||
Helper.CloneProperty(assetdetail, info);
|
||||
assetdetail.MoveStatus = info.MoveStatus;
|
||||
if (info.CurrentLocation != null)
|
||||
{
|
||||
assetdetail.CurrentLocation = new AssetAddressItem();
|
||||
@ -104,6 +119,90 @@ namespace IronIntel.Contractor.Site
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssetExtInfo()
|
||||
{
|
||||
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;
|
||||
|
||||
MachineDeviceBasePage.AssetExtItem info = new MachineDeviceBasePage.AssetExtItem();
|
||||
AssetExtInfo ext = CreateClient<AssetQueryClient>(custid).GetAssetExtInfo(custid, assetid);
|
||||
Helper.CloneProperty(info, ext);
|
||||
|
||||
if (info.InspectReportItem != null)
|
||||
{
|
||||
var temp = new InspectReportInfo();
|
||||
Helper.CloneProperty(temp, info.InspectReportItem);
|
||||
info.InspectReportItem = temp;
|
||||
info.InspectReportItem.CommitTime = info.InspectReportItem.LocalCommitTime == null ? DateTime.MinValue : info.InspectReportItem.LocalCommitTime.Value;
|
||||
info.InspectReportItem.LastUpdatedTime = info.InspectReportItem.LocalLastUpdatedTime == null ? DateTime.MinValue : info.InspectReportItem.LocalLastUpdatedTime.Value;
|
||||
}
|
||||
if (info.Alerts != null)
|
||||
{
|
||||
List<MachineDeviceBasePage.AssetAlertItem> list = new List<MachineDeviceBasePage.AssetAlertItem>();
|
||||
foreach (var a in info.Alerts)
|
||||
{
|
||||
MachineDeviceBasePage.AssetAlertItem ai = new MachineDeviceBasePage.AssetAlertItem();
|
||||
Helper.CloneProperty(ai, a);
|
||||
if (ai.Description.IndexOf("\r\n") > 0)
|
||||
ai.Description = ai.Description.Substring(0, ai.Description.IndexOf("\r\n"));
|
||||
if (ai.Description.IndexOf("\n") > 0)
|
||||
ai.Description = ai.Description.Substring(0, ai.Description.IndexOf("\n"));
|
||||
list.Add(ai);
|
||||
}
|
||||
info.AlertItems = list.ToArray();
|
||||
}
|
||||
if (info.PMPlanInfos != null)
|
||||
{
|
||||
List<MachineDeviceBasePage.AssetPMPlanItem> list = new List<MachineDeviceBasePage.AssetPMPlanItem>();
|
||||
foreach (var a in info.PMPlanInfos)
|
||||
{
|
||||
MachineDeviceBasePage.AssetPMPlanItem ai = new MachineDeviceBasePage.AssetPMPlanItem();
|
||||
Helper.CloneProperty(ai, a);
|
||||
|
||||
list.Add(ai);
|
||||
}
|
||||
info.PMPlanItems = list.ToArray();
|
||||
}
|
||||
|
||||
if (info.AssetStatus != null)
|
||||
{
|
||||
List<MachineDeviceBasePage.AssetStatusItem> list = new List<MachineDeviceBasePage.AssetStatusItem>();
|
||||
foreach (var a in info.AssetStatus)
|
||||
{
|
||||
MachineDeviceBasePage.AssetStatusItem ai = new MachineDeviceBasePage.AssetStatusItem();
|
||||
Helper.CloneProperty(ai, a);
|
||||
|
||||
list.Add(ai);
|
||||
}
|
||||
info.AssetStatusItems = list.ToArray();
|
||||
}
|
||||
if (info.AssetMaintenanceRecord != null)
|
||||
{
|
||||
info.MaintenanceRecordItem = new MachineDeviceBasePage.AssetMaintenanceRecordItem();
|
||||
Helper.CloneProperty(info.MaintenanceRecordItem, info.AssetMaintenanceRecord);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
else
|
||||
return new AssetExtInfo();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("ERROR", "SingleAssetViewBasePage.GetAssetExtInfo", ex.Message, ex.ToString());
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetPMInfo()
|
||||
{
|
||||
try
|
||||
@ -183,7 +282,8 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
var assetid = long.Parse(clientdata[1]);
|
||||
var date = DateTime.Parse(clientdata[2]);
|
||||
return CreateClient<AssetQueryClient>(companyid).GetAssetOnOffTimeline(companyid, assetid, date).Select(s =>
|
||||
Foresight.Fleet.Services.SystemUtil util = CreateClient<Foresight.Fleet.Services.SystemUtil>();
|
||||
return CreateClient<AssetLocationQueryClient>(companyid).GetAssetOnOffTimeline(companyid, assetid, date).Select(s =>
|
||||
{
|
||||
double off;
|
||||
if (s.Off != null)
|
||||
@ -192,7 +292,7 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
else
|
||||
{
|
||||
var now = CreateClient<Foresight.Fleet.Services.SystemUtil>().GetCustomerDateTimeNow(companyid);
|
||||
var now = util.GetCustomerDateTimeNow(companyid);
|
||||
if (now.Date == date.Date && (s.On == null || now > s.On.Value))
|
||||
{
|
||||
off = now.TimeOfDay.TotalSeconds;
|
||||
@ -203,7 +303,7 @@ namespace IronIntel.Contractor.Site
|
||||
off = 24 * 60 * 60 - 1;
|
||||
}
|
||||
}
|
||||
return new
|
||||
return new OnOffItem
|
||||
{
|
||||
HasOn = s.On != null,
|
||||
Start = s.On?.TimeOfDay.TotalSeconds ?? 0,
|
||||
@ -218,6 +318,58 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssetsOnOffTimeline()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"].Split((char)170);
|
||||
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
{
|
||||
companyid = SystemParams.CompanyID;
|
||||
}
|
||||
var assetids = clientdata[1].Split(',').Select(i => long.Parse(i)).ToArray();
|
||||
var date = DateTime.Parse(clientdata[2]).Date;
|
||||
Foresight.Fleet.Services.SystemUtil util = CreateClient<Foresight.Fleet.Services.SystemUtil>();
|
||||
return CreateClient<AssetLocationQueryClient>(companyid).GetAssetsOnOffTimeline(companyid, assetids, date).Select(it => new OnOffItems
|
||||
{
|
||||
AssetId = it.AssetId,
|
||||
Items = it.Events.Select(s =>
|
||||
{
|
||||
double off;
|
||||
if (s.Off != null)
|
||||
{
|
||||
off = s.Off.Value.TimeOfDay.TotalSeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
var now = util.GetCustomerDateTimeNow(companyid);
|
||||
if (now.Date == date.Date && (s.On == null || now > s.On.Value))
|
||||
{
|
||||
off = now.TimeOfDay.TotalSeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 23:59:59.999
|
||||
off = 24 * 60 * 60 - .001;
|
||||
}
|
||||
}
|
||||
return new OnOffItem
|
||||
{
|
||||
HasOn = s.On != null,
|
||||
Start = s.On?.TimeOfDay.TotalSeconds ?? 0,
|
||||
HasOff = s.Off != null,
|
||||
End = off
|
||||
};
|
||||
}).ToArray()
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private string IsCalampPrimaryLocation()
|
||||
{
|
||||
try
|
||||
@ -242,6 +394,36 @@ namespace IronIntel.Contractor.Site
|
||||
return MachineDetailWorkspace.GetConfig();
|
||||
}
|
||||
|
||||
private object GetAssetMapAttachments()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var clientdata = Context.Request.Params["ClientData"];
|
||||
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
|
||||
string companyid = ps[0];
|
||||
if (string.IsNullOrEmpty(companyid))
|
||||
companyid = SystemParams.CompanyID;
|
||||
long assetid = 0;
|
||||
if (!long.TryParse(ps[1], out assetid))
|
||||
return null;
|
||||
|
||||
var client = FleetServiceClientHelper.CreateClient<MapViewQueryClient>(companyid, session.SessionID);
|
||||
return client.GetAssetDocumentsOnMap(companyid, assetid);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private string GetNowFormatDate()
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
return SystemParams.ConvertToUserTimeFromUtc(session.User, DateTime.UtcNow).ToString("M/d/yyyy h:m:s tt");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
class AssetDetailItem
|
||||
{
|
||||
public long ID { get; set; }
|
||||
@ -269,6 +451,9 @@ namespace IronIntel.Contractor.Site
|
||||
public string MapViewIconUrl { get; set; }
|
||||
public bool OnRoad { get; set; }
|
||||
public bool TelematicsEnabled { get; set; }
|
||||
public double? FuelLevel { get; set; }
|
||||
public string CurrentOperator { get; set; }
|
||||
public AssetShareStatus ShareStatus { get; set; }
|
||||
|
||||
public AssetAddressItem CurrentLocation { get; set; }
|
||||
public AssetEngineHoursItem CurrentHours { get; set; }
|
||||
@ -289,18 +474,39 @@ namespace IronIntel.Contractor.Site
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public AssetMoveStatus MoveStatus { get; set; }
|
||||
}
|
||||
|
||||
public class InspectReportInfo : Foresight.Fleet.Services.Inspection.InspectReportItem
|
||||
{
|
||||
public string CommitTimeStr { get { return (CommitTime == null || CommitTime == DateTime.MinValue) ? "" : CommitTime.ToString("M/d/yyyy"); } }
|
||||
public string LastUpdatedTimeStr { get { return (LastUpdatedTime == null || LastUpdatedTime == DateTime.MinValue) ? "" : LastUpdatedTime.ToString("M/d/yyyy"); } }
|
||||
}
|
||||
|
||||
class AssetAttributeItemBase
|
||||
{
|
||||
public long AssetID { get; set; }
|
||||
public DateTime AsofTime { get; set; }//utc time
|
||||
public string AsofTimeStr { get { return AsofTime.ToString(); } }
|
||||
public string AsofTimeStr { get { return AsofTime < Helper.DBMinDateTime ? "" : AsofTime.ToString(); } }
|
||||
public DateTime AsofTimeLocal { get; set; }//AsOftime的用户本地时间表示
|
||||
public string AsofTimeLocalStr { get { return AsofTimeLocal.ToString(); } }
|
||||
public string AsofTimeLocalStr { get { return AsofTimeLocal < Helper.DBMinDateTime ? "" : AsofTimeLocal.ToString(); } }
|
||||
public bool AsofTimeOverdue { get { return AsofTime < DateTime.Now.ToUniversalTime().AddDays(-3); } }
|
||||
public string DataSource { get; set; }
|
||||
public string SubSource { get; set; }
|
||||
public string DataSourceName { get; set; }
|
||||
public bool IsRed
|
||||
{
|
||||
get
|
||||
{
|
||||
bool result = false;
|
||||
if (AsofTimeLocal != null && AsofTimeLocal != DateTime.MinValue
|
||||
&& AsofTimeLocal < DateTime.Now.AddDays(-3))
|
||||
result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AssetAddressItem : AssetAttributeItemBase
|
||||
@ -314,6 +520,14 @@ namespace IronIntel.Contractor.Site
|
||||
public string Country { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
public string Address { get; set; }
|
||||
|
||||
public string EventType { get; set; }
|
||||
public string SpeedLimitUnits { get; set; }
|
||||
public string SpeedUnits { get; set; }
|
||||
public int Heading { get; set; }
|
||||
public double PostedSpeedLimit { get; set; }
|
||||
public double Speed { get; set; }
|
||||
public string MsgUID { get; set; }
|
||||
}
|
||||
|
||||
class AssetEngineHoursItem : AssetAttributeItemBase
|
||||
@ -337,7 +551,19 @@ namespace IronIntel.Contractor.Site
|
||||
}
|
||||
class AssetIdlehoursItem : AssetAttributeItemBase
|
||||
{
|
||||
public double Hours { get; set; }
|
||||
private double _Hours;
|
||||
public double Hours
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Hours;
|
||||
}
|
||||
set
|
||||
{
|
||||
value = value > 0 ? value : 0;
|
||||
_Hours = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
public bool IsPrimary { get; set; }
|
||||
}
|
||||
class AssetOdometerItem : AssetAttributeItemBase
|
||||
@ -379,5 +605,18 @@ namespace IronIntel.Contractor.Site
|
||||
public string[] AlertMessages { get; set; }
|
||||
}
|
||||
|
||||
class OnOffItem
|
||||
{
|
||||
public bool HasOn { get; set; }
|
||||
public bool HasOff { get; set; }
|
||||
public double Start { get; set; }
|
||||
public double End { get; set; }
|
||||
}
|
||||
|
||||
class OnOffItems
|
||||
{
|
||||
public long AssetId { get; set; }
|
||||
public OnOffItem[] Items { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Foresight.Fleet.Services.Customer;
|
||||
using Foresight.Standard;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -11,6 +12,20 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
{
|
||||
public class CustomerProviderBasePage : ContractorBasePage
|
||||
{
|
||||
protected bool IsDev
|
||||
{
|
||||
get
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
if (Helper.DevAccounts.Contains(session.User.ID, StringComparer.OrdinalIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
@ -29,6 +44,30 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
case "DELETECUSTOMERLOCATION":
|
||||
result = DeleteCustomerLocation();
|
||||
break;
|
||||
case "GETDEPARTMENTS":
|
||||
result = GetDepartments();
|
||||
break;
|
||||
case "SAVEDEPARTMENT":
|
||||
result = SaveDepartment();
|
||||
break;
|
||||
case "DELETEDEPARTMENT":
|
||||
result = DeleteDepartment();
|
||||
break;
|
||||
case "GETREGIONS":
|
||||
result = GetRegions();
|
||||
break;
|
||||
case "SAVEREGION":
|
||||
result = SaveRegion();
|
||||
break;
|
||||
case "DELETEREGION":
|
||||
result = DeleteRegion();
|
||||
break;
|
||||
case "GETSYSTEMPARAMS":
|
||||
result = GetSystemParams();
|
||||
break;
|
||||
case "SETSYSTEMPARAMS":
|
||||
result = SetSystemParams();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,19 +88,15 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
CustomerLocation[] locations = CreateClient<CustomerProvider>().GetCustomerLocations(SystemParams.CompanyID);
|
||||
|
||||
List<CustomerLocationItem> list = new List<CustomerLocationItem>();
|
||||
foreach (CustomerLocation lc in locations)
|
||||
CustomerLocation[] alllocs = CreateClient<CustomerProvider>().GetLocations(SystemParams.CompanyID);
|
||||
var plocs = alllocs.Where(d => d.PId <= 0).OrderBy(d => d.Name);
|
||||
List<CustomerLocation> result = new List<CustomerLocation>();
|
||||
foreach (var ploc in plocs)
|
||||
{
|
||||
CustomerLocationItem item = new CustomerLocationItem();
|
||||
Helper.CloneProperty(item, lc);
|
||||
list.Add(item);
|
||||
result.Add(ploc);
|
||||
result.AddRange(alllocs.Where(d => d.PId == ploc.ID).OrderBy(d => d.Name));
|
||||
}
|
||||
if (list.Count() > 0)
|
||||
return list.ToArray().OrderBy(m => m.Name);
|
||||
else
|
||||
return new CustomerLocationItem[0];
|
||||
return result.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -79,7 +114,7 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string data = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
string data = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
HttpPostedFile uploadFile = null;
|
||||
byte[] logobyte = null;
|
||||
if (Request.Files.Count > 0)
|
||||
@ -88,18 +123,16 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
logobyte = ConvertFile2bytes(uploadFile);
|
||||
}
|
||||
|
||||
CustomerLocationItem item = JsonConvert.DeserializeObject<CustomerLocationItem>(data);
|
||||
CustomerLocation location = new CustomerLocation();
|
||||
Helper.CloneProperty(location, item);
|
||||
CustomerLocation location = JsonConvert.DeserializeObject<CustomerLocation>(data);
|
||||
var cp = CreateClient<CustomerProvider>();
|
||||
int locationid = location.ID;
|
||||
if (locationid == -1)
|
||||
locationid = cp.AddCustomerLocation(SystemParams.CompanyID, location);
|
||||
locationid = cp.AddLocation(SystemParams.CompanyID, location);
|
||||
else
|
||||
cp.UpdateCustomerLocation(location);
|
||||
cp.UpdateLocation(SystemParams.CompanyID, location);
|
||||
|
||||
if (logobyte != null)
|
||||
cp.ChangeLocationLOGO(locationid, logobyte);
|
||||
cp.ChangeLocationLOGO(SystemParams.CompanyID, locationid, logobyte);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
@ -113,16 +146,234 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
}
|
||||
}
|
||||
|
||||
private string DeleteCustomerLocation()
|
||||
private object DeleteCustomerLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string id = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
string id = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
int locationid = -1;
|
||||
int.TryParse(id, out locationid);
|
||||
CreateClient<CustomerProvider>().DeleteCustomerLocation(locationid);
|
||||
CreateClient<CustomerProvider>().DeleteLocation(SystemParams.CompanyID, locationid);
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetDepartments()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
DepartmentInfo[] alldeps = CreateClient<CustomerProvider>().GetAllDepartments(SystemParams.CompanyID);
|
||||
var pdeps = alldeps.Where(d => d.PId <= 0).OrderBy(d => d.Name);
|
||||
List<DepartmentInfo> result = new List<DepartmentInfo>();
|
||||
foreach (var pdep in pdeps)
|
||||
{
|
||||
result.Add(pdep);
|
||||
result.AddRange(alldeps.Where(d => d.PId == pdep.Id).OrderBy(d => d.Name));
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object SaveDepartment()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string data = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
|
||||
DepartmentInfo dep = JsonConvert.DeserializeObject<DepartmentInfo>(data);
|
||||
var cp = CreateClient<CustomerProvider>();
|
||||
if (dep.Id > 0)
|
||||
cp.UpdateDepartment(SystemParams.CompanyID, dep);
|
||||
else
|
||||
dep = cp.AddNewDepartment(SystemParams.CompanyID, dep);
|
||||
|
||||
return dep.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeleteDepartment()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string id = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
int depid = -1;
|
||||
int.TryParse(id, out depid);
|
||||
CreateClient<CustomerProvider>().DeleteDepartment(SystemParams.CompanyID, depid);
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#region Region
|
||||
private object GetRegions()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
RegionInfo[] regions = CreateClient<CustomerProvider>().GetRegions(SystemParams.CompanyID);
|
||||
|
||||
if (regions == null || regions.Length == 0)
|
||||
return new RegionItem[0];
|
||||
|
||||
List<RegionItem> ls = new List<RegionItem>();
|
||||
foreach (var region in regions)
|
||||
{
|
||||
RegionItem item = new RegionItem();
|
||||
Helper.CloneProperty(item, region);
|
||||
ls.Add(item);
|
||||
}
|
||||
return ls.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object SaveRegion()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string data = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
|
||||
RegionInfo region = JsonConvert.DeserializeObject<RegionInfo>(data);
|
||||
var cp = CreateClient<CustomerProvider>();
|
||||
if (region.Id > 0)
|
||||
cp.UpdateRegion(SystemParams.CompanyID, region);
|
||||
else
|
||||
cp.AddNewRegion(SystemParams.CompanyID, region);
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object DeleteRegion()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
string clientdata = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
int id = -1;
|
||||
int.TryParse(clientdata, out id);
|
||||
CreateClient<CustomerProvider>().DeleteRegion(SystemParams.CompanyID, id);
|
||||
|
||||
return new string[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region System Params
|
||||
|
||||
private object GetSystemParams()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
StringKeyValue[] items = CreateClient<CustomerProvider>().GetSystemParams(SystemParams.CompanyID);
|
||||
|
||||
if (items == null || items.Length == 0)
|
||||
return new StringKeyValue[0];
|
||||
|
||||
return items;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SetSystemParams()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null && IsDev)
|
||||
{
|
||||
string data = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
|
||||
string[] pstr = JsonConvert.DeserializeObject<string[]>(data);
|
||||
var cp = CreateClient<CustomerProvider>();
|
||||
cp.SetSystemParams(SystemParams.CompanyID, pstr[0], pstr[1]);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
@ -136,14 +387,14 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomerLocationItem
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public string Name { get; set; }
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string Notes { get; set; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
class RegionItem : RegionInfo
|
||||
{
|
||||
public string StartDateStr { get { return StartDate == null ? "" : StartDate.Value.ToShortDateString(); } }
|
||||
public string EndDateStr { get { return EndDate == null ? "" : EndDate.Value.ToShortDateString(); } }
|
||||
public string ProjectedEndDateStr { get { return ProjectedEndDate == null ? "" : ProjectedEndDate.Value.ToShortDateString(); } }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,36 @@ using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Xml;
|
||||
using System.Web;
|
||||
using IronIntel.Services;
|
||||
using IronIntel.Contractor.Users;
|
||||
using Foresight.ServiceModel;
|
||||
using Foresight.Fleet.Services.Styles;
|
||||
using Foresight.Fleet.Services;
|
||||
using Foresight.Fleet.Services.User;
|
||||
using Foresight;
|
||||
using IronIntel.Contractor.Machines;
|
||||
using Foresight.Fleet.Services.JobSite;
|
||||
using Foresight.Fleet.Services.Asset;
|
||||
using System.Web.UI.WebControls;
|
||||
using FI.FIC.Contracts.DataObjects.BaseObject;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace IronIntel.Contractor.Site.SystemSettings
|
||||
{
|
||||
public class SystemSettingsBasePage : ContractorBasePage
|
||||
{
|
||||
protected bool IsDev
|
||||
{
|
||||
get
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
if (Helper.DevAccounts.Contains(session.User.ID, StringComparer.OrdinalIgnoreCase))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
protected void ProcessRequest(string methodName)
|
||||
{
|
||||
object result = null;
|
||||
@ -47,6 +69,39 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
case "SAVESYSTEMOPTIONS":
|
||||
result = SaveSystemOptions();
|
||||
break;
|
||||
case "GETLANGUAGES":
|
||||
result = GetLanguages();
|
||||
break;
|
||||
case "GETSYSTEMUNITOFODOMETER":
|
||||
result = GetSystemUnitOfOdometer();
|
||||
break;
|
||||
case "GETASSETGROUPLIST":
|
||||
result = GetAssetGroupList();
|
||||
break;
|
||||
case "GETJOBSITELIST":
|
||||
result = GetJobsiteList();
|
||||
break;
|
||||
case "GETASSETTYPES":
|
||||
result = GetAssetTypes();
|
||||
break;
|
||||
case "GETFILTERTEMPLATES":
|
||||
result = GetFilterTemplates();
|
||||
break;
|
||||
case "GETFILTERTEMPLATEITEM":
|
||||
result = GetFilterTemplateItem();
|
||||
break;
|
||||
case "GETUSERASSIGNEDASSETGROUPS":
|
||||
result = GetUserAssignedAssetGroups();
|
||||
break;
|
||||
case "GETUSERASSIGNEDJOBSITES":
|
||||
result = GetUserAssignedJobsites();
|
||||
break;
|
||||
case "GETUSERASSIGNEDASSETTYPES":
|
||||
result = GetUserAssignedAssetTypes();
|
||||
break;
|
||||
case "SAVEASSETALERTFILTER":
|
||||
result = SaveAssetAlertFilter();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,10 +120,10 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
{
|
||||
try
|
||||
{
|
||||
if (GetCurrentLoginSession() != null)
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient();
|
||||
CustUIStyleList uis = ic.GetCompanyUIStyles(SystemParams.CompanyID);
|
||||
CustUIStyleList uis = CreateClient<StyleProvider>().GetCompanyUIStyles(SystemParams.CompanyID);
|
||||
|
||||
List<CustUIStyleItem> list = new List<CustUIStyleItem>();
|
||||
foreach (CustUIStyle ui in uis)
|
||||
@ -102,11 +157,10 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
{
|
||||
string uidata = Request.Params["ClientData"];
|
||||
CustUIStyleItem item = JsonConvert.DeserializeObject<CustUIStyleItem>(uidata);
|
||||
item.UIStyleName = HttpUtility.UrlDecode(item.UIStyleName);
|
||||
item.UIStyleName = HttpUtility.HtmlDecode(item.UIStyleName);
|
||||
CustUIStyle ui = new CustUIStyle();
|
||||
Helper.CloneProperty(ui, item);
|
||||
IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient();
|
||||
ic.SetCompanyUIStyle(SystemParams.CompanyID, ui);
|
||||
CreateClient<StyleProvider>().SetCompanyUIStyle(SystemParams.CompanyID, ui);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
@ -127,11 +181,10 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string uistyleid = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
string uistyleid = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
int styleid = -1;
|
||||
int.TryParse(uistyleid, out styleid);
|
||||
IronSysServiceClient ic = SystemParams.GetIronSystemServiceClient();
|
||||
ic.DeleteCompanyUIStyle(SystemParams.CompanyID, styleid);
|
||||
CreateClient<StyleProvider>().DeleteCompanyUIStyle(SystemParams.CompanyID, styleid);
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
@ -173,9 +226,132 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string options = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
UserParamInfo upi = JsonConvert.DeserializeObject<UserParamInfo>(options);
|
||||
UserParams.SetUserParams(session.User.UID, upi);
|
||||
string content = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
var user = JsonConvert.DeserializeObject<UserOptionObject>(content);
|
||||
var uid = session.User.UID;
|
||||
UserParamInfo upi = user.UserParam;
|
||||
|
||||
UserParams.SetUserParams(uid, upi);
|
||||
var uc = CreateClient<UserQueryClient>();
|
||||
uc.UpdateUserPreferredLanguage(uid, upi.PreferredLanguage);
|
||||
uc.UpdateUserTimeZone(uid, upi.TimeZone);
|
||||
|
||||
// save subscribe message
|
||||
if (user.Subscribe != null)
|
||||
{
|
||||
user.Subscribe.UserIID = uid;
|
||||
List<UserAlertFilter> filters = null;
|
||||
if (!string.IsNullOrEmpty(user.UserAlertFilter))
|
||||
{
|
||||
filters = JsonConvert.DeserializeObject<List<UserAlertFilter>>(user.UserAlertFilter);
|
||||
}
|
||||
FI.FIC.Models.WorkspaceManager.SaveSubscribeMessageByEmail(user.Subscribe, filters, uid);
|
||||
}
|
||||
|
||||
|
||||
//FIC Alert Filter Templates
|
||||
var userfilterclient = CreateClient<Foresight.Fleet.Services.User.UserFilterProvider>();
|
||||
if (user.FilterTemplates != null && user.FilterTemplates.Length > 0)
|
||||
{
|
||||
foreach (UserFilterTemplateItem filter in user.FilterTemplates)
|
||||
{
|
||||
if (filter.Id < 0)
|
||||
filter.Id = userfilterclient.AddFilterTemplate(SystemParams.CompanyID, uid, filter.Name);
|
||||
else
|
||||
userfilterclient.ChangeFilterName(SystemParams.CompanyID, filter.Id, filter.Name);
|
||||
|
||||
long[] assetids = null;
|
||||
if (filter.Assets != null && filter.Assets.Length > 0)
|
||||
assetids = filter.Assets.Select(m => m.Id).ToArray();
|
||||
userfilterclient.SetAssetFilter(SystemParams.CompanyID, filter.Id, assetids);
|
||||
|
||||
string[] assetgroups = null;
|
||||
if (filter.AssetGroups != null && filter.AssetGroups.Length > 0)
|
||||
assetgroups = filter.AssetGroups.Select(m => m.GroupID).ToArray();
|
||||
userfilterclient.SetAssetGroupFilter(SystemParams.CompanyID, filter.Id, assetgroups);
|
||||
|
||||
int[] assettypes = null;
|
||||
if (filter.AssetTypes != null && filter.AssetTypes.Length > 0)
|
||||
assettypes = filter.AssetTypes.Select(m => m.ID).ToArray();
|
||||
userfilterclient.SetAssetTypeFilter(SystemParams.CompanyID, filter.Id, assettypes);
|
||||
|
||||
long[] jobsites = null;
|
||||
if (filter.Jobsites != null && filter.Jobsites.Length > 0)
|
||||
jobsites = filter.Jobsites.Select(m => m.ID).ToArray();
|
||||
userfilterclient.SetJobSiteFilter(SystemParams.CompanyID, filter.Id, jobsites);
|
||||
}
|
||||
}
|
||||
if (user.DeleteFilterTemplates != null && user.DeleteFilterTemplates.Length > 0)
|
||||
{
|
||||
foreach (int id in user.DeleteFilterTemplates)
|
||||
{
|
||||
userfilterclient.DeleteFilterTemplate(SystemParams.CompanyID, id);
|
||||
}
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object SaveAssetAlertFilter()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string content = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
var user = JsonConvert.DeserializeObject<UserOptionObject>(content);
|
||||
var uid = session.User.UID;
|
||||
|
||||
var userfilterclient = CreateClient<Foresight.Fleet.Services.User.UserFilterProvider>();
|
||||
if (user.FilterTemplates != null && user.FilterTemplates.Length > 0)
|
||||
{
|
||||
foreach (UserFilterTemplateItem filter in user.FilterTemplates)
|
||||
{
|
||||
if (filter.Id < 0)
|
||||
filter.Id = userfilterclient.AddFilterTemplate(SystemParams.CompanyID, uid, filter.Name);
|
||||
else
|
||||
userfilterclient.ChangeFilterName(SystemParams.CompanyID, filter.Id, filter.Name);
|
||||
|
||||
long[] assetids = null;
|
||||
if (filter.Assets != null && filter.Assets.Length > 0)
|
||||
assetids = filter.Assets.Select(m => m.Id).ToArray();
|
||||
userfilterclient.SetAssetFilter(SystemParams.CompanyID, filter.Id, assetids);
|
||||
|
||||
string[] assetgroups = null;
|
||||
if (filter.AssetGroups != null && filter.AssetGroups.Length > 0)
|
||||
assetgroups = filter.AssetGroups.Select(m => m.GroupID).ToArray();
|
||||
userfilterclient.SetAssetGroupFilter(SystemParams.CompanyID, filter.Id, assetgroups);
|
||||
|
||||
int[] assettypes = null;
|
||||
if (filter.AssetTypes != null && filter.AssetTypes.Length > 0)
|
||||
assettypes = filter.AssetTypes.Select(m => m.ID).ToArray();
|
||||
userfilterclient.SetAssetTypeFilter(SystemParams.CompanyID, filter.Id, assettypes);
|
||||
|
||||
long[] jobsites = null;
|
||||
if (filter.Jobsites != null && filter.Jobsites.Length > 0)
|
||||
jobsites = filter.Jobsites.Select(m => m.ID).ToArray();
|
||||
userfilterclient.SetJobSiteFilter(SystemParams.CompanyID, filter.Id, jobsites);
|
||||
}
|
||||
}
|
||||
if (user.DeleteFilterTemplates != null && user.DeleteFilterTemplates.Length > 0)
|
||||
{
|
||||
foreach (int id in user.DeleteFilterTemplates)
|
||||
{
|
||||
userfilterclient.DeleteFilterTemplate(SystemParams.CompanyID, id);
|
||||
}
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
@ -210,6 +386,46 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
}
|
||||
}
|
||||
|
||||
private object GetSystemUnitOfOdometer()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
return SystemParams.GetStringParam("UnitOfOdometer");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetLanguages()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
return CountryAndRegionCode.SupportedLanguages;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("not login.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetSystemOptions()
|
||||
{
|
||||
try
|
||||
@ -221,11 +437,36 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
double accuracyfilter = 0;
|
||||
double.TryParse(af, out accuracyfilter);
|
||||
|
||||
string au = SystemParams.GetStringParam("AreaUnits");
|
||||
int areaunits = 0;
|
||||
int.TryParse(au, out areaunits);
|
||||
|
||||
string vu = SystemParams.GetStringParam("VolumnUnits");
|
||||
int volumeunits = 0;
|
||||
int.TryParse(vu, out volumeunits);
|
||||
|
||||
string wu = SystemParams.GetStringParam("WeightUnits");
|
||||
int weightunits = 0;
|
||||
int.TryParse(wu, out weightunits);
|
||||
|
||||
string rmd = SystemParams.GetStringParam("MFARememberMeDays");
|
||||
int remembermedays = 0;
|
||||
if (!int.TryParse(rmd, out remembermedays))
|
||||
remembermedays = 30;
|
||||
|
||||
SystemOptionInfo soi = new SystemOptionInfo();
|
||||
soi.TimeZone = SystemParams.GetStringParam("CustomerTimeZone", false);
|
||||
soi.AccuracyFilter = accuracyfilter;
|
||||
soi.UnitOfOdometer = SystemParams.GetStringParam("UnitOfOdometer");
|
||||
soi.AcknowledgingAlerts = SystemParams.GetStringParam("AcknowledgingAlerts");
|
||||
soi.LoginVerifyType = SystemParams.GetStringParam("LoginVerifyType");
|
||||
soi.AreaUnits = areaunits;
|
||||
soi.VolumeUnits = volumeunits;
|
||||
soi.WeightUnits = weightunits;
|
||||
soi.MFARememberMeDays = remembermedays;
|
||||
|
||||
string connectorxml = SystemParams.GetStringParam("Connector");
|
||||
soi.Connectors = ConnectorHelper.FromXML(connectorxml);
|
||||
return soi;
|
||||
}
|
||||
else
|
||||
@ -246,7 +487,7 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
string options = HttpUtility.UrlDecode(Request.Params["ClientData"]);
|
||||
string options = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
|
||||
SystemOptionInfo upi = JsonConvert.DeserializeObject<SystemOptionInfo>(options);
|
||||
|
||||
SystemParams.SetStringParam("CustomerTimeZone", upi.TimeZone);
|
||||
@ -254,6 +495,14 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
SystemParams.SetStringParam("AccuracyFilter", upi.AccuracyFilter.ToString());
|
||||
SystemParams.SetStringParam("UnitOfOdometer", upi.UnitOfOdometer);
|
||||
SystemParams.SetStringParam("AcknowledgingAlerts", upi.AcknowledgingAlerts);
|
||||
SystemParams.SetStringParam("AreaUnits", upi.AreaUnits.ToString());
|
||||
SystemParams.SetStringParam("VolumnUnits", upi.VolumeUnits.ToString());
|
||||
SystemParams.SetStringParam("WeightUnits", upi.WeightUnits.ToString());
|
||||
SystemParams.SetStringParam("LoginVerifyType", upi.LoginVerifyType);
|
||||
SystemParams.SetStringParam("MFARememberMeDays", upi.MFARememberMeDays.ToString());
|
||||
|
||||
XmlDocument doc = ConnectorHelper.ToXml(upi.Connectors);
|
||||
SystemParams.SetStringParam("Connector", doc.InnerXml);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -268,6 +517,334 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region user filter
|
||||
private object GetFilterTemplates()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
|
||||
if (session != null)
|
||||
{
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.UserFilterProvider>();
|
||||
KeyValuePair<int, string>[] filters = client.GetFilterTemplates(SystemParams.CompanyID, session.User.UID);
|
||||
if (filters == null && filters.Length == 0)
|
||||
return new KeyValuePair<int, string>[0];
|
||||
|
||||
return filters;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new KeyValuePair<int, string>[0];
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetFilterTemplateItem()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
string filteridstr = HttpUtility.HtmlDecode(clientdata);
|
||||
int filterid = Convert.ToInt32(filteridstr);
|
||||
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
var client = CreateClient<Foresight.Fleet.Services.User.UserFilterProvider>();
|
||||
|
||||
string useriid = session.User.UID;
|
||||
bool accessallassets = false;
|
||||
Foresight.Fleet.Services.User.UserAdditionalAttribute attrs = CreateClient<Foresight.Fleet.Services.User.UserQueryClient>(SystemParams.CompanyID).GetUserAdditionalAttribute(useriid);
|
||||
if (attrs != null)
|
||||
accessallassets = attrs.AccessAllAssets;
|
||||
|
||||
UserFilterTemplateItem filter = new UserFilterTemplateItem();
|
||||
|
||||
List<AssetListItemInfo> lsasset = new List<AssetListItemInfo>();
|
||||
var fassets = client.GetAssetFilter(SystemParams.CompanyID, filterid);
|
||||
if (fassets != null && fassets.Length > 0)
|
||||
{
|
||||
var selitems = CreateClient<AssetDataAdjustClient>(SystemParams.CompanyID).GetAssetsAssignedToUser(SystemParams.CompanyID, useriid);
|
||||
|
||||
foreach (var ai in fassets)
|
||||
{
|
||||
AssetListItemInfo item = new AssetListItemInfo();
|
||||
item.Id = ai.Id;
|
||||
item.Name = ai.Name;
|
||||
item.VIN = ai.VIN;
|
||||
item.MakeName = ai.MakeName;
|
||||
item.ModelName = ai.ModelName;
|
||||
item.TypeName = ai.TypeName;
|
||||
|
||||
if (accessallassets)
|
||||
lsasset.Add(item);
|
||||
else
|
||||
{
|
||||
if (selitems != null && selitems.Length > 0 && selitems.Select(m => m.Id).Contains(ai.Id))
|
||||
lsasset.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
filter.Assets = lsasset.ToArray();
|
||||
|
||||
List<MachineGroup> lsag = new List<MachineGroup>();
|
||||
var fassetgroups = client.GetAssetGroupFilter(SystemParams.CompanyID, filterid);
|
||||
if (fassetgroups != null && fassetgroups.Length > 0)
|
||||
{
|
||||
var selitems = MachineManagement.GetMachineGroupByUser(useriid).OrderBy((m) => m.GroupName).ToArray();
|
||||
foreach (var kv in fassetgroups)
|
||||
{
|
||||
MachineGroup item = new MachineGroup();
|
||||
item.GroupID = kv.Key;
|
||||
item.GroupName = kv.Value;
|
||||
|
||||
if (accessallassets)
|
||||
lsag.Add(item);
|
||||
else
|
||||
{
|
||||
if (selitems != null && selitems.Length > 0 && selitems.Select(m => m.GroupID).Contains(kv.Key))
|
||||
lsag.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
filter.AssetGroups = lsag.ToArray();
|
||||
|
||||
List<AssetType> lstp = new List<AssetType>();
|
||||
var fassettypes = client.GetAssetTypeFilter(SystemParams.CompanyID, filterid);
|
||||
if (fassettypes != null && fassettypes.Length > 0)
|
||||
{
|
||||
var selitems = MachineManagement.GetMachineTypesByUser(useriid);
|
||||
foreach (var kv in fassettypes)
|
||||
{
|
||||
AssetType item = new AssetType();
|
||||
item.ID = kv.Key;
|
||||
item.Name = kv.Value;
|
||||
if (accessallassets)
|
||||
lstp.Add(item);
|
||||
else
|
||||
{
|
||||
if (selitems != null && selitems.Length > 0 && selitems.Select(m => m.ID).Contains(kv.Key))
|
||||
lstp.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
filter.AssetTypes = lstp.ToArray();
|
||||
|
||||
List<JobSiteItem> lsjs = new List<JobSiteItem>();
|
||||
var fjobsites = client.GetJobsiteFilter(SystemParams.CompanyID, filterid);
|
||||
if (fjobsites != null && fjobsites.Length > 0)
|
||||
{
|
||||
var selitems = CreateClient<JobSiteProvider>().GetUserJobsites(SystemParams.CompanyID, useriid);
|
||||
foreach (var kv in fjobsites)
|
||||
{
|
||||
JobSiteItem item = new JobSiteItem();
|
||||
item.ID = kv.Key;
|
||||
item.Name = kv.Value;
|
||||
if (accessallassets)
|
||||
lsjs.Add(item);
|
||||
else
|
||||
{
|
||||
if (selitems != null && selitems.Length > 0 && selitems.Select(m => m.ID).Contains(kv.Key))
|
||||
lsjs.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
filter.Jobsites = lsjs.ToArray();
|
||||
|
||||
return filter;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetAssetGroupList()
|
||||
{
|
||||
try
|
||||
{
|
||||
MachineGroup[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
items = MachineManagement.GetMachineGroups("").OrderBy((m) => m.GroupName).ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new MachineGroup[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetJobsiteList()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var s = Request.Form["ClientData"];
|
||||
s = HttpUtility.HtmlDecode(s);
|
||||
|
||||
items = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetAssetTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = GetCurrentLoginSession();
|
||||
if (session != null)
|
||||
{
|
||||
AssetType[] types = CreateClient<AssetClassProvider>().GetAssetTypes(SystemParams.CompanyID);
|
||||
return types.OrderBy((t) => t.Name).ToArray();
|
||||
}
|
||||
else
|
||||
return new AssetType[0];
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetUserAssignedAssetGroups()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var uid = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
MachineGroup[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var ui = UserManagement.GetUserByIID(uid);
|
||||
if (ui.UserType < IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
{
|
||||
bool accessallassets = GetAccessAllAssets(uid);
|
||||
|
||||
if (accessallassets)
|
||||
return GetAssetGroupList();
|
||||
else
|
||||
items = MachineManagement.GetMachineGroupByUser(uid).OrderBy((m) => m.GroupName).ToArray();
|
||||
}
|
||||
else
|
||||
return GetAssetGroupList();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new MachineGroup[0];
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private object GetUserAssignedAssetTypes()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientdata = Request.Form["ClientData"];
|
||||
var uid = HttpUtility.HtmlDecode(clientdata);
|
||||
|
||||
AssetType[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var ui = UserManagement.GetUserByIID(uid);
|
||||
if (ui.UserType < IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
{
|
||||
bool accessallassets = GetAccessAllAssets(uid);
|
||||
if (accessallassets)
|
||||
return GetAssetTypes();
|
||||
else
|
||||
items = MachineManagement.GetMachineTypesByUser(uid);
|
||||
|
||||
}
|
||||
else
|
||||
return GetAssetTypes();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new AssetType[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private object GetUserAssignedJobsites()
|
||||
{
|
||||
try
|
||||
{
|
||||
JobSiteItem[] items = null;
|
||||
if (GetCurrentLoginSession() != null)
|
||||
{
|
||||
var uid = Request.Form["ClientData"];
|
||||
uid = HttpUtility.HtmlDecode(uid);
|
||||
|
||||
var ui = UserManagement.GetUserByIID(uid);
|
||||
if (ui.UserType < IronIntel.Contractor.Users.UserTypes.Admin)
|
||||
{
|
||||
bool accessallassets = GetAccessAllAssets(uid);
|
||||
if (accessallassets)
|
||||
return GetJobsiteList();
|
||||
else
|
||||
items = CreateClient<JobSiteProvider>().GetUserJobsites(SystemParams.CompanyID, uid);
|
||||
}
|
||||
else
|
||||
return GetJobsiteList();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new JobSiteItem[0];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.Message;
|
||||
}
|
||||
}
|
||||
private bool GetAccessAllAssets(string uid)
|
||||
{
|
||||
bool accessallassets = false;
|
||||
var attrs = CreateClient<Foresight.Fleet.Services.User.UserQueryClient>(SystemParams.CompanyID).GetUserAdditionalAttribute(uid);
|
||||
if (attrs != null)
|
||||
accessallassets = attrs.AccessAllAssets;
|
||||
return accessallassets;
|
||||
}
|
||||
|
||||
#endregion
|
||||
private class CustUIStyleItem
|
||||
{
|
||||
public int UIStyleID { get; set; }
|
||||
@ -286,7 +863,21 @@ namespace IronIntel.Contractor.Site.SystemSettings
|
||||
public double AccuracyFilter { get; set; }
|
||||
public string UnitOfOdometer { get; set; }
|
||||
public string AcknowledgingAlerts { get; set; }
|
||||
public int AreaUnits { get; set; }
|
||||
public int VolumeUnits { get; set; }
|
||||
public int WeightUnits { get; set; }
|
||||
public string LoginVerifyType { get; set; }
|
||||
public StringKeyValue[] Connectors { get; set; }
|
||||
public int MFARememberMeDays { get; set; }
|
||||
}
|
||||
|
||||
private class UserOptionObject
|
||||
{
|
||||
public UserParamInfo UserParam { get; set; }
|
||||
public SubscribeMessageByEmail Subscribe { get; set; }
|
||||
public string UserAlertFilter { get; set; }
|
||||
public UserFilterTemplateItem[] FilterTemplates { get; set; }
|
||||
public int[] DeleteFilterTemplates { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@ namespace IronIntel.Contractor.Site
|
||||
|
||||
public override string JQueryVersion
|
||||
{
|
||||
get { return "1.12.4"; }
|
||||
get { return "3.6.0"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
27
IronIntelContractorSiteLib/app.config
Normal file
27
IronIntelContractorSiteLib/app.config
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Data.SqlClient" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.6.1.1" newVersion="4.6.1.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
Reference in New Issue
Block a user