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 = ""; private string Logo1html = ""; 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(); MSGWebSocketURL = SystemParams.WebSocketURL + "&msgcodes=200,201"; } 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("
{0}
", 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("
{0}
", cmp.Name); } } } 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; } } }