private void Page_Load(object sender, EventArgs e) { // Put user code to initialize the page here ScoreList.DataSource = Sitecore.Context.Database.GetItem("/sitecore/content/Repository/Profile Gathering Pages").Children; ScoreList.DataBind(); TrackerDataContext tc = Sitecore.Analytics.Tracker.DataContext; StringBuilder sb = new StringBuilder(); if (Tracker.CurrentVisit == null) { return; } if (Tracker.CurrentVisit.Keywords != null && !String.IsNullOrEmpty(Tracker.CurrentVisit.Keywords.Text)) { sb.Append("Search keywords for current visit: " + Tracker.CurrentVisit.Keywords.Text + ".<br/>"); } const int checkVisits = 10; Sitecore.Analytics.Data.DataAccess.VisitorLoadOptions vOptions = new Sitecore.Analytics.Data.DataAccess.VisitorLoadOptions { Start = Tracker.CurrentVisit.VisitorVisitIndex - 1, Count = Tracker.CurrentVisit.VisitorVisitIndex - checkVisits, VisitLoadOptions = VisitLoadOptions.Visits }; foreach (VisitorDataSet.VisitsRow visit in Tracker.Visitor.GetVisits(vOptions).Where( visit => visit.VisitId != Tracker.CurrentVisit.VisitId).OrderByDescending( visit => visit.VisitorVisitIndex)) { if (visit.Keywords != null && !String.IsNullOrEmpty(visit.Keywords.Text)) { sb.Append("Last search keywords from " + visit.StartDateTime + " visit: " + visit.Keywords.Text + "<br/>"); return; } } sb.Append("No search keywords for current or last " + checkVisits + " visits.<br/>"); DMS.Text = sb.ToString(); var profilesRows = tc.Profiles; ProfileScores.DataSource = GetProfileKeys("Keynotes"); ProfileScores.DataBind(); }
protected void BindScoreGrid(long id, T_Batch bid) { //var b_id = _db.T_BatchSet.Where(s => s.CandidateId == id).Select(x => x.BatchId); //var candBatch = _db.T_Batch.FirstOrDefault(s => b_id.Contains(s.Id) && s.IsActive.Value); var candBatch = bid; var b_question = _db.T_BatchQuestions.Where(s => s.BatchId == candBatch.Id).Select(s => s.QuestionId); var quests = _db.T_CandidateAnswers.Where(s => s.CandidateId == id && s.BatchId == candBatch.Id).Select(a => new TestScoreGridModel { QuestionNo = a.QuestionId.Value, OptionType = ErecruitHelper.getQOptionTypeName(a.QuestionId.Value), CandidateOptions = ErecruitHelper.GetCandidateOptions(id, candBatch.Id, a.QuestionId.Value), Url = a.Correct.Value == true ? "../Images/accept.png" : "../Images/delete.png", Alt = a.Correct.Value == true ? "Correct":"Wrong" }).Distinct().ToList(); var answered = quests.Select(s => s.QuestionNo); var unanswered = _db.T_Question.Where(s => b_question.Contains(s.Id) && !answered.Contains(s.Id)).Select(a => new TestScoreGridModel { QuestionNo = a.Id, OptionType = ErecruitHelper.getQOptionTypeName(a.Id), CandidateOptions = "Unanswered", Url = "../Images/help.png", Alt = "?" }).Distinct().ToList(); int i = quests.Count(); if (i > 0) { quests.InsertRange(quests.Count() - 1, unanswered); } else { quests.InsertRange(0, unanswered); } ScoreList.DataSource = quests; ScoreList.DataBind(); ScoreListPanel.Visible = true; }