using Foresight.Fleet.Services.User;
using Foresight.ServiceModel;
using IronIntel.Contractor;
using IronIntel.Contractor.Site.Maintenance;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AlertAutomationManagement : AlertsBasePage
{
    public bool AllowWorkOrderGenerator = false;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckLoginSession())
        {
            RedirectToLoginPage();
        }
        else
        {
            string methodName = Request.Form["MethodName"];
            if (!string.IsNullOrEmpty(methodName))
            {
                ProcessRequest(methodName);
            }
            else if (!IsPostBack)
            {
                this.Title = PageTitle;
                bool license = SystemParams.HasLicense("AlertsManagement");
                if (!license)
                    RedirectToLoginPage();

                bool permission = CheckRight(SystemParams.CompanyID, Feature.ALERTS_MANAGEMENT);
                if (!permission)
                    RedirectToLoginPage();

                AllowWorkOrderGenerator = CheckRight(SystemParams.CompanyID, Feature.WORKORDERGENERATOR);
            }
        }
    }

    public bool IsSupperAdmin
    {
        get
        {
            var user = GetCurrentUser();
            return user.UserType == IronIntel.Contractor.Users.UserTypes.SupperAdmin;
        }
    }
}