Exemple #1
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");
        }
Exemple #2
0
        /// <summary>
        /// Gets a department id based on its name.
        /// </summary>
        /// <param name="from">The from value to parse</param>
        /// <param name="user">The user object that contains the data.</param>
        /// <param name="division"></param>
        /// <returns></returns>
        public EntityId GetDepartment(string from,
                                      ActiveDirectoryUser user,
                                      EntityId division)
        {
            // get the department name
            var departmentName = GetFieldValue(from, user);

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

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

            // did not find the department in the cache
            // try to get it from the serice
            var departmentId = ApiService.GetDepartmentAsync(departmentName, division, AuthToken).GetAwaiter().GetResult();

            if (departmentId != null)
            {
                DepartmentCache.Add(departmentName, departmentId);
                return(new EntityId(departmentId));
            }

            // we did not find the department in the service...create it
            departmentId = ApiService.CreateDepartmentAsync(departmentName, division, AuthToken).GetAwaiter().GetResult();
            if (departmentId != null)
            {
                DepartmentCache.Add(departmentName, departmentId);
                return(new EntityId(departmentId));
            }

            return(null);
        }
Exemple #3
0
        public ActionResult GetPostListJson(string orgCode, string isOrg)
        {
            var dept = new DepartmentBLL().GetEntityByCode(orgCode);

            if (dept != null)
            {
                isOrg = dept.EnCode;
                var entity = new DepartmentBLL().GetEntity(dept.OrganizeId);
                if (entity != null)
                {
                    orgCode = entity.EnCode;
                }
            }
            else
            {
                isOrg = "true";
            }
            DepartmentCache  departBll  = new DepartmentCache();
            DepartmentEntity departList = departBll.GetList().Where(t => t.EnCode == orgCode).FirstOrDefault();
            var data = postCache.GetList(departList.OrganizeId, isOrg).OrderBy(x => x.SortCode);

            return(Content(data.ToJson()));
        }