• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
繁星
不要浪费时间
博客园    首页    新随笔    联系   管理    订阅  订阅

sharepoint 工作流个人代理第一个审批人做代理 时 添加权限的问题

 

下面是个人代理第一个审批人做代理 时 添加权限的问题

问题1:在代理委托类里直接添加 当前审批人权限,流程里 删除已所有人权限,会把加过的权限删除。

2、先执行 item.update();再添加权限。重新发起流程,权限加上了,但流程提示走到第一个审人节点出错(工作流无法更新此项目,可能是因为此项目的一个或多个列需要其他类型的信息),表单的单据状态也没有改变,还是草稿状态

 

 

 

2、 #region 添加审批权限代码

 

            try

            {

                SPSecurity.RunWithElevatedPrivileges(delegate()

                {

                    using (SPSite site = new SPSite(approver.ParentTask.WFContext.Web.Site.ID))

                    {

                        using (SPWeb currentWeb = site.OpenWeb(approver.ParentTask.WFContext.Web.ID))

                        {

 

                                                 

                            SPListItem superItem = currentWeb.Lists[approver.ParentTask.WFContext.ListID].GetItemById(approver.ParentTask.WFContext.ItemID);

                            currentWeb.AllowUnsafeUpdates = true;

                         

                            SPRoleDefinition roleDefinition = currentWeb.RoleDefinitions.GetByType(SPRoleType.Administrator);

                           

                          

                             SPUser user = currentWeb.EnsureUser(toUsername);

                            if (user != null)

                            {

 

                              

                                if (!superItem.HasUniqueRoleAssignments) {

                                    superItem.BreakRoleInheritance(false);

                                                                   

                                    SPUser Curreusername = currentWeb.EnsureUser(userID); //代理人

                                    SPRoleAssignment currentRoleCurre = new SPRoleAssignment(Curreusername.LoginName, Curreusername.Email, Curreusername.Name, Curreusername.Notes);

                                    currentRoleCurre.RoleDefinitionBindings.Add(roleDefinition);

                                    superItem.RoleAssignments.Add(currentRoleCurre);

                                   

                                    SPUser Author = new SPFieldUserValue(currentWeb, superItem["Author"].ToString()).User;//发起人

                                    if (Author.LoginName.ToLower() != user.LoginName.ToLower())

                                    {

                                      

                                        SPRoleAssignment currentRoleAuthor = new SPRoleAssignment(Author.LoginName, Author.Email, Author.Name, Author.Notes);

                                        currentRoleAuthor.RoleDefinitionBindings.Add(roleDefinition);

                                        superItem.RoleAssignments.Add(currentRoleAuthor);

                                    }

                               

                                }

                              

                              

                                SPRoleAssignment currentRole = new SPRoleAssignment(user.LoginName, user.Email, user.Name, user.Notes);//审批人

                                currentRole.RoleDefinitionBindings.Add(roleDefinition);

                                superItem.RoleAssignments.Add(currentRole);

                              

                                                         }

 

                            superItem.SystemUpdate();

                            comment += "a4";

                       // currentWeb.AllowUnsafeUpdates = false;

                    

                         

                        };

                    }

                });

            }

            catch (Exception ex)

            {

               

                new FlowManException("设置代理审批人单据权限出错", ex);

            }

         

            #endregion

posted @ 2011-10-19 22:20  ※繁星※  阅读(755)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3