protected void LoginButton_ServerClick(object sender, EventArgs e)
        {
            string username, password;
            bool rememberme;
            if (RememberMeCheckBox.Checked == true)
            {
                rememberme = true;
            }
            else
            {
                rememberme = false;
            }
            username = Request.Form["UserName"];
            password = Request.Form["Password"];
            rememberme = Convert.ToBoolean(Request.Form["RememberMe"]);
            int userId = 0;
            string name = string.Empty;
            string roles = string.Empty;
            string constr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("Validate_User"))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@Username", username);
                    cmd.Parameters.AddWithValue("@Password", password);
                    cmd.Connection = con;
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    reader.Read();
                    userId = Convert.ToInt32(reader["UserId"]);
                    name = reader["actualname"].ToString();
                    roles = reader["Roles"].ToString();
                    RoleClass r = new RoleClass();
                    //r.SetRole(roles);
                    con.Close();
                }
                switch (userId)
                {
                    case -1:
                        //FailureText.Text = "Username and/or password is incorrect.";
                        break;
                    default:
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddMinutes(2880), rememberme, roles, FormsAuthentication.FormsCookiePath);
                        string hash = FormsAuthentication.Encrypt(ticket);
                        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);

                        if (ticket.IsPersistent)
                        {
                            cookie.Expires = ticket.Expiration;
                        }
                        Response.Cookies.Add(cookie);
                        Response.Redirect(FormsAuthentication.GetRedirectUrl(username, rememberme));
                        break;

                        //FormsAuthentication.RedirectFromLoginPage(name, rememberme);
                        //break;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private RoleClass GetRole()
        {
            int       roleValue = Convert.ToInt32(this.ddlRole.SelectedValue);
            RoleClass r         = new RoleClass(roleValue);

            return(r);
        }
Beispiel #3
0
    /// <summary>
    /// 创建一个GameObject
    /// </summary>
    public void CreateGameObject()
    {
        if (rolePrefab == null)
        {
            return;
        }

        GameObject createObj = GameObject.Instantiate <GameObject>(rolePrefab);
        RoleClass  r1        = createObj.AddComponent <RoleClass>();

        roleList.Add(r1);
        //位置排序
        if (roleList.Count > 1)
        {
            float   sx = -(float)roleList.Count / 2 + 0.5f;
            Vector3 p1 = Vector3.zero;
            for (var i = 0; i < roleList.Count; i++)
            {
                p1.x = sx + (i);
                roleList[i].transform.position = p1;
            }
        }
        //增加到lua容器
        var luaFun = _luaRoleMgr.GetLuaFunction("AddRoleClass");

        if (luaFun == null)
        {
            Debugger.LogError("找不到AddRoleClass");
            return;
        }
        luaFun.Call(createObj);
    }
Beispiel #4
0
        public ActionResult Edit(RoleClass role)
        {
            RoleList roleList = new RoleList();

            roleList.UpdateRole(role);
            return(RedirectToAction("Index"));
        }
 protected void LogIn(object sender, EventArgs e)
 {
     int userId = 0;
         string name = string.Empty;
         string roles = string.Empty;
         string constr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
         using (SqlConnection con = new SqlConnection(constr))
         {
             using (SqlCommand cmd = new SqlCommand("Validate_User"))
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@Username", UserName.Text);
                 cmd.Parameters.AddWithValue("@Password", Password.Text);
                 cmd.Connection = con;
                 con.Open();
                 SqlDataReader reader = cmd.ExecuteReader();
                 reader.Read();
                 userId = Convert.ToInt32(reader["UserId"]);
                 name = reader["actualname"].ToString();
                 roles = reader["Roles"].ToString();
                 RoleClass r = new RoleClass();
                 r.SetRole(roles);
                 con.Close();
             }
             switch (userId)
             {
                 case -1:
                     FailureText.Text = "Username and/or password is incorrect.";
                     break;
                 default:
                     FormsAuthentication.RedirectFromLoginPage(name, RememberMe.Checked);
                     break;
             }
         }
 }
Beispiel #6
0
        public ActionResult Delete(RoleClass role)
        {
            RoleList accList = new RoleList();

            accList.DeleteRole(role);
            return(RedirectToAction("Index"));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     RoleClass r = new RoleClass();
     if (r.GetModalDisplay() == 1)
     {
         ErrorPanel.Visible = true;
     }
 }
    protected void CloseButton_Click(object sender, EventArgs e)
    {
        RoleClass r = new RoleClass();

        r.SetModalDisplay(0);

        ErrorPanel.Visible = false;
    }
Beispiel #9
0
 public spellRow(Nr3 nr, RoleClass roleClass, KeyRep keyRep, Action <Vector3, GameObject> spell, float castTime, float cooldown)
 {
     this.nr        = nr;
     this.roleClass = roleClass;
     this.keyRep    = keyRep;
     this.spell     = spell;
     this.castTime  = castTime;
     this.cooldown  = cooldown;
 }
