示例#1
0
        /// <summary>
        /// Gets a JobTitle value
        /// </summary>
        /// <param name="from">The from value to parse.</param>
        /// <param name="division">The id of the division.</param>
        /// <param name="user">The user object that contains the data.</param>
        /// <returns></returns>
        public EntityId GetJobTitleValue(string from, EntityId division, ActiveDirectoryUser user)
        {
            // get the field value for the job title name
            var jobTitleValue = GetFieldValue(from, user);

            if (string.IsNullOrEmpty(jobTitleValue))
            {
                return(null);
            }

            // check the cache
            if (JobTitleCache.ContainsKey(jobTitleValue))
            {
                return(new EntityId(JobTitleCache.GetValue(jobTitleValue)));
            }

            // job title does not exist in the cache...get it from the service
            var jobTitleId = ApiService.GetJobTitleAsync(jobTitleValue, division, AuthToken).GetAwaiter().GetResult();

            if (jobTitleId != null)
            {
                JobTitleCache.Add(jobTitleValue, jobTitleId);
                return(new EntityId(jobTitleId));
            }

            // did not find the job title in the system so add it.
            jobTitleId = ApiService.CreateJobTitleAsync(jobTitleValue, division, AuthToken).GetAwaiter().GetResult();
            if (jobTitleId != null)
            {
                JobTitleCache.Add(jobTitleValue, jobTitleId);
                return(new EntityId(jobTitleId));
            }

            return(null);
        }
示例#2
0
        /// <summary>
        /// Closes the stream and ends the api session
        /// </summary>
        public void Close()
        {
            // cancel the renew login process
            _timer?.Dispose();

            // close the cache services
            EmployeeCache?.WriteCacheEntries();
            JobTitleCache?.WriteCacheEntries();
            DepartmentCache?.WriteCacheEntries();
            WorkflowCache?.WriteCacheEntries();
            EmployeeGroupCache?.WriteCacheEntries();
            EmployeeProfileCache?.WriteCacheEntries();

            Logger.Debug("Closed the Api Stream");
        }