This commit is contained in:
2024-03-26 15:56:31 +08:00
parent 634e8b71ab
commit 0855ae42cd
547 changed files with 94818 additions and 60463 deletions

View File

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

View File

@ -39,18 +39,22 @@ namespace IronIntel.Contractor.Site
}
string opacity;
string fore;
string ctrlbgcolor = "lightgray";
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";
var g = .299 * c.R + .587 * c.G + .114 * c.B;
fore = g < 127.5 ? "#f0f0f0" : "#0f0f0f";
ctrlbgcolor = g < 221 ? color : "lightgray";//221为light的计算值
}
catch
{
opacity = "rgb(247 142 30/60%)";
fore = "#0f0f0f";
ctrlbgcolor = "lightgray";
}
StyleVariables = $"--title-color: {fore}; --title-bg-color: {color}; --title-bg-opacity-color: {opacity}";
StyleVariables = $"--title-color: {fore}; --title-bg-color: {color}; --title-bg-opacity-color: {opacity};--title-ctrlbg-color: {ctrlbgcolor}; ";
}
return new StyleInfo
{

View File

@ -130,7 +130,7 @@ namespace IronIntel.Contractor.Site.Contact
UserInfo[] items = null;
if (session != null)
{
items = UserManagement.GetUsers();
items = UserManagement.GetUsers(string.Empty, string.Empty, GetLanguageCookie());
}
else
{

View File

@ -16,6 +16,14 @@ namespace IronIntel.Contractor.Site
{
public class ContractorBasePage : IronIntelBasePage
{
public const char SPLIT_CHAR175 = (char)175;//\u00af
public const char SPLIT_CHAR180 = (char)180;//\u00b4
public const char SPLIT_CHAR181 = (char)181;//'µ'
public const char SPLIT_CHAR182 = (char)182;//'¶'
public const char SPLIT_CHAR183 = (char)183;//'·'
public const char SPLIT_CHAR184 = (char)182;//'\u00b8'
public const string OkResult = "OK";
public const string FailedResult = "Failed";
public static string AppVersion
{
get

View File

@ -319,6 +319,10 @@ namespace IronIntel.Contractor.Site.Credentials
try
{
if (!string.IsNullOrEmpty(item.Description))
{
item.Description = HttpUtility.UrlDecode(item.Description);
}
CredentialProvider crd = FleetServiceClientHelper.CreateClient<CredentialProvider>();
crd.UpdateApiCredentialDefs(SystemParams.CompanyID, item, GetCurrentUser().IID);
}

View File

@ -316,8 +316,8 @@ namespace IronIntel.Contractor.Site.Customer
var session = GetCurrentLoginSession();
if (session != null)
{
var users = UserManagement.GetActiveUsers(session.SessionID);
return users.Where(u => u.IsUser).ToArray();
var users = UserManagement.GetAllFollowers(GetLanguageCookie(), session.SessionID);
return users;
}
else
return new UserInfo[0];
@ -565,7 +565,7 @@ namespace IronIntel.Contractor.Site.Customer
var clientdata = Request.Form["ClientData"];
string searchtxt = HttpUtility.HtmlDecode(clientdata);
var users = UserManagement.GetSalespersons(session.SessionID, SystemParams.CompanyID, searchtxt);
var users = UserManagement.GetSalespersons(session.SessionID, GetLanguageCookie(), SystemParams.CompanyID, searchtxt);
users = users.Where(m => !string.IsNullOrWhiteSpace(m.FOB)).OrderBy(m => m.FOB).ToArray();
return users;
}

View File

@ -0,0 +1,52 @@
using Newtonsoft.Json;
namespace IronIntel.Contractor.Site
{
public class GridData<T>
{
[JsonProperty("columns")]
public GridColumnDefinition[] Columns { get; set; }
[JsonProperty("source")]
public T[] Source { get; set; }
[JsonProperty("rowHeight")]
public double RowHeight { get; set; }
[JsonProperty("sortKey")]
public string SortKey { get; set; }
[JsonProperty("sortArray")]
public GridColumnSortDefinition[] SortArray { get; set; }
}
public class GridColumnDefinition
{
[JsonProperty("key")]
public string Key { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("caption")]
public string Caption { get; set; }
[JsonProperty("width")]
public double Width { get; set; }
[JsonProperty("align")]
public string Align { get; set; }
[JsonProperty("visible")]
public bool Visible { get; set; }
}
public class GridColumnSortDefinition
{
[JsonProperty("column")]
public string Column { get; set; }
[JsonProperty("order")]
public string Order { get; set; }
}
}

View File

@ -74,6 +74,9 @@ namespace IronIntel.Contractor.Site
case "GetAssetTypes":
result = GetAssetTypes();
break;
case "GetAssetGroups":
result = GetAssetGroups();
break;
case "GetInspectItems":
result = GetInspectItems();
break;
@ -270,8 +273,6 @@ namespace IronIntel.Contractor.Site
string filter = HttpUtility.HtmlDecode(ps[3]);
WorkOrderListItem[] allworkorders = CreateClient<WorkOrderProvider>().GetWorkOrderItems(SystemParams.CompanyID, null, null, null, null, "", -1, null, null, null);
if (teamintelligence)
{
var client = CreateClient<TeamIntelligenceClient>();
@ -305,25 +306,12 @@ namespace IronIntel.Contractor.Site
inspect.WorkOrderNumber = "Not Assigned";
}
if (allworkorders != null && allworkorders.Length > 0)
{
List<WorkOrderListItem> lswo = new List<WorkOrderListItem>();
lswo = allworkorders.Where(m => m.AssetId == inspect.AssetId).ToList();
if (inspect.WorkOrderId > 0)
{
WorkOrderListItem curwo = allworkorders.FirstOrDefault(m => m.Id == inspect.WorkOrderId);
if (curwo == null)
{
//curwo = new WorkOrderListItem() { Id = inspect.WorkOrderId, WorkOrderNumber = inspect.WorkOrderNumber };
//lswo.Add(curwo);
inspect.WorkOrderId = -1;
inspect.WorkOrderNumber = "Not Assigned";
}
}
lswo = lswo.OrderByDescending(w => !w.Completed).ThenBy(w => w.WorkOrderNumber).ToList();
lswo.Insert(0, new WorkOrderListItem() { Id = -1, WorkOrderNumber = "Not Assigned" });
inspect.WorkOrders = lswo.ToArray();
}
List<WorkOrderListItem> lswo = new List<WorkOrderListItem>();
lswo.Add(new WorkOrderListItem() { Id = -1, WorkOrderNumber = "Not Assigned" });
if (inspect.WorkOrderId > 0)
lswo.Add(new WorkOrderListItem() { Id = inspect.WorkOrderId, WorkOrderNumber = inspect.WorkOrderNumber });
inspect.WorkOrders = lswo.ToArray();
list.Add(inspect);
}
return list.ToArray();
@ -643,13 +631,15 @@ namespace IronIntel.Contractor.Site
{
var client = CreateClient<TeamIntelligenceClient>();
report = client.GetInspection(SystemParams.CompanyID, id);
layout = client.GetInspectReportLayout(SystemParams.CompanyID, id);
if (report != null)
layout = client.GetInspectReportLayout(SystemParams.CompanyID, id);
}
else
{
var client = CreateClient<AssetInspectClient>();
report = client.GetInspection(SystemParams.CompanyID, id);
layout = client.GetInspectReportLayout(SystemParams.CompanyID, id);
if (report != null)
layout = client.GetInspectReportLayout(SystemParams.CompanyID, id);
}
if (report == null)
@ -905,12 +895,9 @@ namespace IronIntel.Contractor.Site
int makeid = -1;
if (!int.TryParse(ps[3], out makeid))
makeid = -1;
int modelid = -1;
if (!int.TryParse(ps[4], out modelid))
modelid = -1;
int typeid = -1;
if (!int.TryParse(ps[5], out typeid))
typeid = -1;
int[] modelids = JsonConvert.DeserializeObject<int[]>(ps[4]);
int[] typeids = JsonConvert.DeserializeObject<int[]>(ps[5]);
string[] groupids = JsonConvert.DeserializeObject<string[]>(ps[6]);
FormTemplateItem[] templates = null;
if (teamintelligence)
@ -921,7 +908,7 @@ namespace IronIntel.Contractor.Site
else
{
var client = CreateClient<AssetInspectClient>();
templates = client.GetAssetTemplateItems(SystemParams.CompanyID, filter, makeid, modelid, typeid, user.IID, state);
templates = client.GetAssetTemplateItems(SystemParams.CompanyID, filter, makeid, modelids, typeids, groupids, user.IID, state);
}
return templates;
}
@ -1099,8 +1086,7 @@ namespace IronIntel.Contractor.Site
}
}
if (!string.IsNullOrEmpty(templateinfo.IssueId)
|| (user.UserType < Users.UserTypes.SupperAdmin && !templateinfo.Editable))
if (user.UserType < Users.UserTypes.SupperAdmin && !templateinfo.Editable)
{
if (teamintelligence)
{
@ -1119,7 +1105,7 @@ namespace IronIntel.Contractor.Site
client.SetTemplateEmailList(SystemParams.CompanyID, templateinfo.Id, useriids, templateinfo.Emails);
}
return new string[] { templateinfo.Id.ToString(), "Saved successfully." };
return templateinfo.Id;
}
FormTemplateInfo newtemp = null;
@ -1133,7 +1119,12 @@ namespace IronIntel.Contractor.Site
var client = CreateClient<AssetInspectClient>();
newtemp = client.UpdateTemplate(SystemParams.CompanyID, templateinfo, session.User.UID);
}
return new string[] { newtemp.Id.ToString(), "Saved successfully." };
if (templateinfo.Id < 0)
{
// add template, need return some properties like Editable, IssueId
return newtemp;
}
return newtemp.Id;
}
else
{
@ -1549,20 +1540,30 @@ namespace IronIntel.Contractor.Site
if (session != null)
{
AssetType[] types = CreateClient<AssetClassProvider>().GetAssetTypes(SystemParams.CompanyID);
types = types.OrderBy((t) => t.Name).ToArray();
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (AssetType md in types)
{
StringKeyValue kv = new StringKeyValue();
kv.Key = md.ID.ToString();
kv.Value = md.Name;
list.Add(kv);
}
return list.ToArray();
return types;
}
else
return new StringKeyValue[0];
return new AssetType[0];
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetAssetGroups()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var groups = CreateClient<AssetQueryClient>(SystemParams.CompanyID).GetAssetGroups(SystemParams.CompanyID, "", session.User.UID);
return groups.OrderBy(g => g.Name).ToArray();
}
else
return new AssetGroupInfo[0];
}
catch (Exception ex)
{
@ -2226,7 +2227,8 @@ namespace IronIntel.Contractor.Site
long assetid = 0;
if (long.TryParse(clientdata, out assetid))
{
return CreateClient<WorkOrderProvider>().GetWorkOrderItemsByAsset(SystemParams.CompanyID, assetid);
var wos = CreateClient<WorkOrderProvider>().GetWorkOrderItemsByAsset(SystemParams.CompanyID, assetid);
return wos.OrderByDescending(w => !w.Completed).ThenBy(w => w.WorkOrderNumber).ToArray();
}
return new WorkOrderListItem[0];

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IronIntel.Contractor.Site</RootNamespace>
<AssemblyName>iicontractorsitelib</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
@ -31,7 +31,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>LHBIS.snk</AssemblyOriginatorKeyFile>
@ -111,6 +111,7 @@
<Compile Include="FITrackerBasePage.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="GridData.cs" />
<Compile Include="InspectionBasePage.cs">
<SubType>ASPXCodeBehind</SubType>
</Compile>

View File

@ -288,11 +288,11 @@ namespace IronIntel.Contractor.Site.JobSite
return new string[] { req.Assets[0].DispatchId.ToString(), "OK" };
}
return "Failed";
return FailedResult;
}
else
{
return "Failed";
return FailedResult;
}
}
catch (Exception ex)
@ -316,11 +316,11 @@ namespace IronIntel.Contractor.Site.JobSite
long id = Convert.ToInt64(kv.Key);
CreateClient<JobSiteDispatchProvider>().DeleteRequirment(SystemParams.CompanyID, id, kv.Value);
return "OK";
return OkResult;
}
else
{
return "Failed";
return FailedResult;
}
}
catch (Exception ex)
@ -429,18 +429,22 @@ namespace IronIntel.Contractor.Site.JobSite
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
bool activeonly = clientdata == "1";
JobSitesAndRegionsItem item = new JobSitesAndRegionsItem();
MapViewJobSiteInfo[] jss = CreateClient<MapViewQueryClient>().GetAvailableJobSites(SystemParams.CompanyID, session.User.UID, string.Empty, false);
//MapViewJobSiteInfo[] jss = CreateClient<MapViewQueryClient>().GetAvailableJobSites(SystemParams.CompanyID, session.User.UID, string.Empty, false);
JobSiteItem[] jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", null, activeonly);
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (MapViewJobSiteInfo js in jss)
foreach (JobSiteItem js in jss)
{
StringKeyValue kv = new StringKeyValue();
kv.Key = js.ID.ToString();
kv.Value = js.Name;
kv.Tag1 = js.StartDate == null ? "" : js.StartDate.Value.ToShortDateString();
kv.Tag2 = js.EndDate == null ? "" : js.EndDate.Value.ToShortDateString();
kv.Tag3 = js.ReginId.ToString();
kv.Tag3 = js.RegionId.ToString();
list.Add(kv);
}
@ -482,12 +486,15 @@ namespace IronIntel.Contractor.Site.JobSite
if (session != null)
{
MachineTypeItem[] types = JobSitesManagement.GetMachineTypes();
var typesinuse = CreateClient<AssetDataAdjustClient>().GetAssetTypesInUse(SystemParams.CompanyID);
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (MachineTypeItem type in types)
{
StringKeyValue kv = new StringKeyValue();
kv.Key = type.ID.ToString();
kv.Value = type.Name;
kv.Tag1 = typesinuse.Contains(type.ID) ? "1" : "0";
list.Add(kv);
}
@ -631,6 +638,7 @@ namespace IronIntel.Contractor.Site.JobSite
HasSchedule = selMinDate != DateTime.MaxValue,
BeginDate = selMinDate,
TotalDays = selMinDate != DateTime.MaxValue ? (selMaxDate - selMinDate).Days + 1 : 0,
RelatedRequirementAssets = reqinfo.RelatedRequirementAssets,
DispatchAssets = items
};
}
@ -654,11 +662,11 @@ namespace IronIntel.Contractor.Site.JobSite
var clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
UserParams.SetStringParameter(session.User.UID, "RequirmentsDefault", clientdata);
return "OK";
return OkResult;
}
else
{
return "Failed";
return FailedResult;
}
}
catch (Exception ex)
@ -717,6 +725,11 @@ namespace IronIntel.Contractor.Site.JobSite
{
JobSiteAssetDispatchItem item = new JobSiteAssetDispatchItem();
Helper.CloneProperty(item, re);
if (!item.Completed)
{
item.CompletedTime = null;
item.CompletedBy = "";
}
ls.Add(item);
}
@ -830,11 +843,11 @@ namespace IronIntel.Contractor.Site.JobSite
disids = item.ObjectIDs;
CreateClient<JobSiteDispatchProvider>().AssignDispatch(SystemParams.CompanyID, disids, item.AssetID);
return "OK";
return OkResult;
}
else
{
return "Failed";
return FailedResult;
}
}
catch (Exception ex)
@ -854,9 +867,11 @@ namespace IronIntel.Contractor.Site.JobSite
var clientdata = Request.Form["ClientData"].Split((char)170);
var id = HttpUtility.HtmlDecode(clientdata[0]);
var data = HttpUtility.HtmlDecode(clientdata[1]);
var disassetsstr = HttpUtility.HtmlDecode(clientdata[2]);
JobSiteAssetDispatchInfo[] assts = JsonConvert.DeserializeObject<JobSiteAssetDispatchInfo[]>(data);
DispatchAssetInfo[] disassets = JsonConvert.DeserializeObject<DispatchAssetInfo[]>(disassetsstr);
long[] dispatchids = CreateClient<JobSiteDispatchProvider>().AddDispatch(SystemParams.CompanyID, Convert.ToInt64(id), assts);
long[] dispatchids = CreateClient<JobSiteDispatchProvider>().AddDispatch(SystemParams.CompanyID, Convert.ToInt64(id), assts, disassets);
return dispatchids;
}
@ -897,11 +912,11 @@ namespace IronIntel.Contractor.Site.JobSite
{
}
return "OK";
return OkResult;
}
else
{
return "Failed";
return FailedResult;
}
}
catch (Exception ex)
@ -924,11 +939,11 @@ namespace IronIntel.Contractor.Site.JobSite
DispatchItem item = JsonConvert.DeserializeObject<DispatchItem>(clientdata);
CreateClient<JobSiteDispatchProvider>().DeleteDispatch(SystemParams.CompanyID, item.DispatchId, item.DeleteNotes);
return "OK";
return OkResult;
}
else
{
return "Failed";
return FailedResult;
}
}
catch (Exception ex)
@ -962,11 +977,11 @@ namespace IronIntel.Contractor.Site.JobSite
SendDispatchRequest(items, si);
return "OK";
return OkResult;
}
else
{
return "Failed";
return FailedResult;
}
}
catch (Exception ex)
@ -1056,11 +1071,11 @@ namespace IronIntel.Contractor.Site.JobSite
bool compeleted = Helper.IsTrue(kv.Value);
CreateClient<JobSiteDispatchProvider>().UpdateDispatchCompleted(SystemParams.CompanyID, dispatchid, compeleted, user.IID);
return "OK";
return OkResult;
}
else
{
return "Failed";
return FailedResult;
}
}
catch (Exception ex)
@ -1079,7 +1094,7 @@ namespace IronIntel.Contractor.Site.JobSite
string clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
long[] ps = JsonConvert.DeserializeObject<long[]>(clientdata);
var items = UserManagement.GetUsersByAssets(session.SessionID, ps, SystemParams.CompanyID);
var items = UserManagement.GetUsersByAssets(session.SessionID, ps, SystemParams.CompanyID, GetLanguageCookie());
return items;
}
else
@ -1116,11 +1131,11 @@ namespace IronIntel.Contractor.Site.JobSite
if (!DateTime.TryParse(ps[6], out endDate))
endDate = DateTime.MaxValue;
bool unscheduled = ps[7] == "1";
int scheduled = Convert.ToInt32(ps[7]);
DispatchAssetInfo[] infos = CreateClient<JobSiteDispatchProvider>().GetAssetSchedulers(SystemParams.CompanyID, jss, regions, assetGroups, assetTypes, beginDate, endDate, unscheduled, searchtxt);
DispatchAssetInfo[] infos = CreateClient<JobSiteDispatchProvider>().GetAssetSchedulers(SystemParams.CompanyID, jss, regions, assetGroups, assetTypes, beginDate, endDate, scheduled, searchtxt);
var items = DispatchAssetItem.Convert(infos, beginDate, endDate).OrderBy(m => m.AssetName).ToArray();
var items = DispatchAssetItem.Convert(infos, beginDate, endDate, true).OrderBy(m => m.AssetName).ToArray();
if (items.Count() == 0)
return null;
@ -1216,8 +1231,15 @@ namespace IronIntel.Contractor.Site.JobSite
public int ConflictDays { get; set; }
public DateTime? BeginDate { get; set; }
public DateTime? EndDate { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? FinishDate { get; set; }
public string NextJobSite { get; set; }
public int DurationDays { get; set; }
public string BeginDateStr { get { return BeginDate == null ? "" : BeginDate.Value.ToString("M/d/yyyy"); } }
public string EndDateStr { get { return EndDate == null ? "" : EndDate.Value.ToString("M/d/yyyy"); } }
public string StartDateStr { get { return StartDate == null ? "" : StartDate.Value.ToString("M/d/yyyy"); } }
public string FinishDateStr { get { return FinishDate == null ? "" : FinishDate.Value.ToString("M/d/yyyy"); } }
public string DistanceStr
{
get
@ -1266,7 +1288,7 @@ namespace IronIntel.Contractor.Site.JobSite
}
}
public static DispatchAssetItem[] Convert(IEnumerable<DispatchAssetInfo> infos, DateTime begindate, DateTime enddate)
public static DispatchAssetItem[] Convert(IEnumerable<DispatchAssetInfo> infos, DateTime begindate, DateTime enddate, bool schedulerlist = false)
{
List<DispatchAssetItem> items = new List<DispatchAssetItem>();
foreach (var i in infos)
@ -1277,6 +1299,7 @@ namespace IronIntel.Contractor.Site.JobSite
item.DistanceToDestJobSite = Math.Round(item.DistanceToDestJobSite.Value, 2);
if (begindate > DateTime.Now.AddYears(-5) && enddate < DateTime.Now.AddYears(5))
item.ConflictDays = GetConflictDays(i, begindate, enddate);
item.AttachedAssets.AddRange(i.AttachedAssets);
foreach (var s in i.Schedules)
{
AssetScheduleItem si = new AssetScheduleItem();
@ -1284,6 +1307,17 @@ namespace IronIntel.Contractor.Site.JobSite
item.Schedules.Add(si);
}
item.ComputeSchedules();
if (schedulerlist)
{ //schedulerlist
if (item.Schedules.Count > 0)
{
var sch = item.Schedules[0];
item.StartDate = sch.BeginDate;
item.FinishDate = sch.EndDate;
item.NextJobSite = sch.JobSiteName;
item.DurationDays = (sch.EndDate - sch.BeginDate).Days + 1;
}
}
items.Add(item);
}

