protected void Page_Load(object sender, EventArgs e)
    {
        ActivateService acs   = new ActivateService();
        AdminService    admin = new AdminService();

        try
        {
            bool stat = admin.isAdmin(Session["username"].ToString());

            if (!stat)
            {
                Response.Redirect("../logout.aspx");
            }
        }
        catch (Exception ex)
        {
            ErrorLog err = new ErrorLog(ex);
            Response.Redirect("../logout.aspx");
        }
    }
Exemple #2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        ibox.msg = "";
        //check if the Rating is still active
        ActivateService acs   = new ActivateService();
        AdminService    admin = new AdminService();

        string une = txtUne.Text.Trim();

        if (une == "")
        {
            ibox.css = false;
            ibox.msg = "Enter your username";
            return;
        }

        if (txtPwd.Text == "")
        {
            ibox.css = false;
            ibox.msg = "Enter your password";
            return;
        }

        bool stat = admin.isAdmin(txtUne.Text);

        if (!acs.Activestate() && !stat)//if rating is closed and the user is not admin
        {
            ibox.msg = "Sorry Rating has been closed by the Administrator.";
            ibox.css = false;
            return;
        }
        StaffService ss = new StaffService();

        try
        {
            if (ss.login(une, txtPwd.Text))
            {
                //get staff department
                Staff st = ss.getUserDetails(une);

                //ensure temp staff are not able to logon
                if (st.description == "Temp")
                {
                    ibox.css = false;
                    ibox.msg = "Sorry, Temporary staffs are not allowed on this platform.";
                    return;
                }

                Session["username"] = une;
                Session["fullname"] = st.fullName;

                Session["deptname"] = st.deptName;
                Rating        r  = new Rating();
                RatingService rs = new RatingService();

                string username = Session["username"].ToString();
                Session["currUser"] = une;
                Response.Redirect("myprofile.aspx");
            }
            else
            {
                ibox.css = false;
                ibox.msg = ss.err;
            }
        }
        catch (Exception ex)
        {
            ErrorLog err = new ErrorLog(ex);
        }
    }
 public void Init()
 {
     service = new ActivateService(testUtils.GetConsumerKey(), testUtils.GetPrivateKey(), Environments.Environment.SANDBOX);
 }