2020-06-09 15:58:22 +08:00

279 lines
11 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using Foresight.Data;
using Foresight.Fleet.Services.User;
namespace IronIntel.Contractor.Users
{
public class AppModuleInfo
{
public string ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool Visible { get; set; }
public string Url { get; set; }
public string IconPath { get; set; }
public string BackColor { get; set; }
public string ForeColor { get; set; }
public bool OpenInNewWindow { get; set; }
public AppModuleType ModuleType { get; set; }
public List<NavigateItem> SubItems { get; set; }
public List<NavigateItem> GetMaintenanceNavigateItems(Tuple<Feature, Permissions>[] pmss)
{
List<NavigateItem> list = new List<NavigateItem>();
NavigateItem item = new NavigateItem();
item.ID = "nav_alertsmanagement";
item.FeatureID = Feature.ALERTS_MANAGEMENT;
item.Title = "Alerts Management **New**";
item.Url = Url + "#" + item.ID;
item.PageUrl = "AlertsManagement.aspx";
item.IconPath = "img/alert.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.ALERTS_MANAGEMENT) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_workorder";
item.FeatureID = Feature.WORK_ORDER;
item.Title = "Work Order **New**";
item.Url = Url + "#" + item.ID;
item.PageUrl = "WorkOrderMaintenance.aspx";
item.IconPath = "img/workorder.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.WORK_ORDER) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_preventative";
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
item.Title = "Absolute Hours Maintenance";
item.Url = Url + "#" + item.ID;
item.PageUrl = "PreventativeMaintenance.aspx";
item.IconPath = "img/preventative.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_timebased";
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
item.Title = "Relative Time Maintenance";
item.Url = Url + "#" + item.ID;
item.PageUrl = "TimeBasedMaintenance.aspx";
item.IconPath = "img/timebased.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_hours";
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
item.Title = "Relative Hours Maintenance";
item.Url = Url + "#" + item.ID;
item.PageUrl = "HoursMaintenance.aspx";
item.IconPath = "img/hours.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_absolutedistance";
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
item.Title = "Absolute Distance Maintenance";
item.Url = Url + "#" + item.ID;
item.PageUrl = "AbsoluteDistanceMaintenance.aspx";
item.IconPath = "img/preventative.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
list.Add(item);
item = new NavigateItem();
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
item.ID = "nav_relativedistance";
item.Title = "Relative Distance Maintenance";
item.Url = Url + "#" + item.ID;
item.PageUrl = "RelativeDistanceMaintenance.aspx";
item.IconPath = "img/hours.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_record";
item.FeatureID = Feature.PREVENTATIVE_MAINTENANCE;
item.Title = "Maintenance Record **Legacy**";
item.Url = Url + "#" + item.ID;
item.PageUrl = "MaintanceRecordsManagement.aspx";
item.IconPath = "img/record.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.PREVENTATIVE_MAINTENANCE) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_fuelrecord";
item.FeatureID = Feature.FUEL_RECORDS;
item.Title = "Fuel Records";
item.Url = Url + "#" + item.ID;
item.PageUrl = "FuelRecordManagement.aspx";
item.IconPath = "img/fuelrecord.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.FUEL_RECORDS) != null)
list.Add(item);
return list;
}
public List<NavigateItem> GetSecurityNavigateItems(Tuple<Feature, Permissions>[] pmss, UserInfo user)
{
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.USERS) == null)
return null;
List<NavigateItem> list = new List<NavigateItem>();
NavigateItem item = new NavigateItem();
item.ID = "nav_users";
item.FeatureID = Feature.USERS;
item.Title = "Users";
item.Url = Url + "#" + item.ID;
item.PageUrl = "UserManage.aspx";
item.IconPath = "img/users.png";
list.Add(item);
item = new NavigateItem();
item.ID = "nav_user_group";
item.Title = "User Group";
item.Url = Url + "#" + item.ID;
item.PageUrl = "UserGroup.aspx";
item.IconPath = "img/usergroup.png";
list.Add(item);
item = new NavigateItem();
item.ID = "nav_dts";
item.Title = "DataTable Permission";
item.Url = Url + "#" + item.ID;
item.PageUrl = "../fic/fic/Management/DataTablePermission.aspx";
//item.IconPath = "img/permission.png";
list.Add(item);
item = new NavigateItem();
item.ID = "nav_filters";
item.Title = "Dashboard Filters";
item.Url = Url + "#" + item.ID;
item.PageUrl = "../fic/fic/Management/FiltersManagement.aspx";
item.IconPath = "img/filters.png";
list.Add(item);
if (IronIntel.Contractor.SystemParams.IsDealer)
{
item = new NavigateItem();
item.ID = "nav_usertocontractor";
item.Title = "User To Contractor";
item.Url = Url + "#" + item.ID;
item.PageUrl = "UserToContractorPage.aspx";
item.IconPath = "img/contractor.png";
list.Add(item);
}
item = new NavigateItem();
item.ID = "nav_curfew";
item.FeatureID = Feature.CURFEW_CONFIG;
item.Title = "Curfew Configuration";
item.Url = Url + "#" + item.ID;
item.PageUrl = "CurfewManage.aspx";
item.IconPath = "img/curfew.png";
list.Add(item);
if (user.UserType == UserTypes.SupperAdmin)
{
item = new NavigateItem();
item.ID = "nav_curfewmt";
item.FeatureID = Feature.CURFEW_CONFIG;
item.Title = "Curfew Movement Tolerance";
item.Url = Url + "#" + item.ID;
item.PageUrl = "CurfewMovementTolerance.aspx";
item.IconPath = "img/curfewmovementtolerance.png";
list.Add(item);
}
return list;
}
public List<NavigateItem> GetAssetsNavigateItems(Tuple<Feature, Permissions>[] pmss, UserInfo user)
{
List<NavigateItem> list = new List<NavigateItem>();
NavigateItem item = new NavigateItem();
item.ID = "nav_managmachines";
item.FeatureID = Feature.MANAGE_ASSETS;
item.Title = "Manage Assets";
item.Url = Url + "#" + item.ID;
item.PageUrl = "ManageMachines.aspx";
item.IconPath = "img/machines.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.MANAGE_ASSETS) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_managrentals";
item.FeatureID = Feature.MANAGE_ASSETS;
item.Title = "Manage Rentals";
item.Url = Url + "#" + item.ID;
item.PageUrl = "ManageRentals.aspx";
item.IconPath = "img/rental.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.MANAGE_ASSETS) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_machinegroups";
item.FeatureID = Feature.ASSET_GROUP;
item.Title = "Asset Groups";
item.Url = Url + "#" + item.ID;
item.PageUrl = "MachineGroups.aspx";
item.IconPath = "img/machinegroups.png";
if (!IronIntel.Contractor.SystemParams.IsDealer && user.UserType >= UserTypes.Admin)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_managegpsdevices";
item.FeatureID = Feature.MANAGE_DEVICES;
item.Title = "Manage Devices";
item.Url = Url + "#" + item.ID;
item.PageUrl = "ManageGPSDevices.aspx";
item.IconPath = "img/devices.png";
if (pmss.FirstOrDefault(m => m.Item1.Id == Feature.MANAGE_DEVICES) != null)
list.Add(item);
item = new NavigateItem();
item.ID = "nav_managmodels";
item.Title = "Manage Models";
item.Url = Url + "#" + item.ID;
item.PageUrl = "ManageModels.aspx";
item.IconPath = "img/model.png";
if (user.UserType >= UserTypes.Admin)
list.Add(item);
return list;
}
}
public class NavigateItem
{
public string ID { get; set; }
public int FeatureID { get; set; }
public string Title { get; set; }
public string Url { get; set; }
public string PageUrl { get; set; }
public string IconPath { get; set; }
}
public class SecurityNavigateItem
{
public string ID { get; set; }
public string Title { get; set; }
public string Url { get; set; }
public string IconPath { get; set; }
}
public enum AppModuleType
{
System,
Workspace
}
}