View File

@ -192,7 +192,10 @@ namespace IronIntel.Contractor.Site.JobSite
{
if (GetCurrentLoginSession() != null)
{
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(SystemParams.CompanyID, "", null, true);
var companyid = Request.Form["ClientData"];
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
var jss = CreateClient<JobSiteProvider>().GetJobSiteItems(companyid, "", null, true);
var js = jss.OrderBy(g => g.Name).Select(i => new
{
i.ID,
@ -695,7 +698,7 @@ namespace IronIntel.Contractor.Site.JobSite
{
if (GetCurrentLoginSession() != null)
{
Users.UserInfo[] items = UserManagement.GetUsers(null, string.Empty);
Users.UserInfo[] items = UserManagement.GetUsers(string.Empty, string.Empty, GetLanguageCookie());
items = items.Where(m => m.Active).OrderBy(u => u.ID).ToArray();
return items;
}

View File

@ -1,4 +1,5 @@
using Foresight.Data;
using FI.FIC.Contracts.DataObjects.BaseObject;
using Foresight.Data;
using Foresight.Fleet.Services;
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.Customer;
@ -47,6 +48,12 @@ namespace IronIntel.Contractor.Site
case "GETGPSSOURCES":
result = GetGPSSources();
break;
case "GETDEVICETYPES":
result = GetDeviceTypes();
break;
case "GETNIMBELINGTYPES":
result = GetNimbelingTypes();
break;
case "CHANGEGPSCONTRACTOR":
result = ChangeGPSContractor();
break;
@ -345,6 +352,7 @@ namespace IronIntel.Contractor.Site
var clientdata = Request.Form["ClientData"].Split((char)170);
var companyid = HttpUtility.HtmlDecode(clientdata[0]);
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
var viewalertstypes = HttpUtility.HtmlDecode(clientdata[2]);
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
@ -352,7 +360,7 @@ namespace IronIntel.Contractor.Site
if (string.IsNullOrWhiteSpace(companyid) && SystemParams.IsDealer)
return new AssetSummaryItem();
AssetExtItem item = new AssetExtItem();
AssetExtInfo ext = CreateClient<AssetQueryClient>(companyid).GetAssetExtInfo(companyid, Convert.ToInt64(assetid));
AssetExtInfo ext = CreateClient<AssetQueryClient>(companyid).GetAssetExtInfo(companyid, Convert.ToInt64(assetid), viewalertstypes);
Helper.CloneProperty(item, ext);
if (item.InspectReportItem != null)
{
@ -857,7 +865,46 @@ namespace IronIntel.Contractor.Site
return ex.Message;
}
}
private object GetDeviceTypes()
{
try
{
if (GetCurrentLoginSession() != null)
{
List<string[]> data = new List<string[]>();
data.Add(DeviceInfo.SmartWitnessTypes);
data.Add(DeviceInfo.IDriveTypes);
return data;
}
else
{
return new List<string[]>();
}
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetNimbelingTypes()
{
try
{
if (GetCurrentLoginSession() != null)
{
return CreateClient<DeviceProvider>().GetNimbelinkTypes();
}
else
{
return new KeyValuePair<string, string>();
}
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetDeviceComments()
{
try
@ -1290,6 +1337,7 @@ namespace IronIntel.Contractor.Site
i.VIN,
i.MakeName,
i.ModelName,
i.TypeID,
i.TypeName,
EngineHours = Math.Round(i.EngineHours ?? 0, 2),
Odometer = Math.Round(i.Odometer ?? 0, 2),
@ -1714,7 +1762,7 @@ namespace IronIntel.Contractor.Site
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
users = UserManagement.GetActiveUsers(session.SessionID, companyid);
users = UserManagement.GetActiveUsers(GetLanguageCookie(), session.SessionID, companyid);
users = users.OrderBy(u => u.DisplayName).ToArray();
}
else
@ -1850,7 +1898,7 @@ namespace IronIntel.Contractor.Site
if (string.IsNullOrEmpty(doc.CustomerID))
doc.CustomerID = SystemParams.CompanyID;
CreateClient<AssetDocumentProvider>(doc.CustomerID).UpdateAssetDocument(doc.CustomerID, doc.Id, doc.Name, doc.Description, doc.VisibleOnWorkOrder, doc.VisibleOnMap, doc.VisibleOnMobile, loginsession.User.UID);
CreateClient<AssetDocumentProvider>(doc.CustomerID).UpdateAssetDocument(doc.CustomerID, doc.Id, doc.Name, doc.Description, doc.VisibleOnWorkOrder, doc.VisibleOnMap, doc.VisibleOnMobile, doc.Url, loginsession.User.UID);
return "OK";
}
@ -1932,6 +1980,7 @@ namespace IronIntel.Contractor.Site
var clientdata = Request.Form["ClientData"].Split((char)170);
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
string timezonestr = HttpUtility.HtmlDecode(clientdata[2]);
if (string.IsNullOrEmpty(customerid))
customerid = SystemParams.CompanyID;
@ -1940,11 +1989,13 @@ namespace IronIntel.Contractor.Site
if (odometers == null || odometers.Length <= 0)
return new CalampOdoInfo[0];
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(timezonestr);//前端页面选中的timezone
List<CalampOdometerInfo> list = new List<CalampOdometerInfo>();
foreach (CalampOdoInfo odo in odometers)
{
CalampOdometerInfo item = new CalampOdometerInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
item.Gps_Calc = Math.Round(item.Gps_Calc, 2);
item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
@ -1972,6 +2023,11 @@ namespace IronIntel.Contractor.Site
p.CustomerID = SystemParams.CompanyID;
DateTime utctime = p.OdometerDate.AddMinutes(-p.OffsetMinute);
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(p.TimeZone);//前端页面选中的timezone
if (timezone != null)
{
utctime = TimeZoneInfo.ConvertTimeToUtc(p.OdometerDate, timezone);
}
CalampOdoInfo[] odometers = CreateClient<AssetDataAdjustClient>(p.CustomerID).GetCalampOdometerHistoryPreview(p.CustomerID, p.AssetID, p.Odometer, p.UOM, utctime);
if (odometers == null || odometers.Length <= 0)
@ -1982,7 +2038,10 @@ namespace IronIntel.Contractor.Site
{
CalampOdometerInfo item = new CalampOdometerInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
if (timezone != null)
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
else
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
item.Gps_Calc = Math.Round(item.Gps_Calc, 2);
item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
@ -2007,6 +2066,7 @@ namespace IronIntel.Contractor.Site
var clientdata = Request.Form["ClientData"].Split((char)170);
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
string timezonestr = HttpUtility.HtmlDecode(clientdata[2]);
if (string.IsNullOrEmpty(customerid))
customerid = SystemParams.CompanyID;
@ -2015,11 +2075,13 @@ namespace IronIntel.Contractor.Site
if (odometers == null || odometers.Length <= 0)
return new CalampOdoInfo[0];
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(timezonestr);//前端页面选中的timezone
List<PedigreeOdometerInfo> list = new List<PedigreeOdometerInfo>();
foreach (PedigreeOdoInfo odo in odometers)
{
PedigreeOdometerInfo item = new PedigreeOdometerInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
item.Gps_Calc = Math.Round(item.Gps_Calc, 2);
item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
@ -2047,6 +2109,11 @@ namespace IronIntel.Contractor.Site
p.CustomerID = SystemParams.CompanyID;
DateTime utctime = p.OdometerDate.AddMinutes(-p.OffsetMinute);
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(p.TimeZone);//前端页面选中的timezone
if (timezone != null)
{
utctime = TimeZoneInfo.ConvertTimeToUtc(p.OdometerDate, timezone);
}
PedigreeOdoInfo[] odometers = CreateClient<AssetDataAdjustClient>(p.CustomerID).GetPedigreeOdometerHistoryPreview(p.CustomerID, p.AssetID, p.Odometer, p.UOM, utctime);
if (odometers == null || odometers.Length <= 0)
@ -2057,7 +2124,10 @@ namespace IronIntel.Contractor.Site
{
PedigreeOdometerInfo item = new PedigreeOdometerInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
if (timezone != null)
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
else
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
item.Gps_Calc = Math.Round(item.Gps_Calc, 2);
item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
@ -2082,6 +2152,7 @@ namespace IronIntel.Contractor.Site
var clientdata = Request.Form["ClientData"].Split((char)170);
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
string timezonestr = HttpUtility.HtmlDecode(clientdata[2]);
if (string.IsNullOrEmpty(customerid))
customerid = SystemParams.CompanyID;
@ -2090,11 +2161,13 @@ namespace IronIntel.Contractor.Site
if (odometers == null || odometers.Length <= 0)
return new CalampOdoInfo[0];
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(timezonestr);//前端页面选中的timezone
List<SmartWitnessOdometerInfo> list = new List<SmartWitnessOdometerInfo>();
foreach (SmartWitnessOdoInfo odo in odometers)
{
SmartWitnessOdometerInfo item = new SmartWitnessOdometerInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
item.Gps_Calc = Math.Round(item.Gps_Calc, 2);
//item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
@ -2122,6 +2195,11 @@ namespace IronIntel.Contractor.Site
p.CustomerID = SystemParams.CompanyID;
DateTime utctime = p.OdometerDate.AddMinutes(-p.OffsetMinute);
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(p.TimeZone);//前端页面选中的timezone
if (timezone != null)
{
utctime = TimeZoneInfo.ConvertTimeToUtc(p.OdometerDate, timezone);
}
SmartWitnessOdoInfo[] odometers = CreateClient<AssetDataAdjustClient>(p.CustomerID).GetSmartWitnessOdometerHistoryPreview(p.CustomerID, p.AssetID, p.Odometer, p.UOM, utctime);
if (odometers == null || odometers.Length <= 0)
@ -2132,7 +2210,10 @@ namespace IronIntel.Contractor.Site
{
SmartWitnessOdometerInfo item = new SmartWitnessOdometerInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
if (timezone != null)
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
else
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
item.Gps_Calc = Math.Round(item.Gps_Calc, 2);
//item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
@ -2265,6 +2346,7 @@ namespace IronIntel.Contractor.Site
var clientdata = Request.Form["ClientData"].Split((char)170);
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
string timezonestr = HttpUtility.HtmlDecode(clientdata[2]);
if (string.IsNullOrEmpty(customerid))
customerid = SystemParams.CompanyID;
@ -2273,11 +2355,13 @@ namespace IronIntel.Contractor.Site
if (eninehours == null || eninehours.Length <= 0)
return new CalampEngineHoursInfo[0];
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(timezonestr);//前端页面选中的timezone
List<CalampEngineHoursInfo> list = new List<CalampEngineHoursInfo>();
foreach (CalampHourInfo eng in eninehours)
{
CalampEngineHoursInfo item = new CalampEngineHoursInfo();
Helper.CloneProperty(item, eng);
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
item.Gps_Calc = Math.Round(item.Gps_Calc, 2);
item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
@ -2305,6 +2389,11 @@ namespace IronIntel.Contractor.Site
p.CustomerID = SystemParams.CompanyID;
DateTime utctime = p.EngineHoursDate.AddMinutes(-p.OffsetMinute);
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(p.TimeZone);//前端页面选中的timezone
if (timezone != null)
{
utctime = TimeZoneInfo.ConvertTimeToUtc(p.EngineHoursDate, timezone);
}
CalampHourInfo[] odometers = CreateClient<AssetQueryClient>(p.CustomerID).GetCalampHourHistoryPreview(p.CustomerID, p.AssetID, p.EngineHours, "Hour", utctime);
if (odometers == null || odometers.Length <= 0)
@ -2315,7 +2404,10 @@ namespace IronIntel.Contractor.Site
{
CalampEngineHoursInfo item = new CalampEngineHoursInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
if (timezone != null)
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
else
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
item.Gps_Calc = Math.Round(item.Gps_Calc, 2);
item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
@ -2340,6 +2432,7 @@ namespace IronIntel.Contractor.Site
var clientdata = Request.Form["ClientData"].Split((char)170);
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
string timezonestr = HttpUtility.HtmlDecode(clientdata[2]);
if (string.IsNullOrEmpty(customerid))
customerid = SystemParams.CompanyID;
@ -2348,11 +2441,13 @@ namespace IronIntel.Contractor.Site
if (eninehours == null || eninehours.Length <= 0)
return new PedigreeEngineHoursInfo[0];
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(timezonestr);//前端页面选中的timezone
List<PedigreeEngineHoursInfo> list = new List<PedigreeEngineHoursInfo>();
foreach (PedigreeHourInfo eng in eninehours)
{
PedigreeEngineHoursInfo item = new PedigreeEngineHoursInfo();
Helper.CloneProperty(item, eng);
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
}
@ -2379,6 +2474,11 @@ namespace IronIntel.Contractor.Site
p.CustomerID = SystemParams.CompanyID;
DateTime utctime = p.EngineHoursDate.AddMinutes(-p.OffsetMinute);
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(p.TimeZone);//前端页面选中的timezone
if (timezone != null)
{
utctime = TimeZoneInfo.ConvertTimeToUtc(p.EngineHoursDate, timezone);
}
PedigreeHourInfo[] eninehours = CreateClient<AssetDataAdjustClient>(p.CustomerID).GetPedigreeHourHistoryPreview(p.CustomerID, p.AssetID, p.EngineHours, "Hour", utctime);
if (eninehours == null || eninehours.Length <= 0)
@ -2389,7 +2489,10 @@ namespace IronIntel.Contractor.Site
{
PedigreeEngineHoursInfo item = new PedigreeEngineHoursInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
if (timezone != null)
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
else
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
item.VBUS_Calc = Math.Round(item.VBUS_Calc, 2);
list.Add(item);
}
@ -2414,6 +2517,7 @@ namespace IronIntel.Contractor.Site
var clientdata = Request.Form["ClientData"].Split((char)170);
var customerid = HttpUtility.HtmlDecode(clientdata[0]);
var assetid = HttpUtility.HtmlDecode(clientdata[1]);
string timezonestr = HttpUtility.HtmlDecode(clientdata[2]);
if (string.IsNullOrEmpty(customerid))
customerid = SystemParams.CompanyID;
@ -2422,11 +2526,13 @@ namespace IronIntel.Contractor.Site
if (eninehours == null || eninehours.Length <= 0)
return new OEMDD2EngineHoursInfo[0];
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(timezonestr);//前端页面选中的timezone
List<OEMDD2EngineHoursInfo> list = new List<OEMDD2EngineHoursInfo>();
foreach (OEMDD2HourInfo eng in eninehours)
{
OEMDD2EngineHoursInfo item = new OEMDD2EngineHoursInfo();
Helper.CloneProperty(item, eng);
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
item.Calculated = Math.Round(item.Calculated, 2);
list.Add(item);
}
@ -2453,6 +2559,11 @@ namespace IronIntel.Contractor.Site
p.CustomerID = SystemParams.CompanyID;
DateTime utctime = p.EngineHoursDate.AddMinutes(-p.OffsetMinute);
TimeZoneInfo timezone = TimeZoneInfo.FindSystemTimeZoneById(p.TimeZone);//前端页面选中的timezone
if (timezone != null)
{
utctime = TimeZoneInfo.ConvertTimeToUtc(p.EngineHoursDate, timezone);
}
OEMDD2HourInfo[] eninehours = CreateClient<AssetDataAdjustClient>(p.CustomerID).GetOEMDD2HourHistoryPreview(p.CustomerID, p.AssetID, p.EngineHours, "Hour", utctime);
if (eninehours == null || eninehours.Length <= 0)
@ -2463,7 +2574,10 @@ namespace IronIntel.Contractor.Site
{
OEMDD2EngineHoursInfo item = new OEMDD2EngineHoursInfo();
Helper.CloneProperty(item, odo);
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
if (timezone != null)
item.AsofTimeLocal = TimeZoneInfo.ConvertTimeFromUtc(item.AsofTime, timezone);
else
item.AsofTimeLocal = item.AsofTime.AddMinutes(p.OffsetMinute);
item.Raw = Math.Round(item.Raw, 2);
item.Calculated = Math.Round(item.Calculated, 2);
list.Add(item);
@ -2858,7 +2972,7 @@ namespace IronIntel.Contractor.Site
if (hourstime < mintime)
return 1;
if (hourstime > maxtime.AddMinutes(1) || hourstime > DateTime.UtcNow)
if (hourstime > maxtime.AddMinutes(1) || hourstime > DateTime.UtcNow.AddMinutes(1))
return 2;
return 0;
@ -3188,6 +3302,8 @@ namespace IronIntel.Contractor.Site
case "ATU-RB-5":
case "ATU-RB-6":
case "ATU-RB-8":
case "ATU-RB-9":
case "ATU-RB-10":
device.DeviceType = t;
break;
default:
@ -3363,7 +3479,6 @@ namespace IronIntel.Contractor.Site
asset.MakeID = -1;
asset.ModelID = -1;
asset.MakeYear = -1;
//asset.UnderCarriageHours = -1;
//asset.Odometer = -1;
//asset.EngineHours = -1;
foreach (StringKeyValue kv in kvs)
@ -3569,18 +3684,6 @@ namespace IronIntel.Contractor.Site
{
asset.Description = dr[kv.Value].ToString().Trim();
}
else if (string.Compare(kv.Key, "Undercarriage Replacement Interval(Hours)", true) == 0)
{
string eh = dr[kv.Value].ToString().Trim();
if (string.IsNullOrEmpty(eh) || eh == "0")
{
asset.UnderCarriageHours = null;
}
else
{
asset.UnderCarriageHours = Helper.ConvertToDouble(eh);
}
}
else if (string.Compare(kv.Key, "Odometer", true) == 0)
{
string eh = dr[kv.Value].ToString().Trim();
@ -4133,6 +4236,12 @@ namespace IronIntel.Contractor.Site
public string EventLocalTimeStr { get { return (EventLocalTime == null || EventLocalTime == DateTime.MinValue) ? "" : EventLocalTime.ToString("M/d/yyyy"); } }
}
public class DeviceTypeItem
{
public List<StringKeyValue> SmartWitnessTypes { get; set; }
public List<StringKeyValue> IDriveTypes { get; set; }
}
}
public class AssetDocumentItem : AssetDocumentInfo

View File

@ -1,14 +1,20 @@
using Foresight.Data;
using FI.FIC.Contracts.DataObjects.BLObject;
using Foresight.Data;
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.AssetHealth;
using Foresight.Fleet.Services.AssetHealth.WorkOrder;
using Foresight.Fleet.Services.Device;
using Foresight.Fleet.Services.JobSite;
using Foresight.Fleet.Services.User;
using Foresight.ServiceModel;
using IronIntel.Contractor.ExportExcel;
using IronIntel.Contractor.Machines;
using IronIntel.Contractor.Maintenance;
using Microsoft.SqlServer.Server;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -64,6 +70,9 @@ namespace IronIntel.Contractor.Site.Maintenance
case "GETJOBSITES":
result = GetJobsites();
break;
case "GETALERTCATEGORY":
result = GetAlertCategory();
break;
case "SAVEAUTOACKNOWLEDGEALERTTYPES":
result = SaveAutoAcknowledgeAlertTypes();
break;
@ -85,6 +94,42 @@ namespace IronIntel.Contractor.Site.Maintenance
case "GETASSIGNTOS":
result = GetAssignTos();
break;
case "GETALERTMAPPINGS":
result = GetAlertMappings();
break;
case "SAVEALERTMAPPING":
result = SaveAlertMapping();
break;
case "DELETEALERTMAPPING":
result = DeleteAlertMapping();
break;
case "SAVEALERTMAPPINGITEM":
result = SaveAlertMappingItem();
break;
case "DELETEALERTMAPPINGITEM":
result = DeleteAlertMappingItem();
break;
case "GETALLALERTMAPPINGDATASOURCE":
result = GetAllAlertMappingDataSource();
break;
case "ADDALERTMAPPINGSOURCE":
result = AddAlertMappingSource();
break;
case "GETIMPORTALERTMAPPINGSCOLUMNS":
result = GetImportAlertMappingsColumns();
break;
case "IMPORTALERTMAPPINGS":
result = ImportAlertMappings();
break;
case "GETALERTMAPPINGDEFAULTCATEGORY":
result = GetAlertMappingDefaultCategory();
break;
case "SETALERTMAPPINGDEFAULTCATEGORY":
result = SetAlertMappingDefaultCategory();
break;
case "UPDATEALERTCOMMENT":
result = UpdateAlertComment();
break;
}
}
}
@ -98,6 +143,566 @@ namespace IronIntel.Contractor.Site.Maintenance
Response.End();
}
#region Alert Mappings
private object GetAlertMappings()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var clientdata = Request.Form["ClientData"];
var searchtxt = HttpUtility.HtmlDecode(clientdata);
AlertMappingInfo[] mappings = CreateClient<AlertProvider>().GetAlertMappings(SystemParams.CompanyID, searchtxt, true);
if (mappings == null || mappings.Length == 0)
return new AlertMappingInfo[0];
return mappings;
}
else
return new AlertMappingInfo[0];
}
catch (Exception ex)
{
return ex.Message;
}
}
private object SaveAlertMapping()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
AlertMappingInfo ami = JsonConvert.DeserializeObject<AlertMappingInfo>(clientdata);
long id = CreateClient<AlertProvider>().SaveAlertMapping(SystemParams.CompanyID, ami);
return id;
}
else
return FailedResult;
}
catch (Foresight.Standard.BusinessException ex)
{
return -1;
}
catch (Exception ex)
{
return ex.Message;
}
}
private string DeleteAlertMapping()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
CreateClient<AlertProvider>().DeleteAlertMapping(SystemParams.CompanyID, Convert.ToInt64(clientdata));
return "";
}
else
return FailedResult;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object SaveAlertMappingItem()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
AlertMappingItem ami = JsonConvert.DeserializeObject<AlertMappingItem>(clientdata);
long itemid = CreateClient<AlertProvider>().SaveAlertMappingItem(SystemParams.CompanyID, ami);
return itemid;
}
else
return FailedResult;
}
catch (Foresight.Standard.BusinessException ex)
{
return -1;
}
catch (Exception ex)
{
return ex.Message;
}
}
private string DeleteAlertMappingItem()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
CreateClient<AlertProvider>().DeleteAlertMappingItem(SystemParams.CompanyID, Convert.ToInt64(clientdata));
return "";
}
else
return FailedResult;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object AddAlertMappingSource()
{
try
{
LoginSession se = GetCurrentLoginSession();
if (se != null)
{
var clientdata = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
AlertMappingSourceInfo source = JsonConvert.DeserializeObject<AlertMappingSourceInfo>(clientdata);
long id = CreateClient<AlertProvider>().AddAlertMappingSource(SystemParams.CompanyID, source);
return id;
}
else
return FailedResult;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetAlertMappingDefaultCategory()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
return SystemParams.GetStringParam(SystemParams.AlertMappingDefaultCategory);
}
return "";
}
catch (Exception ex)
{
return ex.Message;
}
}
private object SetAlertMappingDefaultCategory()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
string clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
SystemParams.SetStringParam(SystemParams.AlertMappingDefaultCategory, clientdata);
return "";
}
return FailedResult;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetAllAlertMappingDataSource()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
var ap = CreateClient<AssetClassProvider>();
AssetMake[] makes = ap.GetAssetMakes("");
AssetModel[] models = ap.GetAssetModels(-1, "");
StringBuilder sbmake = new StringBuilder();
foreach (var m in makes)
{
sbmake.Append(SPLIT_CHAR180 + m.ID.ToString() + SPLIT_CHAR175 + m.Name);
}
if (sbmake.Length > 0)
sbmake = sbmake.Remove(0, 1);
StringBuilder sbmodel = new StringBuilder();
foreach (var m in models)
{
sbmodel.Append(SPLIT_CHAR180 + m.ID.ToString() + SPLIT_CHAR175 + m.Name + SPLIT_CHAR175 + m.MakeId);
}
if (sbmodel.Length > 0)
sbmodel = sbmodel.Remove(0, 1);
AlertMappingSourceInfo[] amsources = CreateClient<AlertProvider>().GetAlertMappingSource(SystemParams.CompanyID, -1);
AlertMappingSourceInfo[] descs = amsources.Where(d => d.Type == 1).OrderBy(d => d.Value).ToArray();
AlertMappingSourceInfo[] categories = amsources.Where(d => d.Type == 2).OrderBy(c => c.Value).ToArray();
StringBuilder sbdescs = new StringBuilder();
foreach (var d in descs)
{
sbdescs.Append(SPLIT_CHAR180 + d.ToString());
}
if (sbdescs.Length > 0)
sbdescs = sbdescs.Remove(0, 1);
StringBuilder sbcategorys = new StringBuilder();
foreach (var c in categories)
{
sbcategorys.Append(SPLIT_CHAR180 + c.ToString());
}
if (sbcategorys.Length > 0)
sbcategorys = sbcategorys.Remove(0, 1);
return new
{
Makes = sbmake.ToString(),
Models = sbmodel.ToString(),
Descriptions = sbdescs.ToString(),
Categories = sbcategorys.ToString()
};
}
else
return null;
}
catch (Exception ex)
{
return ex.Message;
}
}
private object GetImportAlertMappingsColumns()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
string woid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
HttpPostedFile uploadFile = null;
byte[] iconfilebyte = null;
if (Request.Files.Count > 0)
{
uploadFile = Request.Files[0];
iconfilebyte = ConvertFile2bytes(uploadFile);
}
if (iconfilebyte != null)
{
string[] columns = new ImportFromExcel().LoadExcelColumnHead(iconfilebyte);
if (columns != null && columns.Length > 0)
return columns;
}
}
return new string[0];
}
catch (Exception ex)
{
return ex.Message;
}
}
public class ImportResult
{
public int Count = -1;
public List<AlertMappingClient> Datas = new List<AlertMappingClient>();
}
private object ImportAlertMappings()
{
try
{
int count = 0;
var session = GetCurrentLoginSession();
ImportResult result = new ImportResult();
if (session != null)
{
string p = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
bool getData = Convert.ToBoolean(HttpUtility.HtmlDecode(Request.Form["Get"]));
string selected = HttpUtility.HtmlDecode(Request.Form["SelectedData"]);
StringKeyValue[] kvs = JsonConvert.DeserializeObject<StringKeyValue[]>(p);
HttpPostedFile uploadFile = null;
byte[] iconfilebyte = null;
if (Request.Files.Count > 0)
{
uploadFile = Request.Files[0];
iconfilebyte = ConvertFile2bytes(uploadFile);
}
if (iconfilebyte != null)
{
if (!CheckRight(SystemParams.CompanyID, Feature.ALERTS_MANAGEMENT))
return 0;
DataTable dt = new ImportFromExcel().LoadExcelData(iconfilebyte);
if (dt != null && dt.Rows.Count > 0)
{
List<string> sels = new List<string>();
if (!string.IsNullOrEmpty(selected))
{
string[] ss = selected.Split(',');
sels = ss.ToList();
}
int index = 0;
AlertProvider client = CreateClient<AlertProvider>();
string[] alerttypes = new string[] { "", "Red", "Yellow", "Info" };
var ap = CreateClient<AssetClassProvider>();
AssetMake[] makes = ap.GetAssetMakes("");
List<AssetMake> tempmakes = new List<AssetMake>();
tempmakes.Add(new AssetMake() { ID = -1, Name = "(All)" });
tempmakes.AddRange(makes);
makes = tempmakes.ToArray();
AssetModel[] models = ap.GetAssetModels(-1, "");
List<AssetModel> tempmodels = new List<AssetModel>();
tempmodels.Add(new AssetModel() { ID = -1, Name = "(All)", MakeId = -1 });
tempmodels.AddRange(models);
models = tempmodels.ToArray();
AlertMappingInfo[] allmappings = client.GetAlertMappings(SystemParams.CompanyID, string.Empty, true);
var sources = client.GetAlertMappingSource(SystemParams.CompanyID, -1);
List<AlertMappingSourceInfo> all_source = new List<AlertMappingSourceInfo>();
all_source.AddRange(sources);
foreach (DataRow dr in dt.Rows)
{
if (!getData && sels.Count > 0 && sels.Count >= index + 1 && (sels[index] == "false"))
{
index++;
continue;
}
index++;
AlertMappingClient mappinginfo = null;
try
{
mappinginfo = ConvertToImportAlertMappingInfo(dr, kvs, makes, models);
if (!getData)
{
if (allmappings == null || allmappings.Length == 0)
{
result.Datas.Add(mappinginfo);
continue;
}
if (string.IsNullOrEmpty(mappinginfo.Source) || string.IsNullOrEmpty(mappinginfo.Description))
{
result.Datas.Add(mappinginfo);
continue;
}
if (mappinginfo.Make >= -1 && mappinginfo.Models != null && mappinginfo.Models.Length > 0)
{
if (!alerttypes.Contains(mappinginfo.AlertType))
{
result.Datas.Add(mappinginfo);
continue;
}
AlertMappingInfo ami = allmappings.FirstOrDefault(m => string.Compare(m.Source, mappinginfo.Source, true) == 0
&& string.Compare(m.SPN, mappinginfo.SPN, true) == 0 && string.Compare(m.FMI, mappinginfo.FMI, true) == 0
&& string.Compare(m.Description.Replace("\r", "").Replace("\n", ""), mappinginfo.Description.Replace("\r", "").Replace("\n", ""), true) == 0);
if (ami == null)
{
result.Datas.Add(mappinginfo);
continue;
}
else
{
if (ami.Items == null || ami.Items.Count == 0)
{
result.Datas.Add(mappinginfo);
continue;
}
else
{
string new_modelstr = string.Join(",", mappinginfo.Models.OrderBy(m => m));
AlertMappingItem[] mitems = ami.Items.Where(m => m.Make == mappinginfo.Make).ToArray();
AlertMappingItem newitem = null;
foreach (AlertMappingItem item in mitems)
{
string old_modelstr = string.Join(",", item.Models.OrderBy(m => m));
if (string.Compare(new_modelstr, old_modelstr, true) == 0)
{
newitem = item;
break;
}
}
if (newitem == null)
{
result.Datas.Add(mappinginfo);
continue;
}
else
{
newitem.AlertType = mappinginfo.AlertType;
newitem.Category = mappinginfo.Category;
AddAlertMappingItem(client, all_source, newitem);
}
}
}
}
count++;
}
else
{
result.Datas.Add(mappinginfo);
}
}
catch (Exception e)
{
if (mappinginfo != null)
{
result.Datas.Add(mappinginfo);
}
}
}
}
}
if (!getData)
{
result.Count = count;
}
}
return JsonConvert.SerializeObject(result);
}
catch (Exception ex)
{
return ex.Message;
}
}
private void AddAlertMappingItem(AlertProvider client, List<AlertMappingSourceInfo> all_source, AlertMappingItem item)
{
if (!string.IsNullOrWhiteSpace(item.Category))
{
AlertMappingSourceInfo oldsource = all_source.FirstOrDefault(m => m.Type == 2 && string.Compare(m.Value, item.Category, true) == 0);
if (oldsource == null)
{
AlertMappingSourceInfo newsource = new AlertMappingSourceInfo();
newsource.Type = 2;
newsource.Value = item.Category;
newsource.Id = client.AddAlertMappingSource(SystemParams.CompanyID, newsource);
all_source.Add(newsource);
item.CategoryId = newsource.Id;
}
else
item.CategoryId = oldsource.Id;
}
else
{
item.CategoryId = -1;
}
item.Id = client.SaveAlertMappingItem(SystemParams.CompanyID, item);
}
private AlertMappingClient ConvertToImportAlertMappingInfo(DataRow dr, StringKeyValue[] kvs, AssetMake[] makes, AssetModel[] models)
{
AlertMappingClient mapping = new AlertMappingClient();
foreach (StringKeyValue kv in kvs)
{
if (string.IsNullOrEmpty(kv.Key) || string.IsNullOrEmpty(kv.Value))
{
continue;
}
if (dr[kv.Value] == DBNull.Value || dr[kv.Value] == null)
{
continue;
}
if (string.Compare(kv.Key, "Source", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
mapping.Source = s;
}
if (string.Compare(kv.Key, "SPN", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
mapping.SPN = s;
}
if (string.Compare(kv.Key, "FMI", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
mapping.FMI = s;
}
else if (string.Compare(kv.Key, "Description", true) == 0)
{
mapping.Description = dr[kv.Value].ToString().Trim();
}
else if (string.Compare(kv.Key, "Make", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
mapping.MakeName = s;
if (!string.IsNullOrWhiteSpace(s))
{
if (string.Compare("(All)", s, true) == 0)
mapping.Make = -1;
else
{
AssetMake make = makes.FirstOrDefault(m => string.Compare(m.Name, s, true) == 0);
if (make != null)
mapping.Make = make.ID;
}
}
}
else if (string.Compare(kv.Key, "Models", true) == 0)
{
string s = dr[kv.Value].ToString().Trim();
if (!string.IsNullOrWhiteSpace(s))
{
mapping.ModelNames = s;
string[] modelsstr = s.Split(',');
if (modelsstr != null && modelsstr.Length > 0)
{
List<int> lsmodel = new List<int>();
foreach (string str in modelsstr)
{
if (!string.IsNullOrWhiteSpace(str))
{
if (string.Compare("(All)", str, true) == 0)
lsmodel.Add(-1);
else
{
AssetModel model = models.FirstOrDefault(m => mapping.Make == m.MakeId && string.Compare(m.Name, str, true) == 0);
if (model != null)
lsmodel.Add(model.ID);
}
}
}
mapping.Models = lsmodel.ToArray();
}
}
}
else if (string.Compare(kv.Key, "AlertType", true) == 0)
{
mapping.AlertType = dr[kv.Value].ToString().Trim();
}
else if (string.Compare(kv.Key, "Category", true) == 0)
{
mapping.Category = dr[kv.Value].ToString().Trim();
}
}
return mapping;
}
#endregion
private object GetAlerts()
{
try
@ -134,27 +739,33 @@ namespace IronIntel.Contractor.Site.Maintenance
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);
assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted, alertparam.Category);
else
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted);
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted, alertparam.Category);
if (assetalerts == null || assetalerts.Length == 0)
return new AlertInfo[0];
List<AlertInfo> list = new List<AlertInfo>();
return string.Empty;
StringBuilder sb = new StringBuilder();
foreach (AssetAlertGridViewItem item in assetalerts)
{
AlertInfo ai = ConvertAlertObj(item);
list.Add(ai);
sb.Append(SPLIT_CHAR180 + ai.ToString());
}
return list.ToArray();
if (sb.Length > 0)
{
return sb.ToString().Substring(1);
}
return string.Empty;
}
else
return new AlertInfo[0];
return string.Empty;
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.GetAlerts", ex.Message, ex.ToString());
return ex.Message;
return new string[] { ex.Message };
}
}
@ -195,12 +806,12 @@ namespace IronIntel.Contractor.Site.Maintenance
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);
assetalerts = CreateClient<WorkOrderProvider>().GetAssetAlertGridViewItemsByAsset(SystemParams.CompanyID, alertparam.AssetID, beginDate, endDate, alertparam.AlertTypes, alertparam.JobSites, assigned, completed, alertparam.SearchText, alertparam.IncludeunCompleted, alertparam.Category);
else
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted);
assetalerts = CreateClient<AlertProvider>().GetAssetAlertGridViewItems(SystemParams.CompanyID, beginDate, endDate, alertparam.AlertTypes, alertparam.AssetGroups, alertparam.JobSites, assigned, completed, alertparam.SearchText, session.User.UID, alertparam.IncludeunCompleted, alertparam.Category);
if (assetalerts == null || assetalerts.Length == 0)
return new MachineInfoForAlert[0];
return string.Empty;
List<MachineInfoForAlert> machinealerts = new List<MachineInfoForAlert>();
foreach (AssetAlertGridViewItem item in assetalerts)
@ -236,15 +847,24 @@ namespace IronIntel.Contractor.Site.Maintenance
mi.LatestAlertDateTime = ai.AlertLocalTime;
}
return machinealerts.ToArray();
StringBuilder sb = new StringBuilder();
foreach (MachineInfoForAlert mi in machinealerts)
{
sb.Append(SPLIT_CHAR183 + mi.ToString());
}
if (sb.Length > 0)
{
return sb.ToString().Substring(1);
}
return string.Empty;
}
else
return new MachineInfoForAlert[0];
return string.Empty;
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.GetAlerts", ex.Message, ex.ToString());
return ex.Message;
return new string[] { ex.Message };
}
}
@ -291,6 +911,7 @@ namespace IronIntel.Contractor.Site.Maintenance
ai.Recurring = item.Recurring;
ai.Priority = item.Priority;
ai.ExpectedCost = item.ExpectedCost;
ai.Comment = item.Comment;
return ai;
}
@ -300,6 +921,7 @@ namespace IronIntel.Contractor.Site.Maintenance
AlertInfo ai = new AlertInfo();
ai.AlertID = item.ID;
ai.WorkOrderID = item.WorkOrderId;
ai.WorkOrderNumber = item.WorkOrderNumber;
ai.WorkOrderStatus = item.WorkOrderStatus;
ai.AlertType = item.AlertType;
ai.AlertTime_UTC = item.LastAlertTime;
@ -325,6 +947,7 @@ namespace IronIntel.Contractor.Site.Maintenance
//ai.Recurring = item.Recurring;
//ai.Priority = item.Priority;
//ai.ExpectedCost = item.ExpectedCost;
ai.Comment = item.Comment;
return ai;
}
@ -351,6 +974,7 @@ namespace IronIntel.Contractor.Site.Maintenance
ai.AcknowledgedTime_UTC = item.AcknowledgedTime;
ai.AcknowledgedTime_Local = item.AcknowledgedLocalTime;
ai.AcknowledgedComment = item.AcknowledgedComment;
ai.Comment = item.Comment;
return ai;
}
@ -377,27 +1001,34 @@ namespace IronIntel.Contractor.Site.Maintenance
alertparam.AlertStatus = new string[0];
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];
List<AlertInfo> list = new List<AlertInfo>();
return string.Empty;
if (alertparam.AssetID > 0)
ackalerts = ackalerts.Where(m => m.AssetID == alertparam.AssetID).ToArray();
if (ackalerts == null || ackalerts.Length == 0)
return string.Empty;
StringBuilder sb = new StringBuilder();
foreach (AcknowledgedAlertItem item in ackalerts)
{
AlertInfo ai = ConvertAlertObj2(item);
list.Add(ai);
sb.Append(SPLIT_CHAR180 + ai.ToString());
}
if (sb.Length > 0)
{
return sb.ToString().Substring(1);
}
if (list == null)
return new AlertInfo[0];
if (alertparam.AssetID > 0)
list = list.Where(m => m.MachineID == alertparam.AssetID).ToList();
return list.ToArray();
return string.Empty;
}
else
return new AlertInfo[0];
return string.Empty;
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.GetAcknowledgedAlerts", ex.Message, ex.ToString());
return ex.Message;
return new string[] { ex.Message };
}
}
@ -439,10 +1070,10 @@ namespace IronIntel.Contractor.Site.Maintenance
long[] list = JsonConvert.DeserializeObject<long[]>(ids);
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
am.AcknowledgeAlert(se.User.UID, list, acknowledgmentcomment);
return "OK";
return OkResult;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -471,10 +1102,10 @@ namespace IronIntel.Contractor.Site.Maintenance
wp.AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, workorderid, added, true);
if (deleted.Length > 0)
wp.AddOrRemoveAlertsFromWorkOrder(SystemParams.CompanyID, workorderid, deleted, false);
return "OK";
return OkResult;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -618,10 +1249,10 @@ namespace IronIntel.Contractor.Site.Maintenance
string[] alerttypes = JsonConvert.DeserializeObject<string[]>(clientdata);
CreateClient<WorkOrderProvider>().SaveAutoAcknowledgeAlertTypes(SystemParams.CompanyID, alerttypes, session.User.UID);
return "OK";
return OkResult;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -735,7 +1366,7 @@ namespace IronIntel.Contractor.Site.Maintenance
var session = GetCurrentLoginSession();
if (session != null)
{
var users = Users.UserManagement.GetActiveUsers(session.SessionID, SystemParams.CompanyID);
var users = Users.UserManagement.GetActiveUsers(GetLanguageCookie(), session.SessionID, SystemParams.CompanyID);
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (var u in users)
{
@ -788,6 +1419,34 @@ namespace IronIntel.Contractor.Site.Maintenance
return ex.Message;
}
}
private object GetAlertCategory()
{
try
{
var session = GetCurrentLoginSession();
if (session != null)
{
AlertMappingSourceInfo[] sources = CreateClient<AlertProvider>().GetAlertMappingSource(SystemParams.CompanyID, 2);
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (AlertMappingSourceInfo si in sources)
{
StringKeyValue kv = new StringKeyValue();
kv.Key = si.Id.ToString();
kv.Value = si.Value;
list.Add(kv);
}
return list.OrderBy((m) => m.Value).ToArray();
}
else
return new StringKeyValue[0];
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.GetAlertCategory", ex.Message, ex.ToString());
return ex.Message;
}
}
private object GetAlertTypes()
{
@ -795,8 +1454,16 @@ namespace IronIntel.Contractor.Site.Maintenance
{
if (GetCurrentLoginSession() != null)
{
AlertManager am = new AlertManager(SystemParams.DataDbConnectionString);
return am.GetAlertTypes(); ;
Foresight.Standard.StringKeyValue[] types = CreateClient<AlertProvider>().GetAlertTypes(SystemParams.CompanyID);
List<StringKeyValue> list = new List<StringKeyValue>();
foreach (var t in types)
{
StringKeyValue kv = new StringKeyValue();
kv.Key = t.Key;
kv.Value = t.Value;
list.Add(kv);
}
return list.ToArray();
}
else
return new StringKeyValue[0];
@ -854,7 +1521,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return new string[] { generator.Id.ToString(), "" };
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -875,7 +1542,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return new string[0];
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -885,6 +1552,33 @@ namespace IronIntel.Contractor.Site.Maintenance
}
#endregion
private object UpdateAlertComment()
{
try
{
if (GetCurrentLoginSession() != null)
{
var clientdata = HttpUtility.UrlDecode(Request.Form["ClientData"]);
string[] ps = JsonConvert.DeserializeObject<string[]>(clientdata);
if (ps.Length < 2)
{
throw new ArgumentOutOfRangeException();
}
var ids = ps[0].Split(',').Select(s => long.Parse(s)).ToArray();
var provider = CreateClient<AlertProvider>();
provider.SetAlertComment(SystemParams.CompanyID, ids, ps[1]);
return OkResult;
}
throw new UnauthorizedAccessException();
}
catch (Exception ex)
{
AddLog("ERROR", "AlertsBasePage.UpdateAlertComment", ex.Message, ex.ToString());
return ex.Message;
}
}
}
public class AlertsLisenceItem

