public int?GetProjectId(HttpContextBase httpContext) { try { if (ShouldContinue(httpContext) == false) { return(null); } if (_experimentationFactory.IsConfigured == false) { return(null); } var instance = _experimentationFactory.Instance; if (httpContext?.Items["ProjectId"] != null) { return(int.Parse(httpContext.Items["ProjectId"].ToString())); } var experimentMap = GetProjectExperimentMapping(); if (experimentMap == null) { return(null); } var experimentKey = experimentMap.ExperimentKey; var userId = _userRetriever.GetUserId(httpContext); if (userId == string.Empty) { return(0); } var userAttributes = _userRetriever.GetUserAttributes(httpContext); var projectVariation = instance.Activate(experimentKey, userId, userAttributes); if (projectVariation != null) { //Map the experimentation variation key to a project Id var mappingItem = experimentMap.ExperimentMapping.Where(x => x.VariationKey == projectVariation.Key).ToList(); if (mappingItem.Count() == 1 && !string.IsNullOrEmpty(mappingItem.First().ProjectId)) { if (int.TryParse(mappingItem.First().ProjectId, out var projectId)) { if (projectId > 0) { if (httpContext != null) { httpContext.Items["ProjectId"] = projectId; } return(projectId); } } } return(null); } } catch { // ignored } return(null); }
public int GetUserId(string userName, string password) { return(_userRetriever.GetUserId(userName, password)); }