public ActionResult AddCreateProductAuthority(string username)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.Assert(IsUserExist(username), "用户[{0}]不存在", username);

                var allAuthority = m_dbAdapter.Authority.GetProductAuthorityByUsername(username);
                var isExist = allAuthority.Where(x => x.Username.Equals(username, StringComparison.CurrentCultureIgnoreCase))
                              .ToList().Any(x => x.CreateProductAuthority == 1);

                CommUtils.Assert(!isExist, "用户[{0}]已存在创建产品的权限,无需添加", username);

                var productAuthority = new EditProductAuthority();
                productAuthority.Username = username;
                productAuthority.CreateProductAuthority = 1;
                productAuthority.ModifyModelAuthority = 0;
                productAuthority.ModifyTaskAuthority = 0;
                productAuthority.ModifyProjectId = -1;

                m_dbAdapter.Authority.NewProductAuthority(productAuthority);
                NewEditProjectPermissionLog(null, "添加创建产品权限:添加用户[{0}]的创建产品权限", username);

                return ActionUtils.Success(isExist);
            }));
        }
        public ActionResult AddUserProductAuthority(string username, string enterpriseName, string projectGuid,
                                                    bool modifyModel, bool modifyTask)
        {
            return(ActionUtils.Json(() =>
            {
                CommUtils.Assert(modifyModel || modifyTask, "权限类型不能为空");
                CommUtils.Assert(IsUserExist(username), "用户[{0}]不存在", username);
                CommUtils.Assert(m_dbAdapter.Authority.HasEnterpriseByName(enterpriseName), "找不到对应的机构名称[" + enterpriseName + "]");
                CommUtils.Assert(projectGuid != "empty", "产品名称不能为[无]");
                var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid);
                CommUtils.Assert(!m_dbAdapter.Authority.HasProductAuthority(username, project.ProjectId), "用户[" + username + "]已拥有产品[" + project.Name + "]的操作权限,请在该用户的产品列表中直接修改");

                var productAuthority = new EditProductAuthority();
                productAuthority.Username = username;
                productAuthority.ModifyProjectId = project.ProjectId;
                productAuthority.CreateProductAuthority = 0;
                productAuthority.ModifyModelAuthority = Convert.ToInt32(modifyModel);
                productAuthority.ModifyTaskAuthority = Convert.ToInt32(modifyTask);

                m_dbAdapter.Authority.NewProductAuthority(productAuthority);
                var logDescription = modifyModel ? " [编辑模型权限]" : "";
                logDescription += modifyTask ? " [编辑工作权限]" : "";
                NewEditProjectPermissionLog(project.ProjectId, "添加产品权限:添加用户[{0}]的{1}", username, logDescription);

                return ActionUtils.Success("");
            }));
        }
Beispiel #3
0
        public EditProductAuthority NewProductAuthority(EditProductAuthority editProductAuthority)
        {
            var records = HasProductAuthority(editProductAuthority.Username, editProductAuthority.ModifyProjectId);

            CommUtils.Assert(!records, "用户[{0}]已存在该权限", editProductAuthority.Username);

            var newId = Insert("dbo.EditProductAuthority", "product_edit_authority_id", editProductAuthority.GetTableObject());

            editProductAuthority.productEditAuthorityId = newId;
            return(editProductAuthority);
        }
Beispiel #4
0
        public int UpdateProductAuthority(EditProductAuthority editProductAuthority)
        {
            var productAuthorityTable = editProductAuthority.GetTableObject();

            return(m_db.Update("dbo.EditProductAuthority", "product_edit_authority_id", productAuthorityTable, editProductAuthority.productEditAuthorityId));
        }
Beispiel #5
0
 public int DeleteProductAuthority(EditProductAuthority editProductAuthority)
 {
     return(m_db.Delete("dbo.EditProductAuthority", "product_edit_authority_id", editProductAuthority.GetTableObject()));
 }