private static string AuthenticateUser(string username, string password)
        {
            var proxy = new UserManagementServiceClient();
            var result = proxy.AuthenticateUser(username, password);

            return result.CallSuccess ? result.ResultData : result.FailureMessage;
        }
 /// <summary>
 /// Создать
 /// </summary>
 public UserService(IMapper mapper, ILogger logger, CallManagementServiceClient callManagementService, UserManagementServiceClient userManagementServiceClient)
 {
     _mapper = mapper;
     _logger = logger;
     _callManagementServiceClient = callManagementService;
     _userManagementServiceClient = userManagementServiceClient;
 }
 /// <inheritdoc />
 public CallManagementService(
     UnitOfWork unitOfWork,
     CallManagementServiceClient callManagementServiceClient,
     ContactManagementServiceClient contactManagementClient,
     UserManagementServiceClient userManagementServiceClient,
     IParticipantRepository participantRepository,
     InboxDistributionServiceClient inboxDistributionServiceClient,
     MediaRecordingServiceClient mediaRecordingServiceClient,
     ICaseTypeRepository caseTypeRepository,
     ICaseFolderRepository caseFolderRepository,
     ISmsRepository smsRepository,
     PhoneHubMessageService phoneHubMessageService,
     IMapper mapper,
     ILogger logger)
 {
     _callManagementServiceClient = callManagementServiceClient;
     _contactManagementClient     = contactManagementClient;
     _userManagementServiceClient = userManagementServiceClient;
     _participantRepository       = participantRepository;
     _smsRepository = smsRepository;
     _inboxDistributionServiceClient = inboxDistributionServiceClient;
     _mediaRecordingServiceClient    = mediaRecordingServiceClient;
     _caseTypeRepository             = caseTypeRepository;
     _caseFolderRepository           = caseFolderRepository;
     _phoneHubMessageService         = phoneHubMessageService;
     _unitOfWork = unitOfWork;
     _logger     = logger;
     _mapper     = mapper;
 }
Esempio n. 4
0
 public CGUserModel GetUserByUserName(string userName)
 {
     using (UserManagementServiceClient proxy = new UserManagementServiceClient()) {
         UserManagementServiceReference.CGUser serviceUser = proxy.GetCGUserByUserName(userName);
         Models.CGUserModel clientUser = CGUserModelConverter.ConvertFromServiceUserToClientUser(serviceUser);
         return(clientUser);
     }
 }
Esempio n. 5
0
 public bool DeleteCGUser(CGUserModel user)
 {
     using (UserManagementServiceClient proxy = new UserManagementServiceClient()) {
         CGUser cgU = CGUserModelConverter.ConvertFromClientUserToServiceUser(user);
         proxy.DeleteHand(cgU);
         return(proxy.DeleteCGUser(cgU));
     }
 }
 public Models.CGUser GetUserByUserId(string userId)
 {
     using (UserManagementServiceClient proxy = new UserManagementServiceClient()) {
         UserManagementServiceReference.CGUser serviceUser = proxy.GetUserByUserId(userId);
         Models.CGUser clientUser = UserModelModelConverter.ConvertFromServiceUserToClientUser(serviceUser);
         return(clientUser);
     }
 }
Esempio n. 7
0
 public List <CGUserModel> GetAll()
 {
     using (UserManagementServiceClient proxy = new UserManagementServiceClient()) {
         var serviceCGUsers = proxy.GetAll();
         List <Models.CGUserModel> clientCGUsers = CGUserModelConverter.ConvertFromServiceListOfUsersToClientListOfUsers(serviceCGUsers);
         return(clientCGUsers);
     }
 }
