fleet-contractor/Site/IronIntelMasterPage.master.cs
2023-04-28 12:22:26 +08:00

173 lines
5.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using FI.FIC;
using Foresight.Fleet.Services.Customer;
using Foresight.Fleet.Services.Styles;
using Foresight.ServiceModel;
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 IronIntelMasterPage : CommonBase
{
protected string CompanyTitle;
private string Logo1html = "<img class=\"logo\" src=\"{0}\" style=\" \" />";
private string Logo2html = "<img class=\"logocenter\" src=\"{0}\" style=\" \" />";
private string Logo3html = "<img class=\"logoright\" src=\"{0}\" style=\" \" />";
protected string Logo1 = "";
protected string Logo2 = "";
protected string Logo3 = "";
protected string JQueryVersion;
protected string MenuBackgroundColor = "#D7690E";
protected string TitleBarBorderColor = "#FFFFFF";
protected string CompanyID;
protected string UserID;
protected bool IsReadonlyUser;
protected bool CanSeeUserMessage;
protected override bool ExportModule
{
get { return true; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
var cmp = SystemParams.GetCompanyInfo();
CompanyTitle = cmp.Name;
GetLogoHtml(cmp);
GetUIStyle();
GetMainStyle();
}
catch
{
// TODO: errors when get the company name.
}
if (this.Page is IronIntel.Contractor.Site.ContractorBasePage)
{
JQueryVersion = ((IronIntel.Contractor.Site.ContractorBasePage)this.Page).JQueryVersion;
}
}
}
private void GetLogoHtml(CustomerInfo cmp)
{
var root = ResolveUrl("~/");
var sessionid = IronIntelBasePage.GetLoginSessionID(Request);
StringKeyValue kv = UserManagement.GetSiteHederStyleLogo(sessionid);
string styleid = "-1";
bool hasContractorLogo = false;
bool hasDealerLogo = false;
if (kv != null)
{
styleid = kv.Key;
hasContractorLogo = Helper.IsTrue(kv.Tag1);
hasDealerLogo = Helper.IsTrue(kv.Tag2);
}
if (cmp.IsContractor)
{//Logo1 Dealer;Logo2 Contractor(Self)Logo3 IronIntel
CustomerInfo dealer = SystemParams.GetFirstDealerInfo();
if (dealer != null)
{
if (hasDealerLogo)//user Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?cmpid=" + dealer.ID + "&cmpty=dealer&styid=" + styleid);
}
else if (SystemParams.HasLOGO(dealer.ID))//Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?cmpid=" + dealer.ID);
}
else
{
Logo1 = string.Format("<div class=\"logo\">{0}</div>", dealer.Name);
}
}
else
{
Logo1 = string.Empty;
}
if (hasContractorLogo)//User Contractor
{
Logo2 = string.Format(Logo2html, root + "titlelogo.ashx?cmpid=" + cmp.ID + "&cmpty=contractor&styid=" + styleid);
}
else if (SystemParams.HasLOGO(cmp.ID))//Contractor
{
Logo2 = string.Format(Logo2html, root + "titlelogo.ashx?cmpid=" + cmp.ID);
}
else
{
Logo2 = string.Format("<span class=\"logocenter\">{0}</span>", cmp.Name);
}
if (SystemParams.ShowForesightLogo())
Logo3 = string.Format(Logo3html, root + "titlelogo.ashx?cmpid=foresight");
}
else
{//Logo1 Dealer(Self);Logo3 IronIntel
if (hasDealerLogo)//user Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?cmpid=" + cmp.ID + "&cmpty=dealer&styid=" + styleid);
}
else if (SystemParams.HasLOGO(cmp.ID))//Dealer
{
Logo1 = string.Format(Logo1html, root + "titlelogo.ashx?cmpid=" + cmp.ID);
}
else
{
Logo1 = string.Format("<div class=\"logo\">{0}</div>", cmp.Name);
}
Logo2 = "";
if (SystemParams.ShowForesightLogo())
Logo3 = string.Format(Logo3html, root + "titlelogo.ashx?cmpid=foresight");
}
}
protected override StyleInfo GetUIStyle()
{
var info = base.GetUIStyle();
var user = info.User;
if (user != null)
{
UserID = user.ID;
IsReadonlyUser = user.UserType == UserTypes.Readonly;
CanSeeUserMessage = user.UserType == UserTypes.Common || user.UserType == UserTypes.Admin;
var style = info.Style;
if (style != null)
{
if (!string.IsNullOrEmpty(style.MenuBackgroundColor))
{//目前Menu和Module背景色使用同一个颜色,在有设置的情况下
MenuBackgroundColor = style.MenuBackgroundColor;
}
}
}
CompanyID = SystemParams.CompanyID;
return info;
}
private void GetMainStyle()
{
var ms = SystemParams.GetMainStyle();
if (ms != null && !string.IsNullOrEmpty(ms.TitleBarBorderColor))
{
TitleBarBorderColor = ms.TitleBarBorderColor;
}
}
}