Ejemplo n.º 1
0
        /// <summary>
        /// If UserStorageService is provided, Calls Get for given UserId and validate the result.
        /// </summary>
        /// <param name="campaignKey"></param>
        /// <param name="userId"></param>
        /// <param name="userStorageData"></param>
        /// <returns>
        /// Returns userStorageMap if validation is success, else null.
        /// </returns>
        internal UserStorageMap GetUserMap(string campaignKey, string userId, Dictionary <string, dynamic> userStorageData = null)
        {
            if (this._userStorageService == null)
            {
                LogDebugMessage.NoUserStorageServiceGet(file);
                return(null);
            }

            UserStorageMap userMap = TryGetUserMap(userId, campaignKey, userStorageData);

            if (userMap == null || string.IsNullOrEmpty(userMap.CampaignKey) ||
                string.IsNullOrEmpty(userMap.VariationName) || string.IsNullOrEmpty(userMap.UserId) ||
                string.Equals(userMap.UserId, userId) == false || string.Equals(userMap.CampaignKey, campaignKey) == false)
            {
                LogDebugMessage.NoStoredVariation(file, userId, campaignKey);
                return(null);
            }
            LogInfoMessage.GotStoredVariation(file, userMap.VariationName, campaignKey, userId);
            return(userMap);
        }
        /// <summary>
        /// If UserProfileService is provided, Calls Lookup for given UserId and validate the result.
        /// </summary>
        /// <param name="campaignTestKey"></param>
        /// <param name="userId"></param>
        /// <returns>
        /// Returns userProfileMap if validation is success, else null.
        /// </returns>
        internal UserProfileMap GetUserMap(string campaignTestKey, string userId)
        {
            if (this._userProfileService == null)
            {
                LogDebugMessage.NoUserProfileServiceLookup(file);
                return(null);
            }

            UserProfileMap userMap = TryGetUserMap(userId, campaignTestKey);

            if (userMap == null || string.IsNullOrEmpty(userMap.CampaignTestKey) ||
                string.IsNullOrEmpty(userMap.VariationName) || string.IsNullOrEmpty(userMap.UserId) ||
                string.Equals(userMap.UserId, userId) == false || string.Equals(userMap.CampaignTestKey, campaignTestKey) == false)
            {
                LogDebugMessage.NoStoredVariation(file, userId, campaignTestKey);
                return(null);
            }

            LogInfoMessage.GotStoredVariation(file, userMap.VariationName, campaignTestKey, userId);
            LogDebugMessage.GettingStoredVariation(file, userId, campaignTestKey, userMap.VariationName);
            return(userMap);
        }