Esempio n. 8
0
        public void ChangePassword(string username, string newPassword, string oldPassword)
        {
            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => true;
            var client = new UserManagementServiceClient();

            WcfClientHelper.CallMethod((c, u, n, o) => c.SetPassword(username, newPassword, oldPassword), client,
                                       username, newPassword, oldPassword, errorAdapter);
        }
 private static bool DeleteUser(string authToken, string uniqueIdentifier,
     bool deleteResponses)
 {
     var service = new UserManagementServiceClient();
     var result = service.DeleteUser(authToken, uniqueIdentifier, deleteResponses);
     if (result.CallSuccess) return true;
     Console.WriteLine(result.FailureMessage);
     return false;
 }
 private static bool CreateUser(string authToken, string userName, string password, string emailAddress,
     SimpleNameValueCollection profile, bool updateIfExists)
 {
     var service = new UserManagementServiceClient();
     var result = service.CreateUser(authToken, userName, password, emailAddress, profile, updateIfExists);
     if (result.CallSuccess) return true;
     Console.WriteLine(result.FailureMessage);
     return false;
 }
 private static ServiceOperationResultOfPagedListResultOfArrayOfUserDataVUqw3SxCVUqw3SxC getUsers(
     string authToken, string provider, int pageNumber, int pageSize,
     string sortField, bool sortAscending, string filterField, string filterValue, int period,
     string dateFieldName)
 {
     var service = new UserManagementServiceClient();
     var result = service.GetUsers(authToken, provider, pageNumber, pageSize, sortField, sortAscending,
         filterField, filterValue);
     return result.CallSuccess ? result : null;
 }
 public UserGroup(Uri APIUrl)
 {
     try{
         EndpointAddress endpoint = new EndpointAddress(APIUrl.ToString() + WSDL_LOCATION);
         client = new UserManagementServiceClient("BasicHttpBinding_IUserManagementService", endpoint);
     }
     catch(Exception e)
     {
         Console.WriteLine("Invalid URL");
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Retrieve the authentication token required to make web service requests.
        /// </summary>
        /// <param name="username">The name of the user to authenticate.</param>
        /// <param name="password">The user's password.</param>
        /// <returns></returns>
        private static string AuthenticateUser(string username, string password)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.AuthenticateUser(username, password);

            return result.ResultData;
        }
Esempio n. 14
0
 /// <summary>
 /// Конструктор для инъекции зависимостей.
 /// </summary>
 public LanguageService(
     ILanguageRepository languageRepository,
     UnitOfWork unitOfWork,
     IMapper mapper, ILogger logger,
     UserManagementServiceClient userManagementServiceClient)
 {
     _unitOfWork                  = unitOfWork;
     _languageRepository          = languageRepository;
     _mapper                      = mapper;
     _logger                      = logger;
     _userManagementServiceClient = userManagementServiceClient;
 }
Esempio n. 15
0
 /// <summary>
 /// Конструктор для инъекции зависимостей
 /// </summary>
 public LineService(
     CallManagementServiceClient callManagementServiceClient,
     UserManagementServiceClient userManagementServiceClient,
     ILogger logger,
     IMapper mapper,
     UnitOfWork unitOfWork,
     IParticipantRepository participantRepository)
 {
     _userManagementServiceClient = userManagementServiceClient;
     _callManagementServiceClient = callManagementServiceClient;
     _logger                = logger;
     _mapper                = mapper;
     _unitOfWork            = unitOfWork;
     _participantRepository = participantRepository;
 }
        private static bool ChangeUserPassword(string authToken, string uniqueIdentifier,
            string newPassword)
        {
            if (!String.IsNullOrEmpty(newPassword))
            {
                var service = new UserManagementServiceClient();
                var result = service.ChangeUserPassword(authToken, uniqueIdentifier, newPassword);
                if (result.CallSuccess) return true;
                Console.WriteLine(result.FailureMessage);
                return false;
            }
            else
            {
                Console.WriteLine("Password null or empty");
                return false;

            }
        }
Esempio n. 17
0
        /// <summary>
        /// Assign a role to an existing user.
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="uniqueIdentifier">The id of the user to update.</param>
        /// <param name="roleName">The role being assigned to the user.</param>
        /// <returns></returns>
        private static bool AddUserToRole(string authenticationToken, string uniqueIdentifier, string roleName)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.AddUserToRole(authenticationToken, uniqueIdentifier, roleName);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return false;
            }

            // The AddUserToRole method does not return ResultData. Return true if the operation completed successfully.
            return true;
        }
Esempio n. 18
0
 /// <summary>
 /// Конструктор сервиса обработки карточки события.
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="unitOfWork"></param>
 /// <param name="phoneHubMessageService"></param>
 /// <param name="caseRepository"></param>
 /// <param name="caseTypeRepository"></param>
 /// <param name="caseFolderRepository"></param>
 /// <param name="gisService"></param>
 /// <param name="gisFacadeClient"></param>
 /// <param name="mapper"></param>
 /// <param name="userManagementServiceClient"></param>
 public CaseService(
     ILogger logger,
     UnitOfWork unitOfWork,
     PhoneHubMessageService phoneHubMessageService,
     ICaseRepository caseRepository,
     ICaseTypeRepository caseTypeRepository,
     ICaseFolderRepository caseFolderRepository,
     GisService gisService,
     GisFacadeClient gisFacadeClient,
     IMapper mapper,
     UserManagementServiceClient userManagementServiceClient)
 {
     _logger                      = logger;
     _unitOfWork                  = unitOfWork;
     _phoneHubMessageService      = phoneHubMessageService;
     _caseRepository              = caseRepository;
     _caseTypeRepository          = caseTypeRepository;
     _caseFolderRepository        = caseFolderRepository;
     _gisService                  = gisService;
     _gisFacadeClient             = gisFacadeClient;
     _mapper                      = mapper;
     _userManagementServiceClient = userManagementServiceClient;
 }
