This commit is contained in:
2023-04-28 12:22:26 +08:00
parent 88e0a25ecd
commit c9723008af
1047 changed files with 443540 additions and 1 deletions

View File

@ -0,0 +1,463 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AssetLocationHis.aspx.cs" Inherits="AssetLocationHis" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title></title>
<style>
html,
body {
/*font-family: sans-serif;*/
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#layout {
position: absolute;
right: 320px;
left: 0;
top: 0;
bottom: 0;
}
#divsetting {
position: absolute;
width: 320px;
height: 35%;
right: 0;
top: 0;
bottom: 0;
}
#content {
width: 100%;
top: 0px;
bottom: 0;
margin: 0;
position: fixed;
/*color: #6b6b6b;*/
overflow: auto;
}
#parameter_left {
background: #f4f4f4;
height: 100%;
width: 200px;
float: left;
color: #000;
position: relative;
}
div {
cursor: default;
}
</style>
<style type="text/css">
.data-grid {
height: 100%;
font-size: 12px !important;
font-family: "Segoe UI","Segoe UI Web (West European)","Segoe UI",-apple-system,BlinkMacSystemFont,"Roboto","Helvetica Neue",sans-serif !important;
}
</style>
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/default.css")%>" type="text/css" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" type="text/css" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/mapview.css")%>" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/editmultiselect.css")%>" />
<link rel="stylesheet" href="https://js.arcgis.com/3.40/esri/css/esri.css" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/playbar.css")%>" />
<link type="text/css" href="<%=GetFileUrlWithVersion("../js/components/css/gridview.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=GetFileUrlWithVersion("../css/override.css") %>" rel="stylesheet" />
<link href="<%=GetFileUrlWithVersion("../css/panel.css")%>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../fic/fic/css/form.css")%>" />
<script src="<%=GetFileUrlWithVersion("../js/jquery-" + (JQueryVersion ?? "3.6.0") + ".min.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/utility.js")%>" type="text/javascript"></script>
<script type="text/javascript" src="<%=GetFileUrlWithVersion("../js/components/gridview.js") %>"></script>
<script src="<%=GetFileUrlWithVersion("../fic/js/utility.js")%>" type="text/javascript"></script>
<script type="text/javascript" src="<%=GetFileUrlWithVersion("../fic/fic/js/controls/form.js") %>"></script>
<script>
var GridView = window.GridView || window['g5-gridview'];
//必须放在地图js之前
var dojoConfig = {
paths: {
extras1: location.pathname.replace(/\/[^/]+$/, "") + "/../js/mapview"
},
cacheBust: true
};
</script>
<script src="<%=GetFileUrlWithVersion("../js/cookie.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>"></script>
<script>Vue.config.productionTip = false; Vue.config.silent = true;</script>
<script src="https://js.arcgis.com/3.40"></script>
<%--<script src="<%=GetFileUrlWithVersion("js/mapinit3.19.js")%>"></script>--%>
<script src="<%=GetFileUrlWithVersion("../js/language.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/mapview/asset.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/mapview/maphelper.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/mapview/mapview.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/mapview/playbar.js")%>"></script>
<script type="text/javascript">
_network.root = '<%=Page.ResolveUrl("~/")%>';
var currentdate = "<%=CurrentDate %>";
var MachineID;
var isMapLoaded = false;
var leftCtrlWidth = 390;
var rightCtrlWidth = 280;
var mapHelper;
var machineAlert;
var userParams = undefined;
var assetObject = undefined;
var notShowDetail = true;
var notShowIcons = true;
//enableInfoWindow = false;
var Datasource = "";
var PopupViewShowing = false;
var serVersion = "";
var enableSmartWitness = <%=EnableSmartWitness?"true":"false"%>;
_network.assetmapviewquery = function (method, param, callback, error, nolog) {
_network.request("AssetView/AssetMapView.aspx?tp=ashx", -1, method, param, callback, error, nolog);
}
function init() {
loadMap();
}
function loadMap() {
mapHelper = new MapHelper(onMapInitialized);
mapHelper.notShowInfoWindow = true;
assetObject = new AssetObject(mapHelper);
}
function onMapInitialized() {
isMapLoaded = true;
initData(onDataInitialized);
}
function initData(callback) {
$("#historyCtrl").show();//所有类型站点都显示Show History
//$("#contentCtrl").css("bottom", "184px");
$("#autoRecenterDiv").show();
//assetObject.getContractor(callback);
if (callback)
callback();
}
function onDataInitialized() {
isMapLoaded = true;
refreshData();
}
function refreshData() {
try {
assetObject.getCompanyLocations();
getJobSites();
}
catch (e) {
}
}
function getJobSites() {
var ctr = $("#selContractor").val();
if (!ctr) ctr = "";
var item = {
'IsAutoRefresh': false,
'ContractorID': ctr,
'SearchText': '',
'Onroad': '-1',
};
_network.mapviewquery("GetJobSites", JSON.stringify(item), function (data) {
if (data != "-1") {
for (var i = 0; i < data.length; i++) {
var js = data[i];
mapHelper.showJobSite(js);
}
}
}, function () {
});
}
function getlocationhis(cid, aid, name) {
var lcid = $("#selContractor").val();
if (lcid != cid)
getJobSites();
$("#selContractor").val(cid);
MachineID = aid;
var e = {
data: { CompanyID: cid, ID: aid, DisplayName: name }
};
locationHistoryClick(e);
}
function GetLanguageByCookie() {
var lang = getCookie('<%=Common.LanguageCookieName%>');
if (lang == null) {
return "en-us";
} else {
return lang;
}
}
$(function () {
_fleet.currentLang = GetLanguageByCookie();
$("#content").applyFleetLanguageText(true);
init();
initPlayBar();
$("#btnLoadLocationHistory").click(null, function (e) {
//locationHistoryClick();
getLocationHistory();
});
$('#btnQuickLoadLocationHistory').click(null, function () {
getLocationHistory(true);
});
$("#btnClearLocationHistory").click(null, function (e) {
clearLocationHistory();
$("#locationhistoryDiv").hide();
$("#tripDiv").hide();
});
$('#btnLoadTrip').click(null, function () {
getLocationHistory(true);
openTrips(true);
});
$("#btnClearTrip").click(null, function (e) {
$("#tripDiv").hide();
$("#tbTrips").empty();
});
$("#showDealerLocationsDiv").click(null, function (e) {
if ($("#showDealerLocationsDiv").attr("state") == "0") {
assetObject.showLocations();
$("#showDealerLocationsDiv").attr("state", "1").attr("title", GetTextByKey("P_MV_TURNOFFDEALERLOCATIONS", "Turn Off Dealer Locations"));
}
else {
assetObject.clearLocations();
$("#showDealerLocationsDiv").attr("state", "0").attr("title", GetTextByKey("P_MV_TURNONDEALERLOCATIONS", "Turn On Dealer Locations"));
}
});
$("#basemapgalleryDiv").click(null, function (e) {
$("#basemapGallery").show();
});
$("#dateTo").datetimepicker({
timepicker: false,
format: 'm/d/Y',
scrollMonth: false,
scrollTime: false,
scrollInput: false,
});
$("#dateFrom").datetimepicker({
timepicker: false,
format: 'm/d/Y',
scrollMonth: false,
scrollTime: false,
scrollInput: false,
});
$("#dialog_timeperiod").change(null, function (e) {
currentdate = getCurrentDate();
var timeperiod = $("#dialog_timeperiod").val();
var disabled = false;
if (timeperiod !== "4") {
disabled = true;
var time = new Date(currentdate);
var nowtime = new Date(currentdate);
var hours = nowtime.getHours();
var minutes = nowtime.getMinutes();
if (timeperiod === "2") {
time.setDate(time.getDate() - 1);
nowtime.setDate(nowtime.getDate() - 1);
}
else if (timeperiod === "3") {
time.setDate(time.getDate() - 6);
}
else if (timeperiod === "5") {
time.setDate(time.getDate() - 1);
}
time = time.getMonth() + 1 + "/" + time.getDate() + "/" + time.getFullYear();
nowtime = nowtime.getMonth() + 1 + "/" + nowtime.getDate() + "/" + nowtime.getFullYear();
$('#dateFrom').val(time);
$('#dateTo').val(nowtime);
$('#dialog_starttimehour').val('00');
$('#dialog_starttimeminute').val('00');
$('#dialog_endtimehour').val('23');
$('#dialog_endtimeminute').val('59');
if (timeperiod === "5") {
var s_minutes = minutes + 1;
var s_hours = hours;
if (minutes == 59) {
s_hours = s_hours + 1;
s_minutes = 0;
}
$('#dialog_starttimehour').val(setTimeSelect(s_hours));
$('#dialog_starttimeminute').val(setTimeSelect(s_minutes));
$('#dialog_endtimehour').val(setTimeSelect(hours));
$('#dialog_endtimeminute').val(setTimeSelect(minutes));
}
}
});
//$("#splitIcon").click();
initTime();
var time = new Date(currentdate);
time = (time.getMonth() + 1) + "/" + time.getDate() + "/" + time.getFullYear();
$('#dateFrom').val(time);
$('#dateTo').val(time);
$('#dialog_starttimehour').val('00');
$('#dialog_starttimeminute').val('00');
$('#dialog_endtimehour').val('23');
$('#dialog_endtimeminute').val('59');
});
function setTimeSelect(time) {
if (time.toString().length == 1)
return "0" + time;
else
return time.toString();
}
function initTime() {
var c = $('#dialog_starttimehour');
for (var i = 0; i < 24; i++) {
if (i < 10)
c.append($("<option></option>").val("0" + i).text("0" + i))
else
c.append($("<option></option>").val(i).text(i))
}
c = $('#dialog_starttimeminute');
for (var i = 0; i < 60; i++) {
if (i < 10)
c.append($("<option></option>").val("0" + i).text("0" + i))
else
c.append($("<option></option>").val(i).text(i))
}
c = $('#dialog_endtimehour');
for (var i = 0; i < 24; i++) {
if (i < 10)
c.append($("<option></option>").val("0" + i).text("0" + i))
else
c.append($("<option></option>").val(i).text(i))
}
c = $('#dialog_endtimeminute');
for (var i = 0; i < 60; i++) {
if (i < 10)
c.append($("<option></option>").val("0" + i).text("0" + i))
else
c.append($("<option></option>").val(i).text(i))
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="content" style="margin-top: 2px;">
<input id="selContractor" type="hidden" />
<div id="layout">
<div>
<div id="mapView">
</div>
<div id="basemapgalleryDiv">
<div id="basemapImg"></div>
<div id="basemapTitle"></div>
</div>
<div id="basemapGallery"></div>
</div>
<div id="showDealerLocationsDiv" style="display: none; top: 90px;" state="1" title="Turn Off Dealer Locations" data-title-lgid="P_MV_TURNOFFDEALERLOCATIONS">
<%=Logo1 %>
</div>
</div>
<div id="divsetting">
<table style="line-height: 25px;">
<tr>
<td style="padding-left: 5px;" data-lgid="P_MV_ASSET_COLON">Asset:</td>
<td><span id="spMachineName" data-lgid="P_MV_NOASSETSELECTED">No asset selected.</span></td>
</tr>
<tr>
<td style="padding-left: 5px;" data-lgid="P_MV_TIMEPERIOD_COLON">Time Period:</td>
<td>
<select id="dialog_timeperiod" tabindex="12" style="width: 90px; height: 22px;">
<option value="1" selected="selected" data-lgid="P_MV_TODAY">Today</option>
<option value="5" data-lgid="P_MV_LAST24HOURS">Last 24 Hours</option>
<option value="2" data-lgid="P_MV_PRIORDAY">Prior Day</option>
<option value="3" data-lgid="P_MV_LAST7DAYS">Last 7 Days</option>
<option value="4" data-lgid="P_MV_CUSTOM">Custom</option>
</select></td>
</tr>
<tr>
<td style="padding-left: 5px;" data-lgid="P_MV_FROM_COLON">From:</td>
<td>
<input type="text" id="dateFrom" maxlength="12" tabindex="27" style="width: 70px;" />
<select id="dialog_starttimehour" style="width: 48px; margin-left: 3px;" tabindex="3"></select><span style="font-weight: bold;">&nbsp;:&nbsp;</span>
<select id="dialog_starttimeminute" style="width: 48px; margin-left: 0;" tabindex="4"></select>
</td>
</tr>
<tr>
<td style="padding-left: 5px;" data-lgid="P_MV_TO_COLON">To:</td>
<td>
<input type="text" id="dateTo" maxlength="12" tabindex="27" style="width: 70px;" />
<select id="dialog_endtimehour" style="width: 48px; margin-left: 3px;" tabindex="5"></select><span style="font-weight: bold;">&nbsp;:&nbsp;</span>
<select id="dialog_endtimeminute" style="width: 48px; margin-left: 0;" tabindex="6"></select>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center; width: 180px;">
<div id="divPlayBar" style="background-color: #C0C0C0;"></div>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: right;">
<input id="chkExclude00Loc" style="display: none" checked="checked" type="checkbox" /><span style="margin-right: 10px; display: none" data-lgid="P_MV_TO_EXCLUDE00LOCATIONS">Exclude 0,0 Locations</span>
<%--<input type="button" value="Quick Load" data-lgid="P_MV_QUICKLOAD" id="btnQuickLoadLocationHistory" />--%>
<%--<input type="button" value="Playback" data-lgid="P_MV_PLAYBACK" id="btnLoadLocationHistory" />--%>
<%--<span class="clearbtn" id="btnClearLocationHistory" style="margin-left: 5px;"></span>--%>
<%--<input type="button" value="Clear" data-lgid="P_MV_CLEAR" id="btnClearLocationHistory" />
<input type="button" value="Trip" data-lgid="P_MV_TRIP" id="btnLoadTrip" style="display: none;" />--%>
<%--<span id="btnQuickLoadLocationHistory" class="QuickLoad" style="margin-left: 6px;" title="Quick Load/Skip to End" data-title-lgid="P_MV_QUICKLOADSKIPTOEND"></span>--%>
<span id="btnHisLoading" class="QuickLoading" style="margin-left: 6px; display: none;"></span>
<span id="btnLoadTrip" class="TripReport" style="margin-left: 6px;" title="Trip Report" data-title-lgid="P_MV_TRIPREPORT"></span>
<span class="clearbtn" id="btnClearLocationHistory" style="margin-left: 6px;" title="Clear" data-title-lgid="P_MV_CLEAR"></span>
</td>
</tr>
</table>
</div>
<div id="tripDiv" style="display: none;">
<div>
<span class="clearbtn" id="btnClearTrip" style="float: right; padding: 5px;"></span>
</div>
<div style="position: absolute; top: 30px; bottom: 0; right: 0; overflow: auto; width: 100%;">
<table id="tbTrips" style="line-height: 24px; border-collapse: collapse; border-spacing: 0; width: 100%;">
</table>
</div>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
</div>
</form>
</body>
</html>

View File

@ -0,0 +1,111 @@
using DocumentFormat.OpenXml.Wordprocessing;
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.Customer;
using IronIntel.Contractor;
using IronIntel.Contractor.Machines;
using IronIntel.Contractor.MapView;
using IronIntel.Contractor.Site;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AssetLocationHis : ContractorBasePage
{
public string LocationHistoryDateFrom = DateTime.Now.Date.AddMonths(-2).ToShortDateString();
public string LocationHistoryDateTo = DateTime.Now.Date.ToShortDateString();
private string Logo1html = "<img class=\"logo\" src=\"{0}\" style=\"width:24px;height:24px; \" />";
protected string Logo1 = "";
public string CurrentDate = "";
protected void Page_Load(object sender, EventArgs e)
{
string tp = Request.Params["tp"];
if (string.Compare(tp, "ashx", true) == 0)
{
ProcessRequest();
}
else if (!IsPostBack)
{
Title = PageTitle;
if (CheckLoginSession())
{
var cmp = SystemParams.GetCompanyInfo();
GetLogoHtml(cmp);
}
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
CurrentDate = userlocaldate.ToShortDateString();
}
private void GetLogoHtml(CustomerInfo cmp)
{
var root = ResolveUrl("~/");
if (cmp.IsContractor)
{//Logo1 Dealer;
CustomerInfo dealer = SystemParams.GetFirstDealerInfo();
if (dealer != null)
{
if (SystemParams.HasLOGO(dealer.ID))//Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + dealer.ID);
}
else
{
Logo1 = string.Format("<div class=\"logo\">{0}</div>", dealer.Name);
}
}
else
{
Logo1 = string.Empty;
}
}
else
{
if (SystemParams.HasLOGO(cmp.ID))//Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + cmp.ID);
}
else
{
Logo1 = string.Format("<div class=\"logo\">{0}</div>", cmp.Name);
}
}
}
protected void ProcessRequest()
{
object result = null;
string methodName = Request.Form["MethodName"];
try
{
if (methodName != null)
{
}
}
catch (System.Threading.ThreadAbortException)
{
throw;
}
catch (Exception ex)
{
SystemParams.WriteLog("error", "MapViewChart." + methodName, ex.Message, ex.ToString());
}
string json = JsonConvert.SerializeObject(result);
Response.Write(json);
Response.End();
}
public bool EnableSmartWitness
{
get
{
bool lic = SystemParams.HasLicense("SmartWitness");
return lic;
}
}
}

View File

@ -0,0 +1,269 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AssetMapView.aspx.cs" Inherits="AssetMapView" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title></title>
<style>
html,
body {
/*font-family: sans-serif;*/
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#content {
width: 100%;
top: 0px;
bottom: 0;
margin: 0;
position: fixed;
/*color: #6b6b6b;*/
overflow: auto;
}
#parameter_left {
background: #f4f4f4;
height: 100%;
width: 200px;
float: left;
color: #000;
position: relative;
}
div {
cursor: default;
}
</style>
<style type="text/css">
.data-grid {
height: 100%;
font-size: 12px !important;
font-family: "Segoe UI","Segoe UI Web (West European)","Segoe UI",-apple-system,BlinkMacSystemFont,"Roboto","Helvetica Neue",sans-serif !important;
}
</style>
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/default.css")%>" type="text/css" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" type="text/css" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/split_sub.css")%>" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/mapview.css")%>" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/editmultiselect.css")%>" />
<link rel="stylesheet" href="https://js.arcgis.com/3.40/esri/css/esri.css" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" />
<link rel="stylesheet" href="<%=GetFileUrlWithVersion("../css/playbar.css")%>" />
<link type="text/css" href="<%=GetFileUrlWithVersion("../js/components/css/gridview.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=GetFileUrlWithVersion("../css/override.css") %>" rel="stylesheet" />
<link href="<%=GetFileUrlWithVersion("../css/panel.css")%>" rel="stylesheet" type="text/css" />
<script src="<%=GetFileUrlWithVersion("../js/jquery-" + (JQueryVersion ?? "3.6.0") + ".min.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../js/cookie.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/utility.js")%>" type="text/javascript"></script>
<script type="text/javascript" src="<%=GetFileUrlWithVersion("../js/components/gridview.js") %>"></script>
<script>
var GridView = window.GridView || window['g5-gridview'];
//必须放在地图js之前
var dojoConfig = {
paths: {
extras1: location.pathname.replace(/\/[^/]+$/, "") + "/../js/mapview"
},
cacheBust: true
};
</script>
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/vue.min.js")%>"></script>
<script>Vue.config.productionTip = false; Vue.config.silent = true;</script>
<script src="https://js.arcgis.com/3.40"></script>
<%--<script src="<%=GetFileUrlWithVersion("js/mapinit3.19.js")%>"></script>--%>
<%--<script src="<%=GetFileUrlWithVersion("../js/mapview.js")%>"></script>--%>
<%--<script src="<%=GetFileUrlWithVersion("../js/playbar.js")%>"></script>--%>
<script src="<%=GetFileUrlWithVersion("../js/language.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/mapview/asset.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/mapview/maphelper.js")%>"></script>
<script src="<%=GetFileUrlWithVersion("../js/mapview/mapview.js")%>"></script>
<script type="text/javascript">
_network.root = '<%=Page.ResolveUrl("~/")%>';
var MachineID = "<%=MachineID %>";
var VIN = '<%=VIN.Replace("'","\\'") %>';
var Datasource = "<%=Datasource %>";
var currentdate = "<%=CurrentDate %>";
var isMapLoaded = false;
var leftCtrlWidth = 390;
var rightCtrlWidth = 280;
var mapHelper;
var machineAlert;
var userParams = undefined;
var assetObject = undefined;
var notShowDetail = true;
var notShowIcons = true;
enableInfoWindow = false;
var canEditAsset = false;
var canViewWorkOrder = false;
var canViewMR = false;
showMapSlider = false;
var showTooltipIcons = false;
var serVersion = "";
_network.assetmapviewquery = function (method, param, callback, error, nolog) {
_network.request("AssetView/AssetMapView.aspx?tp=ashx", -1, method, param, callback, error, nolog);
}
function init() {
loadMap();
}
function loadMap() {
mapHelper = new MapHelper(onMapInitialized);
mapHelper.notShowInfoWindow = true;
assetObject = new AssetObject(mapHelper);
}
function onMapInitialized() {
isMapLoaded = true;
initData(onDataInitialized);
}
function initData(callback) {
$("#historyCtrl").show();//所有类型站点都显示Show History
//$("#contentCtrl").css("bottom", "184px");
$("#autoRecenterDiv").show();
//assetObject.getContractor(callback);
if (callback)
callback();
}
function onDataInitialized() {
isMapLoaded = true;
refreshData();
setInterval(refreshData, 60 * 1000);//开启定时刷新
}
function refreshData() {
try {
getMachineItem();
//assetObject.getCompanyLocations();
}
catch (e) {
machineAlert = _dialog.showAlert(GetTextByKey("P_MV_UNABLETOOBTAINASSETDATAATTEMPTINGTORECONNECT", 'Unable to obtain asset data. Attempting to reconnect...'), GetTextByKey("P_MV_REFRESHASSETDATA", 'Refresh asset data'));
}
}
function getMachineItem() {
_network.assetmapviewquery("GetMachineItem", htmlencode(JSON.stringify([MachineID, VIN, Datasource])), function (data) {
if (data && typeof (data) !== "string") {
if (data.Location) {
data.Latitude = data.Location.Latitude;
data.Longitude = data.Location.Longitude;
}
mapHelper.clearMachine();
mapHelper.showMachine(data);
mapHelper.locateMachine(data, true, 14);
currentLocationHistoryMachine = data;
//$("#refreshTimeDiv").text(GetTextByKey("P_MV_LASTREFRESHED", "Last Refreshed: ") + getNowFormatDate());
} else
mapHelper.clearMachine();
$('#loadingDiv').hide();
}, function () {
$('#loadingDiv').hide();
});
}
function showOtherIcons() {
var leftCtrl = $("#leftCtrl");
$("#mapMeunDiv").css("left", leftCtrl.width() + 25);
}
function reloaddata(machineid, vin) {
MachineID = machineid;
VIN = vin;
if (isMapLoaded) {
bm = getCookie("basemap");
if (currentbasemap != bm) {
currentbasemap = bm;
mapHelper.changeBaseMap(currentbasemap);
}
if ((MachineID && MachineID > 0)
|| (VIN && VIN !== ""))
refreshData();
else
mapHelper.clearMachine();
}
}
function GetLanguageByCookie() {
var lang = getCookie('<%=Common.LanguageCookieName%>');
if (lang == null) {
return "en-us";
} else {
return lang;
}
}
$(function () {
_fleet.currentLang = GetLanguageByCookie();
currentbasemap = getCookie("basemap");
$("#content").applyFleetLanguageText(true);
init();
$("#showDealerLocationsDiv").click(null, function (e) {
if ($("#showDealerLocationsDiv").attr("state") == "0") {
assetObject.showLocations();
$("#showDealerLocationsDiv").attr("state", "1").attr("title", GetTextByKey("P_MV_TURNOFFDEALERLOCATIONS", "Turn Off Dealer Locations"));
}
else {
assetObject.clearLocations();
$("#showDealerLocationsDiv").attr("state", "0").attr("title", GetTextByKey("P_MV_TURNONDEALERLOCATIONS", "Turn On Dealer Locations"));
}
});
$("#basemapgalleryDiv").click(null, function (e) {
$("#basemapGallery").show();
});
if (typeof window.parent.ondocumentclick == 'function') {
$(document.body).click(window.parent.ondocumentclick);
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="content" style="margin-top: 2px;">
<input id="selContractor" type="hidden" value="<%=CompanyID %>" />
<div id="layout">
<div>
<div id="mapView">
</div>
<div id="basemapgalleryDiv" style="display: none;">
<div id="basemapImg"></div>
<div id="basemapTitle"></div>
</div>
<div id="basemapGallery"></div>
</div>
<div id="mapMeunDiv" style="position: absolute; top: 90px; left: 20px; z-index: 50;">
<div id="showDealerLocationsDiv" style="display: none; top: 90px;" state="1" title="Turn Off Dealer Locations">
<%=Logo1 %>
</div>
</div>
<div id="loadingDiv" style="display: none;">
<div class="loadingmach icnmach icn-spinmach"></div>
</div>
<%--<div id="refreshTimeDiv"></div>--%>
</div>
<div id="mask_bg" style="display: none;"><div class="loading c-spin"></div></div>
</div>
</form>
</body>
</html>

View File

@ -0,0 +1,214 @@
using Foresight.Fleet.Services.Asset;
using Foresight.Fleet.Services.Customer;
using Foresight.ServiceModel;
using IronIntel.Contractor;
using IronIntel.Contractor.iisitebase;
using IronIntel.Contractor.Machines;
using IronIntel.Contractor.MapView;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Users;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AssetMapView : ContractorBasePage
{
public string LocationHistoryDateFrom = DateTime.Now.Date.AddMonths(-2).ToShortDateString();
public string LocationHistoryDateTo = DateTime.Now.Date.ToShortDateString();
private string Logo1html = "<img class=\"logo\" src=\"{0}\" style=\"width:24px;height:24px; \" />";
protected string Logo1 = "";
protected string MachineID = "";
protected string VIN = "";
protected string Datasource = "";
protected string CompanyID = "";
public string CurrentDate = "";
protected void Page_Load(object sender, EventArgs e)
{
string tp = Request.Params["tp"];
if (string.Compare(tp, "ashx", true) == 0)
{
ProcessRequest();
}
else if (!IsPostBack)
{
Title = PageTitle;
if (CheckLoginSession())
{
var cmp = SystemParams.GetCompanyInfo();
GetLogoHtml(cmp);
}
MachineID = Request.Params["machineid"] ?? "";
VIN = Request.Params["vin"] ?? "";
Datasource = Request.Params["ds"] ?? "";
CompanyID = GetCompanyID(MachineID, VIN);
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
CurrentDate = userlocaldate.ToShortDateString();
}
private void GetLogoHtml(CustomerInfo cmp)
{
var root = ResolveUrl("~/");
var sessionid = GetLoginSessionID(Request);
StringKeyValue kv = UserManagement.GetSiteHederStyleLogo(sessionid);
string styleid = "-1";
bool hasDealerLogo = false;
if (kv != null)
{
styleid = kv.Key;
hasDealerLogo = Helper.IsTrue(kv.Tag2);
}
if (cmp.IsContractor)
{//Logo1 Dealer;
CustomerInfo dealer = SystemParams.GetFirstDealerInfo();
if (dealer != null)
{
if (hasDealerLogo)//user Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + dealer.ID + "&styid=" + styleid);
}
else if (SystemParams.HasLOGO(dealer.ID))//Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + dealer.ID);
}
else
{
Logo1 = string.Format("<div class=\"logo\">{0}</div>", dealer.Name);
}
}
else
{
Logo1 = string.Empty;
}
}
else
{
if (hasDealerLogo)//user Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + cmp.ID + "&styid=" + styleid);
}
else if (SystemParams.HasLOGO(cmp.ID))//Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?tp=dealer&cmpid=" + cmp.ID);
}
else
{
Logo1 = string.Format("<div class=\"logo\">{0}</div>", cmp.Name);
}
}
}
protected void ProcessRequest()
{
object result = null;
string methodName = Request.Form["MethodName"];
try
{
if (methodName != null)
{
switch (methodName.ToUpper())
{
case "GETMACHINEITEM":
result = GetMachineItem();
break;
}
}
}
catch (System.Threading.ThreadAbortException)
{
throw;
}
catch (Exception ex)
{
SystemParams.WriteLog("error", "MapViewChart." + methodName, ex.Message, ex.ToString());
}
string json = JsonConvert.SerializeObject(result);
Response.Write(json);
Response.End();
}
private object GetMachineItem()
{
var session = GetCurrentLoginSession();
if (session == null)
return null;
var clientdata = Request.Form["ClientData"];
clientdata = HttpUtility.HtmlDecode(clientdata);
string[] MachinIDOrVIN = JsonConvert.DeserializeObject<string[]>(clientdata);
if (MachinIDOrVIN != null && MachinIDOrVIN.Length == 3)
{
string machineids = MachinIDOrVIN[0];
string vins = MachinIDOrVIN[1];
string datasource = MachinIDOrVIN[2];
if (string.IsNullOrEmpty(machineids) && string.IsNullOrEmpty(vins))
return null;
string machineid = machineids.Split(',')[0];
string vin = vins.Split(',')[0];
string companyid = "";
if (SystemParams.IsDealer)
{
AssetBasicInfo m = null;
var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>();
if (string.IsNullOrEmpty(machineid))
{
m = client.FromAdminAssetBasicInfoByVin(vin);
machineid = m.ID.ToString();
}
else
m = client.FromAdminAssetBasicInfoById(long.Parse(machineid));
if (m != null)
companyid = m.ContractorID;
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
}
else if (string.IsNullOrEmpty(machineid))
{
machineid = MachineManagement.GetMachineIDByVIN(vin);
}
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
var md = AssetMapViewManagement.GetAssetDetailItem(session.SessionID, companyid, long.Parse(machineid), datasource);
return md;
}
return null;
}
private string GetCompanyID(string machineid, string vin)
{
string companyid = "";
if (SystemParams.IsDealer)
{
AssetBasicInfo m = null;
var client = FleetServiceClientHelper.CreateClient<AssetQueryClient>();
if (string.IsNullOrEmpty(machineid))
{
m = client.FromAdminAssetBasicInfoByVin(vin);
machineid = m.ID.ToString();
}
else
m = client.FromAdminAssetBasicInfoById(long.Parse(machineid));
if (m != null)
companyid = m.ContractorID;
if (string.IsNullOrEmpty(companyid))
companyid = SystemParams.CompanyID;
}
return companyid;
}
}

