fleet-contractor/Site/MapView.aspx.cs
2024-03-26 15:56:31 +08:00

241 lines
7.4 KiB
C#

using Foresight.Fleet.Services.Customer;
using Foresight.Fleet.Services.User;
using Foresight.ServiceModel;
using IronIntel.Contractor;
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 MapView : MapViewBasePage
{
public string LocationHistoryDateFrom = DateTime.Now.Date.AddMonths(-2).ToShortDateString();
public string LocationHistoryDateTo = DateTime.Now.Date.ToShortDateString();
public string CurrentDate = "";
public string MSGWebSocketURL = "";
public string AiNotifyAddress = "";
public string MapViewSearchAssetsApiAddress = "";
public string MapViewQueryViewAssetsApiAddress = "";
private string Logo1html = "<img class=\"logo\" src=\"{0}\" style=\"width:24px;height:24px; \" />";
protected string Logo1 = "";
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();
if (!Request.Url.AbsoluteUri.Contains("localhost") && "https".Equals(Request.Url.Scheme, StringComparison.OrdinalIgnoreCase))
{
MSGWebSocketURL = SystemParams.CurrentCustomerParams.WebSocketURL + "?custid=" + SystemParams.CompanyID + "&msgcodes=200,201";
MapViewSearchAssetsApiAddress = SystemParams.CurrentCustomerParams.MapViewSearchAssetsApiAddress;
MapViewQueryViewAssetsApiAddress = SystemParams.CurrentCustomerParams.MapViewQueryViewAssetsApiAddress;
if (!MSGWebSocketURL.Contains("soft.rz"))
{
AiNotifyAddress = SystemParams.CurrentCustomerParams.AiNotifyAddress;
}
}
}
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);
}
}
}
public bool IsDealer
{
get
{
return SystemParams.IsDealer;
}
}
public string CompanyID
{
get
{
return SystemParams.CompanyID;
}
}
public bool CanEditAsset
{
get
{
//var user = GetCurrentUser();
bool permission = CheckRight(SystemParams.CompanyID, Feature.MANAGE_ASSETS);
return permission;
}
}
public bool CanEditJobsite
{
get
{
bool jslic = SystemParams.HasLicense("JobSites");
bool permission = CheckRight(SystemParams.CompanyID, Feature.JOB_SITES);
return !SystemParams.IsDealer && jslic && 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 CanViewInspection
{
get
{
bool lic = SystemParams.HasLicense("Inspection");
bool permission = CheckRight(SystemParams.CompanyID, Feature.INSPECTION_TEMPLATES);
return !SystemParams.IsDealer && lic && permission;
}
}
public bool IsSupperAdmin
{
get
{
var user = GetCurrentUser();
return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
}
}
public bool CanAjdustAttr
{
get
{
return CheckRight(SystemParams.CompanyID, Foresight.Fleet.Services.User.Feature.ASSET_ATTRIBUTE_ADJUSTMENT);
}
}
public bool EnableRouteOptimization
{
get
{
bool lic = SystemParams.HasLicense("RouteOptimization");
return lic;
}
}
}