fleet-contractor/Site/Inspection/FuelReport.aspx.cs
2023-04-28 12:22:26 +08:00

120 lines
4.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Foresight.Fleet.Services.Customer;
using Foresight.Fleet.Services.Inspection;
using Foresight.Fleet.Services.User;
using Foresight.ServiceModel;
using IronIntel.Contractor;
using IronIntel.Contractor.iisitebase;
using IronIntel.Contractor.Site;
using IronIntel.Contractor.Users;
public partial class FuelReport : InspectionBasePage
{
protected string ReportID;
protected bool TeamIntelligence = false;
public bool ReportReadonly = false;
private string Logo2html = "<img class=\"img-logo\" src=\"{0}\" style=\" \" />";
protected string Logo2 = "";
protected void Page_Load(object sender, EventArgs e)
{
CheckUserToken();
if (!CheckLoginSession())
{
RedirectToLoginPage();
}
else
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest(methodName);
}
else if (!IsPostBack)
{
var cmp = SystemParams.GetCompanyInfo();
this.Title = PageTitle;
ReportID = Request.Params["rid"];
TeamIntelligence = Helper.IsTrue(Request.Params["team"]);
if (!string.IsNullOrEmpty(ReportID))
{
object ii = GetFuelReportItem(Convert.ToInt64(ReportID));
if (ii == null)
{//没有权限或ID不正确
Response.Write("You have no right to access the fuel report.");
Response.End();
}
//if (ii is TeamInspectItem)
// TeamIntelligence = true;
//ReportReadonly = Helper.IsTrue(Request.Params["ro"]);
//if (!ReportReadonly)
//{
// var user = GetCurrentUser();
// if (user.UserType == IronIntel.Contractor.Users.UserTypes.Common)
// {
// var client = FleetServiceClientHelper.CreateClient<PermissionProvider>();
// Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID);
// if (pmss.Length > 0)
// {
// Tuple<Feature, Permissions> reportpms = null;
// if (TeamIntelligence)
// reportpms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.TEAM_REPORTS);
// else
// reportpms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.INSPECTION_REPORTS);
// if (reportpms == null || reportpms.Item2 == Permissions.ReadOnly)
// ReportReadonly = true;
// }
// }
//}
}
GetLogoHtml(cmp);
}
}
}
private void GetLogoHtml(CustomerInfo cmp)
{
var root = ResolveUrl("~/");
var sessionid = GetLoginSessionID(Request);
StringKeyValue kv = UserManagement.GetSiteHederStyleLogo(sessionid);
string styleid = "-1";
bool hasContractorLogo = false;
if (kv != null)
{
styleid = kv.Key;
hasContractorLogo = Helper.IsTrue(kv.Tag1);
}
if (cmp.IsContractor)
{
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);
}
}
}
protected override bool CanDirectAccess
{
get
{
return true;
}
}
}