// PRIVATE // /// <summary> /// Reads the child user from database. /// </summary> /// <typeparam name="T">The type of object.</typeparam> /// <param name="dbChildUser">The database child user.</param> private static User ReadChildUserFromDb <T>(T dbChildUser) where T : class { if (typeof(T) == typeof(Db_User)) { Db_User childUserFromDb = dbChildUser as Db_User; return(childUserFromDb == null ? null : new User(childUserFromDb.UserID, childUserFromDb.Username, childUserFromDb.ParentID, (UserStatuses)childUserFromDb.Status, childUserFromDb.CreatedDate)); } return(null); }
// PUBLIC // /// <summary> /// Gets the child user. /// </summary> /// <param name="childUserID">The child user ID.</param> public User GetChildUser(long childUserID) { if (childUserID <= 0) { return(null); } string cacheKey = CacheHelper.BuildCacheKey("ChildUser", childUserID); try { User childUser; if (FCMConfig.Data.EnableCache && CacheUtils.Contains(cacheKey)) { childUser = (User)CacheUtils.GetItem(cacheKey); } else { Db_User dbChildUser = DbProvidersWS.GetChildUser(childUserID); childUser = ReadChildUserFromDb(dbChildUser); if (FCMConfig.Data.EnableCache) { CacheUtils.Add(cacheKey, childUser, null, DateTimeHelper.GetSvcProvDateTimeNow().AddSeconds(FCMConfig.Data.LongCacheDuration), TimeSpan.Zero, cacheNullObjects: FCMConfig.Data.CacheNullObjects); } } return(childUser); } catch (Exception ex) { Logger.Log(LogLevels.Error, string.Format("childUserID:'{0}'", childUserID), ex); return(null); } }