using DocumentFormat.OpenXml.Wordprocessing; using Foresight.Fleet.Services.Asset; using Foresight.Fleet.Services.Customer; using Foresight.Fleet.Services.Styles; 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.Drawing; 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 = ""; protected string Logo1 = ""; public string CurrentDate = ""; protected string StyleVariables = ""; 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); GetUIStyle(); } } 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("
{0}
", 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("
{0}
", 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; } } protected StyleInfo GetUIStyle() { var sessionid = IronIntelBasePage.GetLoginSessionID(Request); var user = UserManagement.GetUserBySessionID(sessionid); CustUIStyle style = null; if (user != null) { style = SystemParams.GetUIStyle(user.IID); string color; if (style != null) { color = style.TitleBarColor; } else { color = "#f78e1e"; } string opacity; string fore; string ctrlbgcolor = "lightgray"; try { var c = ColorTranslator.FromHtml(color); opacity = string.Format("rgb({0} {1} {2}/60%)", c.R, c.G, c.B); var g = .299 * c.R + .587 * c.G + .114 * c.B; fore = g < 127.5 ? "#f0f0f0" : "#0f0f0f"; ctrlbgcolor = g < 221 ? color : "lightgray";//221为light的计算值 } catch { opacity = "rgb(247 142 30/60%)"; fore = "#0f0f0f"; ctrlbgcolor = "lightgray"; } StyleVariables = string.Format("--title-color: {0}; --title-bg-color: {1}; --title-bg-opacity-color: {2};--title-ctrlbg-color: {3}; ", fore, color, opacity, ctrlbgcolor); } return new StyleInfo { User = user, Style = style }; } }