Beispiel #10
0
 public ActionResult Create(RoleClass role)
 {
     if (ModelState.IsValid)
     {
         RoleList accList = new RoleList();
         accList.AddRole(role);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Beispiel #11
0
    public static Action <Vector3, GameObject> index(Nr3 nr, RoleClass roleclass, KeyRep keyrep)
    {
        IQueryable <Action <Vector3, GameObject> > quary = from spellRow row
                                                           in FullSpellBook
                                                           where row.roleClass == roleclass &&
                                                           row.nr == nr &&
                                                           row.keyRep == keyrep
                                                           select row.spell;

        return(quary.First()); // get first spell in resulting table or crash if none exist.
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.User.Identity.IsAuthenticated)
        {
            FormsAuthentication.RedirectToLoginPage();
        }

        RoleClass r = new RoleClass();

        if (Context.User.Identity.Name == "Rabia Aslam" || Context.User.Identity.Name == "Junaid Sultan" || Context.User.Identity.Name == "Nasir Ismail" || Context.User.Identity.Name == "Ahmed Ali")
        { }
        else
        {
            r.SetModalDisplay(1);
            Response.Redirect("~/Default.aspx");
        }
    }
Beispiel #13
0
        public static BasicPersonRole[] Select (int personId, RoleClass roleClass)
        {
            BasicAuthority authority = Authorization.GetPersonAuthority (personId);

            switch (roleClass)
            {
                case RoleClass.System:
                    return authority.SystemPersonRoles;

                case RoleClass.Organization:
                    return authority.OrganizationPersonRoles;

                case RoleClass.Local:
                    return authority.LocalPersonRoles;

                default:
                    throw new InvalidOperationException ("Undefined RoleClass in RolesDataObject.Select: " + roleClass);
            }
        }
Beispiel #14
0
        public ActionResult RoleList()
        {
            var roleList = new List <RoleClass>();
            var roles    = _Context.Roles.Select(x => x).ToList();

            foreach (var item in roles)
            {
                var rm = new RoleClass();
                rm.RoleId   = item.PK_RoleID;
                rm.RoleName = item.RoleName;
                roleList.Add(rm);
            }

            TempData["IsCreate"] = HttpContext.Items["IsCreate"];
            TempData["IsUpdate"] = HttpContext.Items["IsUpdate"];
            TempData["IsDelete"] = HttpContext.Items["IsDelete"];

            return(View(roleList));
        }
Beispiel #15
0
        // GET: Accounts
        public ActionResult Index(string strSearch)
        {
            RoleClass roleDDL = new RoleClass();

            using (DbModel db = new DbModel())
            {
                roleDDL.Id_Role = db.StoreModel.
            }

            AccountList         accList = new AccountList();
            List <AccountClass> obj     = accList.GetAccountClass(string.Empty).OrderBy(x => x.Id_Account).ToList();

            if (!string.IsNullOrEmpty(strSearch))
            {
                obj = obj.Where(x => x.Account.Contains(strSearch) || x.Password.Contains(strSearch) || x.Role.Contains(strSearch)).ToList();
            }
            @ViewBag.strSearch = strSearch;
            return(View(obj));
        }
Beispiel #16
0
        public static BasicPersonRole[] Select(int personId, RoleClass roleClass)
        {
            BasicAuthority authority = Authorization.GetPersonAuthority(personId);

            switch (roleClass)
            {
            case RoleClass.System:
                return(authority.SystemPersonRoles);

            case RoleClass.Organization:
                return(authority.OrganizationPersonRoles);

            case RoleClass.Local:
                return(authority.LocalPersonRoles);

            default:
                throw new InvalidOperationException("Undefined RoleClass in RolesDataObject.Select: " + roleClass);
            }
        }
Beispiel #17
0
        public ActionResult AddEditRole(int id = 0)
        {
            var       aerm          = new AddEditRoleModel();
            RoleClass Role          = new RoleClass();
            var       PrivilegeList = new List <PrivilegeClass>();

            if (id != 0)
            {
                var roleDetail = _Context.Roles.Where(x => x.PK_RoleID == id).Select(x => x).FirstOrDefault();
                Role.RoleName = roleDetail.RoleName;
                Role.RoleId   = roleDetail.PK_RoleID;
                aerm.Role     = Role;
                var userRolePrivileges = _Context.UserRolePrivileges.Where(x => x.FK_RoleID == id).Select(x => x).ToList();
                var privileges         = _Context.Privileges.Select(x => new { x.PK_PrivilegeID, x.PrivilegeName }).ToList();
                foreach (var item in userRolePrivileges)
                {
                    var previlege = new PrivilegeClass();
                    previlege.PrivilegeId   = item.FK_PrivilegeID;
                    previlege.PrivilegeName = privileges.Where(x => x.PK_PrivilegeID == item.FK_PrivilegeID).Select(x => x.PrivilegeName).FirstOrDefault();
                    previlege.IsView        = item.IsView;
                    previlege.IsCreate      = item.IsCreate;
                    previlege.IsUpdate      = item.IsUpdate;
                    previlege.IsDelete      = item.IsDelete;

                    PrivilegeList.Add(previlege);
                }
                aerm.PrivilegeList = PrivilegeList;
            }
            else
            {
                var privileges = _Context.Privileges.Select(x => x).ToList();
                foreach (var item in privileges)
                {
                    var previlege = new PrivilegeClass();
                    previlege.PrivilegeId   = item.PK_PrivilegeID;
                    previlege.PrivilegeName = item.PrivilegeName;
                    PrivilegeList.Add(previlege);
                }
                aerm.PrivilegeList = PrivilegeList;
            }
            return(View(aerm));
        }
Beispiel #18
0
 public virtual void SetRoleClass(RoleClass roleClass)
 {
     this.roleClass.Value = roleClass;
 }
Beispiel #19
0
 public static string GetSpriteNameOfRoleClass(RoleClass roleClass)
 {
     return(RoleClassSpriteName[(int)roleClass]);
 }
Beispiel #20
0
 public static BasicPersonRole[] Select(Person person, RoleClass roleClass)
 {
     return(Select(person.Identity, roleClass));
 }
Beispiel #21
0
 public static BasicPersonRole[] Select (Person person, RoleClass roleClass)
 {
     return Select (person.Identity, roleClass);
 }