//** Assumption! All visits are paired in/out/invalid except the students currently in... public List <ICTReportRow> GenerateCourseReportVisits(int courseID) { List <ICTReportRow> ret = new List <ICTReportRow>(); //working space IList <Visit> list = Repository.GenerateCourseReportVisits(courseID); //get list of valid visits grouped by userID //rules List <SwimTime> baseRules = Repository.GetRulesByCourse(courseID); IList <ISwimTimeRule> converted = SwimTimeToISwimTimeAdaptor.ConvertListOfSwimTimeToListOfISwimTimeRule(); ISwimTimeRuleProcessor temp = SwimTimeRuleProcessorFactory.CreateSwimTimeRuleProcessor(converted); IEnumerator <Visit> i = list.GetEnumerator(); i.Reset(); i.MoveNext(); //initialize iterator while (i.Current != null && i.Current.Visitor != null) //iterate through all visits { int currentUserID = i.Current.Visitor.UserID; List <SwimTimeVisit> cleanVisits = new List <SwimTimeVisit>(); //this users running batch of visits double runningTotal = 0.0; while (i.Current != null && currentUserID == i.Current.Visitor.UserID) //while we are on this userID { Visit prev = i.Current; i.MoveNext(); if (i.Current != null && i.Current.InOutFlag != 1 && prev.InOutFlag == 1) //we have two valid line items { Visit cur = i.Current; //get second visit ret.Add(new ICTReportRow(prev.Visitor.UserID, prev.Visitor.FirstName, prev.Visitor.LastName, prev.InOutFlag, -1.0, prev.VisitTime)); //no display for checkin time...? cleanVisits.Add(new SwimTimeVisit(prev.VisitTime, cur.VisitTime, cur.InOutFlag == 0)); SwimTimeRuleProcessingInformation answer = temp.ProcessMultipleVisits(cleanVisits); runningTotal = answer.GetValidTime(); //get valid time total for this batch of visits ret.Add(new ICTReportRow(cur.Visitor.UserID, cur.Visitor.FirstName, cur.Visitor.LastName, cur.InOutFlag, runningTotal, cur.VisitTime)); i.MoveNext(); //advance iterator } } } return(ret); }