public JsonResult DoUpdateUserGroupInfo()
        {
            string             message   = "操作失败,请与管理员联系";
            UserGroupInfoModel groupInfo = new UserGroupInfoModel();

            groupInfo.UserGroupId = GetFormData("groupId");
            groupInfo.GroupName   = GetFormData("groupName");
            groupInfo.Description = GetFormData("groupDesc");

            List <string> premissionList = (Request.Form["wopBox"] != null) ? Request.Form.GetValues("wopBox").ToList() : null;

            //List<string> premissionList = Request.Form.GetValues("wopBox").ToList();
            if (premissionList == null)
            {
                return(FailedJson("请选择相相对应权限"));
            }
            if (UserGroupInfoService.Instance.UpdateUserGroupInfo(groupInfo, premissionList, out message))
            {
                return(SuccessedJson(message, "UserMgr_UserGroupMgr", "UserMgr_UserGroupMgr", "forward", "/UserMgr/usergroupmgr?gid" + groupInfo.UserGroupId));
            }
            else
            {
                return(FailedJson(message));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="pc">pc</param>
        /// <returns>影响的记录行数</returns>
        public int DeleteMultiple(ParameterCollection pc)
        {
            int ret = 0;

            UserGroupInfoModel usergroupinfo = new UserGroupInfoModel();

            ret = DbUtil.Current.DeleteMultiple(usergroupinfo, pc);

            return(ret);
        }
Beispiel #3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="usergroupinfo">实体</param>
        /// <param name="pc">pc</param>
        /// <returns>影响的记录行数</returns>
        public int UpdateMultiple(UserGroupInfoModel usergroupinfo, ParameterCollection pc)
        {
            int ret = 0;

            usergroupinfo.ModifiedBy = SessionUtil.Current.UserId;
            usergroupinfo.ModifiedOn = DateTime.Now;

            ret = DbUtil.Current.UpdateMultiple(usergroupinfo, pc);

            return(ret);
        }
Beispiel #4
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="usergroupinfo">实体</param>
        /// <returns>影响的记录行数</returns>
        public int Update(UserGroupInfoModel usergroupinfo)
        {
            int ret = 0;

            usergroupinfo.ModifiedBy = SessionUtil.Current.UserId;
            usergroupinfo.ModifiedOn = DateTime.Now;

            ret = DbUtil.Current.Update(usergroupinfo);

            return(ret);
        }
Beispiel #5
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="usergroupid"></param>
        /// <returns>影响的记录行数</returns>
        public int Delete(string usergroupid)
        {
            int ret = 0;

            UserGroupInfoModel usergroupinfo = new UserGroupInfoModel();

            usergroupinfo.UserGroupId = usergroupid;

            ret = DbUtil.Current.Delete(usergroupinfo);

            return(ret);
        }
Beispiel #6
0
        /// <summary>
        /// 根据条件获取实体集合
        /// </summary>
        /// <param name="pc">pc</param>
        /// <param name="obc">obc</param>
        /// <returns>实体</returns>
        public List <UserGroupInfoModel> RetrieveMultiple(ParameterCollection pc, OrderByCollection obc)
        {
            List <UserGroupInfoModel> usergroupinfos = new List <UserGroupInfoModel>();

            UserGroupInfoModel usergroupinfo = new UserGroupInfoModel();
            DataTable          dt            = DbUtil.Current.RetrieveMultiple(usergroupinfo, pc, obc);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                usergroupinfo = new UserGroupInfoModel();
                usergroupinfo.ConvertFrom(dt, i);
                usergroupinfos.Add(usergroupinfo);
            }

            return(usergroupinfos);
        }
Beispiel #7
0
        /// <summary>
        /// 根据主键获取实体
        /// </summary>
        /// <param name="usergroupid"></param>
        /// <returns>实体</returns>
        public UserGroupInfoModel Retrieve(string usergroupid)
        {
            UserGroupInfoModel usergroupinfo = new UserGroupInfoModel();

            usergroupinfo.UserGroupId = usergroupid;

            DataTable dt = DbUtil.Current.Retrieve(usergroupinfo);

            if (dt.Rows.Count < 1)
            {
                return(null);
            }

            usergroupinfo.ConvertFrom(dt);

            return(usergroupinfo);
        }
Beispiel #8
0
        public UserGroupPremissionDomainModel GetUserGroupDomainByGroupIdFromDatabase(string userGroupId)
        {
            if (userGroupId == null)
            {
                return(null);
            }

            UserGroupPremissionDomainModel result = null;

            UserGroupInfoModel groupInfo = Retrieve(userGroupId);

            if (groupInfo != null)
            {
                result = new UserGroupPremissionDomainModel();
                result.WorkOrderPremissionList = new Dictionary <string, RelUsergroupPremissionModel>();
                result.UserGroupInfo           = groupInfo;

                #region 获取工单权限

                string GetWorkOrderPremissionSQL = "SELECT * FROM rel_usergroup_premission WHERE premission_type = 'WORKORDER' AND usergroup_id = $groupId$";
                ParameterCollection pc           = new ParameterCollection();
                pc.Add("groupId", userGroupId);
                DataTable WOPremissin = ExecuteDataTable(GetWorkOrderPremissionSQL, pc);
                if (WOPremissin != null && WOPremissin.Rows.Count > 0)
                {
                    RelUsergroupPremissionModel pre = null;
                    for (int i = 0; i < WOPremissin.Rows.Count; i++)
                    {
                        pre = new RelUsergroupPremissionModel();
                        ModelConvertFrom(pre, WOPremissin, i);
                        result.WorkOrderPremissionList[pre.WorkorderTypeId] = pre;
                    }
                }

                #endregion
            }

            return(result);
        }
Beispiel #9
0
        public bool UpdateUserGroupInfo(UserGroupInfoModel groupInfo, List <string> premissionList, out string message)
        {
            bool result = false;

            message = "操作失败,请与管理员联系";

            if (groupInfo == null)
            {
                message = "参数错误,请与管理员联系";
                return(false);
            }

            Dictionary <string, UserGroupInfoModel> groupList = GetUserGroupList(false);

            if (groupList.ContainsKey(groupInfo.UserGroupId) == false)
            {
                message = "操作失败,不存在的用户组ID";
                return(false);
            }

            try
            {
                BeginTransaction();

                if (Update(groupInfo) == 1)
                {
                    string[] preArr = null;

                    #region 生成工单权限实体列表

                    Dictionary <string, WorkorderTypeInfoModel>      WorkOrderTypeList       = WorkorderTypeInfoService.Instance.GetWorkOrderDictionary(false);
                    Dictionary <string, RelUsergroupPremissionModel> WorkOrderPremissionList = new Dictionary <string, RelUsergroupPremissionModel>();
                    foreach (WorkorderTypeInfoModel item in WorkOrderTypeList.Values)
                    {
                        RelUsergroupPremissionModel pre = new RelUsergroupPremissionModel();
                        pre.UsergroupId     = groupInfo.UserGroupId;
                        pre.WorkorderTypeId = item.WorkorderTypeId;
                        pre.PremissionType  = "WORKORDER";
                        pre.Status          = 0;
                        pre.CanSelect       = 1;
                        pre.CanProcess      = 1;
                        pre.CanClose        = 1;
                        pre.CanDelete       = 1;
                        pre.IsManage        = 1;

                        WorkOrderPremissionList[pre.WorkorderTypeId] = pre;
                    }

                    #endregion

                    foreach (string premission in premissionList)
                    {
                        preArr = premission.Split('_');

                        #region 处理工单权限

                        if (preArr[0].ToUpper() == "WORKORDER")
                        {
                            switch (preArr[2])
                            {
                            case "SELECT":
                                WorkOrderPremissionList[preArr[1]].CanSelect = 0;
                                break;

                            case "PROCESS":
                                WorkOrderPremissionList[preArr[1]].CanProcess = 0;
                                break;

                            case "CLOSE":
                                WorkOrderPremissionList[preArr[1]].CanClose = 0;
                                break;

                            case "DELETE":
                                WorkOrderPremissionList[preArr[1]].CanDelete = 0;
                                break;

                            case "MANAGE":
                                WorkOrderPremissionList[preArr[1]].IsManage = 0;
                                break;

                            default:
                                break;
                            }
                        }

                        #endregion
                    }


                    #region 更新工单权限至数据库

                    string DeleteWorkOrderPremissionSQL = "DELETE FROM rel_usergroup_premission WHERE usergroup_id = $usergroup_id$ AND premission_type = $premission_type$";
                    ParameterCollection pc = new ParameterCollection();
                    pc.Add("usergroup_id", groupInfo.UserGroupId);
                    pc.Add("premission_type", "WORKORDER");

                    if (ExecuteNonQuery(DeleteWorkOrderPremissionSQL, pc) >= 0)
                    {
                        foreach (RelUsergroupPremissionModel item in WorkOrderPremissionList.Values)
                        {
                            if (RelUsergroupPremissionService.Instance.Create(item) != 1)
                            {
                                RollbackTransaction();
                                message = "更新工单权限信息失败";
                                return(false);
                            }
                        }
                    }
                    #endregion

                    CommitTransaction();
                    GetUserGroupList(true);
                    GetUserGroupDomainByGroupId(groupInfo.UserGroupId, true);
                    message = "成功更新用户组信息";
                    result  = true;
                }
                else
                {
                    RollbackTransaction();
                    message = "更新用户组基本信息失败";
                    result  = false;
                }
            }
            catch (Exception ex)
            {
                RollbackTransaction();
                LogUtil.Error("更新用户组信息异常", ex);
                throw ex;
            }

            return(result);
        }