コード例 #1
0
        /// <summary>
        /// Get workflow trace
        /// </summary>
        /// <param name="workflowOids">List of oid</param>
        /// <returns>List of trace</returns>
        public IEnumerable <WorkflowTraceInfo> GetTraceForWorkflow(Guid[] workflowOids)
        {
            // TODO
            // The problem here is that we need to get the avatar for the user
            // who add comment to workflow, but the user information is in an
            // other database.
            // For now use a dictionary to make sure we don't call the service
            // twice for the same user.

            var userHash = new Dictionary <string, string>();

            var traces = _tracer.GetTraceForWorkflow(workflowOids).ToList();

            if (_usersService == null)
            {
                using (var usersOperations = new FlowUsersService())
                {
                    foreach (var t in traces)
                    {
                        if (string.IsNullOrWhiteSpace(t.User))
                        {
                            continue;
                        }

                        if (!userHash.ContainsKey(t.User))
                        {
                            var user = usersOperations.GetUser(new GetUserRequest {
                                User = t.User
                            });
                            if (user.User != null)
                            {
                                userHash.Add(t.User, user.User.PhotoPath);
                            }
                        }

                        if (userHash.ContainsKey(t.User))
                        {
                            t.Avatar = userHash[t.User];
                        }
                    }
                }
            }
            else
            {
                foreach (var t in traces)
                {
                    var user = _usersService.GetUser(new GetUserRequest {
                        User = t.User
                    });
                    t.Avatar = user.User.PhotoPath;
                }
            }
            return(traces);
        }