public void ProcessTask(string requestId) { GetServiceImplementation(out _requestManager); GetServiceImplementation(out _flowManager); GetServiceImplementation(out _accountManager); GetServiceImplementation(out _transactionManager); AppendAuditLogEvent("Loading request with id \"{0}\"", requestId); DataRequest dataRequest = _requestManager.GetDataRequest(requestId); AppendAuditLogEvent("Validating request parameters: {0}", dataRequest); _transactionId = dataRequest.TransactionId; bool createInNaas; string defaultPassword; SystemRoleType defaultRole; bool isUserActive; ICollection <FlowNameAndRole> accessFlows; ICollection <string> usernames = GetBulkAddUsersParams(dataRequest, _flowManager, out createInNaas, out defaultPassword, out defaultRole, out isUserActive, out accessFlows); _transactionManager.ClearRealtimeTransactionDetails(_transactionId); if (CollectionUtils.IsNullOrEmpty(usernames)) { AppendRealtimeDetail("No usernames were specified to add"); return; } AppendRealtimeDetail("Got {0} username(s) to add: {1}", usernames.Count.ToString(), StringUtils.Join(", ", usernames)); AppendRealtimeDetail("Parameters: createInNaas = {0}, defaultPassword = {1}, defaultRole = {2}, permittedFlows = {3}", createInNaas.ToString(), (defaultPassword == null) ? "NONE" : StringUtils.ReplaceAllChars(defaultPassword, "*"), defaultRole.ToString(), CollectionUtils.IsNullOrEmpty(accessFlows) ? "NONE" : StringUtils.Join(", ", accessFlows)); UserAccount userAccount = _accountManager.GetById(dataRequest.ModifiedById); IDictionary <string, string> flowIdToNameMap = _flowManager.GetAllFlowsIdToNameMap(); NodeVisit visit = new NodeVisit(userAccount, null, flowIdToNameMap); if (userAccount == null) { throw new ArgumentException("Could not locate the user with id: \"{0}\"", dataRequest.ModifiedById); } foreach (string username in usernames) { try { // Thread.Sleep(8000); _accountManager.BulkAddUser(username, createInNaas, defaultPassword, defaultRole, accessFlows, isUserActive, visit); AppendRealtimeDetail(StatusActivityType.Success, "Added user {0}", username); } catch (Exception e) { AppendRealtimeDetail(StatusActivityType.Error, "Failed to add user {0}: {1}", username, ExceptionUtils.GetDeepExceptionMessage(e)); } } }