View File

@ -180,7 +180,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return fuleid;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -200,9 +200,9 @@ namespace IronIntel.Contractor.Site.Maintenance
CreateClient<FuelManagementClient>().DeleteFuelRecord(SystemParams.CompanyID, fuleid, session.User.UID);
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -344,9 +344,9 @@ namespace IronIntel.Contractor.Site.Maintenance
string FileName = uploadFile == null ? "" : uploadFile.FileName;
long attid = CreateClient<AttachmentProvider>().AddAttachment(SystemParams.CompanyID, "FuelRecord", fuleid, FileName, "", iconfilebyte);
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -364,9 +364,9 @@ namespace IronIntel.Contractor.Site.Maintenance
string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
CreateClient<AttachmentProvider>().DeleteAttachment(SystemParams.CompanyID, long.Parse(attachid));
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{

View File

@ -330,7 +330,7 @@ namespace IronIntel.Contractor.Site.Maintenance
private void GetUsersData()
{
UserInfo[] user = UserManagement.GetUsers();
UserInfo[] user = UserManagement.GetUsers(string.Empty, string.Empty, GetLanguageCookie());
user = user.OrderBy((u) => u.DisplayName).ToArray();
string json = JsonConvert.SerializeObject(user);
Response.Write(json);
@ -416,9 +416,9 @@ namespace IronIntel.Contractor.Site.Maintenance
string FileName = uploadFile == null ? "" : uploadFile.FileName;
long attid = CreateClient<AttachmentProvider>().AddAttachment(SystemParams.CompanyID, "MaintenanceLog", woid, FileName, "", iconfilebyte);
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -436,9 +436,9 @@ namespace IronIntel.Contractor.Site.Maintenance
string attachid = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
CreateClient<AttachmentProvider>().DeleteAttachment(SystemParams.CompanyID, long.Parse(attachid));
return "OK";
return OkResult;
}
return "Failed";
return FailedResult;
}
catch (Exception ex)
{

View File

@ -49,6 +49,11 @@ namespace IronIntel.Contractor.Site.Maintenance
{
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
list.Remove(item);
item = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
list.Remove(item);
MaintenanceNavigateItem item1 = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
list.Remove(item1);
}
var fuelitem = license.Items.FirstOrDefault(m => m.Key == "FuelRecords");
if (fuelitem == null || !Helper.IsTrue(fuelitem.Value))
@ -85,6 +90,12 @@ namespace IronIntel.Contractor.Site.Maintenance
}
var user = GetCurrentUser();
if (user.UserType != Users.UserTypes.SupperAdmin)
{
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
if (item != null)
list.Remove(item);
}
if (user.UserType == Users.UserTypes.Common)
{
var client = CreateClient<PermissionProvider>();
@ -108,6 +119,11 @@ namespace IronIntel.Contractor.Site.Maintenance
{
MaintenanceNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_alertsmanagement");
list.Remove(item);
item = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
list.Remove(item);
MaintenanceNavigateItem item1 = list.FirstOrDefault(m => m.ID == "nav_alertsmappings");
list.Remove(item1);
}
Tuple<Feature, Permissions> pmpm = pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE);
if (pmpm == null)
@ -175,6 +191,13 @@ namespace IronIntel.Contractor.Site.Maintenance
item1.IconPath = "img/alert.png";
list.Add(item1);
MaintenanceNavigateItem alertmappingsitem = new MaintenanceNavigateItem();
alertmappingsitem.ID = "nav_alertsmappings";
alertmappingsitem.Title = "Alert Mappings";
alertmappingsitem.Url = "AlertMappingManagement.aspx";
alertmappingsitem.IconPath = "img/alert.png";
list.Add(alertmappingsitem);
MaintenanceNavigateItem item3 = new MaintenanceNavigateItem();
item3.ID = "nav_maintenanceschedule";
item3.Title = "Maintenance Schedules";

