Exemplo n.º 1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Master.ShowErrorMsg("");

        if (!c.seRoleOpPvgs.Any(p => string.Compare(p.RoleName, ltrRoleName.Text) == 0))
        {
            Master.ShowErrorMsg(Resources.Lang.ErrMsg_ThereIsnotAnyChangesOfPvg);
            return;
        }

        //取得異動的權限
        List <RoleOpPvg> changes = c.seRoleOpPvgs.Where(p => string.Compare(p.RoleName, ltrRoleName.Text) == 0).ToList();

        c.ClearRoleDataOfRoleOpPvgs(ltrRoleName.Text);

        try
        {
            bool result = empAuth.SaveListOfEmployeeRolePrivileges(new RolePrivilegeParams()
            {
                RoleName    = ltrRoleName.Text,
                pvgChanges  = changes,
                PostAccount = c.GetEmpAccount()
            });

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", StringUtility.GetNoticeOpenerJs("Privilege"), true);
            }
            else
            {
                Master.ShowErrorMsg(Resources.Lang.ErrMsg_RolePrivilegeSaveFailed);
            }

            //新增後端操作記錄
            empAuth.InsertBackEndLogData(new BackEndLogData()
            {
                EmpAccount  = c.GetEmpAccount(),
                Description = string.Format(".{0} .儲存權限/Save privileges .身分/Role[{1}] .異動數量/changes[{2}] 結果/result[{3}]", Title, ltrRoleName.Text, changes.Count, result),
                IP          = c.GetClientIP()
            });
        }
        catch (Exception ex)
        {
            c.LoggerOfUI.Error("", ex);
            Master.ShowErrorMsg(ex.Message);
        }
    }