View File

@ -0,0 +1,368 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AssetSingleWorkspace.aspx.cs" Inherits="MapView_AssetSingleView" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="format-detection" content="telephone=no" />
<title>Single Workspace</title>
<script type="text/javascript" src="<%=Common.GenerateUrl("js/jquery-1.11.3.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("js/lib/vue.min.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("js/promise.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/modal.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("js/utility.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("js/cookie.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/dialog.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/additionalFilter.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/editGridCtrl.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/workspace.js") %>"></script>
<link type="text/css" href="<%=Common.GenerateUrl("fic/css/workspace.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/override.css")%>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/gridview.css")%>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/datagrid.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/design-grid.min.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/css/chart.css")%>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/css/pivot.css")%>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/js/components/css/vue-ctrls.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/css/form.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/css/wizardctrl.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/css/Grid.css")%>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("css/datepicker.min.css")%>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/css/JsTreeCss/style.min.css")%>" rel="stylesheet" />
<link type="text/css" href="<%=Common.GenerateUrl("fic/css/tabcontrol.css") %>" rel="stylesheet" />
<style type="text/css">
body {
/* 禁止选中 */
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;
overflow: hidden;
padding: 0;
margin: 0;
border: 0;
font-family: Verdana;
font-size: 13px;
}
table {
font-size: 13px;
}
input[type='checkbox'] {
vertical-align: -3px;
}
input[type='radio'] {
vertical-align: -3px;
}
input[type='text'] {
height: 20px;
}
select {
height: 21px;
}
.smaller {
font-size: 0.9em;
}
a {
text-decoration: none;
color: #2140fb;
}
a:hover {
text-decoration: underline;
}
a:visited {
color: #2140fb;
}
#content {
width: 100%;
top: 0;
bottom: 0;
margin: 0;
position: fixed;
}
.clear {
display: block;
clear: both;
height: 0;
}
.wsp_pivot_panel {
display: none;
}
.boardContainer {
overflow: hidden;
}
</style>
<script type="text/javascript">
var param = {};
_utility.loginedUser = {};
_utility.isReadOnly = true;
// get the parameter
var search = location.search;
if (search[0] === '?') {
search = search.substring(1);
var s = search.split('&');
for (var i = 0; i < s.length; i++) {
var kv = s[i].split('=');
param[kv[0]] = decodeURIComponent(kv[1]);
}
}
_utility.currentLang = param.lgid;
var sitePath = "<%=this.ResolveUrl("~/fic/") %>";
_utility.rootPath ="<%=this.ResolveUrl("~/") %>";
ApplicationPath = sitePath;
var appPath = "<%=this.ResolveUrl("~/") %>";
function resizeBoard(charts) {
var maxWidth = 0, maxHeight = 0;
var docWidth = $(window.parent.document.body).width();
for (var i = 0; i < charts.length; i++) {
var c = charts[i];
var right = c.Left + c.Width + 16;
var bottom = c.Top + c.Height + 36;
if (right > maxWidth) {
maxWidth = right;
}
if (bottom > maxHeight) {
maxHeight = bottom;
}
}
if (maxWidth < docWidth) {
maxWidth = '100%';
}
window.parent.resizeBoard(maxWidth, maxHeight);
}
function resetPivot(pivots) {
var s = encodeURIComponent(JSON.stringify(pivots));
_utility.loadWspPivots('?wspivots=' + s);
}
</script>
<script type="text/javascript" src="<%=Common.GenerateUrl("js/echarts.min.js")%>"></script>
<%--<script type="text/javascript" src="//cdn.jsdelivr.net/npm/echarts@4.8.0/dist/echarts.js"></script>--%>
<script type="text/javascript" src="<%=Common.GenerateUrl("js/datepicker.min.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("js/lib/vue-color.min.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/gridview.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/about.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/menu.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/pivot.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/controls.js") %>"></script>
<%--<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/editGridCtrl.js") %>"></script>--%>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/datagrid.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/vue-ctrls.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/components/design-grid.min.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/form.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/wizardctrl.js") %>"></script>
<%-- 覆盖fic定义 --%>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/override.js")%>"></script>
<%--<script type="text/javascript" src="<%=Common.GenerateUrl("fic/g5masterjs.js")%>"></script>--%>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/wsp_pivot.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/board.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chart.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/gauge.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/scorecard.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/gridctrl.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/grid.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/graph.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/simplechart.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/favorites.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/charts/fifrs.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/controls/jstree.min.js")%>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/chartTypeWizard.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/alertMessageWizard.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/chartManage/commonOp.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/boardFilters.js") %>"></script>
<script type="text/javascript" src="<%=Common.GenerateUrl("fic/js/Management/workspaceFilters.js") %>"></script>
<script type="text/javascript">
// register the plugin
Vue.use(window['g5-vue-ctrls'].directives);
function GetUserParamter() {
return new Promise(function (resolve, reject) {
_network.query('GetUserParameters', [], function (data) {
if (data.Result) {
_utility.loginedUser.userIId = data.Result.LoginUserIID;
_utility.loginedUser.userId = data.Result.UserID;
_utility.loginedUser.useName = data.Result.UserName;
_utility.loginedUser.CanAccessPublic = data.Result.CanAccessPublic;
_utility.loginedUser.CanAccessSave = data.Result.CanAccessSave;
_utility.loginedUser.UserType = data.Result.UserType;
_utility.loginedUser.UserParameters = data.Result;
_utility.loginedUser.CanExportFile = data.Result.CanExportFile;
_workspace.displayLevel = _utility.loginedUser.UserParameters.DefaultDisplayLevels;
_workspace.displayRefreshTime = _utility.loginedUser.UserParameters.DefaultShowRefreshTime;
_workspace.setDisplayLevel(_workspace.displayLevel);
_workspace.pivotpinned = _utility.loginedUser.UserParameters.DefaultPinPivot;
_workspace.borderpinned = _utility.loginedUser.UserParameters.DefaultPinBorder;
//if (_utility.loginedUser.UserParameters.AutoRotateBoards) {
// _workspace.rotaBoardsTimer = setInterval(_workspace.RunRotaBoards, _utility.loginedUser.UserParameters.AutoRotateBoardsInterval * 1000);
//}
if (typeof _utility.startRotate === 'function') {
_utility.startRotate();
}
if (_utility.themes && _utility.themes[0]) {
var defaultSkin = _utility.themes[0].ID;
for (var i = 0; i < _utility.themes.length; i++) {
var t = _utility.themes[i];
if (_utility.loginedUser.UserParameters.DefaultSkin == t.ID) {
defaultSkin = t.ID;
break;
}
}
_workspace.onchangetheme(defaultSkin);
}
resolve();
} else {
//throw new Error('GetUserParamter error.');
alert(DEFAULT_LANG.not_signed);
window.location = sitePath + 'Logout.ashx';
}
}, reject);
});
}
function initLanguage() {
$("a,span,label,td").filter("[data-langKey]").each(
function () {
var thisElement = $(this);
thisElement.text(GetLanguageByKey(thisElement.data("langkey"), thisElement.data("defaultlang")));
}
);
DEFAULT_LANG.unknown_error = GetLanguageByKey("LHBIS_EXCEPTION_E0X65028018", DEFAULT_LANG.unknown_error);
DEFAULT_LANG.cannot_be_public = GetLanguageByKey("LHBIS_FIC_CLIENT_DIALOGS_RBOARDSAVEDIALOG_A010", DEFAULT_LANG.cannot_be_public);
DEFAULT_LANG.newboard = GetLanguageByKey("LHBIS_FIC_SILVERLIGHT_WSP_WORKSPACEPAGE_A006", DEFAULT_LANG.newboard);
DEFAULT_LANG.must_select_one = GetLanguageByKey("ERROR_LHBIS_FIC_BLC_COMMON_A0004", DEFAULT_LANG.must_select_one);
DEFAULT_LANG.filter = GetLanguageByKey("LHBIS_FIC_CHARTS_CHARTCLIENT_A015", DEFAULT_LANG.filter);
DEFAULT_LANG.multi = GetLanguageByKey("LHBIS_FIC_CHARTS_COMMONCHART_A009", DEFAULT_LANG.multi);
DEFAULT_LANG.ok = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_RSUBSCRIBEMESSAGEDIALOG_A007', DEFAULT_LANG.ok);
DEFAULT_LANG.cancel = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_RSUBSCRIBEMESSAGEDIALOG_A008', DEFAULT_LANG.cancel);
DEFAULT_LANG.save = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_SNAPSHOTCTRL_LIST_A009', DEFAULT_LANG.save);
DEFAULT_LANG.no = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_SYSTEMOPTIONSCTRL_A010', DEFAULT_LANG.no);
DEFAULT_LANG.yes = GetLanguageByKey('LHBIS_FIC_CLIENT_MODULES_SYSTEMOPTIONSCTRL_A009', DEFAULT_LANG.yes);
DEFAULT_LANG.all = GetLanguageByKey('LHBIS_FIC_CHARTS_COMMONCHART_A007', DEFAULT_LANG.all);
DEFAULT_LANG.level = GetLanguageByKey('LHBIS_MULTILANGUAGE_COMMON_A027', DEFAULT_LANG.level);
PIVOTVAL.ALL.text = GetLanguageByKey('LHBIS_FIC_CHARTS_COMMONCHART_A007', DEFAULT_LANG.all);
}
function init() {
// chart comments
var iframe = $('<iframe id="chart_comments_container" style="display:none;margin-right:-420px"></iframe>');
var email_iframe = $('<iframe id="email_subscription_container" style="display:none;margin-right:-900px"></iframe>');
var bg = $('<div id="chart_comments_bg" class="maskbg" style="display:none"></div>').click(function () {
iframe.stop().animate({ 'margin-right': -420 }, ANIMATE_FAST_SPEED, function () {
iframe.hide();
bg.hide();
});
email_iframe.stop().animate({ 'margin-right': -900 }, ANIMATE_FAST_SPEED, function () {
iframe.hide();
bg.hide();
});
});
$(document.body).append(bg, iframe);
$(document.body).append(bg, email_iframe);
}
function catchError(err) {
var msg = err;
if (msg != null && msg.message != null) {
msg = msg.message;
}
_utility.showMessage(msg, DEFAULT_LANG.FIC, null, function () {
window.location = sitePath + 'Logout.ashx';
});
}
function GetWorkspace(iid) {
return new Promise(function (resolve, reject) {
if (iid) {
_network.query('GetWorkspaceByIID', [iid], function (data) {
if (data.Result) {
if (_utility.workspaces == null || _utility.workspaces.length === 0) {
_utility.workspaces = [data.Result];
}
changeWorkspace(data.Result.IID, data.Result.WSPName, data.Result.Level, data.Result.Creater, data.Result.SecretType, data.Result.IsMyCreate, data.Result.WSPDescription);
}
resolve();
});
}
});
}
function changeWorkspace(iid, name, level, Creater, secrettype, IsMyCreate, WSPDescription) {
_network.query('GetWorkspacePersonalCheck', [iid], function (data) {
if (!data.Result && data.ErrorMessage) {
writelog("changeWorkspace", data.ErrorMessage, data.ErrorMessage);
} else {
var personalChecked = data.Result;
if (_workspace.changed && _utility.CanSaveAccessByPersonalIsVisableWhenLogout()) {
$alertdialog.showConfirm(DEFAULT_LANG.FIC,
GetLanguageByKey("LHBIS_FIC_SILVERLIGHT_WSP_WORKSPACEPAGE_A004", 'The Workspace setting defaults have changed, do you want to save the changes?'), [
[DEFAULT_LANG.cancel],
[DEFAULT_LANG.no, function () { _workspace.onchangewsp(iid, name, level, Creater, secrettype, personalChecked, IsMyCreate, WSPDescription); }],
[DEFAULT_LANG.yes, function () { _utility.doSaveWorkspace(function () { _workspace.onchangewsp(iid, name, level, Creater, secrettype, personalChecked, IsMyCreate, WSPDescription); }); }]
]);
} else {
_workspace.onchangewsp(iid, name, level, Creater, secrettype, personalChecked, IsMyCreate, WSPDescription);
}
}
});
}
$(function () {
GetUserParamter()
.then(function () {
GetWorkspace(param.iid).then(init);
})
.catch(catchError);
if (typeof window.parent.ondocumentclick == 'function') {
$(document.body).click(window.parent.ondocumentclick);
}
initLanguage();
// 初始化workspace
_workspace.container = '#content';
_workspace.init();
});
</script>
</head>
<body>
<div id="content">
Loading...
</div>
</body>
</html>

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MapView_AssetSingleView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@ -0,0 +1,195 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/AssetView/AssetViewBase.master" AutoEventWireup="true" CodeFile="AssetTimeline.aspx.cs" Inherits="AssetView_AssetTimeline" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
<style type="text/css">
.table-container {
margin: 4px 10px 0 26px;
}
.table-timeline {
width: 100%;
border-spacing: 0;
table-layout: fixed;
}
.table-timeline th {
width: 4.17%;
border-right: 1px solid white;
background: #444;
color: white;
font-weight: normal;
font-size: 13px;
height: 26px;
}
.table-timeline th,
.table-timeline td {
padding: 0;
}
#td-timeline {
height: 30px;
position: relative;
}
#td-timeline div {
height: 26px;
position: absolute;
background: #64965a;
top: 2px;
border-radius: 6px;
}
#td-timeline div.no-start {
border-radius: 0 6px 6px 0;
}
#td-timeline div.no-end {
border-radius: 6px 0 0 6px;
}
</style>
<script type="text/javascript">
_network.root = '<%=Page.ResolveUrl("~/")%>';
var wids = [];
var dict;
function assetrequest(method, param, callback, error) {
_network.request("AssetView/SingleAssetView.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
});
}
function fillWidths() {
var ths = $('#tr-header').children();
for (var i = 0; i < ths.length; i++) {
wids[i] = $(ths[i]).outerWidth();
}
}
$(function () {
fillWidths();
dict = {};
try {
var search = location.search.substring(1).split('&');
if (search) {
for (var i = 0; i < search.length; i++) {
var ss = search[i].split('=');
dict[ss[0]] = decodeURIComponent(ss[1]);
}
}
} catch (e) {
// failed to load the params, ignore
}
$(window).resize(function () {
fillWidths();
var ds = $('#td-timeline').children();
for (var i = 0; i < ds.length; i++) {
var div = $(ds[i]);
var start = parseFloat(div.attr('start'));
var end = parseFloat(div.attr('end'));
var left = getOffset(start, wids);
var right = getOffset(end, wids);
var w = right - left - 1;
if (w < 1) { w = 1; }
div.css({
left: left,
width: w
});
}
});
});
function getAssetTimeline(id, date) {
var params = [dict.cid || '', id, date];
assetrequest('GetAssetOnOffTimeline', params.join(String.fromCharCode(170)), function (data) {
var parent = $('#td-timeline').empty();
for (var i = 0; i < data.length; i++) {
var div = $('<div></div>');
var startSeconds = data[i].Start;
var endSeconds = data[i].End;
var start = startSeconds / 3600;
var end = endSeconds / 3600;
var title = [];
if (data[i].HasOn) {
title.push('On: ' + hoursToString(startSeconds));
} else {
div.addClass('no-start');
}
if (data[i].HasOff) {
title.push('Off: ' + hoursToString(endSeconds));
} else {
div.addClass('no-end');
}
div.attr({
start: start,
end: end,
title: title.join('\n')
});
var left = getOffset(start, wids);
var right = getOffset(end, wids);
var w = right - left - 1;
if (w < 1) { w = 1; }
div.css({
left: left,
width: w
});
parent.append(div);
}
});
}
function hoursToString(seconds) {
var s = Math.floor(seconds % 60);
seconds = Math.floor(seconds / 60);
var m = seconds % 60;
var h = Math.floor(seconds / 60);
return (h < 10 ? '0' : '') + h + ':' + (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s;
}
function OnRefresh(dt) {
if (dict.id != null) {
getAssetTimeline(dict.id, dt);
}
}
function getOffset(pos, wids) {
var n = Math.floor(pos);
var p = 0;
for (var i = 0; i < n; i++) {
p += wids[i];
}
p += wids[n] * (pos - n);
return p;
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="table-container">
<div style="width: 100px; float: left">
<table class="table-timeline">
<thead>
<tr><th data-lgid="P_MV_TYPE">Type</th></tr>
</thead>
<tbody>
<tr><td style="height: 30px" data-lgid="P_MV_ONOFFEVENTS">On/Off Events</td></tr>
</tbody>
</table>
</div>
<div style="margin-left: 100px">
<table class="table-timeline">
<thead>
<tr id="tr-header">
<th>0:00</th><th>1:00</th><th>2:00</th><th>3:00</th>
<th>4:00</th><th>5:00</th><th>6:00</th><th>7:00</th>
<th>8:00</th><th>9:00</th><th>10:00</th><th>11:00</th>
<th>12:00</th><th>13:00</th><th>14:00</th><th>15:00</th>
<th>16:00</th><th>17:00</th><th>18:00</th><th>19:00</th>
<th>20:00</th><th>21:00</th><th>22:00</th><th>23:00</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="24" id="td-timeline"></td>
</tr>
</tbody>
</table>
</div>
</div>
</asp:Content>

View File

@ -0,0 +1,16 @@
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AssetView_AssetTimeline : ContractorBasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@ -0,0 +1,116 @@
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="AssetViewBase.master.cs" Inherits="AssetViewBaseBase" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title></title>
<link rel="stylesheet" href="<%=GetUrl("css/default.css")%>" type="text/css" />
<link rel="stylesheet" href="<%=GetUrl("css/split_sub.css")%>" type="text/css" />
<style type="text/css">
#search {
background-color: rgb(235, 235, 235);
border: none;
padding-top: 5px;
padding-bottom: 5px;
cursor: pointer;
}
#search:hover {
background: rgb(225, 225, 225);
}
</style>
<style type="text/css">
:root { <%=StyleVariables%> }
.data-grid {
height: 100%;
font-size: 12px !important;
font-family: "Segoe UI","Segoe UI Web (West European)","Segoe UI",-apple-system,BlinkMacSystemFont,"Roboto","Helvetica Neue",sans-serif !important;
}
</style>
<link type="text/css" href="<%=GetUrl("js/components/css/gridview.css") %>" rel="stylesheet" />
<link type="text/css" href="<%=GetUrl("css/override.css") %>" rel="stylesheet" />
<script src="<%=GetUrl("js/jquery-3.6.0.min.js")%>" type="text/javascript"></script>
<script src="<%=GetUrl("js/cookie.js")%>" type="text/javascript"></script>
<script src="<%=GetUrl("js/utility.js")%>" type="text/javascript"></script>
<script type="text/javascript" src="<%=GetUrl("js/components/gridview.js") %>"></script>
<script src="<%=GetUrl("js/language.js")%>" type="text/javascript"></script>
<script type="text/javascript">
<%-- _net.root = '<%=Page.ResolveUrl("~/")%>';--%>
var GridView = window.GridView || window['g5-gridview'];
var canExport = <%= CanExportFile %>;
function getText(s, flag) {
return (s == null)
? (flag ? '<i>null</i>' : '')
: htmlencode(s, $('#div_text_holder')).replace(/ /g, '&nbsp;');
}
function systemrequest(method, param, callback, error) {
_network.request("SystemSettings/SystemOptions.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
showmaskbg(false, true);
showAlert(GetTextByKey('P_WO_PAGEERROR', 'An unknown error occurred. Please refresh page.'), GetTextByKey('P_WO_QUERY', 'Query'));
});
}
var systemunitofodometer;
function GetSystemUnitOfOdometer() {
systemrequest("GetSystemUnitOfOdometer", "", function (data) {
systemunitofodometer = data;
$('#dialogadd_sel_odometeruom').val(systemunitofodometer);
$('#dialogadjust_sel_odometeruom').val(systemunitofodometer);
}, function (err) {
});
}
function GetLanguageByCookie() {
var lang = getCookie('<%=Common.LanguageCookieName%>');
if (lang == null) {
return "en-us";
} else {
return lang;
}
}
$(function () {
_fleet.currentLang = GetLanguageByCookie();
GetSystemUnitOfOdometer();
$("#content1").applyFleetLanguageText(true);
// 加载完毕后通知上级页面
if (typeof window.parent.onsubpageloaded == 'function') {
window.parent.onsubpageloaded();
}
if (typeof window.parent.ondocumentclick == 'function') {
$(document.body).click(window.parent.ondocumentclick);
}
function resizeContent() {
$('#mask_bg').height($(document).outerHeight(false)).width($(document).outerWidth(false));
}
$(window).resize(function () {
resizeContent();
});
//window.onresize = resizeContent;
resizeContent();
window.ondocumentclick = function (e) {
$(document.body).click();
};
if (typeof window.parent.ondocumentclick == 'function') {
$(document.body).click(window.parent.ondocumentclick);
}
});
</script>
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
<div id="content1">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="div_text_holder"></div>
</body>
</html>