Esempio n. 19
0
        /// <summary>
        /// Checks if a user exists with the given unique identifier
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="uniqueIdentifier">Unique identifier to query.</param>
        /// <returns></returns>
        private static bool UserExists(string authenticationToken, string uniqueIdentifier)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.UserExists(authenticationToken, uniqueIdentifier);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return false;
            }

            return result.ResultData;
        }
Esempio n. 20
0
        /// <summary>
        /// Add new profile properties and updates existing ones.
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="uniqueIdentifier">The unique identifiers of the user to update.</param>
        /// <param name="profileProperties">The new list of profile properties to add/update.</param>
        /// <returns></returns>
        private static bool UpdateUserProfile(string authenticationToken, string uniqueIdentifier, IList<KeyValuePair<string, string>> profileProperties)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.UpdateUserProfile(authenticationToken, uniqueIdentifier, BuildProfile(profileProperties));

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return false;
            }

            return true;
        }
Esempio n. 21
0
        /// <summary>
        /// Find users by username and email address.
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="searchTerm">The value to search for.</param>
        /// <returns></returns>
        private static IEnumerable<GroupedResultOfUserDataVUqw3SxC> SearchUsers(string authenticationToken, string searchTerm)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();

            var result = proxy.SearchUsers(authenticationToken, searchTerm);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return null;
            }

            return result.ResultData;
        }
Esempio n. 22
0
        /// <summary>
        /// Get a paged, sorted, and filtered list of user identities.
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="pageNumber">The index of the first page to begin retrieving results from. Specifying 0 disables pagination.</param>
        /// <param name="pageSize">The number of results to display on a page. Specifying 0 disables pagination.</param>
        /// <param name="sortField">The field used when sorting results. Specifying null disables sorting..</param>
        /// <param name="sortAscending">The sort direction.</param>
        /// <param name="filterField">The field to use when filtering results. Specifying null disables filtering.</param>
        /// <param name="filterValue">Filter criteria. Specifying null disables filtering.</param>
        /// <returns>List of user identities matching filters (or all identities if filter values are null).</returns>
        private static IEnumerable<string> ListUserIdentities(
                                            string authenticationToken,
                                            int pageNumber = 0,
                                            int pageSize = 0,
                                            string sortField = null,
                                            bool sortAscending = true,
                                            string filterField = null,
                                            string filterValue = null)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.ListUserIdentities(
                                                                                                authenticationToken,
                                                                                                pageNumber,
                                                                                                pageSize,
                                                                                                sortField,
                                                                                                sortAscending,
                                                                                                filterField,
                                                                                                filterValue);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return null;
            }

            return result.ResultData.ResultPage;
        }
Esempio n. 23
0
        /// <summary>
        /// Get list 
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <returns></returns>
        private static IEnumerable<RoleData> ListAllAvailableUserRoles(string authenticationToken)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.ListAllAvailableUserRoles(authenticationToken);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return new RoleData[0];
            }

            return result.ResultData;
        }
Esempio n. 24
0
        /// <summary>
        /// Delete multiple users.
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="userIds">Array of unique identifiers of the users to delete.</param>
        /// <param name="deleteResponses">Indicates whether the user's responses should be deleted as well.</param>
        /// <returns></returns>
        /// <remarks>
        /// Users and their responses are "soft deleted" from the database. Records are flagged as deleted, but
        /// data is not removed from the database permanently.
        /// </remarks>
        private static bool DeleteUsers(string authenticationToken, string[] userIds, bool deleteResponses)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var result = proxy.DeleteUsers(authenticationToken, userIds, deleteResponses);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return false;
            }

            // The DeleteUsers method does not return ResultData. Return true if the operation completed successfully.
            return true;
        }
Esempio n. 25
0
        /// <summary>
        /// Create a new user.
        /// Because no roles or permissions are explicitly set, the new user will have the "Report Viewer" and "Respondent" role.
        /// Additionally the new user will only be able to access public surveys and reports.
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="username">The new user's username.</param>
        /// <param name="password">The new user's password.</param>
        /// <param name="emailAddress">The new user's email address.</param>
        /// <param name="profileProperties">(Optional) A list of profile properties to associate with the user.</param>
        private static string CreateUser(
                                        string authenticationToken,
                                        string username,
                                        string password,
                                        string emailAddress,
                                        IList<KeyValuePair<string, string>> profileProperties = null)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();
            var profile = BuildProfile(profileProperties);

            var result = proxy.CreateUser(
                authenticationToken,
                username,
                password,
                emailAddress,
                profile,
                true); /* When true, if a user with the same name exists, update that user. */

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return null;
            }

            return result.ResultData;
        }
