/// <summary> /// Get Broadcast Users /// </summary> /// <param name="from">From</param> /// <returns>users</returns> private string GetBroadcastUsers(string from) { GetUserResponse resp; if (_usersService == null) { using (var usersOperations = new FlowUsersService()) { resp = usersOperations.GetUser(new GetUserRequest { User = from }); } } else { resp = _usersService.GetUser(new GetUserRequest { User = from }); } if (resp.User.FollowerCount == 0) { return(string.Empty); } return(resp.User.Follower .Select(f => f.UserName) .Aggregate((current, next) => current + ";" + next)); }
/// <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); }
/// <summary> /// Create MessageInfo /// </summary> /// <param name="user">TopicUser</param> /// <param name="uofw">FlowTasksUnitOfWork</param> /// <param name="users"></param> /// <returns>TopicMessageInfo</returns> private TopicMessageInfo CreateMessageInfo(TopicUser user, FlowTasksUnitOfWork uofw, Dictionary <string, string> users) { var documents = CreateDocuments(user.TopicMessage, uofw); if (!users.ContainsKey(user.TopicMessage.From)) { GetUserResponse resp; if (_usersService == null) { using (var usersOperations = new FlowUsersService()) { resp = usersOperations.GetUser(new GetUserRequest { User = user.TopicMessage.From }); } } else { resp = _usersService.GetUser(new GetUserRequest { User = user.TopicMessage.From }); } users.Add(user.TopicMessage.From, resp.User.PhotoPath); } return(new TopicMessageInfo { From = user.TopicMessage.From, ImageUrl = users[user.TopicMessage.From], To = user.TopicMessage.To, Message = user.TopicMessage.Message, When = user.TopicMessage.Topic.LastChanged, Status = CreateStatusType(user), Attachments = documents }); }