View File

@ -0,0 +1,35 @@
using FI.FIC;
using Foresight.Fleet.Services.Styles;
using IronIntel.Contractor;
using IronIntel.Contractor.iisitebase;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AssetViewBaseBase : CommonBase
{
protected override bool ExportModule
{
get { return true; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
GetUIStyle();
}
catch
{
// TODO: errors when get the ui style.
}
}
}
}

View File

@ -0,0 +1,542 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/AssetView/AssetViewBase.master" AutoEventWireup="true" CodeFile="AssetsTimeline.aspx.cs" Inherits="AssetView_AssetsTimeline" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link href="<%=GetFileUrlWithVersion("../css/jquery.datetimepicker.css")%>" rel="stylesheet" />
<script src="<%=GetFileUrlWithVersion("../js/jquery.datetimepicker.full.js")%>"></script>
<link href="<%=Common.GenerateUrl("../css/tabcontrol.css") %>" rel="stylesheet" />
<script src="<%=GetFileUrlWithVersion("../js/controls.js")%>" type="text/javascript"></script>
<script src="<%=GetFileUrlWithVersion("../Maintenance/js/inputdatactr.js")%>" type="text/javascript"></script>
<style type="text/css">
html {
overflow-x: hidden;
}
.titlePane {
background-color: #444444;
color: #FFFFFF;
line-height: 24px;
padding-left: 6px;
border-radius: 5px 5px 0px 0px;
-webkit-border-radius: 5px 5px 0px 0px;
cursor: default;
}
.titleButton {
position: absolute;
top: 2px;
cursor: pointer;
}
.titleButton:before {
padding-right: 8px;
font-family: 'FontAwesome';
}
.titleButton.close {
right: 3px;
background-position: 0 0;
width: 12px;
height: 17px;
font-size: 15px;
}
.table-container {
margin: 4px 10px 0 26px;
}
.table-timeline {
width: 100%;
border-spacing: 0;
table-layout: fixed;
}
.table-timeline th {
width: 4.17%;
border-right: 1px solid white;
background: #444;
color: white;
font-weight: normal;
font-size: 13px;
height: 26px;
}
.table-timeline th,
.table-timeline td {
padding: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tds-timeline td {
height: 30px;
position: relative;
}
#tds-timeline div {
height: 26px;
position: absolute;
background: #64965a;
top: 2px;
border-radius: 6px;
}
#tds-timeline div.no-start {
border-radius: 0 6px 6px 0;
}
#tds-timeline div.no-end {
border-radius: 6px 0 0 6px;
}
#tab_timeline {
overflow-y: auto;
}
</style>
<script type="text/javascript">
_network.root = '<%=Page.ResolveUrl("~/")%>';
var wids = [];
var grid;
var currentdate = "<%=CurrentDate %>";
function assetrequest(method, param, callback, error) {
_network.request("AssetView/SingleAssetView.aspx", -1, method, param, callback, error || function (e) {
console.log(e);
});
}
function fillWidths() {
var ths = $('#tr-header').children();
for (var i = 0; i < ths.length; i++) {
wids[i] = $(ths[i]).outerWidth();
}
}
$(function () {
fillWidths();
var resizeTimeline = function () {
fillWidths();
var trs = $('#tds-timeline').children('tr');
for (var n = 0; n < trs.length; n++) {
var ds = $(trs[n]).children('td').children();
for (var i = 0; i < ds.length; i++) {
var div = $(ds[i]);
var start = parseFloat(div.attr('start'));
var end = parseFloat(div.attr('end'));
var left = getOffset(start, wids);
var right = getOffset(end, wids);
var w = right - left - 1;
if (w < 1) { w = 1; }
div.css({
left: left,
width: w
});
}
}
};
$(window).resize(function () {
resizeTimeline();
var height = $(window).height() - 70;
$('#tab_timeline').css('height', height);
$('#tab_grid').css('height', height);
grid.resize();
});
$('#date-selector').datetimepicker({
timepicker: false,
format: 'm/d/Y',
scrollMonth: false,
scrollTime: false,
scrollInput: false,
}).val(new DateFormatter().formatDate(new Date(currentdate), 'm/d/Y'));
$('#tab_container').tab({
onclick: function (t, n) {
n();
var key = t.attr('data-href')
$('#' + key).css('height', $(window).height() - 70);
if (key === 'tab_grid') {
grid.resize();
} else {
resizeTimeline();
}
}
});
grid = new GridView('#tab_grid');
grid.columns = [
{
key: 'name',
caption: GetTextByKey('P_MA_ASSETNAME', 'Asset Name'),
width: 180
},
{
key: 'vin',
caption: GetTextByKey('P_MA_VIN', 'VIN/SN'),
width: 160
},
{
key: 'make',
caption: GetTextByKey('P_MA_MAKENAME', 'Make Name'),
width: 100
},
{
key: 'model',
caption: GetTextByKey('P_MA_MODELNAME', 'Model Name'),
width: 100
},
{ key: 'h0', caption: '12AM-1AM', width: 94, align: 'right' },
{ key: 'h1', caption: '1AM-2AM', width: 94, align: 'right' },
{ key: 'h2', caption: '2AM-3AM', width: 94, align: 'right' },
{ key: 'h3', caption: '3AM-4AM', width: 94, align: 'right' },
{ key: 'h4', caption: '4AM-5AM', width: 94, align: 'right' },
{ key: 'h5', caption: '5AM-6AM', width: 94, align: 'right' },
{ key: 'h6', caption: '6AM-7AM', width: 94, align: 'right' },
{ key: 'h7', caption: '7AM-8AM', width: 94, align: 'right' },
{ key: 'h8', caption: '8AM-9AM', width: 94, align: 'right' },
{ key: 'h9', caption: '9AM-10AM', width: 94, align: 'right' },
{ key: 'h10', caption: '10AM-11AM', width: 94, align: 'right' },
{ key: 'h11', caption: '11AM-12PM', width: 94, align: 'right' },
{ key: 'h12', caption: '12PM-1PM', width: 94, align: 'right' },
{ key: 'h13', caption: '1PM-2PM', width: 94, align: 'right' },
{ key: 'h14', caption: '2PM-3PM', width: 94, align: 'right' },
{ key: 'h15', caption: '3PM-4PM', width: 94, align: 'right' },
{ key: 'h16', caption: '4PM-5PM', width: 94, align: 'right' },
{ key: 'h17', caption: '5PM-6PM', width: 94, align: 'right' },
{ key: 'h18', caption: '6PM-7PM', width: 94, align: 'right' },
{ key: 'h19', caption: '7PM-8PM', width: 94, align: 'right' },
{ key: 'h20', caption: '8PM-9PM', width: 94, align: 'right' },
{ key: 'h21', caption: '9PM-10PM', width: 94, align: 'right' },
{ key: 'h22', caption: '10PM-11PM', width: 94, align: 'right' },
{ key: 'h23', caption: '11PM-12AM', width: 94, align: 'right' }
];
grid.canMultiSelect = false;
grid.init();
});
var pcid;
var loading;
function getAssetTimeline(cid, date) {
if (loading) {
return;
}
pcid = cid || '';
var assets = window.parent.allAssets;
if (assets == null) {
return;
}
var selecteds = assets.filter(function (a) { return a.State.Selected }).sort(function (a, b) {
if (a.DisplayName == b.DisplayName) {
return 0;
}
return a.DisplayName > b.DisplayName ? 1 : -1;
});
var parent = $('#tds-timeline').empty();
var idsparent = $('#asset-ids').empty();
loading = true;
$('.maskbg').fadeIn(100);
grid.setData([]);
doGetAssetTimeline(selecteds, 0, parent, idsparent, date);
}
function doGetAssetTimeline(selecteds, start, parent, idsparent, date) {
var endIndex = start + 10000;
var ids = selecteds.slice(start, endIndex).map(function (a) { return a.ID });
if (ids.length <= 0) {
var source = grid.source;
var total = {
name: GetTextByKey('P_MA_TOTALCOLON', 'Total:') + ' ' + source.length,
model: $('<span></span>').css('float', 'right').text(GetTextByKey('P_MA_TOTALRUNTIMECOLON', 'Total Runtime:'))[0].outerHTML
};
for (var h = 0; h < 24; h++) {
var seconds = source.reduce(function (current, s) {
var n = s.Values['s' + h];
return isNaN(n) ? current : current + n;
}, 0);
if (seconds > 0) {
var run =
String(Math.floor(seconds / 3600)).padStart(2, '0') + ':' +
String(Math.floor((seconds % 3600) / 60)).padStart(2, '0') + ':' +
String(Math.round(seconds % 60)).padStart(2, '0');
total['h' + h] = run;
}
}
grid.total = total;
grid.init();
loading = false;
$('.maskbg').fadeOut(100);
return;
}
var params = [pcid, ids, date];
assetrequest('GetAssetsOnOffTimeline', params.join(String.fromCharCode(170)), function (data) {
var source = [];
for (var n = 0; n < data.length; n++) {
var item = $('<td colspan="24"></td>');
var onoff = data[n];
var a = selecteds.filter(function (a) { return a.ID == onoff.AssetId })[0];
var name = (a && a.DisplayName) || onoff.AssetId;
var it = {
name: name,
vin: a.VIN,
make: a.Make,
model: a.Model
};
var idtd = $('<td style="height: 30px"></td>').text(name).attr('title', name);
idsparent.append($('<tr></tr>').append(idtd));
for (var i = 0; i < onoff.Items.length; i++) {
var div = $('<div></div>');
var startSeconds = onoff.Items[i].Start;
var endSeconds = onoff.Items[i].End;
var start = startSeconds / 3600;
var end = endSeconds / 3600;
if (endSeconds > startSeconds) {
var startHour = Math.floor(start);
var endHour = Math.ceil(end);
for (var h = startHour; h < endHour; h++) {
var hourStartSeconds = h * 3600;
var hourEndSeconds = (h + 1) * 3600;
if (startSeconds > hourStartSeconds) {
hourStartSeconds = startSeconds;
}
if (hourEndSeconds - endSeconds >= 1) {
hourEndSeconds = endSeconds;
}
var totalSeconds = hourEndSeconds - hourStartSeconds;
if (it['s' + h] == null) {
it['s' + h] = totalSeconds;
} else {
it['s' + h] += totalSeconds;
}
}
}
var title = [];
if (onoff.Items[i].HasOn) {
title.push('On: ' + hoursToString(startSeconds));
} else {
div.addClass('no-start');
}
if (onoff.Items[i].HasOff) {
title.push('Off: ' + hoursToString(endSeconds));
} else {
div.addClass('no-end');
}
div.attr({
start: start,
end: end,
title: title.join('\n')
});
var left = getOffset(start, wids);
var right = getOffset(end, wids);
var w = right - left - 1;
if (w < 1) { w = 1; }
div.css({
left: left,
width: w
});
item.append(div);
}
for (var h = 0; h < 24; h++) {
var totalSeconds = it['s' + h];
if (totalSeconds == null) {
continue;
}
var text;
if (totalSeconds >= 3600) {
text = '01:00:00';
} else {
text =
'00:' +
String(Math.floor(totalSeconds / 60)).padStart(2, '0') + ':' +
String(Math.round(totalSeconds % 60)).padStart(2, '0');
}
it['h' + h] = text;
}
source.push({ Values: it });
parent.append($('<tr></tr>').append(item));
}
source = grid.source.concat(source);
grid.setData(source);
setTimeout(function () {
doGetAssetTimeline(selecteds, endIndex, parent, idsparent, date);
}, 0);
});
}
function hoursToString(seconds) {
var s = Math.floor(seconds % 60);
seconds = Math.floor(seconds / 60);
var m = Math.round(seconds % 60);
var h = Math.floor(seconds / 60);
return (h < 10 ? '0' : '') + h + ':' + (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s;
}
function OnRefresh(cid, dt) {
//getAssetTimeline(cid, dt || $('#date-selector').val());
pcid = cid;
$('#tds-timeline').empty();
$('#asset-ids').empty();
}
function OnClose() {
window.parent.closePopupView();
}
function OnDateChanged() {
var date = $('#date-selector').val();
if (date == "") {
showAlert(GetTextByKey("P_WO_XXXXXX", "The date is required."), alerttitle);
return false;
}
if (!checkDate(date)) {
showAlert(GetTextByKey("P_WO_XXXXXX", "The date is incorrect."), alerttitle);
return false;
}
getAssetTimeline(pcid, date);
}
function getOffset(pos, wids) {
var n = Math.floor(pos);
var p = 0;
for (var i = 0; i < n; i++) {
p += wids[i];
}
p += wids[n] * (pos - n);
return p;
}
function OnExport() {
var date = $('#date-selector').val();
if (date == "") {
showAlert(GetTextByKey("P_WO_XXXXXX", "The date is required."), alerttitle);
return false;
}
if (!checkDate(date)) {
showAlert(GetTextByKey("P_WO_XXXXXX", "The date is incorrect."), alerttitle);
return false;
}
var assets = window.parent.allAssets;
if (assets == null) {
return;
}
var selecteds = assets.filter(function (a) { return a.State.Selected }).sort(function (a, b) {
if (a.DisplayName == b.DisplayName) {
return 0;
}
return a.DisplayName > b.DisplayName ? 1 : -1;
});
var ids = selecteds.map(function (a) { return a.ID });
var params = ["timeline", pcid, JSON.stringify(ids), date];
var data = new FormData();
data.append('type', 'set');
data.append('ClientData', JSON.stringify(params));
$.ajax({
url: "../ExportToFile.aspx",
type: 'POST',
dataType: 'json',
processData: false,
contentType: false,
data: data,
success: function (data) {
if (data && data != "")
window.open("../ExportToFile.aspx?type=exp&key=" + data);
},
error: function (err) {
}
});
}
function tabchange(index) {
if (index == 0) {
$("#btnexporttimelineexcel").hide();
}
else if (index == 1) {
if (!canExport) {
$("#btnexporttimelineexcel").hide();
}
else {
$("#btnexporttimelineexcel").show();
}
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="titlePane">
<span>&nbsp;</span>
<span class="iconclose titleButton close" onclick="OnClose();" style="z-index: 600"></span>
</div>
<div id="tab_container" style="position: relative">
<ul class="tab_header" style="padding-top: 8px">
<li data-href="tab_timeline" class="selected" onclick="tabchange(0)" data-lgid="P_MV_TIMELINE">Timeline</li>
<li data-href="tab_grid" onclick="tabchange(1)" data-lgid="P_GRID_TITLE">Utilization by Hour</li>
<li style="clear: both"></li>
</ul>
<div id="tab_timeline" data-page="tab_timeline">
<div class="table-container">
<div style="width: 100px; float: left">
<table class="table-timeline">
<thead>
<tr>
<th>&nbsp;</th>
</tr>
</thead>
<tbody id="asset-ids">
<%--<tr><td style="height: 30px" data-lgid="P_MV_ONOFFEVENTS">On/Off Events</td></tr>--%>
</tbody>
</table>
</div>
<div style="margin-left: 100px">
<table class="table-timeline">
<thead>
<tr id="tr-header">
<th>0:00</th>
<th>1:00</th>
<th>2:00</th>
<th>3:00</th>
<th>4:00</th>
<th>5:00</th>
<th>6:00</th>
<th>7:00</th>
<th>8:00</th>
<th>9:00</th>
<th>10:00</th>
<th>11:00</th>
<th>12:00</th>
<th>13:00</th>
<th>14:00</th>
<th>15:00</th>
<th>16:00</th>
<th>17:00</th>
<th>18:00</th>
<th>19:00</th>
<th>20:00</th>
<th>21:00</th>
<th>22:00</th>
<th>23:00</th>
</tr>
</thead>
<tbody id="tds-timeline"></tbody>
</table>
</div>
</div>
</div>
<div id="tab_grid" data-page="tab_grid" style="box-sizing: border-box"></div>
</div>
<div style="position: absolute; right: 6px; top: 30px">
<input type="text" id="date-selector" style="height: 26px; box-sizing: border-box" autocomplete="off" />
<span class="sbutton iconrefresh" onclick="OnDateChanged();" data-lgid="P_APICRE_REFRESH">Refresh</span>
<span id="btnexporttimelineexcel" class="sbutton iconexport" onclick="OnExport();" style="display: none;" data-lgid="P_MR_EXPORTTOEXCEL">Export to Excel</span>
</div>
<div id="mask_bg" class="maskbg" style="display: none; z-index: 550;">
<div class="loading c-spin"></div>
</div>
</asp:Content>

View File

@ -0,0 +1,13 @@
using IronIntel.Contractor;
using IronIntel.Contractor.Site;
using System;
public partial class AssetView_AssetsTimeline : ContractorBasePage
{
public string CurrentDate = "";
protected void Page_Load(object sender, EventArgs e)
{
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
CurrentDate = userlocaldate.ToShortDateString();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,166 @@
using Foresight.Fleet.Services.Styles;
using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.iisitebase;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SingleAssetView : SingleAssetViewBasePage
{
public string CurrentDate = "";
public bool IsDealer = SystemParams.IsDealer;
protected string MenuBackgroundColor = "#D7690E";
protected void Page_Load(object sender, EventArgs e)
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
this.Title = PageTitle;
GetUIStyle();
}
}
DateTime userlocaldate = SystemParams.ConvertToUserTimeFromUtc(GetCurrentLoginSession().User, DateTime.UtcNow);
CurrentDate = userlocaldate.ToShortDateString();
}
private void GetUIStyle()
{
var sessionid = IronIntelBasePage.GetLoginSessionID(Request);
var user = UserManagement.GetUserBySessionID(sessionid);
if (user != null)
{
CustUIStyle style = SystemParams.GetUIStyle(user.IID);
if (style != null)
{
if (!string.IsNullOrEmpty(style.MenuBackgroundColor))
{//目前Menu和Module背景色使用同一个颜色,在有设置的情况下
MenuBackgroundColor = style.MenuBackgroundColor;
}
}
}
}
protected override bool ThrowIfNotAllowed
{
get
{
return true;
}
}
public bool CanEditAsset
{
get
{
string canEdit = Request.Params["canedit"];
var user = GetCurrentUser();
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
return canEdit == "1" && permission;
}
}
public bool CanViewWorkOrder
{
get
{
bool wolic = SystemParams.HasLicense("WorkOrder");
bool permission = CheckRight(SystemParams.CompanyID, Feature.WORK_ORDER);
return !SystemParams.IsDealer && wolic && permission;
}
}
public bool CanViewMR
{
get
{
bool license = SystemParams.HasLicense("PreventativeMaintenance");
bool mrlicense = SystemParams.HasLicense("MaintenanceRecord");
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
return !SystemParams.IsDealer && license && mrlicense && permission && !CanViewWorkOrder;//10486 WorkOrder和Maintenance Record只显示一个
}
}
public bool CanViewPM
{
get
{
bool license = SystemParams.HasLicense("PreventativeMaintenance");
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
return !SystemParams.IsDealer && license && permission;
}
}
public bool CanViewAlertsManagement
{
get
{
bool lic = SystemParams.HasLicense("AlertsManagement");
bool permission = CheckRight(SystemParams.CompanyID, Feature.ALERTS_MANAGEMENT);
return !SystemParams.IsDealer && lic && permission;
}
}
public bool CanViewFuelRecords
{
get
{
bool lic = SystemParams.HasLicense("FuelRecords");
bool permission = CheckRight(SystemParams.CompanyID, Feature.FUEL_RECORDS);
return !SystemParams.IsDealer && lic && permission;
}
}
public bool EnableSmartWitness
{
get
{
bool lic = SystemParams.HasLicense("SmartWitness");
return lic;
}
}
public bool CanEditPM
{
get
{
string canEdit = Request.Params["canedit"];
var user = GetCurrentUser();
bool license = SystemParams.HasLicense("PreventativeMaintenance");
bool permission = CheckRight(SystemParams.CompanyID, Feature.PREVENTATIVE_MAINTENANCE);
return canEdit == "1" && license && permission;
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
public bool CanViewInspection
{
get
{
bool lic = SystemParams.HasLicense("Inspection");
bool permission = CheckRight(SystemParams.CompanyID, Feature.INSPECTION_TEMPLATES);
return !SystemParams.IsDealer && lic && permission;
}
}
}

View File

@ -0,0 +1,171 @@

//************************Add Engine Hours**************************************//
var isAddEH = true;
var primarydatadourceADEH;
function openAddEnginHours() {
primarydatadourceADEH = undefined;
var datetime = customerdatetime.split(' ');
var time = datetime[0];
var st = datetime[1].split(':');
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
var minutes = st[1];
$('#dialogaddgenginehours_enginehours').val('');
$('#dialogadd_enginehourstimezone').val(customertimezone ? customertimezone : "UTC");
$('#dialogaddenginehours_date').val(time);
$('#dialogaddenginehours_timehour').val(hours);
$('#dialogaddenginehours_timeminute').val(minutes);
$('#dialogaddenginehours_Notes').val('');
if (assetdata.TelematicsEnabled && !assetdata.CurrentHours.IsEmpty &&
(assetdata.CurrentHours.DataSource.toLowerCase() == "calamp" || assetdata.CurrentHours.DataSource.toLowerCase() == "pedigree")) {
isAddEH = false;
primarydatadourceADEH = assetdata.CurrentHours.DataSource;
}
else
isAddEH = true;
$('#dialog_addenginehours .dialog-title span.title').text(isAddEH ? GetTextByKey("P_MV_ADDENGINEHOURS", 'Add Engine Hours') : GetTextByKey("P_MV_ADJUSTENGINEHOURS", 'Adjust Engine Hours'));
showmaskbg(true);
$('#dialog_addenginehours')
.attr('act', 'add')
.css({
'top': (document.documentElement.clientHeight - $('#dialog_addenginehours').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_addenginehours').width()) / 2
})
.showDialogfixed();
$('#dialogaddgenginehours_enginehours').focus();
}
function OnAddEngineHours() {
$('#addenginehoursmask').show();
var alerttitle = isAddEH ? GetTextByKey("P_MV_ADDENGINEHOURS", 'Add Engine Hours') : GetTextByKey("P_MV_ADJUSTENGINEHOURS", 'Adjust Engine Hours');
var item = {
'CustomerID': contractorid,
'AssetID': assetid,
'EngineHours': $('#dialogaddgenginehours_enginehours').val(),
'EngineHoursDate': $('#dialogaddenginehours_date').val(),
'Notes': $('#dialogaddenginehours_Notes').val(),
'DataSource': primarydatadourceADEH
};
if (item.EngineHours !== "") {
if (isNaN(item.EngineHours)) {
showAlert(GetTextByKey("P_MV_ENGINEHOURSFORMATERROR", 'Engine Hours format error.'), alerttitle);
$('#addenginehoursmask').hide();
return;
}
else {
if (item.EngineHours <= 0) {
showAlert(GetTextByKey("P_MV_ENGINEHOURSMUSTBEGREATERTHAN0", 'Engine Hours must be greater than 0.'), alerttitle);
$('#addenginehoursmask').hide();
return;
}
}
}
else {
showAlert(GetTextByKey("P_MV_ENGINEHOURSCANNOTBEEMPTY", "Engine Hours cannot be empty."), alerttitle);
$('#addenginehoursmask').hide();
return;
}
if (item.EngineHoursDate === "") {
showAlert(GetTextByKey("P_MV_ENGINEHOURSDATECANNOTBEEMPTY", "Engine Hours Date cannot be empty."), alerttitle);
$('#addenginehoursmask').hide();
return;
}
var offset = $('#dialogadd_enginehourstimezone').find("option:selected").attr("offset");
item.OffsetMinute = offset;
var timezonetext = $('#dialogadd_enginehourstimezone').find("option:selected").text();
var hour = $('#dialogaddenginehours_timehour').val();
var minute = $('#dialogaddenginehours_timeminute').val();
item.EngineHoursDate = item.EngineHoursDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
var time = hour + ":" + minute
var alertmsg = "";
if (isAddEH) {
alertmsg = GetTextByKey("P_MV_UPDATEENGINEHOURS", "Do you want to update the engine hours to reflect: {0} hours at {1} {2}?").replace('{0}', item.EngineHours).replace('{1}', time).replace('{2}', timezonetext);
}
else {
alertmsg = GetTextByKey("P_MV_UPDATEENGINEHOURS1", "If you proceed, engine hours will be updated to reflect: {0} hours at {1} <br/>" +
" {2}. <br/><br/>Note that this asset is telematic enabled and the primary data source is {3}." +
"<br/><br/> Would you like to proceed?").replace('{0}', item.EngineHours).replace('{1}', time).replace('{2}', timezonetext).replace('{3}', assetdata.CurrentHours.DataSourceName);
}
showConfirm1(alertmsg, alerttitle, function () {
$('#addenginehoursmask').hide();
if (isAddEH)
AddManuallyInputEngineHours(item, alerttitle);
else
CheckEngineHourMinimumTime(item, alerttitle);
}, function () {
$('#addenginehoursmask').hide();
});
}
function AddManuallyInputEngineHours(item, alerttitle) {
showloading(true);
var param = JSON.stringify(item);
param = htmlencode(param);
devicerequest("AddManuallyInputEngineHours", param, function (data) {
showloading(false);
if (data !== 'OK') {
showAlert(data, alerttitle);
} else {
loadAssetInfo();
showAlert(GetTextByKey("P_MV_ENGINEHOURSUPDATESUCCESSFUL", "Engine Hours Update Successful."), alerttitle);
}
$('#dialog_addenginehours').hideDialog();
$('#addenginehoursmask').hide();
}, function (err) {
console.log(err);
showloading(false);
showAlert(GetTextByKey("P_MV_FAILEDTOADDENGINEHOURS", 'Failed to add Engine Hours.'), alerttitle);
$('#addenginehoursmask').hide();
});
}
function CheckEngineHourMinimumTime(item, alerttitle) {
var param = JSON.stringify(item);
param = htmlencode(param);
devicerequest("CheckEngineHourMinimumTime", param, function (data) {
if (data > 0) {
if (data == 1)
showAlert(GetTextByKey("P_MV_CHECKENGINEHOURSMINNIMUMTIME", "The adjustment cannot be completed as provided. The engine hours reading date provided cannot be prior to initial telematic data available for the asset."), alerttitle);
else
showAlert(GetTextByKey("P_MV_CHECKENGINEHOURSMINNIMUMTIME1", "The adjustment cannot be completed as provided. The engine hours reading date provided must be prior to or equal to the latest telematic data available for the asset."), alerttitle);
$('#addenginehoursmask').hide();
return;
} else {
SaveAdjustEngineHours(item, alerttitle);
}
}, function (err) {
});
}
function SaveAdjustEngineHours(item, alerttitle) {
showloading(true);
var param = JSON.stringify(item);
param = htmlencode(param);
devicerequest("SaveAdjustEngineHours", param, function (data) {
showloading(false);
if (data !== 'OK') {
showAlert(data, alerttitle);
} else {
loadAssetInfo();
showAlert(GetTextByKey("P_MV_ENGINEHOURSUPDATESUCCESSFUL", "Engine Hours Update Successful."), alerttitle);
}
$('#dialog_addenginehours').hideDialog();
$('#addenginehoursmask').hide();
}, function (err) {
console.log(err);
showloading(false);
showAlert(GetTextByKey("P_MV_FAILEDTOADJUSTENGINEHOURS", 'Failed to adjust Engine Hours.'), alerttitle);
$('#addenginehoursmask').hide();
});
}

View File

@ -0,0 +1,167 @@

//************************Add Odometer**************************************//
var isAddOdo = true;
var primarydatadourceADOdo;
function openAddOdometer() {
primarydatadourceADOdo = undefined;
var datetime = customerdatetime.split(' ');
var time = datetime[0];
var st = datetime[1].split(':');
var hours = st[0].length == 1 ? "0" + st[0] : st[0];
var minutes = st[1];
$('#dialogadd_odometer').val('');
$('#dialogadd_sel_odometeruom').val(systemunitofodometer);
$('#dialogadd_odometertimezone').val(customertimezone ? customertimezone : "UTC");
$('#dialogadd_odometerdate').val(time);
$('#dialogadd_timehour').val(hours);
$('#dialogadd_timeminute').val(minutes);
$('#dialogadd_notes').val('');
if (assetdata.TelematicsEnabled && !assetdata.CurrentOdometer.IsEmpty &&
(assetdata.CurrentOdometer.DataSource.toLowerCase() == "calamp" || assetdata.CurrentOdometer.DataSource.toLowerCase() == "pedigree")) {
isAddOdo = false;
primarydatadourceADOdo = assetdata.CurrentOdometer.DataSource;
}
else
isAddOdo = true;
$('#dialog_addodometer .dialog-title span.title').text(isAddOdo ? GetTextByKey("P_MV_ADDODOMETER", 'Add Odometer') : GetTextByKey("P_MV_ADJUSTODOMETER", 'Adjust Odometer'));
showmaskbg(true);
$('#dialog_addodometer')
.attr('act', 'add')
.css({
'top': (document.documentElement.clientHeight - $('#dialog_addodometer').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_addodometer').width()) / 2
})
.showDialogfixed();
$('#dialogadd_odometer').focus();
}
function OnAddOdometer() {
$('#addodomask').show();
var alerttitle = isAddOdo ? GetTextByKey("P_MV_ADDODOMETER", 'Add Odometer') : GetTextByKey("P_MV_ADJUSTODOMETER", 'Adjust Odometer');
var item = {
'CustomerID': contractorid,
'AssetID': assetid,
'Odometer': $('#dialogadd_odometer').val(),
'UOM': $('#dialogadd_sel_odometeruom').val(),
'OdometerDate': $('#dialogadd_odometerdate').val(),
'Notes': $('#dialogadd_notes').val(),
'DataSource': primarydatadourceADOdo
};
if (item.Odometer !== "") {
if (isNaN(item.Odometer)) {
showAlert(GetTextByKey("P_MV_ODOMETERFORMATERROR", 'Odometer format error.'), alerttitle);
$('#addodomask').hide();
return;
}
else {
if (item.Odometer <= 0) {
showAlert(GetTextByKey("P_MV_ODOMETERMUSTBEGREATERTHAN0", 'ODOMeter must be greater than 0.'), alerttitle);
$('#addodomask').hide();
return;
}
}
}
else {
showAlert(GetTextByKey("P_MV_ODOMETRCANNOTBEEMPTY", "Odometer cannot be empty."), alerttitle);
$('#addodomask').hide();
return;
}
if (item.OdometerDate === "") {
showAlert(GetTextByKey("P_MV_ODOMETRDATACANNOTBEEMPTY", "Odometer date cannot be empty."), alerttitle);
$('#addodomask').hide();
return;
}
var offset = $('#dialogadd_odometertimezone').find("option:selected").attr("offset");
item.OffsetMinute = offset;
var timezonetext = $('#dialogadd_enginehourstimezone').find("option:selected").text();
var hour = $('#dialogadd_timehour').val();
var minute = $('#dialogadd_timeminute').val();
item.OdometerDate = item.OdometerDate.replace("-", "/") + " " + hour + ":" + minute + ":" + "00";
var time = hour + ":" + minute
var alertmsg = "";
if (isAddOdo) {
alertmsg = GetTextByKey("P_MV_UPDATETHEODOMETER", "Do you want to update the odometer to reflect: {0} {1} at {2} {3}?").replace('{0}', item.Odometer).replace('{1}', item.UOM).replace('{2}', time).replace('{3}', timezonetext);
}
else {
alertmsg = GetTextByKey("P_MV_UPDATETHEODOMETER1", "If you proceed, odometer will be updated to reflect: {0} {1} at {2} <br/> {3}.<br/><br/> Note that this asset is telematic enabled and the primary data source is {4}.<br/><br/>Would you like to proceed?").replace('{0}', item.Odometer).replace('{1}', item.UOM).replace('{2}', time).replace('{3}', timezonetext).replace('{4}', assetdata.CurrentOdometer.DataSourceName);
}
showConfirm1(alertmsg, alerttitle, function () {
$('#addodomask').hide();
if (isAddOdo)
AddManuallyInputOdometer(item, alerttitle);
else
CheckOdometerMinnimumTime(item, alerttitle);
}, function () {
$('#addodomask').hide();
});
}
function AddManuallyInputOdometer(item, alerttitle) {
showloading(true);
var param = JSON.stringify(item);
param = htmlencode(param);
devicerequest("AddManuallyInputOdometer", param, function (data) {
showloading(false);
if (data !== 'OK') {
showAlert(data, alerttitle);
} else {
loadAssetInfo();
showAlert(GetTextByKey("P_MV_ODOMETERUPDATESUCCESSFUL", "Odometer Update Successful."), alerttitle);
}
$('#dialog_addodometer').hideDialog();
$('#addodomask').hide();
}, function (err) {
showloading(false);
showAlert(GetTextByKey("P_MV_FAILEDTOADDODOMETER", 'Failed to add Odometer.'), alerttitle);
$('#addodomask').hide();
});
}
function CheckOdometerMinnimumTime(item, alerttitle) {
var param = JSON.stringify(item);
param = htmlencode(param);
devicerequest("CheckOdometerMinnimumTime", param, function (data) {
if (data > 0) {
if (data == 1)
showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME", "The adjustment cannot be completed as provided. The odometer reading date provided cannot be prior to initial telematic data available for the asset."), alerttitle);
else
showAlert(GetTextByKey("P_MA_CHECKODOMETERMINNIMUMTIME1", "The adjustment cannot be completed as provided. The odometer reading date provided must be prior to or equal to the latest telematic data available for the asset."), alerttitle);
$('#addodomask').hide();
return;
} else {
SaveAdjustOdometer(item, alerttitle);
}
}, function (err) {
});
}
function SaveAdjustOdometer(item, alerttitle) {
showloading(true);
var param = JSON.stringify(item);
param = htmlencode(param);
devicerequest("SaveAdjustOdometer", param, function (data) {
showloading(false);
if (data !== 'OK') {
showAlert(data, alerttitle);
} else {
loadAssetInfo();
showAlert(GetTextByKey("P_MV_ODOMETERUPDATESUCCESSFUL", "Odometer Update Successful."), alerttitle);
}
$('#dialog_addodometer').hideDialog();
$('#addodomask').hide();
}, function (err) {
showloading(false);
showAlert(GetTextByKey("P_MV_FAILEDTOADJUSTODOMETER", 'Failed to adjust Odometer.'), alerttitle);
$('#addodomask').hide();
});
}

View File

@ -0,0 +1,574 @@
$(function () {
InitPMGridData();
$('#dialog_pm').dialog(function () {
$("#pmschedulelistmask").hide();
});
$('#dialog_pmschedulelist').dialog(function () {
showmaskbg(false);
GetPMInfo();
});
if (!IsDealer && CanEditPM)
$("#btnaddplan").show();
});
function showPMSchedules() {
showmaskbg(true);
$('#dialog_pmschedulelist').css({
'top': (document.documentElement.clientHeight - $('#dialog_pmschedulelist').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_pmschedulelist').width()) / 2
}).showDialogfixed();
SetAssetItem(assetdata);
getAssetPMSchedules();
}
function SetAssetItem(asset) {
if (isNaN(asset.EngineHours))
asset.EngineHours = asset.CurrentHours.Corrected
if (isNaN(asset.Odometer)) {
asset.Odometer = asset.CurrentOdometer.Corrected;
asset.OdometerUnits = asset.CurrentOdometer.UOM;
}
$("#dialog_pm").data("asset", asset);
}
function showConfirmsub(msg, title, fok, fcancel) {
$("#pmschedulelistmask").show();
_dialog.showConfirmOKCancel(msg, title, function (e) {
$("#pmschedulelistmask").hide();
if (typeof fok === 'function') {
fok(e);
}
}, function () {
if (fcancel)
fcancel();
$("#pmschedulelistmask").hide();
});
}
/****** PM******/
var pmschedules
var grid_pmschedules;
function InitPMGridData() {
grid_pmschedules = new GridView('#pmschedulelist');
grid_pmschedules.lang = {
all: GetTextByKey("P_GRID_ALL", "(All)"),
ok: GetTextByKey("P_GRID_OK", "OK"),
reset: GetTextByKey("P_GRID_RESET", "Reset")
};
var list_columns = [
{ name: 'Selected', caption: "", valueIndex: 'Selected', type: 3, css: { 'width': 30, 'text-align': 'center' } },
{ name: 'PmScheduleName', caption: GetTextByKey("P_MV_SCHEDULENAME", "Schedule Name"), valueIndex: 'PmScheduleName', css: { 'width': 200, 'text-align': 'left' } },
{ name: 'StartValue', caption: GetTextByKey("P_MV_INITIALSERVICEVALUE", "Initial Service Value"), valueIndex: 'StartValue', css: { 'width': 120, 'text-align': 'right' } },
{ name: 'LastAlertTimeString', caption: GetTextByKey("P_MV_LASTSERVICEDATE", "Last Service Date"), valueIndex: 'LastAlertTimeString', css: { 'width': 120, 'text-align': 'left' } },
{ name: 'ServiceName', caption: GetTextByKey("P_MV_LASTSERVICEPERFORMED", "Last Service Performed"), valueIndex: 'ServiceName', css: { 'width': 140, 'text-align': 'left' } }
];
var columns = [];
// head
for (var hd in list_columns) {
var col = {};
col.name = list_columns[hd].name;
col.caption = list_columns[hd].caption;
col.visible = true;
col.sortable = true;
col.width = list_columns[hd].css.width;
col.align = list_columns[hd].css["text-align"]
col.key = list_columns[hd].valueIndex;
if (list_columns[hd].type) {
col.type = list_columns[hd].type;
}
if (col.name === "Selected") {
col.events = {
onchange: function () {
if (this.Selected) {
showSetPMDialog(this);
this.Selected = false;//弹出对话框并取消勾选因为此时机器并没有真正加入到计划在对话框OK刷新列表
grid_pmschedules.reload();
}
else {
var item = this;
var msg = GetTextByKey("P_MV_REMOVEASSETFROMSCHEDULE", "Do you want to remove this asset from the schedule?");
if (item.UnMaintainedAlert && item.UnMaintainedAlert > 0) {
var msg = GetTextByKey("P_MV_REMOVEASSETFROMSCHEDULE_TIPS", "Select OK below will result in the deletion of existing unassigned PM alerts for this asset.<br/> If you do not want those alerts deleted, select CANCEL and assign appropriate alerts to a maintenance record or work order in asset health prior to deletion/removal.");
}
showConfirmsub(msg, GetTextByKey("P_MV_REMOVEASSET", 'Remove Asset'), function () {
removeAssetFromPMSchedule(item);
}, function () {
item.Selected = true;
grid_pmschedules.reload();
});
}
}
};
}
columns.push(col);
}
grid_pmschedules.canMultiSelect = false;
grid_pmschedules.columns = columns;
grid_pmschedules.init();
}
function getAssetPMSchedules() {
$("#pmschedulelistmask").show();
assetrequest1('GetPMSchedulesByAsset', assetid, function (data) {
$("#pmschedulelistmask").hide();
if (typeof (data) === "string") {
showAlert(data, GetTextByKey("P_MV_ERROR", 'Error'));
return;
}
if (data && data.length > 0) {
pmschedules = data;
ShowPMSchedules(data);
}
}, function () {
$("#pmschedulelistmask").hide();
});
}
function ShowPMSchedules() {
var rows = [];
for (var i = 0; i < pmschedules.length; i++) {
var r = pmschedules[i];
if (r.PmScheduleType === "HM" || r.PmScheduleType === "PM")
r.StartValue = r.StartHours;
else if (r.PmScheduleType === "ADM" || r.PmScheduleType === "RDM")
r.StartValue = r.StartOdometer;
else
r.StartValue = r.StartDateString;
var fr = { Values: r };
rows.push(fr);
}
grid_pmschedules.setData(rows);
}
function reshowpmgrid() {
setTimeout(function () {
$("#pmschedulelist").css("height", $(window).height() - $("#pmschedulelist").offset().top - 10);
grid_pmschedules && grid_pmschedules.resize();
});
}
function addAssetToPMSchedule(item) {
$("#pmschedulelistmask").show();
assetrequest1('AddAssetToPMSchedule', JSON.stringify(item), function (data) {
if (data === "OK") {
$("#pmschedulelistmask").hide();
$('#dialog_pm').hideDialog();
//showAlert(data, 'Saved Successfully.');
getAssetPMSchedules();
}
else
showAlert(data, GetTextByKey("P_MV_ERROR", 'Error'));
}, function () {
$("#pmschedulelistmask").hide();
});
}
function removeAssetFromPMSchedule(schedule) {
var assetid = $("#dialog_pm").data("asset").ID;
var scheduleid = schedule.PmScheduleID;
$("#pmschedulelistmask").show();
assetrequest1('RemoveAssetFromPMSchedule', JSON.stringify([assetid, scheduleid]), function (data) {
$("#pmschedulelistmask").hide();
if (data === "OK") {
//showAlert(data, 'Removed Successfully.');
getAssetPMSchedules();
}
else
showAlert(data, GetTextByKey("P_MV_ERROR", 'Error'));
}, function () {
$("#pmschedulelistmask").hide();
});
}
function showSetPMDialog(pmschedule) {
$("#pmschedulelistmask").show();
//$('#dialog_pm .dialog-title span.title').text('Set PM Schedule');
if (pmschedule) {
var contentctrl = $("#dialog_pm .dialog-content");
contentctrl.empty();
//scheduletype === "HM" || scheduletype === "RDM" || scheduletype === "TBM"
if (pmschedule.PmScheduleType === "PM" || pmschedule.PmScheduleType === "ADM") {
createAbsoluteContent(contentctrl, pmschedule);
}
else if (pmschedule.PmScheduleType === "HM" || pmschedule.PmScheduleType === "RDM") {
createRelativeContent(contentctrl, pmschedule);
}
else if (pmschedule.PmScheduleType === "TBM") {
createTBMContent(contentctrl, pmschedule);
}
}
$('#dialog_pm').css({
'top': (document.documentElement.clientHeight - $('#dialog_adjustenginehours').height()) / 3,
'left': (document.documentElement.clientWidth - $('#dialog_adjustenginehours').width()) / 2
}).showDialogfixed();
}
function createAbsoluteContent(contentctrl, pmschedule) {
var text = GetTextByKey("P_MV_WHENWOULDYOULIKETHEFIRSTALERT", "When would you like the first alert?");
contentctrl.append($("<span></span><br />").text(text));
var radio1 = $("<input type='radio' name='pm' checked='checked' />");
contentctrl.append(radio1);
var tag = hasAvailableIntervals(pmschedule);
if (tag)
text = getFirstLineText(pmschedule);
else
text = GetTextByKey("P_MV_NOAVAILABLEINTERVALS", "No available intervals.");
contentctrl.append($("<span></span><br />").text(text));
if (tag) {
var radio2 = $("<input type='radio' name='pm' />");
contentctrl.append(radio2);
text = GetTextByKey("P_MV_ONEORMORESERVICESWASMISSEDALERTMEFOR", "One or more services was missed. Alert me for ");
contentctrl.append($("<span></span>").text(text));
var selInterval = $("<select></select>").prop("disabled", true);
contentctrl.append(selInterval);
contentctrl.append($("<span>" + GetTextByKey("P_MV_NOW", " now.") + "</span>"));
if (pmschedule.Intervals) {
for (var i = 0; i < pmschedule.Intervals.length; i++) {
var interval = pmschedule.Intervals[i];
if (!interval.Recurring) continue;//暂不考虑非周期性Service
selInterval.append($("<option></option>").val(interval.PmIntervalID).text(interval.ServiceName));
}
}
radio1.change(enableInput);
radio2.change(enableInput);
function enableInput() {
if (radio1.prop("checked"))
selInterval.prop("disabled", true);
else
selInterval.prop("disabled", false);
}
}
$("#btnSetPMSchedule").unbind().click(function () {
var asset = $("#dialog_pm").data("asset");
var item = {};
item.AssetID = asset.ID;
item.PmScheduleID = pmschedule.PmScheduleID;
//item.PMType = pmschedule.PmScheduleType;
if (pmschedule.PmScheduleType === "PM")
item.StartHours = asset.EngineHours;
else {
var unit = pmschedule.PmScheduleUom;
var value = asset.Odometer;
if (value > 0 && unit && asset.OdometerUnits
&& unit.toLowerCase().charAt(0) != asset.OdometerUnits.toLowerCase().charAt(0)) {
if (unit.toLowerCase().startsWith("m"))
value = value * 0.6213712;
else
value = value / 0.6213712;
}
item.StartOdometer = Math.round(value);
}
if (radio2 && radio2.prop("checked")) {
item.SelectedIntervalID = selInterval.val();
}
addAssetToPMSchedule(item);
});
}
function createRelativeContent(contentctrl, pmschedule) {
var text = GetTextByKey("P_MV_WHENWOULDYOULIKETHEFIRSTALERT", "When would you like the first alert?");
contentctrl.append($("<span></span><br />").text(text));
var radio1 = $("<input type='radio' name='pm' checked='checked' />");
contentctrl.append(radio1);
var tag = hasAvailableIntervals(pmschedule);
if (tag)
text = getFirstLineText(pmschedule);
else
text = GetTextByKey("P_MV_NOAVAILABLEINTERVALS", "No available intervals.");
contentctrl.append($("<span></span><br />").text(text));
if (tag) {
var radio2 = $("<input type='radio' name='pm' />");
contentctrl.append(radio2);
text = GetTextByKey("P_MV_CALCULATEBASEDUPONLASTSERVICETHE", "Calculate based upon last service. The ");
contentctrl.append($("<span></span>").text(text));
var selInterval = $("<select></select>").prop("disabled", true);
contentctrl.append(selInterval);
contentctrl.append($("<span>" + GetTextByKey("P_MV_SERVICEWASPERFORMEDAT", " service was performed at ") + "</span>"));
var txtStartValue = $("<input type='text' style='width:80px;' />").prop("disabled", true);
contentctrl.append(txtStartValue);
if (pmschedule.AllIntervals) {
var asset = $("#dialog_pm").data("asset");
var value = 0;
if (pmschedule.PmScheduleType === "HM")
value = Math.round(asset.EngineHours);
else
value = Math.round(asset.Odometer);
if (isNaN(value))
value = 0;
var tempIntervals = getIntervalValues(value, pmschedule.AllIntervals);
for (var i = 0; i < tempIntervals.length; i++) {
var interval = tempIntervals[i];
selInterval.append($("<option></option>").val(interval).text(interval));
}
//for (var i = 0; i < pmschedule.AllIntervals.length; i++) {
// var interval = pmschedule.AllIntervals[i];
// selInterval.append($("<option></option>").val(interval).text(interval));
//}
}
radio1.change(enableInput);
radio2.change(enableInput);
function enableInput() {
if (radio1.prop("checked")) {
txtStartValue.prop("disabled", true);
selInterval.prop("disabled", true);
}
else {
txtStartValue.prop("disabled", false);
selInterval.prop("disabled", false);
}
}
}
$("#btnSetPMSchedule").unbind().click(function () {
var asset = $("#dialog_pm").data("asset");
var item = {};
item.AssetID = asset.ID;
item.PmScheduleID = pmschedule.PmScheduleID;
//item.PMType = pmschedule.PmScheduleType;
if (radio1.prop("checked")) {
if (pmschedule.PmScheduleType === "HM")
item.StartHours = asset.EngineHours;
else {
var unit = pmschedule.PmScheduleUom;
var value = asset.Odometer;
if (value > 0 && unit && asset.OdometerUnits
&& unit.toLowerCase().charAt(0) != asset.OdometerUnits.toLowerCase().charAt(0)) {
if (unit.toLowerCase().startsWith("m"))
value = value * 0.6213712;
else
value = value / 0.6213712;
}
item.StartOdometer = Math.round(value);
}
}
else {
if (pmschedule.PmScheduleType === "HM") {
item.StartHours = txtStartValue.val();
if (item.StartHours === "" || isNaN(item.StartHours))
item.StartHours = asset.EngineHours;
}
else {
item.StartOdometer = txtStartValue.val();
if (item.StartOdometer === "" || isNaN(item.StartOdometer)) {
var unit = pmschedule.PmScheduleUom;
var value = asset.Odometer;
if (value > 0 && unit && asset.OdometerUnits
&& unit.toLowerCase().charAt(0) != asset.OdometerUnits.toLowerCase().charAt(0)) {
if (unit.toLowerCase().startsWith("m"))
value = value * 0.6213712;
else
value = value / 0.6213712;
}
item.StartOdometer = Math.round(value);
}
}
item.StartIntervalValue = selInterval.val();
}
addAssetToPMSchedule(item);
});
}
function createTBMContent(contentctrl, pmschedule) {
var text = GetTextByKey("P_MV_WHENWOULDYOULIKETHEFIRSTALERT", "When would you like the first alert?");
contentctrl.append($("<span></span><br />").text(text));
var radio1 = $("<input type='radio' name='pm' checked='checked' />");
contentctrl.append(radio1);
var tag = hasAvailableIntervals(pmschedule);
if (tag)
text = GetTextByKey("P_MV_TRIGGERANALERTASIFSERVICEISDUETODAY", "Trigger an alert as if service is due today.");
else
text = GetTextByKey("P_MV_NOAVAILABLEINTERVALS", "No available intervals.");
contentctrl.append($("<span></span><br />").text(text));
if (tag) {
var radio2 = $("<input type='radio' name='pm' />");
contentctrl.append(radio2);
text = GetTextByKey("P_MV_CALCULATEBASEDUPONLASTSERVICETHELASTSERVICEDATAWAS", "Calculate based upon last service. The last service date was ");
contentctrl.append($("<span></span>").text(text));
var dateparent = $("<span></span>");
contentctrl.append(dateparent);
var txtLastServiceDate = $("<input type='text' style='width:80px;' />").prop("disabled", true);
txtLastServiceDate.datetimepicker({
timepicker: false,
format: 'm/d/Y',
enterLikeTab: false
}).text(currentdate);
dateparent.append(txtLastServiceDate);
contentctrl.append($("<span>" + GetTextByKey("P_MV_FOR", " for ") + "</span>"));
var selInterval = $("<select></select>").prop("disabled", true);
contentctrl.append(selInterval);
if (pmschedule.Intervals) {
for (var i = 0; i < pmschedule.AllIntervals.length; i++) {
var interval = pmschedule.AllIntervals[i];
selInterval.append($("<option></option>").val(interval).text(interval));
}
}
radio1.change(enableInput);
radio2.change(enableInput);
function enableInput() {
if (radio1.prop("checked")) {
txtLastServiceDate.prop("disabled", true);
selInterval.prop("disabled", true);
}
else {
txtLastServiceDate.prop("disabled", false);
selInterval.prop("disabled", false);
}
}
}
$("#btnSetPMSchedule").unbind().click(function () {
var asset = $("#dialog_pm").data("asset");
var item = {};
item.AssetId = asset.ID;
item.PmScheduleID = pmschedule.PmScheduleID;
//item.PMType = pmschedule.PmScheduleType;
if (radio1.prop("checked")) {
item.StartDate = nowdate;
}
else {
item.StartDate = txtLastServiceDate.val();
item.StartIntervalValue = selInterval.val();
if (item.StartDate == "")
item.StartDate = "1900-01-01";
}
addAssetToPMSchedule(item);
});
}
function hasAvailableIntervals(pmschedule) {
if (!pmschedule.Intervals || pmschedule.Intervals.length == 0)
return false;
for (var i = 0; i < pmschedule.Intervals.length; i++) {
var ii = pmschedule.Intervals[i];
if (ii.Recurring)
return true;
}
return false;
}
function getIntervalValues(currentValue, allIntervals) {
var result = [];//取当前值的前两个和后10个Interval
if (allIntervals && allIntervals.length > 0) {
var maxInterval = allIntervals[allIntervals.length - 1];
var pervoid = parseInt(currentValue / maxInterval);
var remain = currentValue % maxInterval;
if (remain > 0)
pervoid++;
var maxpervoid = pervoid + 1;
var minpervoid = pervoid - Math.ceil(10 / allIntervals.length) - 1;//10表示向后取10
if (minpervoid < 0)
minpervoid = 0;
for (var pi = maxpervoid; pi >= minpervoid; pi--) {
for (var i = allIntervals.length - 1; i >= 0; i--) {
var interval = allIntervals[i];
var tempinterval = pi * maxInterval + interval;
result.push(tempinterval);
if (tempinterval >= currentValue) {
if (result.length > 2)
result.splice(0, 1);
}
else if (result.length == 12)
break;
}
}
}
return result;
}
function getFirstLineText(pmschedule) {
var text = "";
if (pmschedule.Intervals && pmschedule.Intervals.length > 0) {
var asset = $("#dialog_pm").data("asset");
var unit = "";
var value = 0;
if (pmschedule.PmScheduleType === "PM" || pmschedule.PmScheduleType === "HM") {
unit = "hours";
value = Math.round(asset.EngineHours);
}
else {
unit = pmschedule.PmScheduleUom;
value = asset.Odometer;
if (value > 0 && unit && asset.OdometerUnits
&& unit.toLowerCase().charAt(0) != asset.OdometerUnits.toLowerCase().charAt(0)) {
if (unit.toLowerCase().startsWith("m"))
value = value * 0.6213712;
else
value = value / 0.6213712;
value = Math.round(value);
}
}
if (isNaN(value))
value = 0;
var minoffset = null;
var nextInterval = null;
for (var i = 0; i < pmschedule.Intervals.length; i++) {
var ii = pmschedule.Intervals[i];
if (!ii.Recurring) continue;//暂不考虑非周期性Service
var offset = 0;
if (value == 0)
offset = ii.Interval;
else if (value % ii.Interval > 0)
offset = ii.Interval - value % ii.Interval;
if (!nextInterval || offset < minoffset) {
nextInterval = ii;
minoffset = offset;
continue;
}
if (offset == minoffset && (ii.Priority < nextInterval.Priority
|| (ii.Priority == nextInterval.Priority && ii.Interval > nextInterval.Interval)))
nextInterval = ii;
}
if (nextInterval) {
text = GetTextByKey("P_MV_THEFIRSTALERTWILLBE", "The first alert will be ");
text += nextInterval.NotificationPeriod + " " + unit;
if (value != 0 && value % nextInterval.Interval == 0)
parseInt(value / nextInterval.Interval) * nextInterval.Interval
else
value = (parseInt(value / nextInterval.Interval) + 1) * nextInterval.Interval;
text += GetTextByKey("P_MV_BEFORETHEASSETREADING", " before the asset reading ") + value + " " + unit;
text += GetTextByKey("P_MV_FOR", " for ") + nextInterval.ServiceName + ".";
}
}
return text;
}