public static ExperienceLogResponse LogInitialEvent(int employerId) { var experienceResponse = new ExperienceLogResponse(); var experienceLog = new ExperienceLogRequest() { EmployerId = employerId, EventName = "StartWebsite", LogComment = string.Format("Animations Website launched ") }; var requestUrl = string.Format("v1/Animation/Experience/LogInitial/{0}", "AnzovinHandshakeId".GetConfigurationValue()); try { using (var client = BaseService.GetClient()) { var response = client.PostAsJsonAsync(requestUrl, experienceLog).Result; if (response.IsSuccessStatusCode) { experienceResponse = response.Content.ReadAsAsync <ExperienceLogResponse>().Result; } } } catch (Exception exc) { HelperService.LogAnonEvent(ExperienceEvents.Error, exc.InnerException == null ? exc.Message : exc.InnerException.InnerException == null ? exc.InnerException.Message : exc.InnerException.InnerException.Message); experienceResponse.ExperienceUserId = Guid.NewGuid().ToString(); } return(experienceResponse); }
public HttpResponseMessage LogInitialExperience(string hsId, [FromBody] ExperienceLogRequest eventLogRequest) { HttpResponseMessage hrm = Request.CreateResponse(HttpStatusCode.Unauthorized); if (ValidateConsumer.IsValidConsumer(hsId)) { hrm = Request.CreateErrorResponse( HttpStatusCode.NoContent, "Unexpected Error"); if (eventLogRequest.EmployerId > 0) { AppendClientVersion(eventLogRequest); using (GetEmployerConnString gecs = new GetEmployerConnString(eventLogRequest.EmployerId)) { try { using (InsertExperienceLog iel = new InsertExperienceLog()) { ExperienceLogResponse elr = new ExperienceLogResponse { ExperienceUserId = Guid.NewGuid().ToString() }; iel.ExperienceEventId = eventLogRequest.EventId; iel.ExperienceEventDesc = eventLogRequest.EventName; iel.ExperienceUserId = elr.ExperienceUserId; iel.Comment = eventLogRequest.LogComment; iel.DeviceId = eventLogRequest.DeviceId; iel.ClientVersion = eventLogRequest.ClientVersion; iel.PostData(gecs.ConnString); hrm = Request.CreateResponse(HttpStatusCode.OK, elr); } } catch (Exception exc) { hrm = Request.CreateErrorResponse(HttpStatusCode.NoContent, String.Format("Insert Experience Event Procedure Failed: {0}", exc.Message)); } } } } return(hrm); }
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()); }