Esempio n. 26
0
 public MainWindow()
 {
     InitializeComponent();
     this.client = new UserManagementServiceClient();
     this.UpdateGrid();
 }
        private static bool RenameUser(string authToken, string uniqueIdentifier, string newUniqueIdentifier)
        {
            if (!String.IsNullOrEmpty(newUniqueIdentifier))
            {
                var service = new UserManagementServiceClient();
                var result = service.RenameUser(authToken, uniqueIdentifier, newUniqueIdentifier);

                if (result.CallSuccess) return true;
                Console.WriteLine(result.FailureMessage);
                return false;
            }
            else
            {
                Console.WriteLine("New Username is NULL or Empty");
                return false;
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Change a network user's domain
        /// </summary>
        /// <param name="authenticationToken">Encrypted forms auth token identifying the requesting user.</param>
        /// <param name="userName">The user's name.</param>
        /// <param name="oldDomain">The user current domain name.</param>
        /// <param name="newDomain">The user's new domain name.</param>
        private static string ChangeUserDomain(string authenticationToken, string userName, string oldDomain, string newDomain)
        {
            /*
             * If you are unable to reference System.Service make sure that the project is configured to
             * use the full 4.0 framework and not the client profile.
             */
            var proxy = new UserManagementServiceClient();

            var result = proxy.ChangeUserDomain(
                authenticationToken,
                userName,
                oldDomain,
                newDomain);

            // Handle exceptions
            if (!result.CallSuccess)
            {
                Console.WriteLine(result.FailureMessage);
                return null;
            }

            return result.ResultData;
        }
Esempio n. 29
0
 public void CreateUser(string id, string email, string userName)
 {
     using (UserManagementServiceClient proxy = new UserManagementServiceClient()) {
         proxy.CreateUser(id, email, userName);
     }
 }
Esempio n. 30
0
        static void Main(string[] args)
        {
            IKernel kernel = FactoryDependency.GetKernel();

            IUserManagementService    userservice    = kernel.Get <IUserManagementService>();
            IProjectManagementService projectservice = kernel.Get <IProjectManagementService>();

            UserManagementServiceClient    clientUser    = null;
            ProjectManagementServiceClient clientProject = null;

            try
            {
                clientUser    = new UserManagementServiceClient("BasicHttpBinding_IUserManagementService");
                clientProject = new ProjectManagementServiceClient("BasicHttpBinding_IProjectManagementService");

                UserWorkflow    workflow        = new UserWorkflow(clientUser);
                ProjectWorkflow projectWorkflow = new ProjectWorkflow(clientProject);

                bool exit = false;

                do
                {
                    System.Console.Clear();
                    System.Console.WriteLine("[1] Create user");
                    System.Console.WriteLine("[2] Read user");
                    System.Console.WriteLine("[3] Update user");
                    System.Console.WriteLine("[4] Delete user");
                    System.Console.WriteLine("[5] Create project");
                    System.Console.WriteLine("[6] Get All projects");
                    System.Console.WriteLine("[0] Exit");
                    System.Console.Write("What do you want to do?:");

                    string opt = System.Console.ReadLine();

                    switch (opt)
                    {
                    case "0":
                        exit = true;
                        break;

                    case "1":
                        //client.Open();
                        workflow.CreateUser();
                        //client.Close();
                        break;

                    case "2":
                        //client.Open();
                        workflow.ReadUser();
                        //client.Close();
                        break;

                    case "3":
                        //client.Open();
                        workflow.UpdateUser();
                        //client.Close();
                        break;

                    case "4":
                        //client.Open();
                        workflow.Delete();
                        //client.Close();
                        break;

                    case "5":
                        projectWorkflow.Create();
                        break;

                    case "6":
                        projectWorkflow.GetAll();
                        break;
                    }

                    System.Console.Write("Continue...");
                    System.Console.ReadKey();
                } while (!exit);
            }
            finally
            {
                if (clientUser != null && clientUser.State == CommunicationState.Opened)
                {
                    clientUser.Close();
                }

                if (clientProject != null && clientProject.State == CommunicationState.Opened)
                {
                    clientProject.Close();
                }
            }
        }
Esempio n. 31
0
 public MainWindow()
 {
     InitializeComponent();
     this.client = new UserManagementServiceClient();
     this.UpdateGrid();
 }
 private static void UpdateUserProfile(string authToken, string userIdentity, SimpleNameValueCollection profile)
 {
     var service = new UserManagementServiceClient();
     var result = service.UpdateUserProfile(authToken, userIdentity, profile);
 }
Esempio n. 33
0
 public UserWorkflow(UserManagementServiceClient client)
 {
     _client = client;
 }
Esempio n. 34
0
        public IList <string> GetRolesForUser(string userName)
        {
            var client = new UserManagementServiceClient();

            return(WcfClientHelper.CallMethod((c, u) => c.GetRolesForUser(userName), client, userName, errorAdapter));
        }