Example #1
0
        private void Edit()
        {
            // 记录历史
            var his = new TB_AccountHistory();

            his.Account  = Account.id;
            his.ActionId = ActionInstance.Find(f => f.Name.Equals("EditRole")).id;
            his.Ip       = Utility.GetClientIP(this.Context);

            var id   = int.Parse(Utility.Decrypt(hidID.Value));
            var role = RoleInstance.Find(f => f.id == id && f.Delete == false);

            role.Description     = txtDescription.Value.Trim();
            role.IsAdministrator = cbIsAdmin.Checked;
            role.IsDefault       = cbIsDefault.Checked;
            var name = txtName.Value.Trim();

            if (!role.Name.Equals(name))
            {
                his.ObjectA = "[id=" + role.id + "] " + role.Name + " to " + name;
            }
            else
            {
                his.ObjectA = "[id=" + role.id + "] " + role.Name;
            }
            role.Name = name;
            Update(role);

            SaveHistory(his);

            ShowNotification("./role_list.aspx", "Success: You have changed role \"" + role.Name + "\".", true);
        }
Example #2
0
 public TempAsHistory(TB_AccountHistory entity)
 {
     Time        = null == entity.ActionTime ? "-" : entity.ActionTime.Value.ToString("yyyy/MM/dd HH:mm:ss");
     User        = entity.TB_Account.Name;
     Action      = entity.TB_AccountAction.Name;
     Description = entity.ObjectA;
 }
Example #3
0
        protected void btSave_Click(object sender, EventArgs e)
        {
            var role = GetRole();

            if (null != role)
            {
                string rights = "";
                foreach (TreeNode tn in tvMenus.CheckedNodes)
                {
                    var id = tn.NavigateUrl.Replace("#", "");
                    rights += "" == rights ? id : ("," + id);
                }
                RoleInstance.Update(f => f.id == role.id && f.Delete == false, action =>
                {
                    action.Permission = rights;
                });

                // 记录历史
                var his = new TB_AccountHistory();
                his.ActionId = ActionInstance.Find(f => f.Name.Equals("RolePermission")).id;
                his.Ip       = Utility.GetClientIP(this.Context);
                his.ObjectA  = "[id=" + role.id + "] " + role.Name;
                SaveHistory(his);

                ShowNotification("./role_list.aspx", "You have changed permission of role \"" + role.Name + "\".");
            }
        }
Example #4
0
 /// <summary>
 /// 保存历史记录
 /// </summary>
 /// <param name="obj"></param>
 protected void SaveHistory(TB_AccountHistory obj)
 {
     obj.ActionTime = DateTime.Now;
     if (obj.Account <= 0 || (int?)null == obj.Account)
     {
         obj.Account = Account.id;
     }
     obj.Ip = Utility.GetClientIP(this.Context);
     HistoryInstance.Add(obj);
 }
Example #5
0
 /// <summary>
 /// 保存历史记录
 /// </summary>
 /// <param name="obj"></param>
 protected void SaveHistory(TB_AccountHistory obj)
 {
     using (var bll = new HistoryBLL())
     {
         obj.ActionTime = DateTime.Now;
         if (obj.Account <= 0 || (int?)null == obj.Account)
         {
             obj.Account = Account.id;
         }
         obj.Ip = Utility.GetClientIP(this.Context);
         bll.Add(obj);
     }
 }
Example #6
0
        protected void bt_Delete_Click(object sender, EventArgs e)
        {
            if ("" != hidID.Value)
            {
                var ids  = GetIdList(hidID.Value.Split(new char[] { ',' }));
                var list = PermissionInstance.FindList(f => ids.Contains(f.id));
                foreach (var tmp in list)
                {
                    tmp.Delete = true;
                    Update(tmp);

                    var his = new TB_AccountHistory();
                    his.Account  = Account.id;
                    his.ActionId = ActionInstance.Find(f => f.Name.Equals("DeletePermission")).id;
                    his.Ip       = Utility.GetClientIP(this.Context);
                    his.ObjectA  = "[id=" + tmp.id + "] " + tmp.Name;
                    SaveHistory(his);
                }
                ShowNotification("./permission_list.aspx", "Success: You have delete " + ids.Count() + " permission(s).");
            }
        }
Example #7
0
        /// <summary>
        /// 更改显示顺序
        /// </summary>
        /// <param name="toupper">true=往上调,false=往下调</param>
        private void ChangeDisplayOrder(bool toupper)
        {
            var id       = int.Parse(Utility.Decrypt(hidID.Value));
            var obj      = PermissionInstance.Find(f => f.id == id);
            var brothers = PermissionInstance.FindList(f => f.Parent == obj.Parent).OrderBy(o => o.DisplayOrder);

            if (obj.DisplayOrder == 0)
            {
                // 原始顺序在第一位时,只有向下调
                if (!toupper)
                {
                    var t = brothers.FirstOrDefault(f => f.DisplayOrder == obj.DisplayOrder + 1);
                    ChangeDisplayOrder(obj, t, toupper);
                }
            }
            else if (obj.DisplayOrder == brothers.Count() - 1)
            {
                // 原始顺序在最后一位时,只有向上调
                if (toupper)
                {
                    var t = brothers.FirstOrDefault(f => f.DisplayOrder == obj.DisplayOrder - 1);
                    ChangeDisplayOrder(obj, t, toupper);
                }
            }
            else
            {
                var t = brothers.FirstOrDefault(f => f.DisplayOrder == (toupper ? (obj.DisplayOrder - 1) : (obj.DisplayOrder + 1)));
                ChangeDisplayOrder(obj, t, toupper);
            }

            var his = new TB_AccountHistory();

            his.Account  = Account.id;
            his.ActionId = ActionInstance.Find(f => f.Name.Equals("EditPermission")).id;
            his.Ip       = Utility.GetClientIP(this.Context);
            his.ObjectA  = "[id=" + obj.id + "] " + obj.Name + ", change display order to " + (toupper ? "lower" : "upper");
            SaveHistory(his);

            ShowNotification("./permission_list.aspx", "Success: You have changed the display order of " + obj.Name + ".");
        }
Example #8
0
        private void NewRole()
        {
            var role = new TB_Role();

            role.AddTime         = DateTime.Now;
            role.Description     = txtDescription.Value.Trim();
            role.IsAdministrator = cbIsAdmin.Checked;
            role.IsDefault       = cbIsDefault.Checked;
            role.Name            = txtName.Value.Trim();
            role.Delete          = false;
            role.Permission      = PermissionInstance.GetDefaultMenus();
            RoleInstance.Add(role);

            // 记录历史
            var his = new TB_AccountHistory();

            his.Account  = Account.id;
            his.ActionId = ActionInstance.Find(f => f.Name.Equals("AddRole")).id;
            his.Ip       = Utility.GetClientIP(this.Context);
            his.ObjectA  = "[id=" + role.id + "] " + role.Name;
            SaveHistory(his);

            ShowNotification("./role_list.aspx", "Success: You added a new role.", true);
        }
Example #9
0
 /// <summary>
 /// 保存历史记录
 /// </summary>
 /// <param name="obj"></param>
 private void SaveHistory(TB_AccountHistory obj)
 {
     obj.ActionTime = DateTime.Now;
     obj.Ip         = Utility.GetClientIP(ctx);
     new HistoryBLL().Add(obj);
 }