protected override void OnPreRender(EventArgs e) { DojoClassManager cManager; DojoAttendanceEntryManager aManager; string classQuery; string attendanceQuery; EnsureChildControls(); if (this.backTime == TimeSpan.Zero) { classQuery = "SigninEnd>=#" + localTime.Subtract(backTime).ToString() + "# AND " + "SigninStart<=#" + localTime.ToString() + "#"; } else { classQuery = "ClassEnd>=#" + localTime.Subtract(backTime).Date.ToString() + "# AND " + "ClassStart<=#" + localTime.AddDays(1).Date.ToString() + "#"; } attendanceQuery = "MemberID=" + memberID.ToString() + " AND " + classQuery; cManager = new DojoClassManager(); aManager = new DojoAttendanceEntryManager();; // Be sure to adjust the backtime if you want earlier signin times. classes = cManager.GetCollection(classQuery, "ClassStart", DojoClassFlags.Instructor, DojoClassFlags.InstructorRank, DojoClassFlags.InstructorPrivateContact); classIdArray = new string[classes.Count]; for (int x = 0; x < classes.Count; x++) { classIdArray[x] = classes[x].iD.ToString(); } Page.ClientScript.RegisterHiddenField("___" + ClientID + "Classes", string.Join(",", classIdArray)); attendance = aManager.GetCollection(attendanceQuery, string.Empty, DojoAttendanceEntryFlags.Class); }
protected override void RenderViewPane(HtmlTextWriter output) { if (ConnectionString == string.Empty) { output.Write("Empty Connection String!"); } DojoClass c = new DojoClass(int.Parse(Page.Request.QueryString[0])); RenderTableBeginTag("_viewPanel", this.CellPadding, this.CellSpacing, Unit.Percentage(100), Unit.Empty, this.CssClass); output.WriteFullBeginTag("tr"); output.WriteBeginTag("th"); output.WriteAttribute("class", this.HeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(c.Name); output.WriteEndTag("th"); output.WriteEndTag("tr"); #region Students Attended DojoAttendanceEntryManager aem = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection entries = aem.GetCollection("ClassID=" + c.ID.ToString(), "LastName, FirstName, MiddleName", DojoAttendanceEntryFlags.Member, DojoAttendanceEntryFlags.MemberPrivateContact); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", this.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Students (" + entries.Count.ToString() + ")"); output.WriteEndTag("td"); output.WriteEndTag("tr"); foreach (DojoAttendanceEntry entry in entries) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", this.defaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(entry.Member.PrivateContact.ConstructName("LS,FMi.")); output.WriteEndTag("td"); output.WriteEndTag("tr"); } #endregion output.WriteEndTag("table"); }
/// <summary> /// Render this control to the output parameter specified. /// </summary> /// <param name="output"> The HTML writer to write out to </param> protected override void RenderContent(HtmlTextWriter output) { DojoAttendanceEntryManager m = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection dojoAttendanceEntryCollection = m.GetCollection(string.Empty, string.Empty, null); // Render Header Row this.headerLockEnabled = true; RenderRow(this.HeaderRowCssClass, ); bool rowflag = false; string rowCssClass; // // Render Records // foreach (DojoAttendanceEntry dojoAttendanceEntry in dojoAttendanceEntryCollection) { if (rowflag) { rowCssClass = defaultRowCssClass; } else { rowCssClass = alternateRowCssClass; } rowflag = !rowflag; output.WriteBeginTag("tr"); output.WriteAttribute("i", dojoAttendanceEntry.ID.ToString()); output.WriteLine(HtmlTextWriter.TagRightChar); output.Indent++; output.Indent--; output.WriteEndTag("tr"); output.WriteLine(); } }
public override void Render(System.Web.UI.HtmlTextWriter output) { TableGrid grid; if (ParentWindow is TableGrid) { grid = (TableGrid)ParentWindow; if (ParentWindow is DojoMemberGrid) { } else if (ParentWindow is DojoTestEligibilityGrid) { } else { throw(new Exception("Parent window is not supported.")); } } else { throw(new Exception("Parent window is not supported.")); } DojoMember m = new DojoMember(int.Parse(grid.Page.Request.QueryString[0])); RenderTableBeginTag(output, "_viewPanel", grid.CellPadding, grid.CellSpacing, Unit.Percentage(100), Unit.Empty, grid.CssClass); output.WriteFullBeginTag("tr"); output.WriteBeginTag("th"); output.WriteAttribute("class", grid.HeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(m.PrivateContact.FullName); output.WriteEndTag("th"); output.WriteEndTag("tr"); #region Contact Information output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Contacts"); if (m.PrivateContact.IsBadAddress) { output.Write(" - <strong>Bad Address</strong>"); } output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(m.PrivateContact.ConstructAddress("<br />")); output.Write("<br />"); if (m.PrivateContact.HomePhone != string.Empty) { output.Write(m.PrivateContact.HomePhone + " (h)<br />"); } if (m.PrivateContact.WorkPhone != string.Empty) { output.Write(m.PrivateContact.WorkPhone + " (w)<br />"); } if (m.PrivateContact.MobilePhone != string.Empty) { output.Write(m.PrivateContact.MobilePhone + " (m)<br />"); } if (m.PrivateContact.Email1 != string.Empty) { output.Write("<a href=\"mailto:"); output.Write(m.PrivateContact.Email1); output.Write("\">"); output.Write(m.PrivateContact.Email1); output.Write("</a>"); output.Write("<br />"); } if (m.PrivateContact.ValidationMemo != null && m.PrivateContact.ValidationMemo.Length > 0) { output.Write("<br />"); output.Write("<strong>Validation Memo : </strong><br />"); output.Write(m.PrivateContact.ValidationMemo.Replace("\n", "<br />")); } output.WriteEndTag("td"); output.WriteEndTag("tr"); #endregion #region Membership Information output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Membership"); if (m.IsPastDue) { output.Write(" - <strong>Past Due</strong>"); } output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("<strong>Student Type</strong> : "); output.Write(m.MemberType.Name); output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("<strong>Membership Date</strong> : "); output.Write(m.MemberSince.ToLongDateString()); output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("<strong>Active Membership</strong> : "); if (m.IsPrimaryOrgActive) { output.Write("Yes"); } else { output.Write("No"); } output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("<strong>Rank</strong> : "); output.Write(m.Rank.Name); output.Write(" (" + m.RankDate.ToShortDateString() + ")"); output.WriteEndTag("td"); output.WriteEndTag("tr"); #endregion #region Attendance Information // Pull last 90 days of attendance from the database int maxEntries = 150; int displayEntries = 5; DateTime minSearchDate = DateTime.Now.Subtract(TimeSpan.FromDays(90)); DojoAttendanceEntryManager aem = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection attendance = aem.GetCollection(maxEntries, "MemberID=" + m.ID.ToString() + " AND ClassStart>=#" + minSearchDate.ToString() + "#", "ClassStart DESC", DojoAttendanceEntryFlags.Class); DojoMember instructor1 = m.Instructor1; DojoMember instructor2 = m.Instructor2; DojoMember instructor3 = m.Instructor3; if (attendance.Count < displayEntries) { displayEntries = attendance.Count; } output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Attendance"); output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("<strong>Time In Membership</strong> : "); output.Write(m.TimeInMembership.TotalHours.ToString("f") + " Hours"); output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("<strong>Time In Rank</strong> : "); output.Write(m.TimeInRank.TotalHours.ToString("f") + " Hours"); output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("<strong>Last Signin</strong> : "); output.Write(m.LastSignin.ToLongDateString()); output.WriteEndTag("td"); output.WriteEndTag("tr"); // Top Instructor output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Ninety Day Instructors"); output.WriteEndTag("td"); output.WriteEndTag("tr"); if (instructor1 != null) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(instructor1.PrivateContact.FullName); output.WriteEndTag("td"); output.WriteEndTag("tr"); } else { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("None"); output.WriteEndTag("td"); output.WriteEndTag("tr"); } if (instructor2 != null) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(instructor2.PrivateContact.FullName); output.WriteEndTag("td"); output.WriteEndTag("tr"); } if (instructor3 != null) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(instructor3.PrivateContact.FullName); output.WriteEndTag("td"); output.WriteEndTag("tr"); } // Display Last 5 Classes output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Ninety Day Activity"); output.WriteEndTag("td"); output.WriteEndTag("tr"); if (displayEntries == 0) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("None"); output.WriteEndTag("td"); output.WriteEndTag("tr"); } else { for (int x = 0; x < displayEntries; x++) { DojoAttendanceEntry entry = attendance[x]; output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write(entry.Class.Name + " - " + entry.Class.ClassStart.ToString("dddd, MMMM d - h:mm tt")); output.WriteEndTag("td"); output.WriteEndTag("tr"); } } #endregion // #region Instructor Information // // if(m.IsInstructor) // { // output.WriteFullBeginTag("tr"); // output.WriteBeginTag("td"); // output.WriteAttribute("class", grid.SubHeaderCssClass); // output.Write(HtmlTextWriter.TagRightChar); // output.Write("Instructor Details"); // output.WriteEndTag("td"); // output.WriteEndTag("tr"); // } // // #endregion #region Security if (this.ParentWindow.Page.User.IsInRole("Tessen/Administrator")) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Security"); output.WriteEndTag("td"); output.WriteEndTag("tr"); if (m.UserAccount == null) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("The member has no associated user account."); output.WriteEndTag("td"); output.WriteEndTag("tr"); } else { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("<strong>Username</strong> : "); output.Write(m.UserAccount.UserName); output.Write("<br />"); output.Write("<strong>Last Access</strong> : "); if (m.UserAccount.LoginDate != DateTime.MinValue) { output.Write(m.UserAccount.LoginDate); } else { output.Write("None"); } output.Write("<br />"); output.Write("<strong>Login Count</strong> : "); output.Write(m.UserAccount.LoginCount); output.WriteEndTag("td"); output.WriteEndTag("tr"); } } #endregion #region Memos if (this.ParentWindow.Page.User.IsInRole("Tessen/Administrator")) { output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Current Attendance Message"); output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); if (m.AttendanceMessage != "") { output.Write(m.AttendanceMessage); } else { output.Write("Empty"); } output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.SubHeaderCssClass); output.Write(HtmlTextWriter.TagRightChar); output.Write("Memo"); output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.WriteAttribute("class", grid.DefaultRowCssClass); output.Write(HtmlTextWriter.TagRightChar); if (m.PrivateContact.MemoText != "") { output.Write(m.PrivateContact.MemoText.Replace("\n", "<br>")); } else { output.Write("Empty"); } output.WriteEndTag("td"); output.WriteEndTag("tr"); } #endregion output.WriteEndTag("table"); }
private void bindDropDownLists() { #region Bind Allowed Child Data msAllowedMemberType1.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager allowedMemberType1Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection allowedMemberType1Collection = allowedMemberType1Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry allowedMemberType1 in allowedMemberType1Collection) { ListItem i = new ListItem(allowedMemberType1.ToString(), allowedMemberType1.ID.ToString()); msAllowedMemberType1.Items.Add(i); } msAllowedMemberType2.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager allowedMemberType2Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection allowedMemberType2Collection = allowedMemberType2Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry allowedMemberType2 in allowedMemberType2Collection) { ListItem i = new ListItem(allowedMemberType2.ToString(), allowedMemberType2.ID.ToString()); msAllowedMemberType2.Items.Add(i); } msAllowedMemberType3.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager allowedMemberType3Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection allowedMemberType3Collection = allowedMemberType3Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry allowedMemberType3 in allowedMemberType3Collection) { ListItem i = new ListItem(allowedMemberType3.ToString(), allowedMemberType3.ID.ToString()); msAllowedMemberType3.Items.Add(i); } msAllowedMemberType4.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager allowedMemberType4Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection allowedMemberType4Collection = allowedMemberType4Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry allowedMemberType4 in allowedMemberType4Collection) { ListItem i = new ListItem(allowedMemberType4.ToString(), allowedMemberType4.ID.ToString()); msAllowedMemberType4.Items.Add(i); } msAllowedMemberType5.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager allowedMemberType5Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection allowedMemberType5Collection = allowedMemberType5Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry allowedMemberType5 in allowedMemberType5Collection) { ListItem i = new ListItem(allowedMemberType5.ToString(), allowedMemberType5.ID.ToString()); msAllowedMemberType5.Items.Add(i); } #endregion #region Bind Denied Child Data msDeniedMemberType1.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager deniedMemberType1Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection deniedMemberType1Collection = deniedMemberType1Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry deniedMemberType1 in deniedMemberType1Collection) { ListItem i = new ListItem(deniedMemberType1.ToString(), deniedMemberType1.ID.ToString()); msDeniedMemberType1.Items.Add(i); } msDeniedMemberType2.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager deniedMemberType2Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection deniedMemberType2Collection = deniedMemberType2Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry deniedMemberType2 in deniedMemberType2Collection) { ListItem i = new ListItem(deniedMemberType2.ToString(), deniedMemberType2.ID.ToString()); msDeniedMemberType2.Items.Add(i); } msDeniedMemberType3.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager deniedMemberType3Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection deniedMemberType3Collection = deniedMemberType3Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry deniedMemberType3 in deniedMemberType3Collection) { ListItem i = new ListItem(deniedMemberType3.ToString(), deniedMemberType3.ID.ToString()); msDeniedMemberType3.Items.Add(i); } msDeniedMemberType4.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager deniedMemberType4Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection deniedMemberType4Collection = deniedMemberType4Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry deniedMemberType4 in deniedMemberType4Collection) { ListItem i = new ListItem(deniedMemberType4.ToString(), deniedMemberType4.ID.ToString()); msDeniedMemberType4.Items.Add(i); } msDeniedMemberType5.Items.Add(new ListItem("Null", "Null")); DojoAttendanceEntryManager deniedMemberType5Manager = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection deniedMemberType5Collection = deniedMemberType5Manager.GetCollection(string.Empty, string.Empty, null); foreach (DojoAttendanceEntry deniedMemberType5 in deniedMemberType5Collection) { ListItem i = new ListItem(deniedMemberType5.ToString(), deniedMemberType5.ID.ToString()); msDeniedMemberType5.Items.Add(i); } #endregion }
///// <summary> ///// Applies the promotion to the attendance database. This will update the ranks on ///// the promotion member's attendance using the dates of the member's attendance. ///// This is necissary to do, because the attendance tracker may have recorded incorrect ///// ranks before the promotion was entered into the database and after the actual test. ///// </summary> ///// <param name="promotion"></param> //public void AttendanceAdjustment(DojoPromotion promotion) //{ // DojoPromotionManager promotionManager; // DojoPromotion nextPromotion; // DojoAttendanceEntryManager attendanceManager; // DojoAttendanceEntryCollection promotionAttendance; // // Try to find member's next promotion if it exists. // promotionManager = new DojoPromotionManager(); // attendanceManager = new DojoAttendanceEntryManager(); // nextPromotion = // promotionManager.FindPromotionByMember(promotion.Member.iD, // promotion.PromotionRank.PromotionRank.iD); // if (nextPromotion == null) // promotionAttendance = attendanceManager.GetCollection( // "DojoClass.ClassStart>=#" + promotion.PromotionDate + "#" + // " AND MemberID=" + promotion.member.iD, // string.Empty, DojoAttendanceEntryFlags.Class); // else // promotionAttendance = attendanceManager.GetCollection( // "DojoClass.ClassStart>=#" + promotion.PromotionDate + "#" + // " AND DojoClass.ClassStart<=#" + nextPromotion.PromotionDate.Subtract(TimeSpan.FromDays(1)) + "#" + // " AND MemberID=" + promotion.member.iD, // string.Empty, DojoAttendanceEntryFlags.Class); // for (int x = 0; x < promotionAttendance.Count; x++) // { // if (promotionAttendance[x].Rank.iD != promotion.PromotionRank.iD) // { // promotionAttendance[x].Rank = promotion.PromotionRank; // promotionAttendance[x].Save(); // } // } //} public void AttendanceAdjustment(DojoMember member) { DateTime nextPromotionDate; int promotionFirstClassIndex; DojoPromotion promotion; DojoPromotionManager promotionManager; DojoPromotionCollection promotions; DojoAttendanceEntryManager attendanceManager; DojoAttendanceEntryCollection attendance; Database database; DbCommand dbCommand; database = DatabaseFactory.CreateDatabase(); // Load member promotions oldest to newest promotionManager = new DojoPromotionManager(); promotions = promotionManager.GetCollection( "MemberID=" + member.ID.ToString(), "PromotionDate", DojoPromotionFlags.PromotionRank); // If the member has no promotions set all attendance // for the member to the member's rank. if (promotions.Count == 0) { dbCommand = database.GetSqlStringCommand( "UPDATE kitTessen_Attendance " + "SET RankID=@RankID " + "WHERE MemberID=@MemberID;"); database.AddInParameter(dbCommand, "@MemberID", DbType.Int32, member.ID); database.AddInParameter(dbCommand, "@RankID", DbType.Int32, member.Rank.ID); database.ExecuteNonQuery(dbCommand); return; } // Load Attendance oldest to newest attendanceManager = new DojoAttendanceEntryManager(); attendance = attendanceManager.GetCollection("MemberID=" + member.ID.ToString(), "ClassStart", DojoAttendanceEntryFlags.Class); // 0 1 2 // First Promotion >>>>>>>>>>>> Next Promotion // DON'T CHANGE 11/04/2003 5/2/2007 1/3/2008 // ...............p............................p.................p // beginner rokyu sankyu nikyu // // 12/13/2001 11/04/2003 5/2/2007 1/1/2008 // c c c c c c c c c c ccc cc c c cc c // 0 1 2 3 4 5 6 7 8 9 012 34 5 6 78 9 // 0=========================================1============================= // Loop through the classes and find the first class // of the first promotion promotionFirstClassIndex = 0; for (int i = 0; i < attendance.Count; i++) { // i=4, 11/04/2003 >= 11/04/2003 true if (attendance[i].Class.ClassStart >= promotions[0].PromotionDate) { promotionFirstClassIndex = i; break; } } // Loop through promotions - oldest to newest for (int p = 0; p < promotions.Count; p++) { promotion = promotions[p]; // Find when the next promotion starts, otherwise // if there is no next promotion change all ranks // on the classes to the current rank. // 0 + 1 = 1 < 3 True // 2 + 1 = 3 < 3 False if (p + 1 < promotions.Count) { // Preload the next promotion date. // 5/2/2007 nextPromotionDate = promotions[p + 1].PromotionDate; // Find first class of next promotion. The last // class of the current promotion is therefore // one behind this one. (-1) // i=4; i<15 for (int i = promotionFirstClassIndex; i < attendance.Count; i++) { // [04] 11/04/2003 < 5/2/2007 True // [10] 04/31/2003 < 5/2/2007 True // [12] 05/02/2007 < 5/2/2007 False if (attendance[i].Class.ClassStart >= nextPromotionDate) { promotionFirstClassIndex = i; break; } if (attendance[i].rank.iD != promotion.promotionRank.iD) { // use internals for speed attendance[i].rank = promotion.promotionRank; attendance[i].isSynced = false; attendance[i].Save(); } } } } }
/// <summary> /// Render this control to the output parameter specified. /// </summary> /// <param name="output"> The HTML writer to write out to </param> protected override void RenderContent(HtmlTextWriter output) { IFormatProvider enFormat = new System.Globalization.CultureInfo("en-US", true); // Attendance Index int attendanceIndex = 0; // The current attendance entry int attendanceIndexMonth = 0; // The current attendance entry at beginning of month int classIndex = 0; // The current class int classIndexMonth = 0; // The current class at beginning of month int year = DateTime.Now.Year; // This year in an integer // Classes DojoAttendanceEntryCollection attendance = null; DojoClassCollection classes = null; // Start card at beginning of year DateTime startDate = DateTime.Parse("1/1/" + year.ToString(), enFormat); // Start times for classes every day DateTime testDateLow = startDate; DateTime testDateHigh = startDate; string[] startStrings = __classTimes.Split('|'); DateTime[] startTimes = new DateTime[startStrings.Length]; TimeSpan[] startSpansBack = new TimeSpan[startStrings.Length]; TimeSpan[] startSpansFor = new TimeSpan[startStrings.Length]; // Parse class string for (int i = 0; i < startTimes.Length; i++) { string[] temp = startStrings[i].Split(','); startTimes[i] = DateTime.Parse(temp[0]); // initialize start spans if (temp.Length > 2) { startSpansFor[i] = TimeSpan.FromMinutes(double.Parse(temp[1])); startSpansBack[i] = TimeSpan.FromMinutes(double.Parse(temp[2])); } else if (temp.Length > 1) { startSpansFor[i] = TimeSpan.FromMinutes(double.Parse(temp[1])); startSpansBack[i] = TimeSpan.Zero; } else { startSpansFor[i] = TimeSpan.Zero; startSpansBack[i] = TimeSpan.Zero; } } // Load member DojoMember m = new DojoMember(__memberID); // Load member's attendance DojoAttendanceEntryManager aem = new DojoAttendanceEntryManager(); attendance = aem.GetCollection("MemberID=" + __memberID + " AND ClassStart>#1/1/" + year.ToString() + "#" + " AND ClassStart<#1/1/" + (year + 1).ToString() + "#", "ClassStart", DojoAttendanceEntryFlags.Class); if (__fillBlanks) { // Load classes DojoClassManager cm = new DojoClassManager(); classes = cm.GetCollection("ClassStart>#1/1/" + year.ToString() + "#" + " AND ClassStart<#1/1/" + (year + 1).ToString() + "#", "ClassStart", null); } // If there is no attendance, display no attendance error if (attendance.Count == 0) { output.WriteFullBeginTag("tr"); output.WriteFullBeginTag("td"); output.Write("No Attendance"); output.WriteEndTag("td"); output.WriteEndTag("tr"); output.WriteLine(); return; } #region Classes From January to December for (int month = 1; month <= 12; month++) { output.WriteFullBeginTag("tr"); // Class Column output.WriteBeginTag("td"); if (this.SubHeaderCssClass != string.Empty) { output.WriteAttribute("class", this.SubHeaderCssClass); } if (this.__dateCellWidth != Unit.Empty) { output.WriteAttribute("width", this.__dateCellWidth.ToString()); } if (this.__dateCellHeight != Unit.Empty) { output.WriteAttribute("height", this.__dateCellHeight.ToString()); } output.Write(HtmlTextWriter.TagRightChar); output.Write(DateTime.Parse(month.ToString() + "/1/2005", enFormat).ToString("MMMM")); output.WriteEndTag("td"); // Days Columns for (int day = 1; day <= 31; day++) { if (day > DateTime.DaysInMonth(year, month)) { output.WriteBeginTag("td"); if (this.SubHeaderCssClass != string.Empty) { output.WriteAttribute("class", this.SubHeaderCssClass); } if (this.__dateCellWidth != Unit.Empty) { output.WriteAttribute("width", this.__dateCellWidth.ToString()); } if (this.__dateCellHeight != Unit.Empty) { output.WriteAttribute("height", this.__dateCellHeight.ToString()); } output.Write(HtmlTextWriter.TagRightChar); output.Write(" "); output.WriteEndTag("td"); continue; } output.WriteBeginTag("td"); if (this.SubHeaderCssClass != string.Empty) { output.WriteAttribute("class", this.SubHeaderCssClass); } if (this.__dateCellWidth != Unit.Empty) { output.WriteAttribute("width", this.__dateCellWidth.ToString()); } if (this.__dateCellHeight != Unit.Empty) { output.WriteAttribute("height", this.__dateCellHeight.ToString()); } output.Write(HtmlTextWriter.TagRightChar); output.Write(day.ToString("##00")); output.WriteEndTag("td"); } output.WriteEndTag("tr"); output.WriteLine(); attendanceIndexMonth = attendanceIndex; classIndexMonth = classIndex; // Class Column and Class Rows for (int iClass = 0; iClass < startTimes.Length; iClass++) { attendanceIndex = attendanceIndexMonth; classIndex = classIndexMonth; output.WriteFullBeginTag("tr"); // Class Title output.WriteFullBeginTag("td"); output.Write(startTimes[iClass].ToString("hh:mm tt")); output.WriteEndTag("td"); for (int day = 1; day <= 31; day++) { if (day > DateTime.DaysInMonth(year, month)) { output.WriteBeginTag("td"); if (this.__blankCellCssClass != string.Empty) { output.WriteAttribute("class", this.__blankCellCssClass); } if (this.__dateCellWidth != Unit.Empty) { output.WriteAttribute("width", this.__dateCellWidth.ToString()); } if (this.__dateCellHeight != Unit.Empty) { output.WriteAttribute("height", this.__dateCellHeight.ToString()); } output.Write(HtmlTextWriter.TagRightChar); output.Write(" "); output.WriteEndTag("td"); continue; } testDateLow = DateTime.Parse(month.ToString() + "/" + day.ToString() + "/" + year.ToString() + " " + startTimes[iClass].Hour.ToString("00") + ":" + startTimes[iClass].Minute.ToString("00"), enFormat); testDateHigh = testDateLow.Add(startSpansFor[iClass]); // set high test date testDateLow = testDateLow.Subtract(startSpansBack[iClass]); // set low test date // Make sure attendance examined is equal to or more than the test date while (attendance[attendanceIndex].Class.ClassStart < testDateLow && attendanceIndex + 1 < attendance.Count) { attendanceIndex++; } // Make sure classes examined is equal to or more than the test date while (classes[classIndex].ClassStart < testDateLow && classIndex + 1 < classes.Count) { classIndex++; } output.WriteBeginTag("td"); if (this.__fillBlanks && !dateCheck(classes[classIndex].ClassStart, testDateLow, testDateHigh) && this.__blankCellCssClass != string.Empty) { output.WriteAttribute("class", __blankCellCssClass); } else if (this.__fillBlanks && classes[classIndex].Instructor.ID == this.__memberID && this.__instructorCellCssClass != string.Empty) { output.WriteAttribute("class", __instructorCellCssClass); } else if (this.__fillBlanks && classes[classIndex].ParentSeminar != null && this.__seminarCellCssClass != string.Empty) { output.WriteAttribute("class", __seminarCellCssClass); } else if (this.__dateCellCssClass != string.Empty) { output.WriteAttribute("class", this.__dateCellCssClass); } if (this.__dateCellWidth != Unit.Empty) { output.WriteAttribute("width", this.__dateCellWidth.ToString()); } if (this.__dateCellHeight != Unit.Empty) { output.WriteAttribute("height", this.__dateCellHeight.ToString()); } output.Write(HtmlTextWriter.TagRightChar); // Now that we have the record closest to the month and date // check to see if it is on the month date and time of the start time, // if it is, display a tick mark, if not an empty if (dateCheck(attendance[attendanceIndex].Class.ClassStart, testDateLow, testDateHigh)) { if (attendance[attendanceIndex].Class.Instructor.ID == this.__memberID) { output.Write("I"); } else { output.Write("X"); } } else { output.Write(" "); } output.WriteEndTag("td"); } output.WriteEndTag("tr"); output.WriteLine(); } #endregion } #region Legend output.WriteFullBeginTag("tr"); output.WriteBeginTag("td"); output.Write(HtmlTextWriter.TagRightChar); output.Write("Legend"); output.WriteEndTag("td"); output.WriteBeginTag("td"); if (this.__blankCellCssClass != string.Empty) { output.WriteAttribute("class", __blankCellCssClass); } output.WriteAttribute("colspan", "6"); output.Write(HtmlTextWriter.TagRightChar); output.Write("No Class"); output.WriteEndTag("td"); output.WriteBeginTag("td"); output.WriteAttribute("colspan", "6"); output.Write(HtmlTextWriter.TagRightChar); output.Write("Unattended"); output.WriteEndTag("td"); output.WriteBeginTag("td"); output.WriteAttribute("colspan", "6"); output.Write(HtmlTextWriter.TagRightChar); output.Write("X - Attended"); output.WriteEndTag("td"); output.WriteBeginTag("td"); if (this.__instructorCellCssClass != string.Empty) { output.WriteAttribute("class", this.__instructorCellCssClass); } output.WriteAttribute("colspan", "6"); output.Write(HtmlTextWriter.TagRightChar); output.Write("I - Instructed"); output.WriteEndTag("td"); output.WriteBeginTag("td"); if (this.__seminarCellCssClass != string.Empty) { output.WriteAttribute("class", this.__seminarCellCssClass); } output.WriteAttribute("colspan", "7"); output.Write(HtmlTextWriter.TagRightChar); output.Write("Seminar"); output.WriteEndTag("td"); output.WriteEndTag("tr"); #endregion }
private void saveAttendance() { DojoMember member; string whereQuery; DojoAttendanceEntryManager aManager; DojoAttendanceEntryCollection attendance; int[] selectedClasses; string[] ids; bool removeEntry; bool formChanged; AttendanceScanner aScanner; // Load Member and set LastSignIn to present time member = new DojoMember(memberID); member.LastSignin = DateTime.Now; // Get classes on the attendance form. classIdArray = Context.Request.Form["___" + ClientID + "Classes"].Split(','); // Build query to get member's attendance for the classes on // the attendance form and get the memberTypeTemplates. whereQuery = "MemberID=" + member.iD; if (classIdArray.Length > 0) { whereQuery += " AND ("; for (int x = 0; x < classIdArray.Length; x++) { if (x == 0) { whereQuery += "ClassID=" + classIdArray[x] + " "; } else { whereQuery += "OR ClassID=" + classIdArray[x] + " "; } } whereQuery += ") "; } aManager = new DojoAttendanceEntryManager(); attendance = aManager.GetCollection(whereQuery, string.Empty, null); // Load selected classes from form. if (Page.Request.Form[this.ClientID + "classoptions"] != null) { ids = Page.Request.Form[this.ClientID + "classoptions"].Split(','); selectedClasses = new int[ids.Length]; for (int x = 0; x < ids.Length; x++) { selectedClasses[x] = int.Parse(ids[x]); } } else { // What the hell is this? selectedClasses = new int[0]; } // Assume that the form has not been changed. formChanged = false; // Save newly checked classes. for (int x = 0; x < selectedClasses.Length; x++) { // Ignore classes already checked! foreach (DojoAttendanceEntry aEntry in attendance) { if (selectedClasses[x] == aEntry.Class.iD) { goto NEXT_ENTRY; } } DojoAttendanceEntry entry = new DojoAttendanceEntry(); entry.Class = DojoClass.NewPlaceHolder(selectedClasses[x]); entry.Member = member; entry.Rank = member.rank; entry.SigninTime = localTime; attendance.Add(entry); entry.Save(); formChanged = true; NEXT_ENTRY: continue; } // Delete unchecked classes. foreach (DojoAttendanceEntry aEntry in attendance) { removeEntry = true; for (int x = 0; x < selectedClasses.Length; x++) { if (aEntry.Class.iD == selectedClasses[x]) { removeEntry = false; } } if (removeEntry) { aEntry.Delete(); formChanged = true; } } // Run attendance scan if form has changed if (formChanged) { aScanner = new AttendanceScanner(); aScanner.RunMemberAttendanceScan(member, TimeSpan.FromHours(1)); member.Save(); } }
/// <summary> /// Render this control to the output parameter specified. /// </summary> /// <param name="output"> The HTML writer to write out to </param> protected override void RenderContent(HtmlTextWriter output) { EnsureChildControls(); DojoAttendanceEntryFlags[] options = new DojoAttendanceEntryFlags[] { DojoAttendanceEntryFlags.Class, DojoAttendanceEntryFlags.Member, DojoAttendanceEntryFlags.Rank, DojoAttendanceEntryFlags.MemberPrivateContact }; DojoAttendanceEntryManager m = new DojoAttendanceEntryManager(); StringBuilder whereQuery = new StringBuilder(); if (ddMembers.SelectedItem.Value != "-1") { whereQuery.Append("MemberID="); whereQuery.Append(ddMembers.SelectedItem.Value); } if (ddClassDefinitions.SelectedItem.Value != "-1") { if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } if (ddClassDefinitions.SelectedItem.Value == "0") { whereQuery.Append("ParentDefinitionID=null"); } else { whereQuery.Append("ParentDefinitionID="); whereQuery.Append(ddClassDefinitions.SelectedItem.Value); } } if (ddInstructors.SelectedItem.Value != "-1") { if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("kitTessen_Classes.InstructorID="); whereQuery.Append(ddInstructors.SelectedItem.Value); } switch (ddSearchMode.SelectedItem.Text) { case "Today": // today if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(LocalTime.Date); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(LocalTime.Date.AddDays(1)); whereQuery.Append("#)"); break; case "This Month": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date).AddMonths(1)); whereQuery.Append("#)"); break; case "Last Month": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.SubtractMonths(LocalTime.Date, 1)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.FirstOfMonth(LocalTime.Date)); whereQuery.Append("#)"); break; case "This Week": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date)); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).AddDays(1)); whereQuery.Append("#)"); break; case "Last Week": if (whereQuery.Length > 0) { whereQuery.Append(" AND "); } whereQuery.Append("(ClassStart>=#"); whereQuery.Append(DateManipulator.FirstOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(7))); whereQuery.Append("# AND ClassStart <#"); whereQuery.Append(DateManipulator.LastOfWeek(LocalTime.Date).Subtract(TimeSpan.FromDays(6))); whereQuery.Append("#)"); break; } attendance = m.GetCollection(whereQuery.ToString(), "ClassStart DESC", options); switch (ddView.SelectedItem.Value) { case "default": RenderView(output, false); break; case "weekly": RenderView(output, true); break; case "weeklysummary": RenderWeeklySummary(output); break; } }
private void Populate(string id) { DojoMember m; string validation; MembershipBuilder b; m = new DojoMember(int.Parse(id)); // We're going to twist the membership builder to get what we want for faster // load times. So what we'll do is load the member into the Load Function // then we'll ask the membership builder for the member back. Pretty // nifty eh? Why? Because the membership builder loads the member's root // and children in one pass. :) :) :) b = new MembershipBuilder(); b.Load(m); // MUAHAHAHA! FASTER! USES ROOT MEMBER! b.ProcessTrees(); // Required for memberships availability b.ProcessHashes(); // Required for memberships availability b.pullData(m); name.Text = m.PrivateContact.FullName; address.Text = m.PrivateContact.ConstructAddress("<br />"); validation = m.PrivateContact.ValidationFlagsToString(); if (validation.Length != 0) { address.Text += "<br /><em>" + validation; } if (m.Parent != null) { addRow(table, Localization.Strings.ParentMember + " : " + m.Parent.PrivateContact.FullName); if (m.Root != null & m.ID != m.Root.ID & m.Parent.ID != m.Root.ID) { addRow(table, Localization.Strings.RootMember + " : " + m.Root.PrivateContact.FullName); } } else { if (m.Root != null & m.Root.ID != m.ID) { addRow(table, Localization.Strings.RootMember + " : " + m.Root.PrivateContact.FullName); } } addRow(table, Localization.Strings.MemberType + " : " + (m.MemberType != null ? m.MemberType.Name : Localization.Strings.IllegalValue)); addRow(table, Localization.Strings.Rank + " : " + string.Format(Localization.Strings.RankFormat, m.Rank != null ? m.Rank.Name : Localization.Strings.NoRankSpecified, m.TimeInRank.Hours)); addRow(table, Localization.Strings.MemberSince + " : " + string.Format(Localization.Strings.MemberSinceFormat, m.MemberSince, m.TimeInMembership.Hours)); // ATTENDANCE ========================================================= int maxEntries = 150; int displayEntries = 5; DateTime minSearchDate = DateTime.Now.Subtract(TimeSpan.FromDays(90)); DojoAttendanceEntryManager aem = new DojoAttendanceEntryManager(); DojoAttendanceEntryCollection attendance = aem.GetCollection(maxEntries, "MemberID=" + m.ID.ToString() + " AND ClassStart>=#" + minSearchDate.ToString() + "#", "ClassStart DESC", DojoAttendanceEntryFlags.Class); DojoMember instructor1 = m.Instructor1; DojoMember instructor2 = m.Instructor2; DojoMember instructor3 = m.Instructor3; if (attendance.Count < displayEntries) { displayEntries = attendance.Count; } addRow(table, Localization.Strings.LastSignin + " : " + m.LastSignin.ToShortDateString()); Table instructorTable = new Table(); addCells(table, new LiteralControl(Localization.Strings.NinetyDayInstructors), instructorTable); if (instructor1 != null) { addRow(instructorTable, instructor1.PrivateContact.FullName); } if (instructor2 != null) { addRow(instructorTable, instructor2.PrivateContact.FullName); } if (instructor3 != null) { addRow(instructorTable, instructor3.PrivateContact.FullName); } Table attendanceTable = new Table(); foreach (DojoAttendanceEntry a in attendance) { addRow(attendanceTable, a.Class.Name); addRow(attendanceTable, a.Class.ClassStart.ToString("dddd, MMMM d - h:mm tt")); } // MEMBERSHIPS ======================================================== membershipsTable = new Table(); addCells(table, new LiteralControl(Localization.Strings.MembershipsCurrent), membershipsTable); availableMembershipsTable = new Table(); addCells(table, new LiteralControl(Localization.Strings.MembershipsAvailable), availableMembershipsTable); DojoMembershipCollection memberships = m.CollateMemberships(); if (memberships.Count == 0) { addRow(membershipsTable, Localization.Strings.NoMemberships); } else { foreach (DojoMembership membership in memberships) { addMembership(membership); } } List <MembershipPackage> packages = b.GetMembershipPackages(m); if (packages.Count == 0) { addRow(availableMembershipsTable, Localization.Strings.NoMemberships); } else { foreach (MembershipPackage package in packages) { if (package.Memberships.Count == 0) { addRow(availableMembershipsTable, package.TypeTemplate.Name); addRow(availableMembershipsTable, Localization.Strings.NoMemberships); } else { addRow(availableMembershipsTable, package.TypeTemplate.Name, package.TotalFee.ToString("c")); foreach (DojoMembership membership in package.Memberships) { addRow(availableMembershipsTable, membership.MembershipTemplate.Name + (membership.PriorMembership == null ? " " + Localization.Strings.StartupMembershipAbbreviation : "") + (membership.IsProRated ? " " + Localization.Strings.ProrateMembershipAbbreviation : ""), membership.Fee.ToString("c")); addRow(availableMembershipsTable, string.Format(Localization.Strings.MembershipDates, membership.StartDate, membership.EndDate), " "); } } } } // SECURITY =========================================================== }
public void RunScan() { DojoBulkAttendanceEntryManager bulkManager; DojoBulkAttendanceEntryCollection bulkAttendance; DojoAttendanceEntryManager m; DojoAttendanceEntryCollection attendance; double classLength; DateTime dayIndex; double dayWeightedHours; double dayWeightedHoursInRank; DateTime firstDayOfWeek; DateTime lastDayOfWeek; DateTime firstDayOfLastWeek; DateTime lastDayOfLastWeek; bulkManager = new DojoBulkAttendanceEntryManager(); bulkAttendance = bulkManager.GetCollection("MemberID=" + member.iD, string.Empty, null); // Load the attendance entry collection and be sure to sort by ClassStart // so that the system can calculate weighted hours properly. m = new DojoAttendanceEntryManager(); attendance = m.GetCollection("MemberID=" + member.iD, "ClassStart", DojoAttendanceEntryFlags.Class); // Clear Data this.totalBulkHours = 0; this.totalBulkHoursInRank = 0; this.totalHours = 0; this.totalHoursInRank = 0; this.totalWeightedHours = 0; this.totalWeightedHoursInRank = 0; this.totalHoursThisWeek = 0; this.totalHoursLastWeek = 0; classLength = 0; dayIndex = DateTime.MinValue; dayWeightedHours = 0; dayWeightedHoursInRank = 0; firstDayOfWeek = DateManipulator.FirstOfWeek(DateTime.Now); lastDayOfWeek = firstDayOfWeek.Add(new TimeSpan(6, 23, 59, 59, 999)); firstDayOfLastWeek = DateManipulator.FirstOfWeek(DateTime.Now.Subtract(TimeSpan.FromDays(7))); lastDayOfLastWeek = firstDayOfLastWeek.Add(new TimeSpan(6, 23, 59, 59, 999)); // Scan Bulk Hours for (int x = 0; x < bulkAttendance.Count; x++) { totalBulkHours += bulkAttendance[x].Duration.TotalHours; if (bulkAttendance[x].rank.iD == member.rank.iD) { totalBulkHoursInRank += bulkAttendance[x].Duration.TotalHours; } } if (attendance.Count > 0) { dayIndex = attendance[0].Class.ClassStart.Date; } for (int x = 0; x < attendance.Count; x++) { classLength = (attendance[x].Class.ClassEnd - attendance[x].Class.ClassStart).TotalHours; // Total Hours totalHours += classLength; // Total Hours in Rank if (attendance[x].rank.iD == member.rank.iD) { totalHoursInRank += classLength; } // Total Weighted Hours if (attendance[x].Class.ClassStart.Date != dayIndex) { // Add Prior Temporary Values totalWeightedHours += dayWeightedHours; totalWeightedHoursInRank += dayWeightedHoursInRank; // Reset Hours for Day dayWeightedHours = 0; dayWeightedHoursInRank = 0; dayIndex = attendance[x].Class.ClassStart.Date; } dayWeightedHours += classLength; if (attendance[x].rank.iD == member.rank.iD) { dayWeightedHoursInRank += classLength; } if (dayWeightedHours > maxDayHours) { dayWeightedHours = maxDayHours; } if (dayWeightedHoursInRank > maxDayHours) { dayWeightedHoursInRank = maxDayHours; } if (attendance[x].Class.ClassStart >= firstDayOfLastWeek && attendance[x].Class.ClassStart <= lastDayOfLastWeek) { totalHoursLastWeek += classLength; } if (attendance[x].Class.ClassStart >= firstDayOfWeek && attendance[x].Class.ClassStart <= lastDayOfWeek) { totalHoursThisWeek += classLength; } // Update Last Signin if (attendance[x].signinTime > lastSignin) { lastSignin = attendance[x].signinTime; } } // Tally Remaining Temporary Values totalWeightedHours += dayWeightedHours; totalWeightedHoursInRank += dayWeightedHoursInRank; // Find Ninety Day Instructors DateTime maxDate = DateTime.Now; DateTime minDate = maxDate.Subtract(TimeSpan.FromDays(90)); instructor1 = attendance.FindTopInstructor(minDate, maxDate, null); instructor2 = attendance.FindTopInstructor(minDate, maxDate, instructor1); instructor3 = attendance.FindTopInstructor(minDate, maxDate, instructor1, instructor2); }