public static CampaignSessionModel GetCampaignSession(CampaignSessionModel campaignSession) { var userContent = new UserContentRecord(); var contentResponse = new UserContentResponse(); /// Call new p_GetCampaignIntro /// and new p_GetCampaignContents var requestUrl = string.Format("v1/Animation/UserContent/UserContent/1/{0}", campaignSession.CampaignContentId); var request = new HttpRequestMessage(HttpMethod.Get, requestUrl); try { using (var client = BaseService.GetClient()) { if (client.DefaultRequestHeaders.Contains("AuthHash")) { client.DefaultRequestHeaders.Remove("AuthHash"); } client.DefaultRequestHeaders.Add("AuthHash", campaignSession.AuthorizationHash); var response = client.SendAsync(request).Result; if (response.IsSuccessStatusCode) { contentResponse = response.Content.ReadAsAsync <UserContentResponse>().Result; userContent = contentResponse.Results.FirstOrDefault(); if (userContent != null) { campaignSession.AnimationTopic = userContent.ContentName; campaignSession.JavaScriptFileName = userContent.ContentFileLocation; campaignSession.BannerImageName = userContent.ContentImageFileName; campaignSession.MemberContentData = userContent.MemberContentData; } } } } catch (Exception exc) { HelperService.LogAnonEvent(ExperienceEvents.Error, exc.InnerException == null ? exc.Message : exc.InnerException.InnerException == null ? exc.InnerException.Message : exc.InnerException.InnerException.Message); } return(campaignSession ?? new CampaignSessionModel()); }
public ActionResult Index() { CampaignSessionModel campaignSession = CampaignSessionModel.Current; if (string.IsNullOrEmpty(campaignSession.ExperienceUserId)) { ExperienceLogResponse logResponse = HelperService.LogInitialEvent(campaignSession.EmployerId); if (logResponse != null) { campaignSession.ExperienceUserId = logResponse.ExperienceUserId; CampaignSessionModel.Current = campaignSession; } } if (null != Request.QueryString["cid"]) { string qparam = Request.QueryString["cid"]; string[] qparams = qparam.Split('|'); if (qparams.Length >= 3 && qparams.Length <= 4) { int employerId = int.Parse(qparams[0]); int campaignId = int.Parse(qparams[1]); int contentId = int.Parse(qparams[2]); if (campaignSession.EmployerId != employerId) { ExperienceLogResponse logResponse = HelperService.LogInitialEvent(employerId); campaignSession.ExperienceUserId = logResponse.ExperienceUserId; CampaignSessionModel.Current = campaignSession; } campaignSession.EmployerId = employerId; campaignSession.CampaignId = campaignId; campaignSession.ContentId = contentId; var campaignIntro = WebApiService.GetCampaignIntro( campaignSession.EmployerId, campaignSession.CampaignId); campaignSession.IntroAnimationType = campaignIntro.ContentType; campaignSession.IntroAnimationName = campaignIntro.ContentName; campaignSession.IntroContentId = campaignIntro.ContentId; CampaignSessionModel.Current = campaignSession; if (qparams.Length == 4) { int cchId = int.Parse(qparams[3]); campaignSession.CchId = cchId; AuthorizationResponse authResponse = WebApiService.GetAuthorizationByCchId( campaignSession.EmployerId, campaignSession.CchId); if (!string.IsNullOrEmpty(authResponse.AuthHash)) { campaignSession.AuthorizationHash = authResponse.AuthHash; CampaignSessionModel.Current = campaignSession; campaignSession = WebApiService.GetCampaignSession(CampaignSessionModel.Current); if (!string.IsNullOrEmpty(campaignSession.JavaScriptFileName)) { campaignSession.IntroAnimationName = "NONE"; } CampaignSessionModel.Current = campaignSession; HelperService.LogUserEvent(ExperienceEvents.AuthenticationSuccess, campaignSession.CchId.ToString()); } else { HelperService.LogAnonEvent(ExperienceEvents.AuthenticationFail, campaignSession.CchId.ToString()); } } } else { HelperService.LogAnonEvent(ExperienceEvents.InvalidQueryParameters, qparam); } } else { HelperService.LogAnonEvent(ExperienceEvents.NoQueryParameters); } ViewBag.Vid = campaignSession.PublicIntroVideoUrl; if (campaignSession.IntroAnimationName.Equals("NONE")) { return(RedirectToAction("Dynamic")); } if (!string.IsNullOrEmpty(campaignSession.IntroAnimationName)) { HelperService.LogAnonEvent(ExperienceEvents.StartIntro, campaignSession.IntroAnimationName); } return(View()); }