Major refactoring: Member => Participant
This commit is contained in:
+1
-1
@@ -131,7 +131,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Types\Swarm\BasicMembership.cs" />
|
||||
<Compile Include="Types\Swarm\BasicParticipation.cs" />
|
||||
<Compile Include="Types\Structure\BasicOrganization.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
@@ -3,9 +3,9 @@ using Swarmops.Common.Interfaces;
|
||||
|
||||
namespace Swarmops.Basic.Types.Swarm
|
||||
{
|
||||
public class BasicMembership : IHasIdentity
|
||||
public class BasicParticipation : IHasIdentity
|
||||
{
|
||||
public BasicMembership (int personId, int organizationId)
|
||||
public BasicParticipation (int personId, int organizationId)
|
||||
{
|
||||
this.PersonId = personId;
|
||||
this.OrganizationId = organizationId;
|
||||
@@ -13,14 +13,14 @@ namespace Swarmops.Basic.Types.Swarm
|
||||
this.DateTerminated = DateTime.MinValue;
|
||||
}
|
||||
|
||||
public BasicMembership (int personId, int organizationId, DateTime memberSince, DateTime expires)
|
||||
public BasicParticipation (int personId, int organizationId, DateTime memberSince, DateTime expires)
|
||||
: this (personId, organizationId)
|
||||
{
|
||||
this.MemberSince = memberSince;
|
||||
this.Expires = expires;
|
||||
}
|
||||
|
||||
public BasicMembership (int membershipId, int personId, int organizationId, DateTime memberSince,
|
||||
public BasicParticipation (int membershipId, int personId, int organizationId, DateTime memberSince,
|
||||
DateTime expires, bool active, DateTime dateTerminated)
|
||||
{
|
||||
this.MembershipId = membershipId;
|
||||
@@ -32,7 +32,7 @@ namespace Swarmops.Basic.Types.Swarm
|
||||
this.DateTerminated = dateTerminated;
|
||||
}
|
||||
|
||||
public BasicMembership (BasicMembership original)
|
||||
public BasicParticipation (BasicParticipation original)
|
||||
: this (
|
||||
original.MembershipId, original.PersonId, original.OrganizationId, original.MemberSince,
|
||||
original.Expires, original.Active, original.DateTerminated)
|
||||
+20
-20
@@ -288,9 +288,9 @@ namespace Swarmops
|
||||
bool upMember = false;
|
||||
bool ppMember = false;
|
||||
|
||||
Memberships memberships = person.GetMemberships();
|
||||
Participations participations = person.GetMemberships();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.Organization.Inherits(2))
|
||||
{
|
||||
@@ -346,9 +346,9 @@ namespace Swarmops
|
||||
|
||||
foreach (Organization org in orgTree)
|
||||
{
|
||||
Memberships memberships = Memberships.ForOrganization (org, true);
|
||||
Participations participations = Participations.ForOrganization (org, true);
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.MemberSince < date && (membership.Active || membership.DateTerminated > date))
|
||||
{
|
||||
@@ -389,9 +389,9 @@ namespace Swarmops
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
|
||||
Memberships memberships = person.GetMemberships();
|
||||
Participations participations = person.GetMemberships();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.OrganizationId == 1 && membership.Active)
|
||||
{
|
||||
@@ -588,8 +588,8 @@ namespace Swarmops
|
||||
{
|
||||
bool activeMemberships = false;
|
||||
|
||||
Memberships memberships = person.GetMemberships();
|
||||
foreach (Membership membership in memberships)
|
||||
Participations participations = person.GetMemberships();
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.Active)
|
||||
{
|
||||
@@ -709,9 +709,9 @@ namespace Swarmops
|
||||
bool foundMismatch = false;
|
||||
DateTime expiry = DateTime.MinValue;
|
||||
|
||||
Memberships memberships = person.GetMemberships();
|
||||
Participations participations = person.GetMemberships();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.Active)
|
||||
{
|
||||
@@ -739,7 +739,7 @@ namespace Swarmops
|
||||
Console.WriteLine ("");
|
||||
Console.WriteLine ("Found mismatch for " + person.Name + ":");
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
Console.WriteLine (" - " + membership.Organization.Name + ": expires " + membership.Expires.ToShortDateString());
|
||||
if (expiry != membership.Expires)
|
||||
@@ -911,23 +911,23 @@ namespace Swarmops
|
||||
{
|
||||
// For each membership in this suborg,§
|
||||
|
||||
Memberships memberships = org.GetMemberships();
|
||||
Participations participations = org.GetMemberships();
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(org.Name + ": " + memberships.Count + " members");
|
||||
Console.WriteLine(org.Name + ": " + participations.Count + " members");
|
||||
Console.WriteLine ("----------------------------------------------------------");
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
// Get the person for this membership and verify that he/she is also a member of PP
|
||||
|
||||
Person member = membership.Person;
|
||||
|
||||
Memberships personMemberships = member.GetMemberships();
|
||||
Participations personParticipations = member.GetMemberships();
|
||||
|
||||
bool ppMember = false;
|
||||
|
||||
foreach (Membership testMembership in personMemberships)
|
||||
foreach (Participation testMembership in personParticipations)
|
||||
{
|
||||
if (testMembership.OrganizationId == 1)
|
||||
{
|
||||
@@ -1397,9 +1397,9 @@ namespace Swarmops
|
||||
Person person = Person.FromIdentity(personId);
|
||||
writer.WriteLine(person.Name + " (#" + person.Identity.ToString() + ")");
|
||||
|
||||
Memberships memberships = person.GetMemberships();
|
||||
Participations participations = person.GetMemberships();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.OrganizationId == 1)
|
||||
{
|
||||
@@ -1562,9 +1562,9 @@ namespace Swarmops
|
||||
{
|
||||
Console.WriteLine(person.Name + " (#" + person.Identity.ToString() + ")");
|
||||
|
||||
Memberships memberships = person.GetMemberships();
|
||||
Participations participations = person.GetMemberships();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.OrganizationId == 1)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -90,7 +90,7 @@
|
||||
<Compile Include="Database-InternalPolls.cs" />
|
||||
<Compile Include="Database-MailTemplates.cs" />
|
||||
<Compile Include="Database-Media.cs" />
|
||||
<Compile Include="Database-Memberships.cs" />
|
||||
<Compile Include="Database-Participation.cs" />
|
||||
<Compile Include="Database-Geographies.cs" />
|
||||
<Compile Include="Database-MotionAmendments.cs" />
|
||||
<Compile Include="Database-Motions.cs" />
|
||||
|
||||
@@ -67,27 +67,27 @@ public class ListPersonDataSource
|
||||
if (this.listedPersons != null)
|
||||
{
|
||||
People ppl = People.FromIdentities(this.listedPersons);
|
||||
Dictionary<int, List<BasicMembership>> membershipTable =
|
||||
Memberships.GetMembershipsForPeople(this.listedPersons, Membership.GracePeriod);
|
||||
Memberships membershipsToLoad = new Memberships();
|
||||
Dictionary<int, List<BasicParticipation>> membershipTable =
|
||||
Participations.GetParticipationsForPeople(this.listedPersons, Participation.GracePeriod);
|
||||
Participations participationsToLoad = new Participations();
|
||||
foreach (Person p in ppl)
|
||||
{
|
||||
if (membershipTable.ContainsKey(p.Identity))
|
||||
{
|
||||
foreach (BasicMembership bm in membershipTable[p.Identity])
|
||||
foreach (BasicParticipation bm in membershipTable[p.Identity])
|
||||
{
|
||||
if (bm.OrganizationId == this.selectedOrgId)
|
||||
{
|
||||
Membership ms = Membership.FromBasic(bm);
|
||||
membershipsToLoad.Add(ms);
|
||||
Participation ms = Participation.FromBasic(bm);
|
||||
participationsToLoad.Add(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Membership.LoadPaymentStatuses(membershipsToLoad);
|
||||
Participation.LoadPaymentStatuses(participationsToLoad);
|
||||
|
||||
Dictionary<int, Membership> memberships = new Dictionary<int, Membership>();
|
||||
foreach (Membership ms in membershipsToLoad)
|
||||
Dictionary<int, Participation> memberships = new Dictionary<int, Participation>();
|
||||
foreach (Participation ms in participationsToLoad)
|
||||
{
|
||||
memberships[ms.Identity] = ms;
|
||||
}
|
||||
@@ -97,11 +97,11 @@ public class ListPersonDataSource
|
||||
ListPerson lp = new ListPerson(p);
|
||||
if (membershipTable.ContainsKey(p.Identity))
|
||||
{
|
||||
foreach (BasicMembership bm in membershipTable[p.Identity])
|
||||
foreach (BasicParticipation bm in membershipTable[p.Identity])
|
||||
{
|
||||
if (bm.OrganizationId == this.selectedOrgId)
|
||||
{
|
||||
Membership ms = memberships[bm.MembershipId];
|
||||
Participation ms = memberships[bm.MembershipId];
|
||||
lp.JoinedDate = ms.MemberSince;
|
||||
lp.ExpiresDate = ms.Expires;
|
||||
lp.MembershipId = ms.Identity;
|
||||
|
||||
@@ -112,15 +112,15 @@ namespace Swarmops.Logic.Communications
|
||||
}
|
||||
|
||||
|
||||
public static OutboundComm CreateMembershipLetter (ParticipantMailType mailType, Membership membership,
|
||||
public static OutboundComm CreateMembershipLetter (ParticipantMailType mailType, Participation participation,
|
||||
Person actingPerson)
|
||||
{
|
||||
List<Person> recipients = People.FromSingle (membership.Person);
|
||||
List<Person> recipients = People.FromSingle (participation.Person);
|
||||
|
||||
OutboundComm comm = OutboundComm.Create (null, null, membership.Organization,
|
||||
OutboundComm comm = OutboundComm.Create (null, null, participation.Organization,
|
||||
CommResolverClass.Unknown, null,
|
||||
CommTransmitterClass.CommsTransmitterMail,
|
||||
new PayloadEnvelope (new ParticipantMailPayload (mailType, membership, actingPerson)).ToXml(),
|
||||
new PayloadEnvelope (new ParticipantMailPayload (mailType, participation, actingPerson)).ToXml(),
|
||||
OutboundCommPriority.Low);
|
||||
|
||||
foreach (Person person in recipients)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Swarmops.Logic.Communications.Transmission
|
||||
public string BodyTemplate { get; set; }
|
||||
|
||||
|
||||
public ParticipantMailPayload (ParticipantMailType mailType, Membership membership, Person actingPerson)
|
||||
public ParticipantMailPayload (ParticipantMailType mailType, Participation participation, Person actingPerson)
|
||||
{
|
||||
Strings = new SerializableDictionary<MailPayloadString, string>();
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace Swarmops.Logic.Communications.Transmission
|
||||
{
|
||||
case ParticipantMailType.MemberAddedWelcome:
|
||||
Strings[MailPayloadString.ActingPerson] = actingPerson.Name;
|
||||
Strings[MailPayloadString.MembershipExpiry] = membership.Expires.ToLongDateString();
|
||||
Strings[MailPayloadString.OrganizationName] = membership.Organization.Name;
|
||||
Strings[MailPayloadString.MembershipExpiry] = participation.Expires.ToLongDateString();
|
||||
Strings[MailPayloadString.OrganizationName] = participation.Organization.Name;
|
||||
Strings[MailPayloadString.Regularship] =
|
||||
Participant.Localized (membership.Organization.RegularLabel, TitleVariant.Ship);
|
||||
Participant.Localized (participation.Organization.RegularLabel, TitleVariant.Ship);
|
||||
|
||||
BodyTemplate =
|
||||
Resources.Logic_Communications_Transmission_DefaultCommTemplates
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Swarmops.Logic.DataObjects
|
||||
row.OrgId = orgId;
|
||||
Geographies gTree = geo.ThisAndBelow();
|
||||
int[] members = SwarmDb.GetDatabaseForReading()
|
||||
.GetMembersForOrganizationsAndGeographies (orgs.Identities, gTree.Identities);
|
||||
.GetParticipantsForOrganizationsAndGeographies (orgs.Identities, gTree.Identities);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,17 +12,17 @@ namespace Swarmops.Logic.DataObjects
|
||||
#if !__MonoCS__
|
||||
[DataObjectMethod (DataObjectMethodType.Select)]
|
||||
#endif
|
||||
public static Membership[] Select (int personId)
|
||||
public static Participation[] Select (int personId)
|
||||
{
|
||||
return
|
||||
Memberships.FromArray (SwarmDb.GetDatabaseForReading().GetMemberships (Person.FromIdentity (personId)))
|
||||
Participations.FromArray (SwarmDb.GetDatabaseForReading().GetParticipations (Person.FromIdentity (personId)))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
#if !__MonoCS__
|
||||
[DataObjectMethod (DataObjectMethodType.Select)]
|
||||
#endif
|
||||
public static Membership[] Select (Person person)
|
||||
public static Participation[] Select (Person person)
|
||||
{
|
||||
return Select (person.Identity);
|
||||
}
|
||||
@@ -30,9 +30,9 @@ namespace Swarmops.Logic.DataObjects
|
||||
#if !__MonoCS__
|
||||
[DataObjectMethod (DataObjectMethodType.Select)]
|
||||
#endif
|
||||
public static Membership[] SelectStatic (Memberships memberships)
|
||||
public static Participation[] SelectStatic (Participations participations)
|
||||
{
|
||||
return memberships.ToArray();
|
||||
return participations.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -364,10 +364,10 @@
|
||||
<Compile Include="Swarm\ExternalActivity.cs" />
|
||||
<Compile Include="Swarm\ExternalIdentity.cs" />
|
||||
<Compile Include="Swarm\Interfaces.cs" />
|
||||
<Compile Include="Swarm\Membership.cs" />
|
||||
<Compile Include="Swarm\Participation.cs" />
|
||||
<Compile Include="Swarm\MembershipEvent.cs" />
|
||||
<Compile Include="Swarm\MembershipEvents.cs" />
|
||||
<Compile Include="Swarm\Memberships.cs" />
|
||||
<Compile Include="Swarm\Participations.cs" />
|
||||
<Compile Include="Swarm\OfficerChain.cs" />
|
||||
<Compile Include="Swarm\Parley.cs" />
|
||||
<Compile Include="Swarm\ParleyAttendee.cs" />
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace Swarmops.Logic.Security
|
||||
|
||||
bool hasActiveMemberships = false;
|
||||
|
||||
Memberships memberships = candidate.GetMemberships();
|
||||
Participations participations = candidate.GetMemberships();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.Active)
|
||||
{
|
||||
@@ -327,8 +327,8 @@ namespace Swarmops.Logic.Security
|
||||
links += "\r\n\r\n";
|
||||
links += "#" + p.PersonId;
|
||||
links += " [Member of:";
|
||||
Memberships msList = p.GetMemberships();
|
||||
foreach (Membership ms in msList)
|
||||
Participations msList = p.GetMemberships();
|
||||
foreach (Participation ms in msList)
|
||||
{
|
||||
++membershipCount;
|
||||
links += " (" + ms.Organization.Name + "," + ms.MemberSince.ToString ("yyyy-MM-dd") + ")";
|
||||
@@ -500,7 +500,7 @@ namespace Swarmops.Logic.Security
|
||||
string links = "";
|
||||
foreach (Person p in candidatePeople)
|
||||
{
|
||||
Memberships msList = p.GetMemberships();
|
||||
Participations msList = p.GetMemberships();
|
||||
if (msList.Count == 0 && p.IsActivist)
|
||||
{
|
||||
personIsActivist = true;
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace Swarmops.Logic.Security
|
||||
}
|
||||
orgLookup[Organization.Identity] = true;
|
||||
|
||||
Dictionary<int, List<BasicMembership>> membershipLookup = null;
|
||||
Dictionary<int, List<BasicParticipation>> membershipLookup = null;
|
||||
|
||||
if (HasSystemAccess(AccessType.Read) || HasAccess(new Access(Organization, aspect, AccessType.Read)))
|
||||
{
|
||||
@@ -348,7 +348,7 @@ namespace Swarmops.Logic.Security
|
||||
// or org-wide read access (at least) to participant/personal data at current Organization
|
||||
|
||||
// Optimization: Get all memberships in advance, without instantiating logic objects
|
||||
membershipLookup = Memberships.GetMembershipsForPeople (rawList.Identities, 0);
|
||||
membershipLookup = Participations.GetParticipationsForPeople (rawList.Identities, 0);
|
||||
|
||||
foreach (Person person in rawList)
|
||||
{
|
||||
@@ -358,9 +358,9 @@ namespace Swarmops.Logic.Security
|
||||
|
||||
if (membershipLookup.ContainsKey (person.Identity))
|
||||
{
|
||||
List<BasicMembership> list = membershipLookup[person.Identity];
|
||||
List<BasicParticipation> list = membershipLookup[person.Identity];
|
||||
|
||||
foreach (BasicMembership basicMembership in list)
|
||||
foreach (BasicParticipation basicMembership in list)
|
||||
{
|
||||
if (orgLookup.ContainsKey (basicMembership.OrganizationId))
|
||||
{
|
||||
@@ -407,8 +407,8 @@ namespace Swarmops.Logic.Security
|
||||
geoLookup[Position.GeographyId] = true;
|
||||
|
||||
// Optimization: Get all memberships in advance, without instantiating logic objects
|
||||
Dictionary<int, List<BasicMembership>> personLookup =
|
||||
Memberships.GetMembershipsForPeople(rawList.Identities, 0);
|
||||
Dictionary<int, List<BasicParticipation>> personLookup =
|
||||
Participations.GetParticipationsForPeople(rawList.Identities, 0);
|
||||
|
||||
foreach (Person person in rawList)
|
||||
{
|
||||
@@ -422,9 +422,9 @@ namespace Swarmops.Logic.Security
|
||||
{
|
||||
// Geography hit. Test Membership / Organization.
|
||||
|
||||
List<BasicMembership> list = personLookup[person.Identity];
|
||||
List<BasicParticipation> list = personLookup[person.Identity];
|
||||
|
||||
foreach (BasicMembership basicMembership in list)
|
||||
foreach (BasicParticipation basicMembership in list)
|
||||
{
|
||||
if (orgLookup.ContainsKey (basicMembership.OrganizationId))
|
||||
{
|
||||
|
||||
@@ -449,9 +449,9 @@ namespace Swarmops.Logic.Special.Sweden
|
||||
|
||||
bool hasActiveMemberships = false;
|
||||
|
||||
Memberships memberships = person.GetMemberships();
|
||||
Participations participations = person.GetMemberships();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.Active)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Swarmops.Logic.Structure
|
||||
{
|
||||
People members =
|
||||
People.FromMemberships (
|
||||
Memberships.ForOrganizations (Organization.FromIdentity (orgId).ThisAndBelow()));
|
||||
Participations.ForOrganizations (Organization.FromIdentity (orgId).ThisAndBelow()));
|
||||
|
||||
foreach (Person person in members)
|
||||
{
|
||||
|
||||
@@ -437,7 +437,7 @@ namespace Swarmops.Logic.Structure
|
||||
|
||||
public int GetMemberCount()
|
||||
{
|
||||
return Memberships.GetMemberCountForOrganization (this);
|
||||
return Participations.GetParticipantCountForOrganization (this);
|
||||
}
|
||||
|
||||
public NewsletterFeeds GetNewsletterFeeds()
|
||||
@@ -893,12 +893,12 @@ namespace Swarmops.Logic.Structure
|
||||
}
|
||||
|
||||
|
||||
public Memberships GetMemberships (bool includeTerminated)
|
||||
public Participations GetMemberships (bool includeTerminated)
|
||||
{
|
||||
return Memberships.ForOrganization (this, includeTerminated);
|
||||
return Participations.ForOrganization (this, includeTerminated);
|
||||
}
|
||||
|
||||
public Memberships GetMemberships()
|
||||
public Participations GetMemberships()
|
||||
{
|
||||
return GetMemberships (false);
|
||||
}
|
||||
|
||||
@@ -290,17 +290,17 @@ namespace Swarmops.Logic.Structure
|
||||
|
||||
public int GetMembershipCount()
|
||||
{
|
||||
return Memberships.GetMemberCountForOrganizations (this);
|
||||
return Participations.GetParticipantCountForOrganizations (this);
|
||||
}
|
||||
|
||||
public int GetMemberCount()
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading().GetMemberCountForOrganizations (Identities);
|
||||
return SwarmDb.GetDatabaseForReading().GetParticipantCountForOrganizations (Identities);
|
||||
}
|
||||
|
||||
public int GetMemberCountForGeographies (Geographies geographies)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading().GetMemberCountForOrganizationsAndGeographies (Identities,
|
||||
return SwarmDb.GetDatabaseForReading().GetParticipantCountForOrganizationsAndGeographies (Identities,
|
||||
geographies.Identities);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ namespace Swarmops.Logic.Support.LogEntries
|
||||
// Do not call empty ctor directly. Intended for serialization only.
|
||||
}
|
||||
|
||||
public PersonAddedLogEntry (Membership membership, Person actingPerson)
|
||||
public PersonAddedLogEntry (Participation participation, Person actingPerson)
|
||||
{
|
||||
DateTime = System.DateTime.UtcNow;
|
||||
MembershipId = membership.Identity;
|
||||
MembershipId = participation.Identity;
|
||||
ActingPersonId = actingPerson.Identity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
// Second phase, load all memberships
|
||||
|
||||
BasicMembership[] allMemberships = SwarmDb.GetDatabaseForReading().GetMemberships();
|
||||
BasicParticipation[] allParticipations = SwarmDb.GetDatabaseForReading().GetParticipations();
|
||||
|
||||
// Third phase - for every membership, generate one or two membership events
|
||||
|
||||
MembershipEvents result = new MembershipEvents();
|
||||
|
||||
foreach (BasicMembership membership in allMemberships)
|
||||
foreach (BasicParticipation membership in allParticipations)
|
||||
{
|
||||
int geographyId = 1;
|
||||
int birthYear = 0;
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Swarmops.Basic.Types;
|
||||
using Swarmops.Basic.Types.Swarm;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
|
||||
namespace Swarmops.Logic.Swarm
|
||||
{
|
||||
public class Memberships : List<Membership>
|
||||
{
|
||||
public int[] Identities
|
||||
{
|
||||
get { return LogicServices.ObjectsToIdentifiers (ToArray()); }
|
||||
}
|
||||
|
||||
public static Memberships FromArray (BasicMembership[] basicArray)
|
||||
{
|
||||
Memberships result = new Memberships();
|
||||
|
||||
result.Capacity = basicArray.Length*11/10;
|
||||
foreach (BasicMembership basic in basicArray)
|
||||
{
|
||||
result.Add (Membership.FromBasic (basic));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public static BasicMembership[] GetMembershipsForPerson (int personId)
|
||||
{
|
||||
return LogicServices.GetDatabase().GetMembershipsForPerson(personId);
|
||||
}*/
|
||||
|
||||
public static int GetMemberCountForOrganization (Organization organization)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading().GetMembershipCountForOrganizations (new[] {organization.Identity});
|
||||
}
|
||||
|
||||
public static int GetMemberCountForOrganizations (int[] organizationIds)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading().GetMembershipCountForOrganizations (organizationIds);
|
||||
}
|
||||
|
||||
public static int GetMemberCountForOrganizationSince (Organization org, DateTime sinceDateTime)
|
||||
{
|
||||
return GetMemberCountForOrganizationSince (org.Identity, sinceDateTime);
|
||||
}
|
||||
|
||||
public static int GetMemberCountForOrganizationSince (int orgId, DateTime sinceDateTime)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading()
|
||||
.GetMembershipCountForOrganizationsSince (new[] {orgId}, sinceDateTime);
|
||||
}
|
||||
|
||||
public static int GetMemberCountForOrganizations (Organizations organizations)
|
||||
{
|
||||
List<int> idArray = new List<int>();
|
||||
|
||||
foreach (Organization organization in organizations)
|
||||
{
|
||||
idArray.Add (organization.Identity);
|
||||
}
|
||||
|
||||
return GetMemberCountForOrganizations (idArray.ToArray());
|
||||
}
|
||||
/*
|
||||
public Memberships RemoveToMatchAuthority (Geography personGeography, Authority authority)
|
||||
{
|
||||
return Authorization.FilterMembershipsToMatchAuthority (this, personGeography, authority);
|
||||
}*/
|
||||
|
||||
public static Memberships ForOrganization (Organization organization, bool includeTerminated)
|
||||
{
|
||||
if (!includeTerminated)
|
||||
{
|
||||
return ForOrganization (organization);
|
||||
}
|
||||
|
||||
return FromArray (SwarmDb.GetDatabaseForReading().GetMemberships (organization));
|
||||
}
|
||||
|
||||
public static Memberships ForOrganization (Organization organization)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading().GetMemberships (organization, DatabaseCondition.ActiveTrue));
|
||||
}
|
||||
|
||||
public static Memberships ForOrganizations (Organizations organizations, bool includeTerminated)
|
||||
{
|
||||
if (!includeTerminated)
|
||||
{
|
||||
return ForOrganizations (organizations);
|
||||
}
|
||||
|
||||
return FromArray (SwarmDb.GetDatabaseForReading().GetMemberships (organizations));
|
||||
}
|
||||
|
||||
public static Memberships ForOrganizations (Organizations organizations)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading().GetMemberships (organizations, DatabaseCondition.ActiveTrue));
|
||||
}
|
||||
|
||||
public static Memberships GetExpiring (Organization organization, DateTime dateExpiry)
|
||||
{
|
||||
return GetExpiring (organization, dateExpiry, dateExpiry);
|
||||
}
|
||||
|
||||
public static Memberships GetExpired (Organization organization)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading().GetExpiringMemberships (organization, DateTime.MinValue,
|
||||
DateTime.Now));
|
||||
}
|
||||
|
||||
public static Memberships GetExpired (Organization organization, DateTime lowerBound, DateTime upperBound)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading()
|
||||
.GetExpiringMemberships (organization, lowerBound, upperBound, DatabaseCondition.None));
|
||||
}
|
||||
|
||||
public static Memberships GetExpiring (Organization organization, DateTime lowerBound, DateTime upperBound)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading().GetExpiringMemberships (organization, lowerBound, upperBound));
|
||||
}
|
||||
|
||||
|
||||
public static Dictionary<int, List<BasicMembership>> GetMembershipsForPeople (int[] personIds, int gracePeriod)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading().GetMembershipsForPeople (personIds, gracePeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,226 +1,226 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Swarmops.Basic.Types;
|
||||
using Swarmops.Basic.Types.Swarm;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
|
||||
namespace Swarmops.Logic.Swarm
|
||||
{
|
||||
public class Membership : BasicMembership
|
||||
{
|
||||
public static readonly int GracePeriod = 28;
|
||||
private Organization organization;
|
||||
private BasicMembershipPaymentStatus paymentStatus;
|
||||
private Person person;
|
||||
|
||||
private Membership (BasicMembership basic)
|
||||
: base (basic)
|
||||
{
|
||||
}
|
||||
|
||||
public Person Person
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.person == null)
|
||||
{
|
||||
this.person = Person.FromIdentity (base.PersonId);
|
||||
}
|
||||
|
||||
return this.person;
|
||||
}
|
||||
}
|
||||
|
||||
public Organization Organization
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.organization == null)
|
||||
{
|
||||
this.organization = Organization.FromIdentity (base.OrganizationId);
|
||||
}
|
||||
|
||||
return this.organization;
|
||||
}
|
||||
}
|
||||
|
||||
public new DateTime Expires
|
||||
{
|
||||
get { return base.Expires; }
|
||||
set
|
||||
{
|
||||
if (base.Expires != value)
|
||||
{
|
||||
if (PersonId > 0 && OrganizationId > 0 && base.Expires != new DateTime (1900, 1, 1))
|
||||
{
|
||||
ChurnData.LogRetention (PersonId, OrganizationId, base.Expires);
|
||||
}
|
||||
SwarmDb.GetDatabaseForWriting().SetMembershipExpires (Identity, value);
|
||||
base.Expires = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MembershipPaymentStatus PaymentStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
LoadPaymentStatus();
|
||||
return this.paymentStatus.Status;
|
||||
}
|
||||
private set
|
||||
{
|
||||
throw new InvalidOperationException (
|
||||
"It is not allowed to set PaymentStatus separately. Use SetPaymentStatus() method.");
|
||||
|
||||
// Rick: Isn't it better to not have a setter at all and get the error compile-time rather than run-time?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DateTime PaymentStatusDate
|
||||
{
|
||||
get
|
||||
{
|
||||
LoadPaymentStatus();
|
||||
return this.paymentStatus.StatusDateTime;
|
||||
}
|
||||
private set
|
||||
{
|
||||
throw new InvalidOperationException (
|
||||
"It is not allowed to set PaymentStatusDate separately. Use SetPaymentStatus() method");
|
||||
|
||||
// Rick: Isn't it better to not have a setter at all and get the error compile-time rather than run-time?
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPaymentStatus (MembershipPaymentStatus status, DateTime dateTime)
|
||||
{
|
||||
SwarmDb.GetDatabaseForWriting().SetMembershipPaymentStatus (Identity, status, dateTime);
|
||||
LoadPaymentStatus();
|
||||
this.paymentStatus.Status = status;
|
||||
this.paymentStatus.StatusDateTime = dateTime;
|
||||
}
|
||||
|
||||
private void LoadPaymentStatus()
|
||||
{
|
||||
if (this.paymentStatus == null)
|
||||
{
|
||||
this.paymentStatus = SwarmDb.GetDatabaseForReading().GetMembershipPaymentStatus (Identity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Optimization metod, loadMultiple in one call
|
||||
public static void LoadPaymentStatuses (Memberships mss)
|
||||
{
|
||||
Dictionary<int, BasicMembershipPaymentStatus> statuses =
|
||||
SwarmDb.GetDatabaseForReading().GetMembershipPaymentStatuses (mss.Identities);
|
||||
foreach (Membership ms in mss)
|
||||
{
|
||||
if (ms.paymentStatus == null && statuses.ContainsKey (ms.Identity))
|
||||
{
|
||||
ms.paymentStatus = statuses[ms.Identity];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Membership FromBasic (BasicMembership basic)
|
||||
{
|
||||
return new Membership (basic);
|
||||
}
|
||||
|
||||
public static Membership FromIdentity (int membershipId)
|
||||
{
|
||||
return FromBasic (SwarmDb.GetDatabaseForReading().GetMembership (membershipId));
|
||||
}
|
||||
|
||||
public static Membership FromIdentityAggressive (int membershipId)
|
||||
{
|
||||
return FromBasic (SwarmDb.GetDatabaseForWriting().GetMembership (membershipId));
|
||||
}
|
||||
|
||||
public static Membership FromPersonAndOrganization (int personId, int organizationId)
|
||||
{
|
||||
return FromBasic (SwarmDb.GetDatabaseForReading().GetActiveMembership (personId, organizationId));
|
||||
}
|
||||
|
||||
public static Membership Create (int personId, int organizationId, DateTime expires)
|
||||
{
|
||||
int membershipId = SwarmDb.GetDatabaseForWriting().CreateMembership (personId, organizationId, expires);
|
||||
|
||||
return FromIdentityAggressive (membershipId);
|
||||
}
|
||||
|
||||
public static Membership Create (Person person, Organization organization, DateTime expires)
|
||||
{
|
||||
return Create (person.Identity, organization.Identity, expires);
|
||||
}
|
||||
|
||||
public static Membership Import (Person person, Organization organization, DateTime memberSince,
|
||||
DateTime expires)
|
||||
{
|
||||
return
|
||||
FromIdentity (SwarmDb.GetDatabaseForWriting()
|
||||
.ImportMembership (person.Identity, organization.Identity, memberSince,
|
||||
expires));
|
||||
}
|
||||
|
||||
|
||||
//public void Terminate ()
|
||||
//{
|
||||
// Terminate(EventSource.Unknown);
|
||||
//}
|
||||
|
||||
|
||||
public void Terminate (EventSource eventSource, Person actingPerson, string description)
|
||||
{
|
||||
if (base.Active)
|
||||
{
|
||||
|
||||
// REMOVED: everything Roles related; being phased out
|
||||
|
||||
|
||||
PWLog.Write (actingPerson.Identity, PWLogItem.Person, Person.Identity, PWLogAction.MemberLost,
|
||||
eventSource + ":" + description, string.Empty);
|
||||
PWEvents.CreateEvent (EventSource.PirateWeb, EventType.LostMember, actingPerson.Identity, OrganizationId, Person.GeographyId,
|
||||
Person.Identity, 0, OrganizationId.ToString());
|
||||
|
||||
|
||||
//Added LogChurn here to make SURE they always are logged with the membership.
|
||||
if (PersonId > 0 && OrganizationId > 0 && base.Expires != new DateTime (1900, 1, 1))
|
||||
{
|
||||
ChurnData.LogChurn (PersonId, OrganizationId);
|
||||
}
|
||||
SwarmDb.GetDatabaseForWriting().TerminateMembership (Identity);
|
||||
base.Active = false;
|
||||
base.DateTerminated = DateTime.Now;
|
||||
|
||||
// Remove all newsletter subscriptions once the membership is terminated (to make sure default is now off and only turn off explicitly turned-on subscriptions)
|
||||
|
||||
// HACK HACK HACK: uses feed IDs in an extremely ugly way to loop 1-9. Should use NewsletterFeeds.ForOrganization() once support for newsletters in different orgs are established.
|
||||
|
||||
for (int newsletterFeedId = 1; newsletterFeedId < 10; newsletterFeedId++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.person.IsSubscribing (newsletterFeedId))
|
||||
{
|
||||
this.person.SetSubscription (newsletterFeedId, false);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignore nonexisting newsletter feeds -- this is a hack anyway
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using Swarmops.Basic.Types;
|
||||
using Swarmops.Basic.Types.Swarm;
|
||||
using Swarmops.Common.Enums;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
|
||||
namespace Swarmops.Logic.Swarm
|
||||
{
|
||||
public class Participation : BasicParticipation
|
||||
{
|
||||
public static readonly int GracePeriod = 28;
|
||||
private Organization organization;
|
||||
private BasicMembershipPaymentStatus paymentStatus;
|
||||
private Person person;
|
||||
|
||||
private Participation (BasicParticipation basic)
|
||||
: base (basic)
|
||||
{
|
||||
}
|
||||
|
||||
public Person Person
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.person == null)
|
||||
{
|
||||
this.person = Person.FromIdentity (base.PersonId);
|
||||
}
|
||||
|
||||
return this.person;
|
||||
}
|
||||
}
|
||||
|
||||
public Organization Organization
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.organization == null)
|
||||
{
|
||||
this.organization = Organization.FromIdentity (base.OrganizationId);
|
||||
}
|
||||
|
||||
return this.organization;
|
||||
}
|
||||
}
|
||||
|
||||
public new DateTime Expires
|
||||
{
|
||||
get { return base.Expires; }
|
||||
set
|
||||
{
|
||||
if (base.Expires != value)
|
||||
{
|
||||
if (PersonId > 0 && OrganizationId > 0 && base.Expires != new DateTime (1900, 1, 1))
|
||||
{
|
||||
ChurnData.LogRetention (PersonId, OrganizationId, base.Expires);
|
||||
}
|
||||
SwarmDb.GetDatabaseForWriting().SetParticipationExpires (Identity, value);
|
||||
base.Expires = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MembershipPaymentStatus PaymentStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
LoadPaymentStatus();
|
||||
return this.paymentStatus.Status;
|
||||
}
|
||||
private set
|
||||
{
|
||||
throw new InvalidOperationException (
|
||||
"It is not allowed to set PaymentStatus separately. Use SetPaymentStatus() method.");
|
||||
|
||||
// Rick: Isn't it better to not have a setter at all and get the error compile-time rather than run-time?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DateTime PaymentStatusDate
|
||||
{
|
||||
get
|
||||
{
|
||||
LoadPaymentStatus();
|
||||
return this.paymentStatus.StatusDateTime;
|
||||
}
|
||||
private set
|
||||
{
|
||||
throw new InvalidOperationException (
|
||||
"It is not allowed to set PaymentStatusDate separately. Use SetPaymentStatus() method");
|
||||
|
||||
// Rick: Isn't it better to not have a setter at all and get the error compile-time rather than run-time?
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPaymentStatus (MembershipPaymentStatus status, DateTime dateTime)
|
||||
{
|
||||
SwarmDb.GetDatabaseForWriting().SetMembershipPaymentStatus (Identity, status, dateTime);
|
||||
LoadPaymentStatus();
|
||||
this.paymentStatus.Status = status;
|
||||
this.paymentStatus.StatusDateTime = dateTime;
|
||||
}
|
||||
|
||||
private void LoadPaymentStatus()
|
||||
{
|
||||
if (this.paymentStatus == null)
|
||||
{
|
||||
this.paymentStatus = SwarmDb.GetDatabaseForReading().GetMembershipPaymentStatus (Identity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Optimization metod, loadMultiple in one call
|
||||
public static void LoadPaymentStatuses (Participations mss)
|
||||
{
|
||||
Dictionary<int, BasicMembershipPaymentStatus> statuses =
|
||||
SwarmDb.GetDatabaseForReading().GetMembershipPaymentStatuses (mss.Identities);
|
||||
foreach (Participation ms in mss)
|
||||
{
|
||||
if (ms.paymentStatus == null && statuses.ContainsKey (ms.Identity))
|
||||
{
|
||||
ms.paymentStatus = statuses[ms.Identity];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Participation FromBasic (BasicParticipation basic)
|
||||
{
|
||||
return new Participation (basic);
|
||||
}
|
||||
|
||||
public static Participation FromIdentity (int membershipId)
|
||||
{
|
||||
return FromBasic (SwarmDb.GetDatabaseForReading().GetParticipation (membershipId));
|
||||
}
|
||||
|
||||
public static Participation FromIdentityAggressive (int membershipId)
|
||||
{
|
||||
return FromBasic (SwarmDb.GetDatabaseForWriting().GetParticipation (membershipId));
|
||||
}
|
||||
|
||||
public static Participation FromPersonAndOrganization (int personId, int organizationId)
|
||||
{
|
||||
return FromBasic (SwarmDb.GetDatabaseForReading().GetActiveParticipation (personId, organizationId));
|
||||
}
|
||||
|
||||
public static Participation Create (int personId, int organizationId, DateTime expires)
|
||||
{
|
||||
int membershipId = SwarmDb.GetDatabaseForWriting().CreateParticipation (personId, organizationId, expires);
|
||||
|
||||
return FromIdentityAggressive (membershipId);
|
||||
}
|
||||
|
||||
public static Participation Create (Person person, Organization organization, DateTime expires)
|
||||
{
|
||||
return Create (person.Identity, organization.Identity, expires);
|
||||
}
|
||||
|
||||
public static Participation Import (Person person, Organization organization, DateTime memberSince,
|
||||
DateTime expires)
|
||||
{
|
||||
return
|
||||
FromIdentity (SwarmDb.GetDatabaseForWriting()
|
||||
.ImportParticipation (person.Identity, organization.Identity, memberSince,
|
||||
expires));
|
||||
}
|
||||
|
||||
|
||||
//public void Terminate ()
|
||||
//{
|
||||
// Terminate(EventSource.Unknown);
|
||||
//}
|
||||
|
||||
|
||||
public void Terminate (EventSource eventSource, Person actingPerson, string description)
|
||||
{
|
||||
if (base.Active)
|
||||
{
|
||||
|
||||
// REMOVED: everything Roles related; being phased out
|
||||
|
||||
|
||||
PWLog.Write (actingPerson.Identity, PWLogItem.Person, Person.Identity, PWLogAction.MemberLost,
|
||||
eventSource + ":" + description, string.Empty);
|
||||
PWEvents.CreateEvent (EventSource.PirateWeb, EventType.LostMember, actingPerson.Identity, OrganizationId, Person.GeographyId,
|
||||
Person.Identity, 0, OrganizationId.ToString());
|
||||
|
||||
|
||||
//Added LogChurn here to make SURE they always are logged with the membership.
|
||||
if (PersonId > 0 && OrganizationId > 0 && base.Expires != new DateTime (1900, 1, 1))
|
||||
{
|
||||
ChurnData.LogChurn (PersonId, OrganizationId);
|
||||
}
|
||||
SwarmDb.GetDatabaseForWriting().TerminateParticipation (Identity);
|
||||
base.Active = false;
|
||||
base.DateTerminated = DateTime.Now;
|
||||
|
||||
// Remove all newsletter subscriptions once the membership is terminated (to make sure default is now off and only turn off explicitly turned-on subscriptions)
|
||||
|
||||
// HACK HACK HACK: uses feed IDs in an extremely ugly way to loop 1-9. Should use NewsletterFeeds.ForOrganization() once support for newsletters in different orgs are established.
|
||||
|
||||
for (int newsletterFeedId = 1; newsletterFeedId < 10; newsletterFeedId++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.person.IsSubscribing (newsletterFeedId))
|
||||
{
|
||||
this.person.SetSubscription (newsletterFeedId, false);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignore nonexisting newsletter feeds -- this is a hack anyway
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Swarmops.Basic.Types;
|
||||
using Swarmops.Basic.Types.Swarm;
|
||||
using Swarmops.Database;
|
||||
using Swarmops.Logic.Security;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Support;
|
||||
|
||||
namespace Swarmops.Logic.Swarm
|
||||
{
|
||||
public class Participations : PluralBase<Participations, Participation, BasicParticipation>
|
||||
{
|
||||
|
||||
public static int GetParticipantCountForOrganization (Organization organization)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading().GetParticipantCountForOrganizations (new[] {organization.Identity});
|
||||
}
|
||||
|
||||
public static int GetParticipantCountForOrganizations (int[] organizationIds)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading().GetParticipantCountForOrganizations (organizationIds);
|
||||
}
|
||||
|
||||
public static int GetParticipantCountForOrganizationSince (Organization org, DateTime sinceDateTime)
|
||||
{
|
||||
return GetParticipantCountForOrganizationSince (org.Identity, sinceDateTime);
|
||||
}
|
||||
|
||||
public static int GetParticipantCountForOrganizationSince (int orgId, DateTime sinceDateTime)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading()
|
||||
.GetParticipantCountForOrganizationsSince (new[] {orgId}, sinceDateTime);
|
||||
}
|
||||
|
||||
public static int GetParticipantCountForOrganizations (Organizations organizations)
|
||||
{
|
||||
List<int> idArray = new List<int>();
|
||||
|
||||
foreach (Organization organization in organizations)
|
||||
{
|
||||
idArray.Add (organization.Identity);
|
||||
}
|
||||
|
||||
return GetParticipantCountForOrganizations (idArray.ToArray());
|
||||
}
|
||||
|
||||
public static Participations ForOrganization (Organization organization, bool includeTerminated)
|
||||
{
|
||||
if (!includeTerminated)
|
||||
{
|
||||
return ForOrganization (organization);
|
||||
}
|
||||
|
||||
return FromArray (SwarmDb.GetDatabaseForReading().GetParticipations (organization));
|
||||
}
|
||||
|
||||
public static Participations ForOrganization (Organization organization)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading().GetParticipations (organization, DatabaseCondition.ActiveTrue));
|
||||
}
|
||||
|
||||
public static Participations ForOrganizations (Organizations organizations, bool includeTerminated)
|
||||
{
|
||||
if (!includeTerminated)
|
||||
{
|
||||
return ForOrganizations (organizations);
|
||||
}
|
||||
|
||||
return FromArray (SwarmDb.GetDatabaseForReading().GetParticipations (organizations));
|
||||
}
|
||||
|
||||
public static Participations ForOrganizations (Organizations organizations)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading().GetParticipations (organizations, DatabaseCondition.ActiveTrue));
|
||||
}
|
||||
|
||||
public static Participations GetExpiring (Organization organization, DateTime dateExpiry)
|
||||
{
|
||||
return GetExpiring (organization, dateExpiry, dateExpiry);
|
||||
}
|
||||
|
||||
public static Participations GetExpired (Organization organization)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading().GetExpiringParticipations (organization, DateTime.MinValue,
|
||||
DateTime.Now));
|
||||
}
|
||||
|
||||
public static Participations GetExpired (Organization organization, DateTime lowerBound, DateTime upperBound)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading()
|
||||
.GetExpiringParticipations (organization, lowerBound, upperBound, DatabaseCondition.None));
|
||||
}
|
||||
|
||||
public static Participations GetExpiring (Organization organization, DateTime lowerBound, DateTime upperBound)
|
||||
{
|
||||
return
|
||||
FromArray (SwarmDb.GetDatabaseForReading().GetExpiringParticipations (organization, lowerBound, upperBound));
|
||||
}
|
||||
|
||||
|
||||
public static Dictionary<int, List<BasicParticipation>> GetParticipationsForPeople (int[] personIds, int gracePeriod)
|
||||
{
|
||||
return SwarmDb.GetDatabaseForReading().GetParticipationsForPeople (personIds, gracePeriod);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,11 +19,11 @@ namespace Swarmops.Logic.Swarm
|
||||
get { return LogicServices.ObjectsToIdentifiers (ToArray()); }
|
||||
}
|
||||
|
||||
public static People FromMemberships (Memberships memberships)
|
||||
public static People FromMemberships (Participations participations)
|
||||
{
|
||||
List<int> personIds = new List<int>();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
personIds.Add (membership.PersonId);
|
||||
}
|
||||
@@ -312,9 +312,9 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
// Get the list of all memberships
|
||||
|
||||
Dictionary<int, List<BasicMembership>> memberships =
|
||||
Dictionary<int, List<BasicParticipation>> memberships =
|
||||
SwarmDb.GetDatabaseForReading()
|
||||
.GetMembershipsForPeople (LogicServices.ObjectsToIdentifiers (candidates));
|
||||
.GetParticipationsForPeople (LogicServices.ObjectsToIdentifiers (candidates));
|
||||
|
||||
People result = new People();
|
||||
|
||||
@@ -324,7 +324,7 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
if (memberships.ContainsKey (basicPerson.Identity))
|
||||
{
|
||||
foreach (BasicMembership membership in memberships[basicPerson.Identity])
|
||||
foreach (BasicParticipation membership in memberships[basicPerson.Identity])
|
||||
{
|
||||
if (lookup.ContainsKey (membership.OrganizationId))
|
||||
{
|
||||
|
||||
+26
-26
@@ -397,7 +397,7 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
//not set, make a guess...
|
||||
|
||||
foreach (Membership ms in GetMemberships (false))
|
||||
foreach (Participation ms in GetMemberships (false))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -616,21 +616,21 @@ namespace Swarmops.Logic.Swarm
|
||||
}
|
||||
|
||||
|
||||
public Memberships GetMemberships (bool includeTerminated)
|
||||
public Participations GetMemberships (bool includeTerminated)
|
||||
{
|
||||
if (!includeTerminated)
|
||||
{
|
||||
return GetMemberships();
|
||||
}
|
||||
|
||||
return Memberships.FromArray (SwarmDb.GetDatabaseForReading().GetMemberships (this));
|
||||
return Participations.FromArray (SwarmDb.GetDatabaseForReading().GetParticipations (this));
|
||||
}
|
||||
|
||||
public Memberships GetMemberships()
|
||||
public Participations GetMemberships()
|
||||
{
|
||||
return
|
||||
Memberships.FromArray (SwarmDb.GetDatabaseForReading()
|
||||
.GetMemberships (this, DatabaseCondition.ActiveTrue));
|
||||
Participations.FromArray (SwarmDb.GetDatabaseForReading()
|
||||
.GetParticipations (this, DatabaseCondition.ActiveTrue));
|
||||
}
|
||||
|
||||
|
||||
@@ -640,12 +640,12 @@ namespace Swarmops.Logic.Swarm
|
||||
/// <param name="gracePeriod">For exired, number of days to add to allow it to be returned</param>
|
||||
/// <param name="orgId"></param>
|
||||
/// <returns></returns>
|
||||
public Membership GetRecentMembership (int gracePeriod, int orgId)
|
||||
public Participation GetRecentMembership (int gracePeriod, int orgId)
|
||||
{
|
||||
List<int> orgIdList = new List<int>();
|
||||
orgIdList.Add (orgId);
|
||||
Memberships mss = GetRecentMemberships (orgIdList, gracePeriod);
|
||||
foreach (Membership ms in mss)
|
||||
Participations mss = GetRecentMemberships (orgIdList, gracePeriod);
|
||||
foreach (Participation ms in mss)
|
||||
{
|
||||
if (ms.OrganizationId == orgId)
|
||||
return ms;
|
||||
@@ -658,7 +658,7 @@ namespace Swarmops.Logic.Swarm
|
||||
/// </summary>
|
||||
/// <param name="gracePeriod">For exired, number of days to add to allow it to be returned</param>
|
||||
/// <returns></returns>
|
||||
public Memberships GetRecentMemberships (int gracePeriod)
|
||||
public Participations GetRecentMemberships (int gracePeriod)
|
||||
{
|
||||
List<int> orgIdList = new List<int>();
|
||||
return GetRecentMemberships (orgIdList, gracePeriod);
|
||||
@@ -670,7 +670,7 @@ namespace Swarmops.Logic.Swarm
|
||||
/// <param name="orgs">List of ids. If empty, all orgs</param>
|
||||
/// <param name="gracePeriod">For exired, number of days to add to allow it to be returned</param>
|
||||
/// <returns></returns>
|
||||
public Memberships GetRecentMemberships (Organizations orgs, int gracePeriod)
|
||||
public Participations GetRecentMemberships (Organizations orgs, int gracePeriod)
|
||||
{
|
||||
List<int> orgIdList = new List<int> (orgs.Identities);
|
||||
return GetRecentMemberships (orgIdList, gracePeriod);
|
||||
@@ -682,16 +682,16 @@ namespace Swarmops.Logic.Swarm
|
||||
/// <param name="orgs">List of ids. If empty, all orgs</param>
|
||||
/// <param name="gracePeriod">For exired, number of days to add to allow it to be returned</param>
|
||||
/// <returns></returns>
|
||||
public Memberships GetRecentMemberships (List<int> orgs, int gracePeriod)
|
||||
public Participations GetRecentMemberships (List<int> orgs, int gracePeriod)
|
||||
{
|
||||
Memberships memberships = GetMemberships (true);
|
||||
Dictionary<int, Membership> collectMembers = new Dictionary<int, Membership>();
|
||||
Participations participations = GetMemberships (true);
|
||||
Dictionary<int, Participation> collectMembers = new Dictionary<int, Participation>();
|
||||
|
||||
memberships.Sort (
|
||||
delegate (Membership ms1, Membership ms2) { return ms2.DateTerminated.CompareTo (ms1.DateTerminated); });
|
||||
participations.Sort (
|
||||
delegate (Participation ms1, Participation ms2) { return ms2.DateTerminated.CompareTo (ms1.DateTerminated); });
|
||||
|
||||
//Keep one for each org, the active one or the one with the highest Terminationdate
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (orgs.Count == 0 || orgs.Contains (membership.OrganizationId))
|
||||
{
|
||||
@@ -710,13 +710,13 @@ namespace Swarmops.Logic.Swarm
|
||||
}
|
||||
}
|
||||
|
||||
Memberships collectedMS = new Memberships();
|
||||
Participations collectedMS = new Participations();
|
||||
collectedMS.AddRange (collectMembers.Values);
|
||||
|
||||
if (collectedMS.Count > 0)
|
||||
{
|
||||
//sort to get most recent first
|
||||
collectedMS.Sort (delegate (Membership ms1, Membership ms2)
|
||||
collectedMS.Sort (delegate (Participation ms1, Participation ms2)
|
||||
{
|
||||
if (ms1.Active && ms1.Active != ms2.Active)
|
||||
return -1; // active before terminated
|
||||
@@ -785,14 +785,14 @@ namespace Swarmops.Logic.Swarm
|
||||
return newPerson;
|
||||
}
|
||||
|
||||
public Membership AddMembership (Organization organization, DateTime expires)
|
||||
public Participation AddMembership (Organization organization, DateTime expires)
|
||||
{
|
||||
return AddMembership (organization.Identity, expires);
|
||||
}
|
||||
|
||||
public Membership AddMembership (int organizationId, DateTime expires)
|
||||
public Participation AddMembership (int organizationId, DateTime expires)
|
||||
{
|
||||
return Membership.Create (Identity, organizationId, expires);
|
||||
return Participation.Create (Identity, organizationId, expires);
|
||||
}
|
||||
|
||||
private bool? HasExplicitSubscription (int newsletterFeedId)
|
||||
@@ -1023,9 +1023,9 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
public bool MemberOf (int orgId)
|
||||
{
|
||||
Memberships memberships = GetMemberships();
|
||||
Participations participations = GetMemberships();
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.OrganizationId == orgId)
|
||||
{
|
||||
@@ -1038,8 +1038,8 @@ namespace Swarmops.Logic.Swarm
|
||||
|
||||
public bool MemberOfWithInherited (int orgId)
|
||||
{
|
||||
Memberships memberships = GetMemberships();
|
||||
foreach (Membership membership in memberships)
|
||||
Participations participations = GetMemberships();
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.Organization.IsOrInherits (orgId))
|
||||
{
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
|
||||
Positions.CreateOrganizationDefaultPositions (newOrganization, titleType);
|
||||
|
||||
Membership.Create (CurrentUser, newOrganization, DateTime.UtcNow.AddYears (2));
|
||||
Participation.Create (CurrentUser, newOrganization, DateTime.UtcNow.AddYears (2));
|
||||
|
||||
string successMessage = String.Format (Resources.Pages.Admin.CreateOrganization_Success,
|
||||
Participant.Localized (peopleLabel, TitleVariant.Ship));
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace Swarmops.Frontend.Pages.v5.Security
|
||||
|
||||
private void PopulateRepeater()
|
||||
{
|
||||
Memberships memberships = CurrentUser.GetMemberships();
|
||||
Participations participations = CurrentUser.GetMemberships();
|
||||
|
||||
List<OrganizationParameters> availableOrganizations = new List<OrganizationParameters>();
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.OrganizationId == 1 && !PilotInstallationIds.IsPilot (PilotInstallationIds.PiratePartySE))
|
||||
{
|
||||
|
||||
@@ -114,14 +114,14 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
|
||||
street, this.TextPostal.Text, this.TextCity.Text, this.DropCountries.SelectedValue, dateOfBirth,
|
||||
(PersonGender)Enum.Parse(typeof(PersonGender), this.DropGenders.SelectedValue));
|
||||
|
||||
Membership newMembership = Membership.Create (newPerson, CurrentOrganization, DateTime.Today.AddYears (1));
|
||||
Participation newParticipation = Participation.Create (newPerson, CurrentOrganization, DateTime.Today.AddYears (1));
|
||||
|
||||
OutboundComm.CreateMembershipLetter (ParticipantMailType.MemberAddedWelcome, newMembership, CurrentUser);
|
||||
OutboundComm.CreateMembershipLetter (ParticipantMailType.MemberAddedWelcome, newParticipation, CurrentUser);
|
||||
|
||||
SwarmopsLogEntry logEntry = SwarmopsLog.CreateEntry (newPerson,
|
||||
new Swarmops.Logic.Support.LogEntries.PersonAddedLogEntry (newMembership, CurrentUser));
|
||||
new Swarmops.Logic.Support.LogEntries.PersonAddedLogEntry (newParticipation, CurrentUser));
|
||||
|
||||
logEntry.CreateAffectedObject (newMembership);
|
||||
logEntry.CreateAffectedObject (newParticipation);
|
||||
logEntry.CreateAffectedObject (CurrentUser);
|
||||
|
||||
// Clear form and make way for next person
|
||||
|
||||
@@ -54,16 +54,16 @@ namespace Swarmops.Utility.BotCode
|
||||
|
||||
Organizations orgTree = poll.Organization.ThisAndBelow();
|
||||
|
||||
Memberships memberships = Memberships.ForOrganizations (orgTree);
|
||||
Participations participations = Participations.ForOrganizations (orgTree);
|
||||
|
||||
Dictionary<int, bool> dupeCheck = new Dictionary<int, bool>();
|
||||
|
||||
int count = 0;
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
Console.Write ("\r - voters: {0:D6}/{1:D6} (person #{2:D6})...", ++count,
|
||||
memberships.Count, membership.PersonId);
|
||||
participations.Count, membership.PersonId);
|
||||
|
||||
if (!membership.Active)
|
||||
{
|
||||
|
||||
@@ -34,14 +34,14 @@ namespace Swarmops.Utility.BotCode
|
||||
{
|
||||
if (org.AcceptsMembers)
|
||||
{
|
||||
Memberships memberships = org.GetMemberships();
|
||||
Participations participations = org.GetMemberships();
|
||||
|
||||
string orgSummary = org.Name + "\r\n";
|
||||
|
||||
// Iterate over membership roster and filter by date
|
||||
|
||||
List<int> relevantPersonIds = new List<int>();
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.MemberSince > membersAfter && membership.MemberSince < membersBefore)
|
||||
{
|
||||
@@ -112,9 +112,9 @@ namespace Swarmops.Utility.BotCode
|
||||
|
||||
foreach (Organization org in orgs)
|
||||
{
|
||||
Memberships memberships = Memberships.GetExpiring (org, lowerBound, upperBound);
|
||||
Participations participations = Participations.GetExpiring (org, lowerBound, upperBound);
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
if (membership.OrganizationId%7 != weekDayInteger)
|
||||
{
|
||||
@@ -206,10 +206,10 @@ namespace Swarmops.Utility.BotCode
|
||||
|
||||
foreach (Organization organization in organizations)
|
||||
{
|
||||
Memberships memberships = Memberships.GetExpired (organization);
|
||||
Participations participations = Participations.GetExpired (organization);
|
||||
// Mail each expiring member
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
//only remove expired memberships
|
||||
if (membership.Expires > DateTime.Now.Date)
|
||||
@@ -222,13 +222,13 @@ namespace Swarmops.Utility.BotCode
|
||||
|
||||
// Mail
|
||||
|
||||
Memberships personMemberships = person.GetMemberships();
|
||||
Memberships membershipsToDelete = new Memberships();
|
||||
foreach (Membership personMembership in personMemberships)
|
||||
Participations personParticipations = person.GetMemberships();
|
||||
Participations participationsToDelete = new Participations();
|
||||
foreach (Participation personMembership in personParticipations)
|
||||
{
|
||||
if (personMembership.Expires <= DateTime.Now.Date)
|
||||
{
|
||||
membershipsToDelete.Add (personMembership);
|
||||
participationsToDelete.Add (personMembership);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,15 +236,15 @@ namespace Swarmops.Utility.BotCode
|
||||
ExpiredMail expiredmail = new ExpiredMail();
|
||||
string membershipsIds = "";
|
||||
|
||||
if (membershipsToDelete.Count > 1)
|
||||
if (participationsToDelete.Count > 1)
|
||||
{
|
||||
foreach (Membership personMembership in membershipsToDelete)
|
||||
foreach (Participation personMembership in participationsToDelete)
|
||||
{
|
||||
membershipsIds += "," + personMembership.MembershipId;
|
||||
}
|
||||
membershipsIds = membershipsIds.Substring (1);
|
||||
string expiredMemberships = "";
|
||||
foreach (Membership personMembership in membershipsToDelete)
|
||||
foreach (Participation personMembership in participationsToDelete)
|
||||
{
|
||||
if (personMembership.OrganizationId != organization.Identity)
|
||||
{
|
||||
@@ -272,7 +272,7 @@ namespace Swarmops.Utility.BotCode
|
||||
|
||||
string orgIdString = string.Empty;
|
||||
|
||||
foreach (Membership personMembership in membershipsToDelete)
|
||||
foreach (Participation personMembership in participationsToDelete)
|
||||
{
|
||||
if (personMembership.Active)
|
||||
{
|
||||
@@ -292,11 +292,11 @@ namespace Swarmops.Utility.BotCode
|
||||
|
||||
foreach (Organization org in orgs)
|
||||
{
|
||||
Memberships memberships = Memberships.GetExpiring (org, dateExpiry);
|
||||
Participations participations = Participations.GetExpiring (org, dateExpiry);
|
||||
|
||||
// Mail each expiring member
|
||||
|
||||
foreach (Membership membership in memberships)
|
||||
foreach (Participation membership in participations)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -376,7 +376,7 @@ namespace Swarmops.Utility.BotCode
|
||||
}
|
||||
|
||||
[Obsolete ("Generalize and localize this function.", true)]
|
||||
public static void SendReminderMail (Membership membership)
|
||||
public static void SendReminderMail (Participation participation)
|
||||
{
|
||||
/*
|
||||
// First, determine the organization template to use. Prioritize a long ancestry.
|
||||
|
||||
Reference in New Issue
Block a user