Пример #1
0
        /// <summary>
        /// Synchronizes the child users.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <param name="groupID">The group ID.</param>
        public void SynchronizeChildUsers(long userID, long groupID)
        {
            if (userID <= 0)
            {
                return;
            }

            try
            {
                string newSSOAuthToken;
                SSOAuth_UserBasicData[] userBasicDataList =
                    SSOAuthWS.GetGroupUsers(GetSSOAuthData(FCMConfig.Security.SSOApplicationID, SSOAuthToken),
                                            out newSSOAuthToken);

                SSOAuthToken = newSSOAuthToken;

                if (userBasicDataList == null)
                {
                    return;
                }

                foreach (SSOAuth_UserBasicData userBasicData in userBasicDataList)
                {
                    if (userBasicData.RoleID.ToLower() != "child")
                    {
                        continue;
                    }

                    bool synchronised =
                        DbProvidersWS.SynchronizeChildUser(ValidationUtils.GetLong(userBasicData.UserID, 0),
                                                           userBasicData.Username, userID, groupID, userBasicData.Deleted) == 1;

                    if (!synchronised)
                    {
                        Logger.Log(LogLevels.Info,
                                   string.Format("Child user synchronize error | childUserID:'{0}', username:'******', parentID='{2}' groupID:'{3}'",
                                                 userBasicData.UserID, userBasicData.Username, userID, groupID));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevels.Error, string.Format("userID:'{0}', groupID:'{1}'", userID, groupID), ex);
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the child users.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        public List <User> GetChildUsers(long userID)
        {
            if (userID <= 0)
            {
                return(null);
            }

            try
            {
                Db_User[]   dbChildUsers = DbProvidersWS.GetChildUsers(userID);
                List <User> childUsers   = ReadChildUsersFromDb(dbChildUsers);

                return(childUsers);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevels.Error, string.Format("userID:'{0}', serviceType:'{1}'", userID), ex);
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// Synchronizes the user.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        /// <param name="username">The username.</param>
        /// <param name="parentID">The parent ID.</param>
        /// <param name="groupID">The group ID.</param>
        private static bool SynchronizeUser(long userID, string username, long parentID, long groupID, string firstName, string lastName, string place)
        {
            if (userID <= 0 || StringUtils.IsNullOrEmptyOrWS(username))
            {
                return(false);
            }

            try
            {
                bool syncronized =
                    DbProvidersWS.SynchronizeUser(userID, username, (parentID == 0 ? FCMConstants.NotDefinedIntValue : parentID), groupID, firstName, lastName, place) == 1;
                return(syncronized);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevels.Error, string.Format("userID:'{0}', username:'******', parentID:'{2}', groupID:'{3}'",
                                                          userID, username, parentID, groupID), ex);

                return(false);
            }
        }
Пример #4
0
        // 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);
            }
        }