Example #1
0
        private void saveuserprojecttree(HttpContext context)
        {
            int UserID = WebUtil.GetIntValue(context, "UserID");
            int RoleID = WebUtil.GetIntValue(context, "RoleID");

            Foresight.DataAccess.User user = null;
            Foresight.DataAccess.Role role = null;
            if (UserID > 0)
            {
                user = User.GetUser(UserID);
            }
            if (RoleID > 0)
            {
                role = Role.GetRole(RoleID);
            }
            string[] IDArry = new string[] { };
            string   IDList = context.Request.Params["IdList"];

            if (!string.IsNullOrEmpty(IDList))
            {
                IDArry = JsonConvert.DeserializeObject <string[]>(IDList);
            }
            string cmdtext       = string.Empty;
            var    ProjectIDList = new List <int>();

            foreach (var item in IDArry)
            {
                int ProjectID = 0;
                int.TryParse(item, out ProjectID);
                if (ProjectID <= 0)
                {
                    continue;
                }
                if (!ProjectIDList.Contains(ProjectID))
                {
                    ProjectIDList.Add(ProjectID);
                    cmdtext += "insert into [RoleProject] (RoleID,ProjectID,UserID) values (" + RoleID + "," + ProjectID + "," + UserID + ");";
                }
            }
            string[] CompanyIDArray = new string[] { };
            string   CompanyIDs     = context.Request.Params["CompanyIDList"];

            if (!string.IsNullOrEmpty(CompanyIDs))
            {
                CompanyIDArray = JsonConvert.DeserializeObject <string[]>(CompanyIDs);
            }
            var CompanyIDList = new List <int>();

            foreach (var item in CompanyIDArray)
            {
                int CompanyID = 0;
                int.TryParse(item, out CompanyID);
                if (CompanyID <= 0)
                {
                    continue;
                }
                if (!CompanyIDList.Contains(CompanyID))
                {
                    CompanyIDList.Add(CompanyID);
                    cmdtext += "insert into [UserCompany] (RoleID,CompanyID,UserID) values (" + RoleID + "," + CompanyID + "," + UserID + ");";
                }
            }
            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    Foresight.DataAccess.RoleProject.DeleteRoleProjectRoleId(RoleID, UserID, helper);
                    Foresight.DataAccess.UserCompany.Delete_UserCompany(RoleID, UserID, helper);
                    if (!string.IsNullOrEmpty(cmdtext))
                    {
                        helper.Execute(cmdtext, CommandType.Text, new List <SqlParameter>());
                    }
                    helper.Commit();
                }
                catch (Exception)
                {
                    helper.Rollback();
                    WebUtil.WriteJson(context, new { status = false });
                    return;
                }
            }
            try
            {
                #region 权限修改日志
                string name = role != null ? "角色" + role.RoleName : string.Empty;
                name = user != null ? "用户" + user.LoginName : name;
                string LogID = role != null?role.RoleID.ToString() : string.Empty;

                LogID = user != null ? "用户" + user.UserID.ToString() : name;
                APPCode.CommHelper.SaveOperationLog(string.Join(",", IDArry.ToArray()), Utility.EnumModel.OperationModule.RoleProject.ToString(), "资源权限", LogID, "RoleProject", IsHide: true);
                APPCode.CommHelper.SaveOperationLog(name + "权限修改", Utility.EnumModel.OperationModule.RoleProject.ToString(), "权限修改", LogID, "RoleProject", IsHide: true);
                Web.APPCode.CacheHelper.RemoveMyViewProjectTree();
                #endregion
            }
            catch (Exception)
            {
            }
            WebUtil.WriteJson(context, new { status = true });
        }
Example #2
0
 private void SetInfo(Foresight.DataAccess.Role data)
 {
     this.tdRoleName.Value = data.RoleName;
     this.tdRoleDesc.Value = data.RoleDes;
 }
Example #3
0
        private void saveservicetypeoperation(HttpContext context)
        {
            int UserID = WebUtil.GetIntValue(context, "UserID");
            int RoleID = WebUtil.GetIntValue(context, "RoleID");

            Foresight.DataAccess.User user = null;
            Foresight.DataAccess.Role role = null;
            if (UserID > 0)
            {
                user = User.GetUser(UserID);
            }
            if (RoleID > 0)
            {
                role = Role.GetRole(RoleID);
            }
            string IDList = context.Request.Params["IdList"];

            string[] IDArry = new string[] { };
            if (!string.IsNullOrEmpty(IDList))
            {
                IDArry = IDList.Split(',');
            }
            string cmdtext = string.Empty;

            foreach (var item in IDArry)
            {
                int ModuleID = 0;
                int.TryParse(item, out ModuleID);
                if (ModuleID <= 0)
                {
                    continue;
                }
                cmdtext += "insert into [UserServiceType] (RoleID,ServiceTypeID,UserID) values (" + RoleID + "," + ModuleID + "," + UserID + ");";
            }
            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    Foresight.DataAccess.UserServiceType.DeleteUserServiceTypeByRoleId(RoleID, UserID, helper);
                    if (!string.IsNullOrEmpty(cmdtext))
                    {
                        helper.Execute(cmdtext, CommandType.Text, new List <SqlParameter>());
                    }
                    helper.Commit();
                }
                catch (Exception ex)
                {
                    helper.Rollback();
                    WebUtil.WriteJson(context, new { status = false, error = ex.Message });
                    return;
                }
            }
            try
            {
                #region 权限修改日志
                string name = role != null ? "角色" + role.RoleName : string.Empty;
                name = user != null ? "用户" + user.LoginName : name;
                string LogID = role != null?role.RoleID.ToString() : string.Empty;

                LogID = user != null ? "用户" + user.UserID.ToString() : name;
                APPCode.CommHelper.SaveOperationLog(string.Join(",", IDArry.ToArray()), Utility.EnumModel.OperationModule.RoleModule.ToString(), "操作权限", LogID, "RoleModule", user.RealName, IsHide: true);
                APPCode.CommHelper.SaveOperationLog(name + "权限修改", Utility.EnumModel.OperationModule.RoleModuleSave.ToString(), "权限修改", LogID, "Role", IsHide: true);
                #endregion
            }
            catch (Exception)
            {
            }
            WebUtil.WriteJson(context, new { status = true });
        }