View File

@ -190,7 +190,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return string.Empty;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
@ -235,14 +235,15 @@ namespace IronIntel.Contractor.Site.Maintenance
PmScheduleType = item.Type,
PmScheduleUom = item.ScheduleUom,
Notes = item.Notes,
Intervals = item.Intervals
Intervals = item.Intervals,
Enabled = item.Enabled
};
MaintenanceManagement.UpdatePmSchedule(session.SessionID, si, session.User.UID);
return si.PmScheduleID;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -278,7 +279,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return string.Empty;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -310,7 +311,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return string.Empty;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
{
@ -330,7 +331,7 @@ namespace IronIntel.Contractor.Site.Maintenance
return string.Empty;
}
else
return "Failed";
return FailedResult;
}
catch (Exception ex)
@ -465,6 +466,7 @@ namespace IronIntel.Contractor.Site.Maintenance
}
public double? StartHours { get; set; }
public DateTime? StartDate { get; set; }
public int TypeID { get; set; }
public string TypeName { get; set; }
public int AlertsCount { get; set; }
public int UnMaintainedAlert { get; set; }
@ -512,6 +514,7 @@ namespace IronIntel.Contractor.Site.Maintenance
public string Notes { get; set; }
public PmIntervalItem[] Intervals { get; set; }
public bool Enabled { get; set; }
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -121,6 +121,9 @@ namespace IronIntel.Contractor.Site.MapView
case "GetNowFormatDate":
result = GetNowFormatDate();
break;
case "GetAssetLocationDataSources":
result = GetAssetLocationDataSources();
break;
default:
break;
}
@ -340,8 +343,13 @@ namespace IronIntel.Contractor.Site.MapView
string datasource = "";
if (ps.Length > 5)
datasource = ps[5];
string subsource = "";
if (ps.Length > 6)
{
subsource = ps[6];
}
item = AssetMapViewManagement.GetMachineLocationHistory(LoginSession.SessionID, ps[0], dtFrom, dtTo, companyid, notShow00loc, datasource);
item = AssetMapViewManagement.GetMachineLocationHistory(LoginSession.SessionID, ps[0], dtFrom, dtTo, companyid, notShow00loc, datasource, subsource);
}
else
{
@ -390,6 +398,25 @@ namespace IronIntel.Contractor.Site.MapView
}
}
private DataSourceInfo[] GetAssetLocationDataSources()
{
if (LoginSession != null)
{
string p = Context.Request.Params["ClientData"];
string[] ps = p.Split(';');
string companyid = ps.Length > 1 ? ps[1].Trim() : null;//companyid
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
var client = FleetServiceClientHelper.CreateClient<AssetLocationQueryClient>(companyid, LoginSession.SessionID);
return client.GetAssetLocationDataSources(companyid, long.Parse(ps[0]));
}
else
{
return Array.Empty<DataSourceInfo>();
}
}
private Tuple<string, string> GetLocationPrimaryDataSource()
{
if (LoginSession != null)
@ -515,7 +542,7 @@ namespace IronIntel.Contractor.Site.MapView
string data = Context.Request.Params["ClientData"];
MapViewSearchItem item = JsonConvert.DeserializeObject<MapViewSearchItem>(data);
return UserParams.SaveMapViewSearch(LoginSession.SessionID, LoginSession.User.UID, item);
return UserParams.SaveMapViewSearch(LoginSession.SessionID, LoginSession.User.UID, item, GetLanguageCookie());
}
return new MapViewSearchItem[0];
@ -528,7 +555,7 @@ namespace IronIntel.Contractor.Site.MapView
string p = Context.Request.Params["ClientData"];
p = HttpUtility.HtmlDecode(p);
return UserParams.DeleteMapViewSearch(LoginSession.SessionID, LoginSession.User.UID, p);
return UserParams.DeleteMapViewSearch(LoginSession.SessionID, LoginSession.User.UID, p, GetLanguageCookie());
}
return new MapViewSearchItem[0];
}
@ -596,7 +623,7 @@ namespace IronIntel.Contractor.Site.MapView
UserInfo[] users;
if (LoginSession != null)
{
users = UserManagement.GetUsers().Where(u => u.Active).ToArray();
users = UserManagement.GetUsers(string.Empty, string.Empty, GetLanguageCookie()).Where(u => u.Active).ToArray();
}
else
{
@ -615,7 +642,8 @@ namespace IronIntel.Contractor.Site.MapView
string contractorid = p.Substring(0, index);
string assetid = p.Substring(index + 1);
items = UserManagement.GetUsersByAssetID(LoginSession.SessionID, Convert.ToInt64(assetid), contractorid);
var lang = GetLanguageCookie();
items = UserManagement.GetUsersByAssetID(LoginSession.SessionID, Convert.ToInt64(assetid), contractorid, lang);
}
else
{
@ -634,7 +662,7 @@ namespace IronIntel.Contractor.Site.MapView
string contractorid = p.Substring(0, index);
string jsid = p.Substring(index + 1);
items = UserManagement.GetUsersByJobsiteID(LoginSession.SessionID, Convert.ToInt64(jsid), contractorid);
items = UserManagement.GetUsersByJobsiteID(LoginSession.SessionID, GetLanguageCookie(), Convert.ToInt64(jsid), contractorid);
}
else
{
@ -969,7 +997,9 @@ namespace IronIntel.Contractor.Site.MapView
public static string GetUserLanguage(Foresight.Standard.StringKeyValue[] alllangs, string uid)
{
var lang = "en-us";
var lang = SystemParams.CustomerDetail.LanguageId;
if (string.IsNullOrEmpty(lang))
lang = "en-us";
if (alllangs != null)
{
var item = alllangs.FirstOrDefault(m => m.Key == uid);
@ -1254,7 +1284,7 @@ namespace IronIntel.Contractor.Site.MapView
public class AssetTripItem : AssetTripInfo
{
public TripColor Color { get; set; }
public string TripTimeStr { get { return TripTime == null ? "" : TripTime.Value.ToString(); } }
public string TripTimeStr { get { return TripTime == null ? "" : TripTime.Value.ToString("hh\\:mm\\:ss"); } }
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

View File

@ -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("23.5.11")]
[assembly: AssemblyFileVersion("24.3.19")]

View File

@ -168,7 +168,7 @@ namespace IronIntel.Contractor.Site.Security
UserInfo[] items = null;
if (GetCurrentLoginSession() != null)
{
items = UserManagement.GetUsers();
items = UserManagement.GetUsers(string.Empty, string.Empty, GetLanguageCookie());
}
else
{

View File

@ -191,7 +191,7 @@ namespace IronIntel.Contractor.Site.Security
if (session != null)
{
//contact = ContactManagement.GetContacts();
users = UserManagement.GetActiveUsers(session.SessionID);
users = UserManagement.GetActiveUsers(GetLanguageCookie(),session.SessionID);
users = users.OrderBy(u => u.DisplayName).ToArray();
}
else

View File

@ -48,7 +48,7 @@ namespace IronIntel.Contractor.Site.Security
list.Remove(item);
}
if (user.UserType != UserTypes.SupperAdmin)
if (user.UserType != UserTypes.SupperAdmin || IronIntel.Contractor.SystemParams.IsDealer)
{
SecurityNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_curfewmt");
if (item != null)

View File

@ -92,7 +92,7 @@ namespace IronIntel.Contractor.Site.Security
// 返回带 Users 数据的详细用户组对象
group = UserManagement.GetGroup(guid.ToString());
}
var users = UserManagement.GetUsers().OrderBy(u => u.ID).ToArray();
var users = UserManagement.GetUsers(string.Empty, string.Empty, GetLanguageCookie()).OrderBy(u => u.ID).ToArray();
return new GroupDetail
{

View File

@ -56,7 +56,7 @@ namespace IronIntel.Contractor.Site.Security
private void GetUsers()
{
string json = "";
var users = UserManagement.GetUnmanagementUsers().OrderBy(u => u.DisplayName).ToArray();
var users = UserManagement.GetUnmanagementUsers(GetLanguageCookie()).OrderBy(u => u.DisplayName).ToArray();
json = JsonConvert.SerializeObject(users);
Response.Write(json);
Response.End();

View File

@ -130,13 +130,14 @@ namespace IronIntel.Contractor.Site
var clientdata = Request.Form["ClientData"].Split((char)170);
var custid = HttpUtility.HtmlDecode(clientdata[0]);
var assetidstr = HttpUtility.HtmlDecode(clientdata[1]);
var viewalertstypes = HttpUtility.HtmlDecode(clientdata[2]);
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);
AssetExtInfo ext = CreateClient<AssetQueryClient>(custid).GetAssetExtInfo(custid, assetid, viewalertstypes);
Helper.CloneProperty(info, ext);
if (info.InspectReportItem != null)

View File

@ -18,6 +18,7 @@ using Foresight.Fleet.Services.Asset;
using System.Web.UI.WebControls;
using FI.FIC.Contracts.DataObjects.BaseObject;
using System.Security.Cryptography;
using Foresight.Fleet.Services.Customer;
namespace IronIntel.Contractor.Site.SystemSettings
{
@ -454,8 +455,12 @@ namespace IronIntel.Contractor.Site.SystemSettings
if (!int.TryParse(rmd, out remembermedays))
remembermedays = 30;
string locsourcestr = SystemParams.GetStringParam("BreadcrumbLocationSource");
int locsource = 0;
int.TryParse(locsourcestr, out locsource);
SystemOptionInfo soi = new SystemOptionInfo();
soi.TimeZone = SystemParams.GetStringParam("CustomerTimeZone", false);
soi.TimeZone = CreateClient<CustomerProvider>().GetCustomerTimeZone(SystemParams.CompanyID);
soi.AccuracyFilter = accuracyfilter;
soi.UnitOfOdometer = SystemParams.GetStringParam("UnitOfOdometer");
soi.AcknowledgingAlerts = SystemParams.GetStringParam("AcknowledgingAlerts");
@ -464,9 +469,11 @@ namespace IronIntel.Contractor.Site.SystemSettings
soi.VolumeUnits = volumeunits;
soi.WeightUnits = weightunits;
soi.MFARememberMeDays = remembermedays;
soi.BreadcrumbLocationSource = locsource;
string connectorxml = SystemParams.GetStringParam("Connector");
soi.Connectors = ConnectorHelper.FromXML(connectorxml);
return soi;
}
else
@ -489,8 +496,7 @@ namespace IronIntel.Contractor.Site.SystemSettings
{
string options = HttpUtility.HtmlDecode(Request.Params["ClientData"]);
SystemOptionInfo upi = JsonConvert.DeserializeObject<SystemOptionInfo>(options);
SystemParams.SetStringParam("CustomerTimeZone", upi.TimeZone);
CreateClient<CustomerProvider>().SaveCustomerTimeZone(SystemParams.CompanyID, upi.TimeZone);
SystemParams.SetStringParam("CustomerTimeZoneOffset", upi.Offset.ToString());
SystemParams.SetStringParam("AccuracyFilter", upi.AccuracyFilter.ToString());
SystemParams.SetStringParam("UnitOfOdometer", upi.UnitOfOdometer);
@ -500,6 +506,7 @@ namespace IronIntel.Contractor.Site.SystemSettings
SystemParams.SetStringParam("WeightUnits", upi.WeightUnits.ToString());
SystemParams.SetStringParam("LoginVerifyType", upi.LoginVerifyType);
SystemParams.SetStringParam("MFARememberMeDays", upi.MFARememberMeDays.ToString());
SystemParams.SetStringParam("BreadcrumbLocationSource", upi.BreadcrumbLocationSource.ToString());
XmlDocument doc = ConnectorHelper.ToXml(upi.Connectors);
SystemParams.SetStringParam("Connector", doc.InnerXml);
@ -873,6 +880,7 @@ namespace IronIntel.Contractor.Site.SystemSettings
public string LoginVerifyType { get; set; }
public StringKeyValue[] Connectors { get; set; }
public int MFARememberMeDays { get; set; }
public int BreadcrumbLocationSource { get; set; }
}
private class UserOptionObject

View File

@ -252,6 +252,7 @@ namespace IronIntel.Contractor.Site
string p = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
string[] ps = JsonConvert.DeserializeObject<string[]>(p);
var attrs = JsonConvert.DeserializeObject<Foresight.Fleet.Services.User.UserAdditionalAttribute>(ps[1]);
attrs.UserIID = ps[0];
var client = CreateClient<Foresight.Fleet.Services.User.UserQueryClient>(SystemParams.CompanyID);
client.UpdateUserAdditionalAttribute(ps[0], attrs);
@ -488,7 +489,7 @@ namespace IronIntel.Contractor.Site
Users.UserObject userobject = new Users.UserObject();
UserInfo user = new UserInfo();
List<KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>> features = new List<KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>>();
List<Foresight.Standard.StringKeyValue> messagetypes = new List<Foresight.Standard.StringKeyValue>();
List<MessageRestrictInfo> messagetypes = new List<MessageRestrictInfo>();
var userclient = CreateClient<Foresight.Fleet.Services.User.UserQueryClient>();
StringKeyValue kv1 = kvs.FirstOrDefault(m => string.Compare(m.Key, "ID", true) == 0);
@ -554,6 +555,8 @@ namespace IronIntel.Contractor.Site
features.Add(feature);
feature = new KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>(256, new Foresight.Fleet.Services.User.Permissions[] { Foresight.Fleet.Services.User.Permissions.FullControl });
features.Add(feature);
feature = new KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>(257, new Foresight.Fleet.Services.User.Permissions[] { Foresight.Fleet.Services.User.Permissions.FullControl });
features.Add(feature);
}
foreach (StringKeyValue kv in kvs)
@ -891,6 +894,10 @@ namespace IronIntel.Contractor.Site
language = "fr-fr";
else if (string.Compare("français (Canada)", langname, true) == 0)
language = "fr-ca";
else if (string.Compare("España", langname, true) == 0)
language = "es";
else if (string.Compare("português", langname, true) == 0)
language = "pt";
user.PreferredLanguage = language;
}
@ -970,6 +977,10 @@ namespace IronIntel.Contractor.Site
{
SetUserPermissions(features, Convert.ToInt32(kv.Key), dr[kv.Value].ToString().Trim());
}
if (string.Compare(kv.Key, Foresight.Fleet.Services.User.Feature.OPENWORKORDERS.ToString(), true) == 0)
{
SetUserPermissions(features, Convert.ToInt32(kv.Key), dr[kv.Value].ToString().Trim());
}
if (string.Compare(kv.Key, Foresight.Fleet.Services.User.Feature.JOB_SITES.ToString(), true) == 0)
{
SetUserPermissions(features, Convert.ToInt32(kv.Key), dr[kv.Value].ToString().Trim());
@ -1085,6 +1096,18 @@ namespace IronIntel.Contractor.Site
{
SetMessageTypeRestrict(messagetypes, Convert.ToInt32(kv.Key), dr[kv.Value].ToString().Trim());
}
else if (string.Compare(kv.Key, "90", true) == 0)
{
SetMessageTypeRestrict(messagetypes, Convert.ToInt32(kv.Key), dr[kv.Value].ToString().Trim());
}
else if (string.Compare(kv.Key, "100", true) == 0)
{
SetMessageTypeRestrict(messagetypes, Convert.ToInt32(kv.Key), dr[kv.Value].ToString().Trim());
}
else if (string.Compare(kv.Key, "110", true) == 0)
{
SetMessageTypeRestrict(messagetypes, Convert.ToInt32(kv.Key), dr[kv.Value].ToString().Trim());
}
#endregion
}
@ -1152,22 +1175,22 @@ namespace IronIntel.Contractor.Site
features.Add(new KeyValuePair<int, Foresight.Fleet.Services.User.Permissions[]>(id, permissions));
}
private void SetMessageTypeRestrict(List<Foresight.Standard.StringKeyValue> msgtypes, int id, string s)
private void SetMessageTypeRestrict(List<MessageRestrictInfo> msgtypes, int id, string s)
{
Foresight.Standard.StringKeyValue kv = new Foresight.Standard.StringKeyValue();
kv.Key = id.ToString();
MessageRestrictInfo kv = new MessageRestrictInfo();
kv.MessageType = id;
if (string.Compare(s, "0", true) == 0 || string.Compare(s, "None", true) == 0)
kv.Value = ((int)Restricts.None).ToString();
kv.MessageType = ((int)Restricts.None);
else if (string.Compare(s, "1", true) == 0 || string.Compare(s, "MyWorkOrders", true) == 0 || string.Compare(s, "My Work Orders", true) == 0)
kv.Value = ((int)Restricts.MyWorkOrders).ToString();
kv.MessageType = ((int)Restricts.MyWorkOrders);
else if (string.Compare(s, "10", true) == 0 || string.Compare(s, "MyLocationOrDepartment", true) == 0 || string.Compare(s, "My Location Or Department", true) == 0)
kv.Value = ((int)Restricts.MyLocationOrDepartment).ToString();
kv.MessageType = ((int)Restricts.MyLocationOrDepartment);
else if (string.Compare(s, "99999", true) == 0 || string.Compare(s, "All", true) == 0 || string.Compare(s, "FullControl", true) == 0 || string.Compare(s, "Full Control", true) == 0)
kv.Value = ((int)Restricts.All).ToString();
kv.MessageType = ((int)Restricts.All);
else
kv.Value = ((int)Restricts.None).ToString();
kv.MessageType = ((int)Restricts.None);
Foresight.Standard.StringKeyValue msgtype = msgtypes.FirstOrDefault(m => string.Compare(m.Key, id.ToString(), true) == 0);
MessageRestrictInfo msgtype = msgtypes.FirstOrDefault(m => m.MessageType == id);
msgtypes.Remove(msgtype);
msgtypes.Add(kv);
}
@ -1266,20 +1289,33 @@ namespace IronIntel.Contractor.Site
}
private object GetUsers()
{
string p = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
string[] ps = JsonConvert.DeserializeObject<string[]>(p);
int active = Convert.ToInt32(ps[0]);
var searchtxt = ps[1];
var items = UserManagement.GetUsers(null, searchtxt).OrderBy(u => u.ID).ToArray();
if (active == 1)
var session = GetCurrentLoginSession();
if (session != null)
{
items = items.Where(m => m.Active).OrderBy(u => u.ID).ToArray();
string p = HttpUtility.HtmlDecode(Request.Form["ClientData"]);
string[] ps = JsonConvert.DeserializeObject<string[]>(p);
int active = Convert.ToInt32(ps[0]);
var searchtxt = ps[1];
string lang = session.User.PreferredLanguage;
if (string.IsNullOrWhiteSpace(lang))
{
if (session.User.UserType == Foresight.Fleet.Services.User.UserTypes.SupperAdmin)
lang = "en";
else
lang = SystemParams.CustomerDetail.LanguageId;
}
var items = UserManagement.GetUsers(string.Empty, searchtxt, lang).OrderBy(u => u.ID).ToArray();
if (active == 1)
{
items = items.Where(m => m.Active).OrderBy(u => u.ID).ToArray();
}
else if (active == 0)
{
items = items.Where(m => !m.Active).OrderBy(u => u.ID).ToArray();
}
return items;
}
else if (active == 0)
{
items = items.Where(m => !m.Active).OrderBy(u => u.ID).ToArray();
}
return items;
return null;
}
private object GetUserInfo()
@ -2117,7 +2153,7 @@ namespace IronIntel.Contractor.Site
return new MessageTypeItem[0];
List<MessageTypeItem> ls = new List<MessageTypeItem>();
Foresight.Standard.StringKeyValue[] kvs = null;
MessageRestrictInfo[] kvs = null;
if (!string.IsNullOrEmpty(useriid))
kvs = CreateClient<MessageProvider>().GetUserMessageRestricts(SystemParams.CompanyID, useriid);
foreach (Foresight.Fleet.Services.MessageType type in messagetypes)
@ -2128,12 +2164,17 @@ namespace IronIntel.Contractor.Site
if (kvs == null || kvs.Length == 0)
{
typeitem.RestrictType = (int)Restricts.All;
typeitem.RestrictType = (int)Restricts.MyWorkOrders;
}
else
{
Foresight.Standard.StringKeyValue kv = kvs.FirstOrDefault(m => Convert.ToInt32(m.Key) == typeitem.Id);
typeitem.RestrictType = kv == null ? 0 : Convert.ToInt32(kv.Value);
MessageRestrictInfo kv = kvs.FirstOrDefault(m => m.MessageType == typeitem.Id);
typeitem.RestrictType = kv == null ? 1 : kv.RestrictType;
if (kv != null)
{
typeitem.AdditionalText = kv.AdditionalText;
typeitem.AdditionalEmail = kv.AdditionalEmail;
}
}
ls.Add(typeitem);
@ -2141,28 +2182,35 @@ namespace IronIntel.Contractor.Site
return ls.ToArray();
}
private List<Foresight.Standard.StringKeyValue> GetUserMessageTypes(string useriid)
private List<MessageRestrictInfo> GetUserMessageTypes(string useriid)
{
Foresight.Fleet.Services.MessageType[] messagetypes = Foresight.Fleet.Services.MessageType.MessageTypes;
if (messagetypes == null)
return new List<Foresight.Standard.StringKeyValue>();
return new List<MessageRestrictInfo>();
List<Foresight.Standard.StringKeyValue> ls = new List<Foresight.Standard.StringKeyValue>();
Foresight.Standard.StringKeyValue[] kvs = null;
List<MessageRestrictInfo> ls = new List<MessageRestrictInfo>();
MessageRestrictInfo[] kvs = null;
if (!string.IsNullOrEmpty(useriid))
kvs = CreateClient<MessageProvider>().GetUserMessageRestricts(SystemParams.CompanyID, useriid);
foreach (Foresight.Fleet.Services.MessageType type in messagetypes)
{
Foresight.Standard.StringKeyValue kv = new Foresight.Standard.StringKeyValue();
kv.Key = type.Id.ToString();
MessageRestrictInfo kv = new MessageRestrictInfo();
kv.MessageType = type.Id;
if (kvs == null || kvs.Length == 0)
{
kv.Value = ((int)Restricts.All).ToString();
kv.RestrictType = (int)Restricts.MyWorkOrders;
}
else
{
Foresight.Standard.StringKeyValue kv1 = kvs.FirstOrDefault(m => Convert.ToInt32(m.Key) == type.Id);
kv.Value = kv1 == null ? "0" : kv1.Value;
MessageRestrictInfo kv1 = kvs.FirstOrDefault(m => m.MessageType == type.Id);
if (kv != null)
{
kv = kv1;
}
else
{
kv.RestrictType = (int)Restricts.MyWorkOrders;
}
}
ls.Add(kv);
@ -2373,6 +2421,8 @@ namespace IronIntel.Contractor.Site
public int Id { get; set; }
public string Name { get; set; }
public int RestrictType { get; set; }
public bool AdditionalText { get; set; }
public bool AdditionalEmail { get; set; }
public Restricts[] AvailableRestricts { get; set; }
}
public class ImportUserPermissionItem

View File

@ -1,27 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<?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" />
<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" />
<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" />
<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" />
<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" />
<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>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>