private void AddAggregateDependency(QueryScope associatedScope, AggregateExpression aggregateExpression) { if (associatedScope == null) { AggregateList currentUnscopedAggregateList = _unscopedAggregateExpressionStack.Peek(); currentUnscopedAggregateList.Add(aggregateExpression); } else { AggregateList associatedAggregateExpressions; if (!_aggregateDependencies.TryGetValue(associatedScope, out associatedAggregateExpressions)) { associatedAggregateExpressions = new AggregateList(); _aggregateDependencies.Add(associatedScope, associatedAggregateExpressions); } associatedAggregateExpressions.Add(aggregateExpression); } }
/// <summary> /// Reads the attribute. /// </summary> private DothtmlAttributeNode ReadAttribute() { var startIndex = CurrentIndex; var attribute = new DothtmlAttributeNode(); // attribute name DothtmlNameNode nameOrPrefix = ReadName(false, false, DothtmlTokenType.Text); if (Peek().Type == DothtmlTokenType.Colon) { attribute.PrefixSeparatorToken = Read(); attribute.AttributePrefixNode = nameOrPrefix; attribute.AttributeNameNode = ReadName(false, false, DothtmlTokenType.Text); } else { attribute.AttributeNameNode = nameOrPrefix; } //spaces before separator belong to name attribute.AttributeNameNode.WhitespacesAfter = SkipWhiteSpace(); if (Peek().Type == DothtmlTokenType.Equals) { attribute.ValueSeparatorToken = Read(); var valueStartTokens = SkipWhiteSpace(); var valueEndTokens = new AggregateList <DothtmlToken>(); // attribute value if (Peek().Type == DothtmlTokenType.SingleQuote || Peek().Type == DothtmlTokenType.DoubleQuote) { var quote = Peek().Type; Read(); valueStartTokens = valueStartTokens.AddLen(1); var startingWhitespaces = SkipWhiteSpace(); if (Peek().Type == DothtmlTokenType.OpenBinding) { attribute.ValueNode = ReadBindingValue(false, true); } else { attribute.ValueNode = ReadTextValue(false, true, DothtmlTokenType.Text); } //we had to jump forward to decide attribute.ValueNode.WhitespacesBefore = startingWhitespaces; Assert(quote); valueEndTokens.Add(PeekPart()); Read(); } else { attribute.ValueNode = ReadTextValue(false, false, DothtmlTokenType.Text); //these are not part of any attribute or value SkipWhiteSpace(); } attribute.ValueStartTokens = valueStartTokens; valueEndTokens.Add(SkipWhiteSpace()); attribute.ValueEndTokens = valueEndTokens; } attribute.Tokens.Add(GetTokensFrom(startIndex)); return(attribute); }
public override QueryNode VisitSelectQuery(SelectQuery query) { _unscopedAggregateExpressionStack.Push(new AggregateList()); // Visit FROM table references if (query.TableReferences != null) { query.TableReferences = VisitTableReference(query.TableReferences); } if (QueryHasAggregates(query.QueryScope)) { _errorReporter.AggregateInOn(); return(query); } // Visit WHERE expression if (query.WhereClause != null) { query.WhereClause = VisitExpression(query.WhereClause); } if (QueryHasAggregates(query.QueryScope)) { _errorReporter.AggregateInWhere(); return(query); } // Visit GROUP BY clause if (query.GroupByColumns != null) { for (int i = 0; i < query.GroupByColumns.Length; i++) { query.GroupByColumns[i] = VisitExpression(query.GroupByColumns[i]); } } if (QueryHasAggregates(query.QueryScope)) { _errorReporter.AggregateInGroupBy(); return(query); } // Visit select list. for (int i = 0; i < query.SelectColumns.Length; i++) { query.SelectColumns[i].Expression = VisitExpression(query.SelectColumns[i].Expression); } // Visit having clause. if (query.HavingClause != null) { query.HavingClause = VisitExpression(query.HavingClause); } // Visit ORDER BY. if (query.OrderByColumns != null) { for (int i = 0; i < query.OrderByColumns.Length; i++) { query.OrderByColumns[i].Expression = VisitExpression(query.OrderByColumns[i].Expression); } } AggregateList unscopedAggregateList = _unscopedAggregateExpressionStack.Pop(); ICollection <AggregateExpression> directAggregateDependencies = GetAggregateDependencies(query.QueryScope); List <AggregateExpression> aggregateDependencies = new List <AggregateExpression>(); aggregateDependencies.AddRange(unscopedAggregateList.Values); if (directAggregateDependencies != null) { aggregateDependencies.AddRange(directAggregateDependencies); } query.AggregateDependencies = aggregateDependencies.ToArray(); return(query); }
//public PartialViewResult GuardianInfo(string studentNumber) //{ // var GuardianInfoes = Db.Guardians.Include(p => p.Student).Where(s => s.GuardianEmail.Contains(studentNumber)); // return PartialView(GuardianInfoes); //} #region Result Display public async Task <ActionResult> PrintSecondTerm(string id, string term, string sessionName) { _resultCommand = new ResultCommandManager(id, term, sessionName, userSchool); var reportModel = new ReportVm(); var newCalist = new List <ContinuousAssesmentVm>(); foreach (var ca in _resultCommand._studentCa) { var caVm = new ContinuousAssesmentVm { SubjectName = ca.Subject.SubjectName, SubjectPosition = _resultCommand.FindSubjectPosition(ca.SubjectId), SubjectHighest = _resultCommand.SubjectHighest(ca.SubjectId), SubjectLowest = _resultCommand.SubjectLowest(ca.SubjectId), ClassAverage = await _resultCommand.CalculateClassAverage(ca.SubjectId), FirstCa = ca.FirstCa, SecondCa = ca.SecondCa, ThirdCa = ca.ThirdCa, ForthCa = ca.ForthCa, FifthCa = ca.FifthCa, SixthCa = ca.SixthCa, SeventhCa = ca.SeventhCa, EightCa = ca.EightCa, NinthtCa = ca.NinthtCa, ExamCa = ca.ExamCa, Total = ca.Total, Grading = ca.Grading, Remark = ca.Remark, StaffName = ca.StaffName }; newCalist.Add(caVm); } reportModel.ContinuousAssesmentVms = newCalist; reportModel.NoOfStudentPerClass = await _resultCommand.NumberOfStudentPerClass(); reportModel.NoOfSubjectOffered = await _resultCommand.SubjectOfferedByStudent(); reportModel.AggregateScore = _resultCommand.TotalScorePerStudent(); reportModel.Average = await _resultCommand.CalculateAverage(); reportModel.OverAllGrade = _gradeRemark.Grading(reportModel.Average, _resultCommand._className, userSchool); var myOtherSkills = await Db.Psychomotors.AsNoTracking().Where(s => s.StudentId.Contains(id) && s.TermName.Contains(term) && s.SessionName.Contains(sessionName) && s.ClassName.Equals(_resultCommand._className)) .Select(c => c.Id).FirstOrDefaultAsync(); reportModel.BehaviorCategory = await Db.BehaviorSkillCategories.AsNoTracking() .Where(s => s.SchoolId.Equals(userSchool)) .Select(x => x.Name).ToListAsync(); reportModel.AssignBehaviors = await Db.AssignBehaviors.Where(s => s.SchoolId.Equals(userSchool) && s.StudentId.Contains(id) && s.TermName.Contains(term) && s.SessionName.Contains(sessionName)).ToListAsync(); reportModel.AssignBehavior = reportModel.AssignBehaviors.FirstOrDefault(); reportModel.ReportCard = await Db.ReportCards.FirstOrDefaultAsync(x => x.SchoolId.Equals(userSchool) && x.TermName.ToUpper().Equals(term) && x.SessionName.Equals(sessionName)); //ViewBag.Class = reportModel.PrincipalComment = _gradeRemark.PrincipalRemark(reportModel.Average, _resultCommand._className, userSchool); reportModel.TermName = term; reportModel.SessionName = sessionName; reportModel.ClassName = _resultCommand._className; reportModel.Student = await Db.Students.FindAsync(id); reportModel.CaSetUp = await Db.CaSetUps.AsNoTracking().Where(x => x.IsTrue.Equals(true) && x.Class.FullClassName.Equals(_resultCommand._className)) .OrderBy(o => o.CaOrder).ToListAsync(); reportModel.CaSetUpCount = reportModel.CaSetUp.Count(); var myAggregateList = new List <AggregateList>(); var classMate = Db.AssignedClasses.AsNoTracking().Where(x => x.ClassName.Equals(_resultCommand._className)) .Select(s => s.StudentId).ToList(); foreach (var student in classMate) { var aggregateList = new AggregateList() { Score = await Db.CaLists.AsNoTracking().Where(x => x.SchoolId.Equals(userSchool) && x.StudentId.Equals(student) && x.ClassName.Equals(_resultCommand._className) && x.TermName.Equals(term) && x.SessionName.Equals(sessionName)) .SumAsync(s => s.Total), StudentId = student }; myAggregateList.Add(aggregateList); } reportModel.AggregatePosition = _resultCommand.FindAggregatePosition(myAggregateList); //return View(reportModel); return(new ViewAsPdf("PrintSecondTerm", reportModel)); }