/// <summary> /// Convenience method for creating an implementation of <see cref="IMembership"/>. /// </summary> /// <remarks> /// <para> /// This method is intended to be used by Big Segment store implementations; application code /// does not need to use it. /// </para> /// <para> /// Store implementations are free to implement <see cref="IMembership"/> in any way that they /// find convenient and efficient, depending on what format they obtain values in from the /// database, but this method provides a simple way to do it as long as there are enumerations /// of included and excluded segment references. As described in <see cref="IMembership"/>, a /// <code>segmentRef</code> is not the same as the key property in the segment data model; it /// includes the key but also versioning information that the SDK will provide. The store /// implementation should not be concerned with the format of this. /// </para> /// <para> /// The returned object's <see cref="IMembership.CheckMembership(string)"/> method will return /// <see langword="true"/> for any <code>segmentRef</code> that is in the included list, /// <see langword="false"/> for any <code>segmentRef</code> that is in the excluded list and /// not also in the included list (that is, inclusions override exclusions), and /// <see langword="null"/> for all others. /// </para> /// <para> /// The method is optimized to return a singleton empty membership object whenever the /// inclusion and exclusion lists are both empty. /// </para> /// <para> /// The returned object implements <see cref="Object.Equals(object)"/> in such a way that it /// correctly tests equality when compared to any object returned from this factory method, /// but is always unequal to any other types of objects. /// </para> /// </remarks> /// <param name="includedSegmentRefs">the inclusion list (null is equivalent to an empty /// enumeration)</param> /// <param name="excludedSegmentRefs">the exclusion list (null is equivalent to an empty /// enumeration)</param> /// <returns>an <see cref="IMembership"/></returns> public static IMembership NewMembershipFromSegmentRefs( IEnumerable <string> includedSegmentRefs, IEnumerable <string> excludedSegmentRefs ) { var builder = new MembershipBuilder(); builder.AddRefs(excludedSegmentRefs, false); // add excludes first so includes will override them builder.AddRefs(includedSegmentRefs, true); return(builder.Build()); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { MembershipBuilder builder = new MembershipBuilder(); builder.Load(Member); builder.ProcessTrees(); builder.ProcessHashes(); List <MembershipPackage> packages = builder.GetMembershipPackages(Member); EnsureChildControls(); bind(packages); } }
public void RaisePostBackEvent(string eventArgument) { if (eventArgument.Length > 0) { MembershipBuilder builder = new MembershipBuilder(); builder.Load(Member); builder.ProcessTrees(); builder.ProcessHashes(); List <MembershipPackage> packages = builder.GetMembershipPackages(Member); // Add selected memberships to cart foreach (MembershipPackage package in packages) { if (eventArgument == package.TypeTemplate.ID.ToString()) { package.RemoveFromCart(); package.AddToCart(); Page.Response.Redirect("~/Cart.aspx"); } } } }
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 ddCommands_SelectIndexChanged(object sender, EventArgs e) { switch (ddCommands.SelectedItem.Value) { case "activate": { DojoMember member = new DojoMember(selectedID); member.IsPrimaryOrgActive = true; member.AddMemoMessage(DateTime.Now.ToString() + " : Activated"); member.PrivateContact.Save(); member.Save(); break; } case "cleardues": { DojoMember member = new DojoMember(selectedID); member.IsPastDue = false; member.AddMemoMessage(DateTime.Now.ToString() + " : Cleared Dues\r\n" + member.AttendanceMessage); member.AttendanceMessage = string.Empty; member.PrivateContact.Save(); member.Save(); break; } case "pastdue": { DojoMember member = new DojoMember(selectedID); member.IsPastDue = true; member.AddMemoMessage(DateTime.Now.ToString() + " : Past Due"); member.PrivateContact.Save(); member.Save(); break; } case "deactivate": { DojoMember member = new DojoMember(selectedID); member.IsPrimaryOrgActive = false; member.AddMemoMessage(DateTime.Now.ToString() + " : Deactivated"); member.PrivateContact.Save(); member.Save(); break; } case "validateaddress": { DojoMember member = new DojoMember(selectedID); member.PrivateContact.IsBadAddress = false; member.AddMemoMessage(DateTime.Now.ToString() + " : Address Validated"); member.PrivateContact.Save(); break; } case "invalidateaddress": { DojoMember member = new DojoMember(selectedID); member.PrivateContact.IsBadAddress = true; member.AddMemoMessage(DateTime.Now.ToString() + " : Address Invalidated"); member.PrivateContact.Save(); break; } case "grantmembership": { DojoMember member = new DojoMember(selectedID); MembershipBuilder builder = new MembershipBuilder(); builder.Load(); // TODO: SPEED ME UP USING THE ROOT MEMBER SEARCH! builder.ProcessTrees(); builder.ProcessHashes(); List <MembershipPackage> packages = builder.GetMembershipPackages(member); if (packages.Count > 0) { MembershipPackage package = packages[0]; package.ApplyGrant(); package.Save(); registerNotification("Membership package for " + member.PrivateContact.FullName + " has been granted. Any sub-members have also been granted " + "memberships."); } packages = null; builder = null; break; } } ddCommands.SelectedIndex = 0; }