2023-04-28 12:21:24 +08:00

64 lines
2.0 KiB
C#

using IronIntel.Contractor.Users;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IronIntel.Contractor.Site.Security
{
public class SecurityBasePage : ContractorBasePage
{
protected void ProcessRequest(string methodName)
{
object result = null;
if (methodName != null)
{
switch (methodName.ToUpper())
{
case "GETNAVS":
result = GetNavigations();
break;
}
}
string json = JsonConvert.SerializeObject(result);
Response.Write(json);
Response.End();
}
private SecurityNavigateItem[] GetNavigations()
{
var user = GetCurrentUser();
List<SecurityNavigateItem> list = Acl.GetSecurityNavigateItems(user).ToList();
Foresight.Fleet.Services.Customer.LicenseInfo license = SystemParams.GetLicense();
if (license != null && license.Items.Count > 0)
{
Foresight.Fleet.Services.Customer.LicenseItem li = license.Items.FirstOrDefault(m => m.Key == "CurfewConfiguration");
if (li == null || !Helper.IsTrue(li.Value))
{
SecurityNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_curfew");
if (item != null)
list.Remove(item);
item = list.FirstOrDefault(m => m.ID == "nav_curfewmt");
if (item != null)
list.Remove(item);
}
if (user.UserType != UserTypes.SupperAdmin)
{
SecurityNavigateItem item = list.FirstOrDefault(m => m.ID == "nav_curfewmt");
if (item != null)
list.Remove(item);
}
}
return list.ToArray();
}
}
}