/// <summary> /// Get Domains For User /// </summary> /// <param name="user">User</param> /// <param name="role">Role</param> /// <returns>List of string</returns> private IEnumerable <string> GetDomainsForUser(string user, string role) { List <string> res = new List <string>(); if (_usersService == null) { using (var usersOperations = new FlowUsersService()) { var domains = usersOperations.GetDomainsForUser(new GetDomainsForUserRequest { User = user, Role = role }); if (domains != null) { res.AddRange(domains.Domains); } } } else { var domains = _usersService.GetDomainsForUser(new GetDomainsForUserRequest { User = user, Role = role }); if (domains != null) { res.AddRange(domains.Domains); } } return(res); }
protected override void Execute(NativeActivityContext context) { Log.Debug("OnInitMgrTask -> Start"); TaskStateData taskStatus = WorkflowAction.GetTaskState(context, HolidayWfUtility.Holidaymgr); using (var proxy = new FlowUsersService()) { var resp = proxy.GetRolesForUser(new GetRolesForUserRequest { IsPrimaryRole = true, User = taskStatus.Parameters[HolidayWfUtility.UserParameter] }); var role = resp.Roles.First(); Log.Debug("OnInitMgrTask -> Assign task to " + string.Format("{{r.Mgr{0}}}", role)); taskStatus.TaskInfo.AssignedToUsers = string.Format("{{r.Mgr{0}}}", role); } // Test //taskStatus.TaskInfo.AssignedToUsers = "{r.MgrDev}"; Result.Set(context, taskStatus); Log.Debug("OnInitMgrTask -> End"); }
/// <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)); }
public void Can_Call_Proxy_For_User() { using (FlowUsersService proxy = new FlowUsersService("FlowUsersService_Endpoint")) { proxy.IsValidUser(new IsValidUserRequest { Domain = "google", User = "******" }); } }
/// <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> /// Get User From Name /// </summary> /// <param name="usersService"></param> /// <param name="domain">Domain</param> /// <param name="u">User</param> /// <returns>User</returns> private static string GetUserFromName(IFlowUsersService usersService, string domain, string u) { if (usersService == null) { using (var usersOperations = new FlowUsersService()) { return(usersOperations.IsValidUser(new IsValidUserRequest { Domain = domain, User = u }).IsValid ? u : string.Empty); } } return(usersService.IsValidUser(new IsValidUserRequest { Domain = domain, User = u }).IsValid ? u : string.Empty); }
/// <summary> /// Get User From Role /// </summary> /// <param name="usersService"></param> /// <param name="r">User</param> /// <returns>User</returns> private static IEnumerable <string> GetUserFromRole(IFlowUsersService usersService, string r) { IEnumerable <string> users; if (usersService == null) { using (var usersOperations = new FlowUsersService()) { users = usersOperations.GetUsersByRoles(new GetUsersByRolesRequest { Roles = new[] { r } }).Users; return(users); } } users = usersService.GetUsersByRoles(new GetUsersByRolesRequest { Roles = new[] { r } }).Users; return(users); }
protected override void Execute(NativeActivityContext context) { Log.Debug("OnRunGenericTask -> Start"); var req = Request.Get(context); var workflowStateData = context.GetExtension <WorkflowStateData>(); using (var proxy = new FlowUsersService()) { var resp = proxy.GetRolesForUser(new GetRolesForUserRequest { IsPrimaryRole = true, User = workflowStateData.Parameters[HolidayWfUtility.UserParameter] }); var role = resp.Roles.First(); workflowStateData.AddParameter("UserRole", string.Format("{{r.Mgr{0}}}", role)); workflowStateData.AddParameter("IsUserMgr", role.StartsWith("Mgr") ? "Y" : "N"); } Result.Set(context, req); Log.Debug("OnRunGenericTask -> End"); }
/// <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 }); }