예제 #1
0
        /// <summary>
        /// Renders the specified task lists.
        /// </summary>
        /// <param name="taskLists">The task lists.</param>
        /// <param name="mergeRoles">if set to <c>true</c> [merge roles].</param>
        /// <returns></returns>
        private string Render(Dictionary <string, TaskListCollection> taskLists, bool mergeRoles)
        {
            Dictionary <TaskDistiller, TaskListCollection> distillers = new Dictionary <TaskDistiller, TaskListCollection>();
            //按角色分别呈现角色对应的任务列表
            StringBuilder sb = new StringBuilder();

            if (mergeRoles)
            {
                TaskDistiller      distiller = null;
                TaskListCollection list      = new TaskListCollection();
                foreach (string roleName in taskLists.Keys)
                {
                    distiller = GetRoleDistiller(roleName);
                    list.AddRange(taskLists[roleName]);
                }
                sb.Append(distiller.Render.TaskListsToHtml(list.ToArray()));
            }
            else
            {
                foreach (string roleName in taskLists.Keys)
                {
                    TaskDistiller distiller = GetRoleDistiller(roleName);
                    //合并呈现
                    sb.Append(distiller.Render.TaskListsToHtml(taskLists[roleName].ToArray()));
                }
            }
            return(sb.ToString());
        }
예제 #2
0
        /// <summary>
        /// 将角色-实例集合转化为用户的任务列表
        /// </summary>
        /// <param name="userId">用户Id.</param>
        /// <param name="instances">角色-实例集合.</param>
        /// <returns></returns>
        private Dictionary <string, TaskListCollection> ConvertToTasklists(string userId, InstanceCollection instances)
        {
            Dictionary <string, TaskListCollection> taskLists = new Dictionary <string, TaskListCollection>();
            IUserIdentity       userIdentity = identityService.GetUserIdentity(userId);
            List <ApprovalRole> allRoles     = instances.GetAllRoles();

            //按角色分别呈现角色对应的任务列表
            foreach (ApprovalRole role in allRoles)
            {
                InstanceCollection c = instances.GetByRole(role);

                TaskListCollection lists = new TaskListCollection();
                //获取该角色对应的提取器对象
                TaskDistiller distiller = GetRoleDistiller(role.Name);
                distiller.ForRole = role;
                if (distiller.ItemDistiller is IInitializableDistiller)
                {
                    ((IInitializableDistiller)(distiller.ItemDistiller)).Initialize(role, c);
                }

                List <InstanceCollection> collection = c.SplitByEaId();
                foreach (InstanceCollection one in collection)
                {
                    List <ITaskItem> items = new List <ITaskItem>();

                    ITaskItem taskItem = distiller.ItemDistiller.Distill(one, userIdentity);
                    items.Add(taskItem);
                    TaskList list = new TaskList(one.TaskName, items);
                    //给任务列表名称赋值
                    if (!string.IsNullOrEmpty(this.taskName))
                    {
                        list.Cagegory = this.taskName;
                    }
                    lists.Merge(list);
                }
                taskLists.Add(role.Name, lists);
            }
            return(taskLists);
        }