Example #1
0
        public void CanGetAuthorizationByCchId()
        {
            if (!Debugger.IsAttached)
            {
                return;
            }

            var response = WebApiService.GetAuthorizationByCchId(11, 57020);

            Assert.IsNotNull(response);
            Assert.IsFalse(string.IsNullOrEmpty(response.AuthHash));
        }
Example #2
0
        public void CanLogInitialEvent()
        {
            if (!Debugger.IsAttached)
            {
                return;
            }

            var response = WebApiService.GetAuthorizationByCchId(11, 57020);

            var result = WebApiService.LogUserEvent(new DynamicAnimation.Models.ExperienceLogRequest()
            {
                CchId            = 57020,
                ContentId        = "unittest",
                EmployerId       = 11,
                EventId          = 0,
                EventName        = "UnitTest",
                ExperienceUserId = "unittest",
                LogComment       = "CanLogInitialEvent UnitTest Run"
            }, response.AuthHash);

            Assert.IsNotNull(result);
        }
Example #3
0
        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());
        }