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

75 lines
2.4 KiB
C#

using Foresight.Fleet.Services.User;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.JobSite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class JobSiteManage : JobSitesBasePage
{
protected bool CanConfig = false;
protected void Page_Load(object sender, EventArgs e)
{
string methodName = Request.Form["MethodName"];
if (!string.IsNullOrEmpty(methodName))
{
ProcessRequest();
}
else if (!IsPostBack)
{
Title = PageTitle;
if (CheckLoginSession())
{
bool license = SystemParams.HasLicense("JobSites");
bool permission = CheckRight(SystemParams.CompanyID, Feature.JOB_SITES);
if (!license || !permission)
RedirectToEntryPage();
bool autoCreate = SystemParams.HasLicense("AutoCreationConfig");
var user = GetCurrentUser();
if (autoCreate)
{
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin)
{
CanConfig = true;
}
else
{
var client = FleetServiceClientHelper.CreateClient<PermissionProvider>();
Tuple<Feature, Permissions>[] pmss = client.GetUserPermissions(SystemParams.CompanyID, user.IID);
if (pmss.Length > 0)
{
Tuple<Feature, Permissions> autojobsitespms = pmss.FirstOrDefault(m => m.Item1.Id == Feature.JOB_SITES_AUTOCREATE);
if (autojobsitespms != null)
{
CanConfig = true;
}
}
}
}
}
}
}
protected override int FeatureID
{
get
{
return Foresight.Fleet.Services.User.Feature.JOB_SITES;
}
}
public bool IsAdmin
{
get
{
var user = GetCurrentUser();
if (user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin || user.UserType == IronIntel.Contractor.Users.UserTypes.Admin)
return true;
else
return false;
}
}
}