Committing split of dbops into read/write/admin ops, for security and multi-db deployments. THIS BREAKS THE INSTALLATION.

This commit is contained in:
Rick Falkvinge
2012-11-06 07:37:48 +00:00
parent e9c01ec818
commit 8a4608b2cb
113 changed files with 498 additions and 478 deletions
+3 -3
View File
@@ -320,7 +320,7 @@ namespace Activizr.Backend
foreach (BasicAutoMail autoMail in allAutoMails)
{
int id = PirateDb.GetDatabase().SetAutoMail(autoMail);
int id = PirateDb.GetDatabaseForWriting().SetAutoMail(autoMail);
Organization org = null;
@@ -556,7 +556,7 @@ namespace Activizr.Backend
Console.Write("Member count PPSE, Memberships method... ");
Console.WriteLine(Organization.PPSE.GetMemberships().Count);
Console.Write("Member count PPSE, direct person count... ");
Console.WriteLine(PirateDb.GetDatabase().GetMembersForOrganizations(new int[] {1}).Length);
Console.WriteLine(PirateDb.GetDatabaseForReading().GetMembersForOrganizations(new int[] {1}).Length);
Console.Write("Newsletter recipient count... ");
Console.WriteLine(People.FromNewsletterFeed(NewsletterFeed.TypeID.ChairmanBlog).Count);
@@ -566,7 +566,7 @@ namespace Activizr.Backend
Console.Write("Membership count UPSE, count method... ");
Console.WriteLine(Organization.FromIdentity(Organization.UPSEid).GetTree().GetMembershipCount());
Console.Write("Member count UPSE, direct person count... ");
Console.WriteLine(PirateDb.GetDatabase().GetMembersForOrganizations(Organization.FromIdentity(Organization.UPSEid).GetTree().Identities).Length);
Console.WriteLine(PirateDb.GetDatabaseForReading().GetMembersForOrganizations(Organization.FromIdentity(Organization.UPSEid).GetTree().Identities).Length);
Console.Write("Members expiring in next ten days...");
+24
View File
@@ -15,6 +15,23 @@ namespace Activizr.Database
/// </summary>
public partial class PirateDb
{
public static PirateDb GetDatabaseForReading()
{
return new PirateDb(DatabaseConnect.Default.Read);
}
public static PirateDb GetDatabaseForWriting()
{
return new PirateDb(DatabaseConnect.Default.Write);
}
public static PirateDb GetDatabaseForAdmin()
{
return new PirateDb(DatabaseConnect.Default.Admin);
}
[Obsolete ("Do not use. Use PirateDb.GetDatabaseForReading(), ...ForWriting() or ...ForAdmin().", true)]
public static PirateDb GetDatabase()
{
// First, check if a previous invocation has put anything in the cashe.
@@ -123,6 +140,7 @@ namespace Activizr.Database
return db;
}
[Obsolete ("Do not use. Use GetDatabaseForAdmin().", true)]
public static PirateDb GetDatabaseAsAdmin()
{
string connectionString = string.Empty;
@@ -204,12 +222,18 @@ namespace Activizr.Database
return new PirateDb(DbProviderFactories.GetFactory(DefaultProviderName), connectionString);
}
[Obsolete ("Do not use. Hardwireto MySQL.")]
public PirateDb(DbProviderFactory ProviderFactory, string ConnectionString)
{
this.ProviderFactory = ProviderFactory;
this.ConnectionString = ConnectionString;
}
public PirateDb(string connectionString)
{
this.ConnectionString = connectionString;
}
// The instance connection details.
private DbProviderFactory ProviderFactory;
private string ConnectionString;
+5 -5
View File
@@ -26,7 +26,7 @@ namespace Activizr.Logic.Cache
{
if (loadCache || lastRefresh.AddMinutes(cacheLifeSpanMinutes) < DateTime.Now)
{
__geographyCache = PirateDb.GetDatabase().GetHashedGeographies();
__geographyCache = PirateDb.GetDatabaseForReading().GetHashedGeographies();
lastRefresh = DateTime.Now;
loadCache = false;
}
@@ -241,8 +241,8 @@ namespace Activizr.Logic.Cache
static public void SetGeographyName (int geographyId, string name)
{
PirateDb.GetDatabase().SetGeographyName(geographyId, name);
BasicGeography geo = PirateDb.GetDatabase().GetGeography(geographyId);
PirateDb.GetDatabaseForWriting().SetGeographyName(geographyId, name);
BasicGeography geo = PirateDb.GetDatabaseForReading().GetGeography(geographyId);
Dictionary<int, List<BasicGeography>> hashedGeographies = GetHashedGeographies();
hashedGeographies[geographyId][0] = geo;
}
@@ -251,12 +251,12 @@ namespace Activizr.Logic.Cache
* Might be handled....
public GeographyLevel[] GetGeographyLevelsAtGeographyId (int geographyId)
{
return PirateDb.GetDatabase().GetGeographyLevelsAtGeographyId(geographyId);
return PirateDb.GetDatabaseForReading().GetGeographyLevelsAtGeographyId(geographyId);
}
public int[] GetGeographyIdsFromLevel (int countryId, GeographyLevel level)
{
return PirateDb.GetDatabase().GetGeographyIdsFromLevel(countryId, level);
return PirateDb.GetDatabaseForReading().GetGeographyIdsFromLevel(countryId, level);
}
************************/
+1 -1
View File
@@ -32,7 +32,7 @@ namespace Activizr.Logic.Cache
if (!__MailTemplateCache.ContainsKey(templateName))
{
BasicMailTemplate[] basicTemplates = PirateDb.GetDatabase().GetMailTemplatesByName(templateName);
BasicMailTemplate[] basicTemplates = PirateDb.GetDatabaseForReading().GetMailTemplatesByName(templateName);
List<BasicMailTemplate> tmplList = new List<BasicMailTemplate>(basicTemplates);
__MailTemplateCache[templateName] = tmplList;
+8 -8
View File
@@ -27,7 +27,7 @@ namespace Activizr.Logic.Cache
{
if (needsReload)
{
__organizationCache = PirateDb.GetDatabase().GetHashedOrganizations();
__organizationCache = PirateDb.GetDatabaseForReading().GetHashedOrganizations();
__cachedUptakeGeographies = null;
lastRefresh = DateTime.Now;
needsReload = false;
@@ -72,7 +72,7 @@ namespace Activizr.Logic.Cache
bool AutoAssignNewMembers, int DefaultCountryId)
{
int Identity = PirateDb.GetDatabase().CreateOrganization(ParentOrganizationId,
int Identity = PirateDb.GetDatabaseForWriting().CreateOrganization(ParentOrganizationId,
NameInternational,
Name,
NameShort,
@@ -90,7 +90,7 @@ namespace Activizr.Logic.Cache
string NameShort, string Domain, string MailPrefix, int AnchorGeographyId, bool AcceptsMembers,
bool AutoAssignNewMembers, int DefaultCountryId, int OrganizationId)
{
PirateDb.GetDatabase().UpdateOrganization(ParentOrganizationId, NameInternational, Name, NameShort, Domain,
PirateDb.GetDatabaseForWriting().UpdateOrganization(ParentOrganizationId, NameInternational, Name, NameShort, Domain,
MailPrefix, AnchorGeographyId, AcceptsMembers, AutoAssignNewMembers, DefaultCountryId,
OrganizationId);
@@ -106,7 +106,7 @@ namespace Activizr.Logic.Cache
// Let this be for the moment, new and old parents need to be loaded as well. Better right now to reload the whole cache.
//lock (loadCacheLock)
//{
// __organizationCache[objectId][0] = Organization.FromBasic(PirateDb.GetDatabase().GetOrganization(objectId));
// __organizationCache[objectId][0] = Organization.FromBasic(PirateDb.GetDatabaseForReading().GetOrganization(objectId));
//}
}
@@ -268,7 +268,7 @@ namespace Activizr.Logic.Cache
internal static void DeleteOrganization (int p)
{
PirateDb.GetDatabase().DeleteOrganization(p);
PirateDb.GetDatabaseForWriting().DeleteOrganization(p);
needsReload = true;
}
@@ -289,7 +289,7 @@ namespace Activizr.Logic.Cache
if (__cachedUptakeGeographies == null)
{
__cachedUptakeGeographies = PirateDb.GetDatabase().GetAllOrganizationUptakeGeographyIds();
__cachedUptakeGeographies = PirateDb.GetDatabaseForReading().GetAllOrganizationUptakeGeographyIds();
}
}
return __cachedUptakeGeographies;
@@ -362,7 +362,7 @@ namespace Activizr.Logic.Cache
internal static void AddOrgUptakeGeography (int p, int geoId)
{
PirateDb.GetDatabase().AddOrgUptakeGeography(p, geoId);
PirateDb.GetDatabaseForWriting().AddOrgUptakeGeography(p, geoId);
lock (loadCacheLock)
{
__cachedUptakeGeographies = null;
@@ -372,7 +372,7 @@ namespace Activizr.Logic.Cache
internal static void DeleteOrgUptakeGeography (int p, int geoId)
{
PirateDb.GetDatabase().DeleteOrgUptakeGeography(p, geoId);
PirateDb.GetDatabaseForWriting().DeleteOrgUptakeGeography(p, geoId);
lock (loadCacheLock)
{
__cachedUptakeGeographies = null;
+4 -4
View File
@@ -23,7 +23,7 @@ namespace Activizr.Logic.Communications
set
{
base.Body = value;
PirateDb.GetDatabase().SetAutoMail (this); // saves changes
PirateDb.GetDatabaseForWriting().SetAutoMail (this); // saves changes
}
}
@@ -36,7 +36,7 @@ namespace Activizr.Logic.Communications
public static AutoMail FromTypeOrganizationAndGeography (AutoMailType type, Organization org, Geography geo)
{
BasicAutoMail basic = PirateDb.GetDatabase().GetAutoMail (type, org.Identity, geo.Identity);
BasicAutoMail basic = PirateDb.GetDatabaseForReading().GetAutoMail (type, org.Identity, geo.Identity);
if (basic == null)
{
@@ -55,7 +55,7 @@ namespace Activizr.Logic.Communications
public static AutoMail Create (AutoMailType type, Organization org, Geography geo,
Person author, string title, string body)
{
PirateDb.GetDatabase().SetAutoMail (type, org.Identity, geo.Identity,
PirateDb.GetDatabaseForWriting().SetAutoMail (type, org.Identity, geo.Identity,
author == null ? 0 : author.Identity, title, body);
return FromTypeOrganizationAndGeography (type, org, geo);
}
@@ -67,7 +67,7 @@ namespace Activizr.Logic.Communications
public static BasicAutoMail[] GetAllForMigration()
{
return PirateDb.GetDatabase().GetAllAutoMailsForMigration();
return PirateDb.GetDatabaseForReading().GetAllAutoMailsForMigration();
}
}
}
@@ -23,13 +23,13 @@ namespace Activizr.Logic.Communications
public static CommunicationTurnaround FromIdentity (Organization organization, int communicationTypeId, int communicationId)
{
return
FromBasic(PirateDb.GetDatabase().GetCommunicationTurnaround(organization.Identity, communicationTypeId,
FromBasic(PirateDb.GetDatabaseForReading().GetCommunicationTurnaround(organization.Identity, communicationTypeId,
communicationId));
}
public static CommunicationTurnaround Create (Organization organization, int communicationId, DateTime dateTimeOpened)
{
PirateDb.GetDatabase().CreateCommunicationTurnaround(organization.Identity, 1, communicationId, dateTimeOpened);
PirateDb.GetDatabaseForWriting().CreateCommunicationTurnaround(organization.Identity, 1, communicationId, dateTimeOpened);
return FromIdentity(organization, 1, communicationId);
}
@@ -52,7 +52,7 @@ namespace Activizr.Logic.Communications
personId = person.Identity;
}
PirateDb.GetDatabase().SetCommunicationTurnaroundResponded(this.OrganizationId, this.CommunicationTypeId, this.CommunicationId, dateTime, personId);
PirateDb.GetDatabaseForWriting().SetCommunicationTurnaroundResponded(this.OrganizationId, this.CommunicationTypeId, this.CommunicationId, dateTime, personId);
base.Responded = true;
}
@@ -71,7 +71,7 @@ namespace Activizr.Logic.Communications
personId = person.Identity;
}
PirateDb.GetDatabase().SetCommunicationTurnaroundClosed(this.OrganizationId, this.CommunicationTypeId, this.CommunicationId, dateTime, personId);
PirateDb.GetDatabaseForWriting().SetCommunicationTurnaroundClosed(this.OrganizationId, this.CommunicationTypeId, this.CommunicationId, dateTime, personId);
base.Open = false;
}
@@ -19,12 +19,12 @@ namespace Activizr.Logic.Communications
{
if (includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetCommunicationTurnarounds(organization));
return FromArray(PirateDb.GetDatabaseForReading().GetCommunicationTurnarounds(organization));
}
else
{
return
FromArray(PirateDb.GetDatabase().GetCommunicationTurnarounds(organization,
FromArray(PirateDb.GetDatabaseForReading().GetCommunicationTurnarounds(organization,
DatabaseCondition.OpenTrue));
}
}
+4 -4
View File
@@ -519,7 +519,7 @@ namespace Activizr.Logic.Communications
public static MailTemplate FromIdentity (int templateId)
{
BasicMailTemplate basic = PirateDb.GetDatabase().GetMailTemplateById(templateId);
BasicMailTemplate basic = PirateDb.GetDatabaseForReading().GetMailTemplateById(templateId);
return FromBasic(basic);
}
@@ -531,7 +531,7 @@ namespace Activizr.Logic.Communications
public static List<MailTemplate> GetAll ()
{
BasicMailTemplate[] basic = PirateDb.GetDatabase().GetAllMailTemplates();
BasicMailTemplate[] basic = PirateDb.GetDatabaseForReading().GetAllMailTemplates();
List<MailTemplate> resultlist = new List<MailTemplate>();
foreach (BasicMailTemplate bt in basic)
{
@@ -550,7 +550,7 @@ namespace Activizr.Logic.Communications
int organizationId,
string templateBody)
{
int retId = PirateDb.GetDatabase().SetMailTemplate(0,
int retId = PirateDb.GetDatabaseForWriting().SetMailTemplate(0,
templateName,
languageCode,
countryCode,
@@ -564,7 +564,7 @@ namespace Activizr.Logic.Communications
public void Update ()
{
TemplateBody = TemplateBody; //to make sure the HTMlDoc is taken into account
PirateDb.GetDatabase().SetMailTemplate(this); // saves changes
PirateDb.GetDatabaseForWriting().SetMailTemplate(this); // saves changes
MailTemplateCache.loadCache = true;
}
+1 -1
View File
@@ -28,7 +28,7 @@ namespace Activizr.Logic.Communications
public static NewsletterFeed FromIdentity (int identity)
{
return FromBasic(PirateDb.GetDatabase().GetNewsletterFeed((int)identity));
return FromBasic(PirateDb.GetDatabaseForReading().GetNewsletterFeed((int)identity));
}
public static NewsletterFeed FromBasic (BasicNewsletterFeed basic)
+16 -16
View File
@@ -58,7 +58,7 @@ namespace Activizr.Logic.Communications
/// <returns>An OutboundMail from the database</returns>
public static OutboundMail FromIdentity (int outboundMailId)
{
return FromBasic(PirateDb.GetDatabase().GetOutboundMail(outboundMailId));
return FromBasic(PirateDb.GetDatabaseForReading().GetOutboundMail(outboundMailId));
}
@@ -75,7 +75,7 @@ namespace Activizr.Logic.Communications
Organization organization, Geography geography, DateTime releaseDateTime)
{
return
FromIdentity(PirateDb.GetDatabase().CreateOutboundMail(MailAuthorType.Person, author.Identity, title,
FromIdentity(PirateDb.GetDatabaseForWriting().CreateOutboundMail(MailAuthorType.Person, author.Identity, title,
body, mailPriority, mailType,
geography.Identity, organization.Identity,
releaseDateTime));
@@ -115,7 +115,7 @@ namespace Activizr.Logic.Communications
int organizationId, int geographyId, DateTime releaseDateTime)
{
int mailID = PirateDb.GetDatabase().CreateOutboundMail(authorType, 0, title,
int mailID = PirateDb.GetDatabaseForWriting().CreateOutboundMail(authorType, 0, title,
body, mailPriority, mailType, geographyId,
organizationId, releaseDateTime);
@@ -130,7 +130,7 @@ namespace Activizr.Logic.Communications
{
List<OutboundMail> retList = new List<OutboundMail>();
BasicOutboundMail[] mails
= PirateDb.GetDatabase().GetDuplicateOutboundMail(this.AuthorType, AuthorPersonId, Title,
= PirateDb.GetDatabaseForReading().GetDuplicateOutboundMail(this.AuthorType, AuthorPersonId, Title,
Body, MailPriority, MailType, GeographyId, OrganizationId, afterTime, recipientId);
foreach (BasicOutboundMail mail in mails)
{
@@ -142,7 +142,7 @@ namespace Activizr.Logic.Communications
public static OutboundMail GetFirstUnresolved ()
{
BasicOutboundMail[] mails = PirateDb.GetDatabase().GetTopUnresolvedOutboundMail(1);
BasicOutboundMail[] mails = PirateDb.GetDatabaseForReading().GetTopUnresolvedOutboundMail(1);
if (mails.Length > 0)
{
@@ -154,7 +154,7 @@ namespace Activizr.Logic.Communications
public static OutboundMail GetFirstUnprocessed ()
{
BasicOutboundMail[] mails = PirateDb.GetDatabase().GetTopUnprocessedOutboundMail(1);
BasicOutboundMail[] mails = PirateDb.GetDatabaseForReading().GetTopUnprocessedOutboundMail(1);
if (mails.Length > 0)
{
@@ -173,7 +173,7 @@ namespace Activizr.Logic.Communications
get { return base.StartProcessDateTime; }
set
{
PirateDb.GetDatabase().SetOutboundMailStartProcess(Identity);
PirateDb.GetDatabaseForWriting().SetOutboundMailStartProcess(Identity);
base.StartProcessDateTime = DateTime.Now;
}
}
@@ -238,7 +238,7 @@ namespace Activizr.Logic.Communications
{
return
OutboundMailRecipients.FromArray(
PirateDb.GetDatabase().GetTopOutboundMailRecipients(Identity, batchSize), this);
PirateDb.GetDatabaseForReading().GetTopOutboundMailRecipients(Identity, batchSize), this);
}
public void AddRecipient (Person person, bool asOfficer)
@@ -269,12 +269,12 @@ namespace Activizr.Logic.Communications
public void AddRecipient (int personId, bool asOfficer)
{
PirateDb.GetDatabase().CreateOutboundMailRecipient(Identity, personId, asOfficer, (int)OutboundMailRecipient.RecipientType.Person);
PirateDb.GetDatabaseForWriting().CreateOutboundMailRecipient(Identity, personId, asOfficer, (int)OutboundMailRecipient.RecipientType.Person);
}
private void AddReporterRecipient (int identity)
{
PirateDb.GetDatabase().CreateOutboundMailRecipient(Identity, identity, false, (int)OutboundMailRecipient.RecipientType.Reporter);
PirateDb.GetDatabaseForWriting().CreateOutboundMailRecipient(Identity, identity, false, (int)OutboundMailRecipient.RecipientType.Reporter);
}
#endregion
@@ -282,37 +282,37 @@ namespace Activizr.Logic.Communications
public void SetReadyForPickup ()
{
PirateDb.GetDatabase().SetOutboundMailReadyForPickup(Identity);
PirateDb.GetDatabaseForWriting().SetOutboundMailReadyForPickup(Identity);
base.ReadyForPickup = true;
}
public void SetResolved ()
{
PirateDb.GetDatabase().SetOutboundMailResolved(Identity);
PirateDb.GetDatabaseForWriting().SetOutboundMailResolved(Identity);
base.Resolved = true;
}
public void SetProcessed ()
{
PirateDb.GetDatabase().SetOutboundMailProcessed(Identity);
PirateDb.GetDatabaseForWriting().SetOutboundMailProcessed(Identity);
base.Processed = true;
}
public void SetRecipientCount (int recipientCount)
{
PirateDb.GetDatabase().SetOutboundMailRecipientCount(Identity, recipientCount);
PirateDb.GetDatabaseForWriting().SetOutboundMailRecipientCount(Identity, recipientCount);
base.RecipientCount = recipientCount;
}
public void IncrementSuccesses ()
{
PirateDb.GetDatabase().IncrementOutboundMailSuccesses(Identity);
PirateDb.GetDatabaseForWriting().IncrementOutboundMailSuccesses(Identity);
base.RecipientsSuccess++;
}
public void IncrementFailures ()
{
PirateDb.GetDatabase().IncrementOutboundMailFailures(Identity);
PirateDb.GetDatabaseForWriting().IncrementOutboundMailFailures(Identity);
base.RecipientsFail++;
}
@@ -112,12 +112,12 @@ namespace Activizr.Logic.Communications
public static void Create (int outboundMailId, int personId, bool asOfficer, int personType)
{
PirateDb.GetDatabase().CreateOutboundMailRecipient(outboundMailId, personId, asOfficer, personType);
PirateDb.GetDatabaseForWriting().CreateOutboundMailRecipient(outboundMailId, personId, asOfficer, personType);
}
public void Delete ()
{
PirateDb.GetDatabase().DeleteOutboundMailRecipient(Identity);
PirateDb.GetDatabaseForWriting().DeleteOutboundMailRecipient(Identity);
}
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Activizr.Logic.Communications
public static OutboundMails GetTopUnprocessed (int count)
{
BasicOutboundMail[] basicMails = PirateDb.GetDatabase().GetTopUnprocessedOutboundMail (count);
BasicOutboundMail[] basicMails = PirateDb.GetDatabaseForReading().GetTopUnprocessedOutboundMail (count);
return FromArray (basicMails);
}
+2 -2
View File
@@ -24,14 +24,14 @@ namespace Activizr.Logic.Communications
public static PaperLetter Create(int creatingPersonId, int organizationId, string fromName,
string[] replyAddressLines, DateTime receivedDate, int toPersonId, RoleType toPersonInRole, bool personal)
{
return FromIdentity(PirateDb.GetDatabase().
return FromIdentity(PirateDb.GetDatabaseForWriting().
CreatePaperLetter(organizationId, fromName, String.Join("|", replyAddressLines),
receivedDate, toPersonId, toPersonInRole, personal, creatingPersonId));
}
public static PaperLetter FromIdentity (int paperLetterId)
{
return FromBasic(PirateDb.GetDatabase().GetPaperLetter(paperLetterId));
return FromBasic(PirateDb.GetDatabaseForReading().GetPaperLetter(paperLetterId));
}
public static PaperLetter FromBasic (BasicPaperLetter basic)
+2 -2
View File
@@ -33,7 +33,7 @@ namespace Activizr.Logic.Communications
public static PaperLetters ForOrganization (int organizationId)
{
return FromArray(PirateDb.GetDatabase().GetPaperLettersForOrganization(organizationId));
return FromArray(PirateDb.GetDatabaseForReading().GetPaperLettersForOrganization(organizationId));
}
public static PaperLetters ForPerson (Person person)
@@ -43,7 +43,7 @@ namespace Activizr.Logic.Communications
public static PaperLetters ForPerson (int personId)
{
return FromArray(PirateDb.GetDatabase().GetPaperLettersForPerson(personId));
return FromArray(PirateDb.GetDatabaseForReading().GetPaperLettersForPerson(personId));
}
}
}
+1 -1
View File
@@ -405,7 +405,7 @@ namespace Activizr.Logic.Communications
{
for (int i = 0; i < phoneNumbers.Length; i++)
{
BasicPerson[] people = PirateDb.GetDatabase().GetPeopleFromPhoneNumber("SE", phoneNumbers[i]);
BasicPerson[] people = PirateDb.GetDatabaseForReading().GetPeopleFromPhoneNumber("SE", phoneNumbers[i]);
foreach (BasicPerson bp in people)
{
//Only add if not seen.
@@ -27,7 +27,7 @@ namespace Activizr.Logic.Communications
{
lastLoad = DateTime.Now;
String serviceName = Persistence.Key["SMSService"];
BasicExternalCredential basicCredential = PirateDb.GetDatabase().GetExternalCredential(serviceName);
BasicExternalCredential basicCredential = PirateDb.GetDatabaseForReading().GetExternalCredential(serviceName);
Encoding enc = Encoding.GetEncoding(28591); //ISO encoding (latin1)
credential = new ServiceCredential(basicCredential.Login, basicCredential.Password, basicCredential.ServiceName, enc);
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Activizr.Logic.DataObjects
#endif
public static Membership[] Select (int personId)
{
return Memberships.FromArray (PirateDb.GetDatabase().GetMemberships (Person.FromIdentity(personId))).ToArray();
return Memberships.FromArray(PirateDb.GetDatabaseForReading().GetMemberships(Person.FromIdentity(personId))).ToArray();
}
#if !__MonoCS__
+20 -20
View File
@@ -28,13 +28,13 @@ namespace Activizr.Logic.Financial
public static ExpenseClaim FromIdentity (int expenseId)
{
return FromBasic (PirateDb.GetDatabase().GetExpenseClaim (expenseId));
return FromBasic (PirateDb.GetDatabaseForReading().GetExpenseClaim (expenseId));
}
public static ExpenseClaim Create (Person claimer, Organization organization, FinancialAccount budget,
DateTime expenseDate, string description, Int64 amountCents)
{
ExpenseClaim newClaim = FromIdentity (PirateDb.GetDatabase().CreateExpenseClaim (claimer.Identity, organization.Identity,
ExpenseClaim newClaim = FromIdentity (PirateDb.GetDatabaseForWriting().CreateExpenseClaim (claimer.Identity, organization.Identity,
budget.Identity, expenseDate, description, amountCents));
// Create the financial transaction with rows
@@ -77,7 +77,7 @@ namespace Activizr.Logic.Financial
{
// OBSOLETE
// PirateDb.GetDatabase().CreateExpenseEvent (Identity, eventType, personId);
// PirateDb.GetDatabaseForWriting().CreateExpenseEvent (Identity, eventType, personId);
// TODO: Repopulate Events property, when created
}
@@ -147,7 +147,7 @@ namespace Activizr.Logic.Financial
{
if (base.Attested != value)
{
PirateDb.GetDatabase().SetExpenseClaimAttested(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetExpenseClaimAttested(this.Identity, value);
base.Attested = value;
}
}
@@ -163,7 +163,7 @@ namespace Activizr.Logic.Financial
{
if (base.Validated != value)
{
PirateDb.GetDatabase().SetExpenseClaimValidated(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetExpenseClaimValidated(this.Identity, value);
base.Validated = value;
}
}
@@ -177,7 +177,7 @@ namespace Activizr.Logic.Financial
if (base.Open != value)
{
base.Open = value;
PirateDb.GetDatabase().SetExpenseClaimOpen(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetExpenseClaimOpen(this.Identity, value);
}
}
@@ -191,7 +191,7 @@ namespace Activizr.Logic.Financial
if (base.Claimed != value)
{
base.Claimed = value;
PirateDb.GetDatabase().SetExpenseClaimClaimed(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetExpenseClaimClaimed(this.Identity, value);
UpdateFinancialTransaction(this.Claimer);
}
}
@@ -206,7 +206,7 @@ namespace Activizr.Logic.Financial
if (base.Repaid != value)
{
base.Repaid = value;
PirateDb.GetDatabase().SetExpenseClaimRepaid(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetExpenseClaimRepaid(this.Identity, value);
}
}
@@ -220,7 +220,7 @@ namespace Activizr.Logic.Financial
if (base.KeepSeparate != value)
{
base.KeepSeparate = value;
PirateDb.GetDatabase().SetExpenseClaimKeepSeparate(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetExpenseClaimKeepSeparate(this.Identity, value);
}
}
@@ -234,7 +234,7 @@ namespace Activizr.Logic.Financial
}
set
{
PirateDb.GetDatabase().SetExpenseClaimDescription(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetExpenseClaimDescription(this.Identity, value);
base.Description = value;
}
}
@@ -280,14 +280,14 @@ namespace Activizr.Logic.Financial
}
base.AmountCents = amountCents;
PirateDb.GetDatabase().SetExpenseClaimAmount(this.Identity, amountCents);
PirateDb.GetDatabaseForWriting().SetExpenseClaimAmount(this.Identity, amountCents);
UpdateFinancialTransaction(settingPerson);
}
public void SetBudget (FinancialAccount budget, Person settingPerson)
{
PirateDb.GetDatabase().SetExpenseClaimBudget (this.Identity, budget.Identity);
PirateDb.GetDatabaseForWriting().SetExpenseClaimBudget (this.Identity, budget.Identity);
base.BudgetId = budget.Identity;
UpdateFinancialTransaction(settingPerson);
}
@@ -366,8 +366,8 @@ namespace Activizr.Logic.Financial
public void Validate(Person validator)
{
PirateDb.GetDatabase().SetExpenseClaimValidated(this.Identity, true);
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Validation,
PirateDb.GetDatabaseForWriting().SetExpenseClaimValidated(this.Identity, true);
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Validation,
FinancialDependencyType.ExpenseClaim, this.Identity,
DateTime.Now, validator.Identity, (double) this.Amount);
base.Validated = true;
@@ -375,8 +375,8 @@ namespace Activizr.Logic.Financial
public void Devalidate (Person devalidator)
{
PirateDb.GetDatabase().SetExpenseClaimValidated(this.Identity, false);
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Devalidation,
PirateDb.GetDatabaseForWriting().SetExpenseClaimValidated(this.Identity, false);
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Devalidation,
FinancialDependencyType.ExpenseClaim, this.Identity,
DateTime.Now, devalidator.Identity, (double) this.Amount);
base.Validated = false;
@@ -389,8 +389,8 @@ namespace Activizr.Logic.Financial
public void Attest(Person attester)
{
PirateDb.GetDatabase().SetExpenseClaimAttested(this.Identity, true);
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Attestation,
PirateDb.GetDatabaseForWriting().SetExpenseClaimAttested(this.Identity, true);
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
FinancialDependencyType.ExpenseClaim, this.Identity,
DateTime.Now, attester.Identity, (double) this.Amount);
base.Attested = true;
@@ -398,8 +398,8 @@ namespace Activizr.Logic.Financial
public void Deattest(Person deattester)
{
PirateDb.GetDatabase().SetExpenseClaimAttested(this.Identity, false);
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Deattestation,
PirateDb.GetDatabaseForWriting().SetExpenseClaimAttested(this.Identity, false);
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Deattestation,
FinancialDependencyType.ExpenseClaim, this.Identity,
DateTime.Now, deattester.Identity, (double) this.Amount);
base.Attested = false;
+5 -5
View File
@@ -64,19 +64,19 @@ namespace Activizr.Logic.Financial
public static ExpenseClaims FromClaimingPersonAndOrganization (Person person, Organization organization)
{
return
FromArray(PirateDb.GetDatabase().GetExpenseClaimsByClaimerAndOrganization(person.Identity,
FromArray(PirateDb.GetDatabaseForReading().GetExpenseClaimsByClaimerAndOrganization(person.Identity,
organization.Identity));
}
public static ExpenseClaims FromClaimingPerson (Person person)
{
return FromArray(PirateDb.GetDatabase().GetExpenseClaimsByClaimer(person.Identity));
return FromArray(PirateDb.GetDatabaseForReading().GetExpenseClaimsByClaimer(person.Identity));
}
public static ExpenseClaims FromOrganization (Organization org)
{
return FromArray(PirateDb.GetDatabase().GetExpenseClaimsByOrganization(org.Identity));
return FromArray(PirateDb.GetDatabaseForReading().GetExpenseClaimsByOrganization(org.Identity));
}
@@ -89,11 +89,11 @@ namespace Activizr.Logic.Financial
{
if (includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetExpenseClaims(org));
return FromArray(PirateDb.GetDatabaseForReading().GetExpenseClaims(org));
}
else
{
return FromArray(PirateDb.GetDatabase().GetExpenseClaims(org, DatabaseCondition.OpenTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetExpenseClaims(org, DatabaseCondition.OpenTrue));
}
}
+15 -15
View File
@@ -19,17 +19,17 @@ namespace Activizr.Logic.Financial
[Obsolete("This method uses floating point for financials. Deprecated. Do not use.")]
public double BalanceTotal
{
get { return PirateDb.GetDatabase().GetFinancialAccountBalanceTotal(Identity); }
get { return PirateDb.GetDatabaseForReading().GetFinancialAccountBalanceTotal(Identity); }
}
public Int64 BalanceTotalCents
{
get { return PirateDb.GetDatabase().GetFinancialAccountBalanceTotalCents(Identity); }
get { return PirateDb.GetDatabaseForReading().GetFinancialAccountBalanceTotalCents(Identity); }
}
public static FinancialAccount FromIdentity (int identity)
{
return FromBasic(PirateDb.GetDatabase().GetFinancialAccount(identity));
return FromBasic(PirateDb.GetDatabaseForReading().GetFinancialAccount(identity));
}
public static FinancialAccount FromBasic (BasicFinancialAccount basic)
@@ -40,30 +40,30 @@ namespace Activizr.Logic.Financial
[Obsolete("This method uses floating point for financials. Deprecated. Do not use.")]
public decimal GetDelta(DateTime start, DateTime end)
{
return PirateDb.GetDatabase().GetFinancialAccountBalanceDelta(Identity, start, end);
return PirateDb.GetDatabaseForReading().GetFinancialAccountBalanceDelta(Identity, start, end);
}
public Int64 GetDeltaCents(DateTime start, DateTime end)
{
return PirateDb.GetDatabase().GetFinancialAccountBalanceDeltaCents(Identity, start, end);
return PirateDb.GetDatabaseForReading().GetFinancialAccountBalanceDeltaCents(Identity, start, end);
}
public FinancialAccountRows GetLastRows(int rowCount)
{
BasicFinancialAccountRow[] basicRows = PirateDb.GetDatabase().GetLastFinancialAccountRows(Identity, rowCount);
BasicFinancialAccountRow[] basicRows = PirateDb.GetDatabaseForReading().GetLastFinancialAccountRows(Identity, rowCount);
return FinancialAccountRows.FromArray(basicRows);
}
public FinancialAccountRows GetRows(DateTime start, DateTime end)
{
BasicFinancialAccountRow[] basicRows = PirateDb.GetDatabase().GetFinancialAccountRows(Identity, start, end);
BasicFinancialAccountRow[] basicRows = PirateDb.GetDatabaseForReading().GetFinancialAccountRows(Identity, start, end);
return FinancialAccountRows.FromArray(basicRows);
}
[Obsolete("This method uses floating point for financials. Deprecated. Do not use.")]
public double GetBudget(int year)
{
return PirateDb.GetDatabase().GetFinancialAccountBudget(this.Identity, year);
return PirateDb.GetDatabaseForReading().GetFinancialAccountBudget(this.Identity, year);
}
public Int64 GetBudgetCents (int year)
@@ -73,28 +73,28 @@ namespace Activizr.Logic.Financial
public Int64[] GetBudgetMonthly (int year)
{
return PirateDb.GetDatabase().GetFinancialAccountBudgetMonthly(this.Identity, year);
return PirateDb.GetDatabaseForReading().GetFinancialAccountBudgetMonthly(this.Identity, year);
}
[Obsolete("This method uses floating point for financials. Deprecated. Do not use.")]
public void SetBudget(int year, double amount)
{
PirateDb.GetDatabase().SetFinancialAccountBudget(this.Identity, year, amount);
PirateDb.GetDatabaseForWriting().SetFinancialAccountBudget(this.Identity, year, amount);
}
public void SetBudgetCents (int year, Int64 amount)
{
PirateDb.GetDatabase().SetFinancialAccountBudget(this.Identity, year, amount / 100.0); // TODO: Change db structure to use cents
PirateDb.GetDatabaseForWriting().SetFinancialAccountBudget(this.Identity, year, amount / 100.0); // TODO: Change db structure to use cents
}
public void SetBudgetMontly (int year, int month, Int64 amountCents)
{
PirateDb.GetDatabase().SetFinancialAccountBudgetMonthly(this.Identity, year, month, amountCents);
PirateDb.GetDatabaseForWriting().SetFinancialAccountBudgetMonthly(this.Identity, year, month, amountCents);
}
public static FinancialAccount Create (int pOrganizationId, string pName, FinancialAccountType pAccountType, int pParentFinancialAccountId)
{
int accountId = PirateDb.GetDatabase().CreateFinancialAccount(pOrganizationId, pName, pAccountType, pParentFinancialAccountId);
int accountId = PirateDb.GetDatabaseForWriting().CreateFinancialAccount(pOrganizationId, pName, pAccountType, pParentFinancialAccountId);
return FromIdentity(accountId);
}
@@ -119,14 +119,14 @@ namespace Activizr.Logic.Financial
}
set
{
PirateDb.GetDatabase().SetFinancialAccountOwner(this.Identity, value.Identity);
PirateDb.GetDatabaseForWriting().SetFinancialAccountOwner(this.Identity, value.Identity);
}
}
public FinancialAccounts Children
{
get { return FinancialAccounts.FromArray(PirateDb.GetDatabase().GetFinancialAccountChildren(this.Identity)); }
get { return FinancialAccounts.FromArray(PirateDb.GetDatabaseForReading().GetFinancialAccountChildren(this.Identity)); }
}
public FinancialAccounts GetTree ()
+9 -9
View File
@@ -13,12 +13,12 @@ namespace Activizr.Logic.Financial
{
public static FinancialAccounts ForOrganization(Organization organization)
{
return FromArray(PirateDb.GetDatabase().GetFinancialAccountTreeForOrganization(organization.Identity));
return FromArray(PirateDb.GetDatabaseForReading().GetFinancialAccountTreeForOrganization(organization.Identity));
}
public static FinancialAccounts ForOwner(Person person)
{
return FromArray(PirateDb.GetDatabase().GetFinancialAccountsOwnedByPerson(person.Identity));
return FromArray(PirateDb.GetDatabaseForReading().GetFinancialAccountsOwnedByPerson(person.Identity));
}
@@ -56,7 +56,7 @@ namespace Activizr.Logic.Financial
public static FinancialAccounts FromBankTransactionTag (string tag)
{
int[] accountIdentities = PirateDb.GetDatabase().GetObjectsByOptionalData(ObjectType.FinancialAccount,
int[] accountIdentities = PirateDb.GetDatabaseForReading().GetObjectsByOptionalData(ObjectType.FinancialAccount,
ObjectOptionalDataType.
BankTransactionTag,
tag.ToLower());
@@ -71,32 +71,32 @@ namespace Activizr.Logic.Financial
return new FinancialAccounts();
}
return FromArray(PirateDb.GetDatabase().GetFinancialAccounts(financialAccountIds));
return FromArray(PirateDb.GetDatabaseForReading().GetFinancialAccounts(financialAccountIds));
}
public FinancialAccountRows GetRows (DateTime start, DateTime end)
{
BasicFinancialAccountRow[] basicRows = PirateDb.GetDatabase().GetFinancialAccountRows(Identities, start, end);
BasicFinancialAccountRow[] basicRows = PirateDb.GetDatabaseForReading().GetFinancialAccountRows(Identities, start, end);
return FinancialAccountRows.FromArray(basicRows);
}
[Obsolete("This function uses double-point variables for money. Use GetBudgetSumCents instead.")]
public double GetBudgetSum(int year)
{
return PirateDb.GetDatabase().GetFinancialAccountsBudget(this.Identities, year);
return PirateDb.GetDatabaseForReading().GetFinancialAccountsBudget(this.Identities, year);
}
public Int64 GetBudgetSumCents(int year)
{
// TODO: Add support in database
return (Int64) (PirateDb.GetDatabase().GetFinancialAccountsBudget(this.Identities, year) * 100);
return (Int64)(PirateDb.GetDatabaseForReading().GetFinancialAccountsBudget(this.Identities, year) * 100);
}
public Int64 GetDeltaCents(DateTime start, DateTime end)
{
return PirateDb.GetDatabase().GetFinancialAccountBalanceDeltaCents(this.Identities, start, end);
return PirateDb.GetDatabaseForReading().GetFinancialAccountBalanceDeltaCents(this.Identities, start, end);
}
@@ -172,7 +172,7 @@ namespace Activizr.Logic.Financial
Dictionary<int, FinancialAccounts> result = new Dictionary<int, FinancialAccounts>();
FinancialAccounts allAccounts = FromArray(PirateDb.GetDatabase().GetFinancialAccountsForOrganization(Organization.PPSEid)); // HACK HACK HACK
FinancialAccounts allAccounts = FromArray(PirateDb.GetDatabaseForReading().GetFinancialAccountsForOrganization(Organization.PPSEid)); // HACK HACK HACK
// Add the nodes.
+10 -10
View File
@@ -26,26 +26,26 @@ namespace Activizr.Logic.Financial
public static FinancialTransaction FromIdentity (int financialTransactionId)
{
return FromBasic (PirateDb.GetDatabase().GetFinancialTransaction (financialTransactionId));
return FromBasic (PirateDb.GetDatabaseForReading().GetFinancialTransaction (financialTransactionId));
}
public static FinancialTransaction FromDependency (IHasIdentity dependency)
{
return FromBasic(PirateDb.GetDatabase().GetFinancialTransactionFromDependency(dependency));
return FromBasic(PirateDb.GetDatabaseForReading().GetFinancialTransactionFromDependency(dependency));
}
public static FinancialTransaction FromImportKey (Organization organization, string importKey)
{
return
FromBasic(PirateDb.GetDatabase().GetFinancialTransactionFromImportKey(organization.Identity, importKey));
FromBasic(PirateDb.GetDatabaseForReading().GetFinancialTransactionFromImportKey(organization.Identity, importKey));
}
public static FinancialTransaction ImportWithStub (int organizationId, DateTime dateTime, int financialAccountId,
Int64 amountCents, string description, string importHash, int personId)
{
int transactionId = PirateDb.GetDatabase().CreateFinancialTransactionStub (organizationId, dateTime,
int transactionId = PirateDb.GetDatabaseForWriting().CreateFinancialTransactionStub (organizationId, dateTime,
financialAccountId, amountCents,
description, importHash, personId);
@@ -60,7 +60,7 @@ namespace Activizr.Logic.Financial
public static FinancialTransaction Create (int organizationId, DateTime dateTime, string description)
{
int transactionId = PirateDb.GetDatabase().CreateFinancialTransaction (organizationId, dateTime, description);
int transactionId = PirateDb.GetDatabaseForWriting().CreateFinancialTransaction (organizationId, dateTime, description);
return FromIdentity (transactionId);
}
@@ -70,7 +70,7 @@ namespace Activizr.Logic.Financial
{
get
{
return FinancialTransactionRows.FromArray (PirateDb.GetDatabase().GetFinancialTransactionRows (Identity));
return FinancialTransactionRows.FromArray (PirateDb.GetDatabaseForReading().GetFinancialTransactionRows (Identity));
}
}
@@ -88,7 +88,7 @@ namespace Activizr.Logic.Financial
set
{
base.Description = value;
PirateDb.GetDatabase().SetFinancialTransactionDescription (this.Identity, value);
PirateDb.GetDatabaseForWriting().SetFinancialTransactionDescription (this.Identity, value);
}
}
@@ -129,7 +129,7 @@ namespace Activizr.Logic.Financial
return;
}
PirateDb.GetDatabase().CreateFinancialTransactionRow(Identity, financialAccountId, amountCents, personId);
PirateDb.GetDatabaseForWriting().CreateFinancialTransactionRow(Identity, financialAccountId, amountCents, personId);
}
private FinancialTransaction ContinuedTransaction
@@ -167,7 +167,7 @@ namespace Activizr.Logic.Financial
{
set
{
PirateDb.GetDatabase().SetFinancialTransactionDependency(
PirateDb.GetDatabaseForWriting().SetFinancialTransactionDependency(
this.Identity, GetFinancialDependencyType(value), value.Identity);
}
get
@@ -179,7 +179,7 @@ namespace Activizr.Logic.Financial
FinancialDependencyType dependencyType;
int foreignId;
PirateDb.GetDatabase().GetFinancialTransactionDependency(this.Identity, out dependencyType,
PirateDb.GetDatabaseForReading().GetFinancialTransactionDependency(this.Identity, out dependencyType,
out foreignId);
if (foreignId == 0)
+1 -1
View File
@@ -46,7 +46,7 @@ namespace Activizr.Logic.Financial
public static FinancialTransactionRow FromIdentity (int identity)
{
return FromBasic (PirateDb.GetDatabase().GetFinancialTransactionRow (identity));
return FromBasic (PirateDb.GetDatabaseForReading().GetFinancialTransactionRow (identity));
}
public string AccountName
+4 -4
View File
@@ -18,16 +18,16 @@ namespace Activizr.Logic.Financial
public static FinancialTransactions GetUnbalanced (Organization organization)
{
return FromArray(PirateDb.GetDatabase().GetUnbalancedFinancialTransactions(organization.Identity));
return FromArray(PirateDb.GetDatabaseForReading().GetUnbalancedFinancialTransactions(organization.Identity));
}
public static FinancialTransactions GetIncomplete(int organizationId)
{
FinancialTransactions unbalanced =
FromArray(PirateDb.GetDatabase().GetUnbalancedFinancialTransactions(organizationId));
FromArray(PirateDb.GetDatabaseForReading().GetUnbalancedFinancialTransactions(organizationId));
FinancialTransactions undocumented =
FromArray(PirateDb.GetDatabase().GetUndocumentedFinancialTransactions(organizationId));
FromArray(PirateDb.GetDatabaseForReading().GetUndocumentedFinancialTransactions(organizationId));
FinancialTransactions allIncomplete = LogicalOr(unbalanced, undocumented);
@@ -50,7 +50,7 @@ namespace Activizr.Logic.Financial
public static FinancialTransactions ForDependentObject (IHasIdentity foreignObject)
{
return
FromArray(PirateDb.GetDatabase().GetDependentFinancialTransactions(GetDependencyType(foreignObject),
FromArray(PirateDb.GetDatabaseForReading().GetDependentFinancialTransactions(GetDependencyType(foreignObject),
foreignObject.Identity));
}
+2 -2
View File
@@ -19,7 +19,7 @@ namespace Activizr.Logic.Financial
public static void Create (FinancialValidationType validationType, IHasIdentity foreignObject, Person actingPerson, double amount)
{
PirateDb.GetDatabase().CreateFinancialValidation(validationType, GetDependencyType(foreignObject), foreignObject.Identity,
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(validationType, GetDependencyType(foreignObject), foreignObject.Identity,
DateTime.Now, actingPerson.Identity, amount);
}
@@ -45,7 +45,7 @@ namespace Activizr.Logic.Financial
public static FinancialValidations ForObject (IHasIdentity financialDependency)
{
return
FromArray(PirateDb.GetDatabase().GetFinancialValidations(GetDependencyType(financialDependency),
FromArray(PirateDb.GetDatabaseForReading().GetFinancialValidations(GetDependencyType(financialDependency),
financialDependency.Identity));
}
}
+10 -10
View File
@@ -16,7 +16,7 @@ namespace Activizr.Logic.Financial
FinancialAccount budget, string supplier, string payToAccount, string ocr,
string invoiceReference, Person creatingPerson)
{
InboundInvoice newInvoice = FromIdentity(PirateDb.GetDatabase().
InboundInvoice newInvoice = FromIdentity(PirateDb.GetDatabaseForWriting().
CreateInboundInvoice(organization.Identity, dueDate, budget.Identity,
supplier, payToAccount, ocr,
invoiceReference, amountCents, creatingPerson.Identity));
@@ -49,7 +49,7 @@ namespace Activizr.Logic.Financial
public static InboundInvoice FromIdentity (int inboundInvoiceId)
{
return new InboundInvoice(PirateDb.GetDatabase().GetInboundInvoice(inboundInvoiceId));
return new InboundInvoice(PirateDb.GetDatabaseForReading().GetInboundInvoice(inboundInvoiceId));
}
public FinancialAccount Budget
@@ -80,7 +80,7 @@ namespace Activizr.Logic.Financial
{
if (base.Open != value)
{
PirateDb.GetDatabase().SetInboundInvoiceOpen(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetInboundInvoiceOpen(this.Identity, value);
base.Open = value;
}
}
@@ -108,7 +108,7 @@ namespace Activizr.Logic.Financial
{
if (value != base.DueDate)
{
PirateDb.GetDatabase().SetInboundInvoiceDueDate(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetInboundInvoiceDueDate(this.Identity, value);
base.DueDate = value;
}
}
@@ -139,7 +139,7 @@ namespace Activizr.Logic.Financial
public void SetBudget (FinancialAccount budget, Person settingPerson)
{
base.BudgetId = budget.Identity;
PirateDb.GetDatabase().SetInboundInvoiceBudget(this.Identity, budget.Identity);
PirateDb.GetDatabaseForWriting().SetInboundInvoiceBudget(this.Identity, budget.Identity);
UpdateTransaction(settingPerson);
}
@@ -147,7 +147,7 @@ namespace Activizr.Logic.Financial
public void SetAmountCents (Int64 amountCents, Person settingPerson)
{
base.AmountCents = amountCents;
PirateDb.GetDatabase().SetInboundInvoiceAmount(this.Identity, amountCents);
PirateDb.GetDatabaseForWriting().SetInboundInvoiceAmount(this.Identity, amountCents);
UpdateTransaction(settingPerson);
}
@@ -181,8 +181,8 @@ namespace Activizr.Logic.Financial
public void Attest(Person attester)
{
PirateDb.GetDatabase().SetInboundInvoiceAttested(this.Identity, true);
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Attestation,
PirateDb.GetDatabaseForWriting().SetInboundInvoiceAttested(this.Identity, true);
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
FinancialDependencyType.InboundInvoice, this.Identity,
DateTime.Now, attester.Identity, (double) this.Amount);
base.Attested = true;
@@ -190,8 +190,8 @@ namespace Activizr.Logic.Financial
public void Deattest(Person deattester)
{
PirateDb.GetDatabase().SetInboundInvoiceAttested(this.Identity, false);
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Deattestation,
PirateDb.GetDatabaseForWriting().SetInboundInvoiceAttested(this.Identity, false);
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Deattestation,
FinancialDependencyType.InboundInvoice, this.Identity,
DateTime.Now, deattester.Identity, (double) this.Amount);
base.Attested = false;
+1 -1
View File
@@ -28,7 +28,7 @@ namespace Activizr.Logic.Financial
/// <returns>The list of inbound invoices.</returns>
public static InboundInvoices ForOrganization (Organization organization, bool includeClosed)
{
return FromArray (PirateDb.GetDatabase().GetInboundInvoices(organization,
return FromArray (PirateDb.GetDatabaseForReading().GetInboundInvoices(organization,
includeClosed
? DatabaseCondition.None
: DatabaseCondition.OpenTrue));
+7 -7
View File
@@ -25,7 +25,7 @@ namespace Activizr.Logic.Financial
public static OutboundInvoice FromIdentity (int outboundInvoiceId)
{
return FromBasic(PirateDb.GetDatabase().GetOutboundInvoice(outboundInvoiceId));
return FromBasic(PirateDb.GetDatabaseForReading().GetOutboundInvoice(outboundInvoiceId));
}
public static OutboundInvoice FromReference (string reference)
@@ -50,7 +50,7 @@ namespace Activizr.Logic.Financial
public static OutboundInvoice Create (Organization organization, Person createdByPerson, DateTime dueDate, FinancialAccount budget, string customerName, string invoiceAddressMail, string invoiceAddressPaper, Currency currency, bool domestic, string theirReference)
{
OutboundInvoice invoice = FromIdentity (PirateDb.GetDatabase().CreateOutboundInvoice(organization.Identity, createdByPerson != null? createdByPerson.Identity : 0, dueDate,
OutboundInvoice invoice = FromIdentity (PirateDb.GetDatabaseForWriting().CreateOutboundInvoice(organization.Identity, createdByPerson != null? createdByPerson.Identity : 0, dueDate,
budget.Identity, customerName, invoiceAddressPaper,
invoiceAddressMail, currency.Identity, string.Empty, domestic, Authentication.CreateRandomPassword(6), theirReference));
@@ -74,7 +74,7 @@ namespace Activizr.Logic.Financial
public void AddItem(string description, double amount)
{
PirateDb.GetDatabase().CreateOutboundInvoiceItem(this.Identity, description, amount);
PirateDb.GetDatabaseForWriting().CreateOutboundInvoiceItem(this.Identity, description, amount);
}
@@ -82,7 +82,7 @@ namespace Activizr.Logic.Financial
{
// NOTE: MUST NOT ADD FINANCIAL TRANSACTION LINES HERE; SURCHARGES ARE ADDED AS LINE ITEMS ON PAYMENT
PirateDb.GetDatabase().CreateOutboundInvoiceItem(this.Identity, description, amountCents);
PirateDb.GetDatabaseForWriting().CreateOutboundInvoiceItem(this.Identity, description, amountCents);
}
@@ -147,7 +147,7 @@ namespace Activizr.Logic.Financial
{
if (value == true)
{
PirateDb.GetDatabase().SetOutboundInvoiceSent(this.Identity, true);
PirateDb.GetDatabaseForWriting().SetOutboundInvoiceSent(this.Identity, true);
base.Sent = true;
}
else
@@ -165,7 +165,7 @@ namespace Activizr.Logic.Financial
{
if (value != base.Open)
{
PirateDb.GetDatabase().SetOutboundInvoiceOpen(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetOutboundInvoiceOpen(this.Identity, value);
base.Open = value;
}
}
@@ -204,7 +204,7 @@ namespace Activizr.Logic.Financial
}
set
{
PirateDb.GetDatabase().SetOutboundInvoiceReference(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetOutboundInvoiceReference(this.Identity, value);
base.Reference = value;
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ namespace Activizr.Logic.Financial
public static OutboundInvoiceItem FromIdentity (int outboundInvoiceItemId)
{
return FromBasic(PirateDb.GetDatabase().GetOutboundInvoiceItem(outboundInvoiceItemId));
return FromBasic(PirateDb.GetDatabaseForReading().GetOutboundInvoiceItem(outboundInvoiceItemId));
}
public decimal Amount
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Activizr.Logic.Financial
{
public static OutboundInvoiceItems ForInvoice (OutboundInvoice invoice)
{
return FromArray(PirateDb.GetDatabase().GetOutboundInvoiceItems(invoice));
return FromArray(PirateDb.GetDatabaseForReading().GetOutboundInvoiceItems(invoice));
}
}
}
+2 -2
View File
@@ -19,11 +19,11 @@ namespace Activizr.Logic.Financial
{
if (includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetOutboundInvoices(organization));
return FromArray(PirateDb.GetDatabaseForReading().GetOutboundInvoices(organization));
}
else
{
return FromArray (PirateDb.GetDatabase().GetOutboundInvoices(organization, DatabaseCondition.OpenTrue));
return FromArray (PirateDb.GetDatabaseForReading().GetOutboundInvoices(organization, DatabaseCondition.OpenTrue));
}
}
}
+5 -5
View File
@@ -26,12 +26,12 @@ namespace Activizr.Logic.Financial
public static Payment FromIdentity (int paymentId)
{
return FromBasic(PirateDb.GetDatabase().GetPayment(paymentId));
return FromBasic(PirateDb.GetDatabaseForReading().GetPayment(paymentId));
}
public static Payment ForOutboundInvoice (OutboundInvoice invoice)
{
BasicPayment[] array = PirateDb.GetDatabase().GetPayments(invoice);
BasicPayment[] array = PirateDb.GetDatabaseForReading().GetPayments(invoice);
if (array.Length == 0)
{
@@ -61,7 +61,7 @@ namespace Activizr.Logic.Financial
PWEvents.CreateEvent(EventSource.PirateWeb, EventType.OutboundInvoicePaid, 0, group.Organization.Identity,
Geography.RootIdentity, 0, invoice.Identity, string.Empty);
return FromIdentity (PirateDb.GetDatabase().CreatePayment(group.Identity, amount, reference, fromAccount, key, hasImage,
return FromIdentity (PirateDb.GetDatabaseForWriting().CreatePayment(group.Identity, amount, reference, fromAccount, key, hasImage,
invoice.Identity));
}
@@ -74,7 +74,7 @@ namespace Activizr.Logic.Financial
invoice.SetPaid();
PaymentGroup group = PaymentGroup.Create(organization, dateTime, currency, createdByPerson);
Payment newPayment = FromIdentity(PirateDb.GetDatabase().CreatePayment(group.Identity, amountCents, string.Empty, string.Empty, string.Empty, false,
Payment newPayment = FromIdentity(PirateDb.GetDatabaseForWriting().CreatePayment(group.Identity, amountCents, string.Empty, string.Empty, string.Empty, false,
invoice.Identity));
group.AmountCents = amountCents;
@@ -155,7 +155,7 @@ namespace Activizr.Logic.Financial
{
if (!string.IsNullOrEmpty(data))
{
PirateDb.GetDatabase().CreatePaymentInformation(this.Identity, type, data);
PirateDb.GetDatabaseForWriting().CreatePaymentInformation(this.Identity, type, data);
}
}
+6 -6
View File
@@ -17,7 +17,7 @@ namespace Activizr.Logic.Financial
public static PaymentGroup FromIdentity (int paymentGroupId)
{
return FromBasic(PirateDb.GetDatabase().GetPaymentGroup(paymentGroupId));
return FromBasic(PirateDb.GetDatabaseForReading().GetPaymentGroup(paymentGroupId));
}
public static PaymentGroup FromBasic (BasicPaymentGroup basic)
@@ -28,14 +28,14 @@ namespace Activizr.Logic.Financial
public static PaymentGroup Create (Organization organization, DateTime timestamp, Currency currency, Person createdByPerson)
{
return
FromIdentity(PirateDb.GetDatabase().CreatePaymentGroup(organization.Identity, timestamp,
FromIdentity(PirateDb.GetDatabaseForWriting().CreatePaymentGroup(organization.Identity, timestamp,
currency.Identity,
System.DateTime.Now, createdByPerson.Identity));
}
public static PaymentGroup FromTag (Organization organization, string tag)
{
BasicPaymentGroup basicGroup = PirateDb.GetDatabase().GetPaymentGroupByTag(organization.Identity, tag);
BasicPaymentGroup basicGroup = PirateDb.GetDatabaseForReading().GetPaymentGroupByTag(organization.Identity, tag);
if (basicGroup == null)
{
@@ -56,7 +56,7 @@ namespace Activizr.Logic.Financial
set
{
base.Tag = value;
PirateDb.GetDatabase().SetPaymentGroupTag(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetPaymentGroupTag(this.Identity, value);
}
}
@@ -66,7 +66,7 @@ namespace Activizr.Logic.Financial
set
{
base.AmountCents = value;
PirateDb.GetDatabase().SetPaymentGroupAmount(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetPaymentGroupAmount(this.Identity, value);
}
}
@@ -81,7 +81,7 @@ namespace Activizr.Logic.Financial
set
{
base.Open = value;
PirateDb.GetDatabase().SetPaymentGroupOpen(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetPaymentGroupOpen(this.Identity, value);
}
}
+2 -2
View File
@@ -19,11 +19,11 @@ namespace Activizr.Logic.Financial
{
if (includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetPaymentGroups(organization));
return FromArray(PirateDb.GetDatabaseForReading().GetPaymentGroups(organization));
}
else
{
return FromArray(PirateDb.GetDatabase().GetPaymentGroups(organization, DatabaseCondition.OpenTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetPaymentGroups(organization, DatabaseCondition.OpenTrue));
}
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ namespace Activizr.Logic.Financial
public static PaymentInformationList ForPayment (Payment payment)
{
BasicPaymentInformation[] basicInfoList = PirateDb.GetDatabase().GetPaymentInformation(payment.Identity);
BasicPaymentInformation[] basicInfoList = PirateDb.GetDatabaseForReading().GetPaymentInformation(payment.Identity);
return FromArray(basicInfoList);
}
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Activizr.Logic.Financial
{
public static Payments ForPaymentGroup (PaymentGroup group)
{
return FromArray(PirateDb.GetDatabase().GetPayments(group));
return FromArray(PirateDb.GetDatabaseForReading().GetPayments(group));
}
}
}
+16 -16
View File
@@ -44,7 +44,7 @@ namespace Activizr.Logic.Financial
DependentSalariesNet = new Salaries();
DependentSalariesTax = new Salaries();
BasicFinancialDependency[] dependencies = PirateDb.GetDatabase().GetPayoutDependencies(this.Identity);
BasicFinancialDependency[] dependencies = PirateDb.GetDatabaseForReading().GetPayoutDependencies(this.Identity);
foreach (BasicFinancialDependency dependency in dependencies)
{
@@ -81,7 +81,7 @@ namespace Activizr.Logic.Financial
public static Payout FromIdentity (int payoutId)
{
return FromBasic(PirateDb.GetDatabase().GetPayout(payoutId));
return FromBasic(PirateDb.GetDatabaseForReading().GetPayout(payoutId));
}
@@ -98,7 +98,7 @@ namespace Activizr.Logic.Financial
{
if (this.Identity != 0)
{
PirateDb.GetDatabase().SetPayoutAmount(this.Identity, (Int64)(value * 100));
PirateDb.GetDatabaseForWriting().SetPayoutAmount(this.Identity, (Int64)(value * 100));
}
base.AmountCents = (Int64)value * 100;
}
@@ -114,7 +114,7 @@ namespace Activizr.Logic.Financial
{
if (this.Identity != 0)
{
PirateDb.GetDatabase().SetPayoutAmount(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetPayoutAmount(this.Identity, value);
}
base.AmountCents = value;
}
@@ -130,7 +130,7 @@ namespace Activizr.Logic.Financial
{
if (this.Identity != 0)
{
PirateDb.GetDatabase().SetPayoutReference(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetPayoutReference(this.Identity, value);
}
base.Reference = value;
}
@@ -149,7 +149,7 @@ namespace Activizr.Logic.Financial
}
set
{
PirateDb.GetDatabase().SetPayoutOpen(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetPayoutOpen(this.Identity, value);
base.Open = value;
}
}
@@ -211,13 +211,13 @@ namespace Activizr.Logic.Financial
referenceString = "Expense Claims " + Formatting.GenerateRangeString(identityList);
}
int payoutId = PirateDb.GetDatabase().CreatePayout(organizationId, bank, account,
int payoutId = PirateDb.GetDatabaseForWriting().CreatePayout(organizationId, bank, account,
referenceString, amountCents, DateTime.Today.AddDays(1),
creator.Identity);
foreach (int claimId in identityList)
{
PirateDb.GetDatabase().CreatePayoutDependency(payoutId, FinancialDependencyType.ExpenseClaim,
PirateDb.GetDatabaseForWriting().CreatePayoutDependency(payoutId, FinancialDependencyType.ExpenseClaim,
claimId);
}
@@ -236,12 +236,12 @@ namespace Activizr.Logic.Financial
expectedPayment = DateTime.Today;
}
int payoutId = PirateDb.GetDatabase().CreatePayout(invoice.OrganizationId, string.Empty, invoice.PayToAccount,
int payoutId = PirateDb.GetDatabaseForWriting().CreatePayout(invoice.OrganizationId, string.Empty, invoice.PayToAccount,
invoice.Ocr.Length > 0 ? "OCR " + invoice.Ocr : "Ref# " + invoice.InvoiceReference,
invoice.AmountCents, expectedPayment,
creator.Identity);
PirateDb.GetDatabase().CreatePayoutDependency(payoutId, FinancialDependencyType.InboundInvoice,
PirateDb.GetDatabaseForWriting().CreatePayoutDependency(payoutId, FinancialDependencyType.InboundInvoice,
invoice.Identity);
invoice.Open = false;
@@ -254,12 +254,12 @@ namespace Activizr.Logic.Financial
Salary salary = Salary.FromIdentity(Int32.Parse(components[0].Substring(1)));
int payoutId = PirateDb.GetDatabase().CreatePayout(salary.PayrollItem.OrganizationId, salary.PayrollItem.Person.BankName, salary.PayrollItem.Person.BankAccount,
int payoutId = PirateDb.GetDatabaseForWriting().CreatePayout(salary.PayrollItem.OrganizationId, salary.PayrollItem.Person.BankName, salary.PayrollItem.Person.BankAccount,
"Salary " + salary.PayoutDate.ToString("yyyy-MMM"),
salary.NetSalaryCents, salary.PayoutDate,
creator.Identity);
PirateDb.GetDatabase().CreatePayoutDependency(payoutId, FinancialDependencyType.Salary,
PirateDb.GetDatabaseForWriting().CreatePayoutDependency(payoutId, FinancialDependencyType.Salary,
salary.Identity);
salary.NetPaid = true;
@@ -305,12 +305,12 @@ namespace Activizr.Logic.Financial
referenceString = "Tax for salaries " + Formatting.GenerateRangeString(identityList);
}
int payoutId = PirateDb.GetDatabase().CreatePayout(organization.Identity, "The Tax Man", organization.Parameters.TaxAccount, organization.Parameters.TaxOcr,
int payoutId = PirateDb.GetDatabaseForWriting().CreatePayout(organization.Identity, "The Tax Man", organization.Parameters.TaxAccount, organization.Parameters.TaxOcr,
amountCents, payDay, creator.Identity);
foreach (int salaryId in identityList)
{
PirateDb.GetDatabase().CreatePayoutDependency(payoutId, FinancialDependencyType.Salary,
PirateDb.GetDatabaseForWriting().CreatePayoutDependency(payoutId, FinancialDependencyType.Salary,
salaryId);
}
@@ -457,7 +457,7 @@ namespace Activizr.Logic.Financial
public void MigrateDependenciesTo (Payout migrationTarget)
{
PirateDb.GetDatabase().MovePayoutDependencies(this.Identity, migrationTarget.Identity);
PirateDb.GetDatabaseForWriting().MovePayoutDependencies(this.Identity, migrationTarget.Identity);
migrationTarget.RecalculateAmount();
this.RecalculateAmount();
}
@@ -502,7 +502,7 @@ namespace Activizr.Logic.Financial
salary.TaxPaid = false;
}
PirateDb.GetDatabase().ClearPayoutDependencies(this.Identity);
PirateDb.GetDatabaseForWriting().ClearPayoutDependencies(this.Identity);
RecalculateAmount();
this.Open = false;
}
+2 -2
View File
@@ -20,11 +20,11 @@ namespace Activizr.Logic.Financial
{
if (includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetPayouts(organization));
return FromArray(PirateDb.GetDatabaseForReading().GetPayouts(organization));
}
else
{
return FromArray(PirateDb.GetDatabase().GetPayouts(organization, DatabaseCondition.OpenTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetPayouts(organization, DatabaseCondition.OpenTrue));
}
}
+2 -2
View File
@@ -29,7 +29,7 @@ namespace Activizr.Logic.Financial
/// <returns>The payroll.</returns>
public static Payroll ForOrganization (Organization organization, bool includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetPayroll(organization,
return FromArray(PirateDb.GetDatabaseForReading().GetPayroll(organization,
includeClosed? DatabaseCondition.None : DatabaseCondition.OpenTrue));
}
@@ -51,7 +51,7 @@ namespace Activizr.Logic.Financial
/// <returns>The payroll.</returns>
public static Payroll GetAll(bool includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetPayroll(includeClosed? DatabaseCondition.None : DatabaseCondition.OpenTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetPayroll(includeClosed? DatabaseCondition.None : DatabaseCondition.OpenTrue));
}
}
}
+3 -3
View File
@@ -20,7 +20,7 @@ namespace Activizr.Logic.Financial
public static PayrollAdjustment FromIdentity (int payrollAdjustmentId)
{
return FromBasic (PirateDb.GetDatabase().GetPayrollAdjustment(payrollAdjustmentId));
return FromBasic (PirateDb.GetDatabaseForReading().GetPayrollAdjustment(payrollAdjustmentId));
}
@@ -45,7 +45,7 @@ namespace Activizr.Logic.Financial
throw new InvalidOperationException("Payroll adjustment #" + this.Identity.ToString() + " cannot be closed; is already closed");
}
PirateDb.GetDatabase().ClosePayrollAdjustment(this.Identity, salary.Identity);
PirateDb.GetDatabaseForWriting().ClosePayrollAdjustment(this.Identity, salary.Identity);
base.Open = false;
base.SalaryId = salary.Identity;
}
@@ -53,7 +53,7 @@ namespace Activizr.Logic.Financial
public static PayrollAdjustment Create (PayrollItem item, PayrollAdjustmentType type, double amount, string description)
{
int id = PirateDb.GetDatabase().CreatePayrollAdjustment(item.Identity, type, amount, description);
int id = PirateDb.GetDatabaseForWriting().CreatePayrollAdjustment(item.Identity, type, amount, description);
return PayrollAdjustment.FromIdentity(id);
}
+2 -2
View File
@@ -11,12 +11,12 @@ namespace Activizr.Logic.Financial
{
static public PayrollAdjustments ForPayrollItem (PayrollItem payrollItem)
{
return FromArray(PirateDb.GetDatabase().GetPayrollAdjustments(payrollItem, DatabaseCondition.OpenTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetPayrollAdjustments(payrollItem, DatabaseCondition.OpenTrue));
}
static public PayrollAdjustments ForSalary (Salary salary)
{
return FromArray(PirateDb.GetDatabase().GetPayrollAdjustments(salary));
return FromArray(PirateDb.GetDatabaseForReading().GetPayrollAdjustments(salary));
}
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ namespace Activizr.Logic.Financial
public static PayrollItem FromIdentity (int payrollItemId)
{
return FromBasic (PirateDb.GetDatabase().GetPayrollItem(payrollItemId));
return FromBasic (PirateDb.GetDatabaseForReading().GetPayrollItem(payrollItemId));
}
+2 -2
View File
@@ -24,7 +24,7 @@ namespace Activizr.Logic.Financial
public static Refund FromIdentity (int refundId)
{
return FromBasic(PirateDb.GetDatabase().GetRefund(refundId));
return FromBasic(PirateDb.GetDatabaseForReading().GetRefund(refundId));
}
public static Refund Create (Payment payment, Person creatingPerson)
@@ -39,7 +39,7 @@ namespace Activizr.Logic.Financial
throw new ArgumentException("Refund amount cannot exceed payment amount");
}
Refund refund = FromIdentity(PirateDb.GetDatabase().CreateRefund(payment.Identity, creatingPerson.Identity, amountCents));
Refund refund = FromIdentity(PirateDb.GetDatabaseForWriting().CreateRefund(payment.Identity, creatingPerson.Identity, amountCents));
PWEvents.CreateEvent(EventSource.PirateWeb, EventType.RefundCreated, 0, refund.Payment.OutboundInvoice.Organization.Identity,
Geography.RootIdentity, 0, refund.Identity, string.Empty);
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Activizr.Logic.Financial
static public Salaries ForOrganization(Organization organization, bool includeClosed)
{
return FromArray (PirateDb.GetDatabase().GetSalaries(organization,
return FromArray (PirateDb.GetDatabaseForWriting().GetSalaries(organization,
includeClosed? DatabaseCondition.None : DatabaseCondition.OpenTrue));
}
+7 -7
View File
@@ -24,7 +24,7 @@ namespace Activizr.Logic.Financial
static public Salary FromIdentity (int salaryId)
{
return FromBasic(PirateDb.GetDatabase().GetSalary(salaryId));
return FromBasic(PirateDb.GetDatabaseForReading().GetSalary(salaryId));
}
static public Salary Create (int payrollItemId, DateTime payoutDate)
@@ -135,7 +135,7 @@ namespace Activizr.Logic.Financial
static private Salary Create (PayrollItem payrollItem, DateTime payoutDate, Int64 netSalaryCents, Int64 subtractiveTaxCents, Int64 additiveTaxCents)
{
return
FromIdentity(PirateDb.GetDatabase().CreateSalary(payrollItem.Identity, payoutDate, payrollItem.BaseSalaryCents, netSalaryCents,
FromIdentity(PirateDb.GetDatabaseForWriting().CreateSalary(payrollItem.Identity, payoutDate, payrollItem.BaseSalaryCents, netSalaryCents,
subtractiveTaxCents, additiveTaxCents));
}
@@ -185,7 +185,7 @@ namespace Activizr.Logic.Financial
{
if (value != base.NetSalaryCents)
{
PirateDb.GetDatabase().SetSalaryNetSalary(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetSalaryNetSalary(this.Identity, value);
base.NetSalaryCents = value;
}
}
@@ -239,7 +239,7 @@ namespace Activizr.Logic.Financial
get { return base.NetPaid; }
set
{
PirateDb.GetDatabase().SetSalaryNetPaid(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetSalaryNetPaid(this.Identity, value);
base.NetPaid = value;
base.Open = !(base.NetPaid && base.TaxPaid);
}
@@ -250,7 +250,7 @@ namespace Activizr.Logic.Financial
get { return base.TaxPaid; }
set
{
PirateDb.GetDatabase().SetSalaryTaxPaid(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetSalaryTaxPaid(this.Identity, value);
base.NetPaid = value;
base.Open = !(base.NetPaid && base.TaxPaid);
}
@@ -287,9 +287,9 @@ namespace Activizr.Logic.Financial
public void Attest(Person attester)
{
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Attestation,
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
FinancialDependencyType.Salary, this.Identity, DateTime.Now, attester.Identity, this.NetSalaryCents / 100.0);
PirateDb.GetDatabase().SetSalaryAttested(this.Identity, true);
PirateDb.GetDatabaseForWriting().SetSalaryAttested(this.Identity, true);
}
public void Deattest(Person deattester)
+3 -3
View File
@@ -16,7 +16,7 @@ namespace Activizr.Logic.Financial
return 0.0; // no tax
}
double taxLevel = PirateDb.GetDatabase().GetTaxLevel(country.Identity, taxLevelIdentifier,
double taxLevel = PirateDb.GetDatabaseForReading().GetTaxLevel(country.Identity, taxLevelIdentifier,
(int) Math.Floor(grossSalary));
if (taxLevel < 1.0)
@@ -39,7 +39,7 @@ namespace Activizr.Logic.Financial
// Clear existing tables for countryId
PirateDb.GetDatabase().DeleteTaxLevels(country.Identity);
PirateDb.GetDatabaseForWriting().DeleteTaxLevels(country.Identity);
string[] lines = data.Split('\n'); // if \r\n is used, the \r will be harmlessly at the end of lines
@@ -70,7 +70,7 @@ namespace Activizr.Logic.Financial
tax = tax / 100.0;
}
PirateDb.GetDatabase().CreateTaxLevel(country.Identity, taxLevelId, lowerBracket, tax);
PirateDb.GetDatabaseForWriting().CreateTaxLevel(country.Identity, taxLevelId, lowerBracket, tax);
}
}
+7 -7
View File
@@ -22,29 +22,29 @@ namespace Activizr.Logic.Governance
public static Ballot FromIdentity (int ballotId)
{
return FromBasic(PirateDb.GetDatabase().GetBallot(ballotId));
return FromBasic(PirateDb.GetDatabaseForReading().GetBallot(ballotId));
}
public static Ballot Create (Election election, Organization organization, Geography geography, string name, int ballotCount, string deliveryAddress)
{
return FromIdentity(PirateDb.GetDatabase().CreateBallot(election.Identity, name, organization.Identity, geography.Identity, ballotCount, deliveryAddress));
return FromIdentity(PirateDb.GetDatabaseForWriting().CreateBallot(election.Identity, name, organization.Identity, geography.Identity, ballotCount, deliveryAddress));
}
public void AddCandidate (Person person)
{
PirateDb.GetDatabase().CreateBallotCandidate(this.Identity, person.Identity);
PirateDb.GetDatabaseForWriting().CreateBallotCandidate(this.Identity, person.Identity);
}
public void ClearCandidates()
{
PirateDb.GetDatabase().ClearBallotCandidates(this.Identity);
PirateDb.GetDatabaseForWriting().ClearBallotCandidates(this.Identity);
}
public People Candidates
{
get
{
return People.FromIdentities(PirateDb.GetDatabase().GetBallotCandidates(this.Identity), true);
return People.FromIdentities(PirateDb.GetDatabaseForReading().GetBallotCandidates(this.Identity), true);
}
}
@@ -59,7 +59,7 @@ namespace Activizr.Logic.Governance
{
if (value != base.Count) {
base.Count = value;
PirateDb.GetDatabase().SetBallotCount(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetBallotCount(this.Identity, value);
}
}
get { return base.Count; }
@@ -72,7 +72,7 @@ namespace Activizr.Logic.Governance
if (value != base.DeliveryAddress)
{
base.DeliveryAddress = value;
PirateDb.GetDatabase().SetBallotDeliveryAddress(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetBallotDeliveryAddress(this.Identity, value);
}
}
get { return base.DeliveryAddress; }
+2 -2
View File
@@ -15,12 +15,12 @@ namespace Activizr.Logic.Governance
public static Ballots ForElection (Election election)
{
return FromArray(PirateDb.GetDatabase().GetBallots(election, Organization.PPSE)); // HACK HACK HACK -- PPSE hardcoded
return FromArray(PirateDb.GetDatabaseForReading().GetBallots(election, Organization.PPSE)); // HACK HACK HACK -- PPSE hardcoded
}
public static Dictionary<int,int> GetBallotsForPerson (Person person)
{
return PirateDb.GetDatabase().GetBallotsForPerson(person.Identity);
return PirateDb.GetDatabaseForReading().GetBallotsForPerson(person.Identity);
}
}
}
+2 -2
View File
@@ -45,13 +45,13 @@ namespace Activizr.Logic.Governance
public People GetDocumentedCandidates (Organization organization)
{
return
People.FromIdentities(PirateDb.GetDatabase().GetDocumentedCandidates(this.Identity,
People.FromIdentities(PirateDb.GetDatabaseForReading().GetDocumentedCandidates(this.Identity,
organization.Identity));
}
public void SetCandidateDocumented (Organization organization, Person candidate)
{
PirateDb.GetDatabase().SetCandidateDocumentationReceived(this.Identity, organization.Identity, candidate.Identity);
PirateDb.GetDatabaseForWriting().SetCandidateDocumentationReceived(this.Identity, organization.Identity, candidate.Identity);
}
public static Election September2010 { get { return FromIdentity(3); } }
+1 -1
View File
@@ -20,7 +20,7 @@ namespace Activizr.Logic.Governance
public static Meeting FromIdentity (int meetingId)
{
return FromBasic(PirateDb.GetDatabase().GetMeeting(meetingId));
return FromBasic(PirateDb.GetDatabaseForReading().GetMeeting(meetingId));
}
}
}
+9 -9
View File
@@ -24,7 +24,7 @@ namespace Activizr.Logic.Governance
public static MeetingElection Create (Person creator, Organization org, Geography geo, string name, InternalPollResultsType resultsType, int maxVoteLength, DateTime runningOpens, DateTime runningCloses, DateTime votingOpens, DateTime votingCloses)
{
return
FromIdentity(PirateDb.GetDatabase().CreateInternalPoll(org.Identity, geo.Identity, name, maxVoteLength,
FromIdentity(PirateDb.GetDatabaseForWriting().CreateInternalPoll(org.Identity, geo.Identity, name, maxVoteLength,
resultsType, creator.Identity, runningOpens,
runningCloses, votingOpens, votingCloses));
}
@@ -32,7 +32,7 @@ namespace Activizr.Logic.Governance
public static MeetingElection FromIdentity (int internalPollId)
{
return FromBasic(PirateDb.GetDatabase().GetInternalPoll(internalPollId));
return FromBasic(PirateDb.GetDatabaseForReading().GetInternalPoll(internalPollId));
}
@@ -63,12 +63,12 @@ namespace Activizr.Logic.Governance
public void AddVoter (Person person)
{
PirateDb.GetDatabase().CreateInternalPollVoter(this.Identity, person.Identity);
PirateDb.GetDatabaseForWriting().CreateInternalPollVoter(this.Identity, person.Identity);
}
public MeetingElectionVote CreateVote(Person person, string ipAddress)
{
if (PirateDb.GetDatabase().GetInternalPollVoterStatus(this.Identity, person.Identity) != InternalPollVoterStatus.CanVote)
if (PirateDb.GetDatabaseForReading().GetInternalPollVoterStatus(this.Identity, person.Identity) != InternalPollVoterStatus.CanVote)
{
throw new InvalidOperationException("Voter status is not open");
}
@@ -87,18 +87,18 @@ namespace Activizr.Logic.Governance
voteGeography = person.Geography;
}
PirateDb.GetDatabase().CloseInternalPollVoter(this.Identity, person.Identity, ipAddress);
PirateDb.GetDatabaseForWriting().CloseInternalPollVoter(this.Identity, person.Identity, ipAddress);
return MeetingElectionVote.Create(this, voteGeography);
}
public InternalPollVoterStatus GetVoterStatus (Person person)
{
return PirateDb.GetDatabase().GetInternalPollVoterStatus(this.Identity, person.Identity);
return PirateDb.GetDatabaseForReading().GetInternalPollVoterStatus(this.Identity, person.Identity);
}
public Dictionary<int,int> GetCandidatePersonMap()
{
return PirateDb.GetDatabase().GetCandidateIdPersonIdMap(this.Identity);
return PirateDb.GetDatabaseForReading().GetCandidateIdPersonIdMap(this.Identity);
}
public MeetingElectionVoters GetClosedVoters()
@@ -118,7 +118,7 @@ namespace Activizr.Logic.Governance
{
if (value != base.VotingOpen)
{
PirateDb.GetDatabase().SetInternalPollVotingOpen(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetInternalPollVotingOpen(this.Identity, value);
base.VotingOpen = value;
}
}
@@ -131,7 +131,7 @@ namespace Activizr.Logic.Governance
{
if (value != base.RunningOpen)
{
PirateDb.GetDatabase().SetInternalPollRunningOpen(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetInternalPollRunningOpen(this.Identity, value);
base.RunningOpen = value;
}
}
+6 -6
View File
@@ -23,7 +23,7 @@ namespace Activizr.Logic.Governance
{
if (!cache.ContainsKey(internalPollCandidateId))
{
cache [internalPollCandidateId] = FromBasic(PirateDb.GetDatabase().GetInternalPollCandidate(internalPollCandidateId));
cache [internalPollCandidateId] = FromBasic(PirateDb.GetDatabaseForReading().GetInternalPollCandidate(internalPollCandidateId));
}
return cache[internalPollCandidateId];
@@ -32,7 +32,7 @@ namespace Activizr.Logic.Governance
public static MeetingElectionCandidate FromPersonAndPoll (Person person, MeetingElection poll)
{
MeetingElectionCandidates candidates =
MeetingElectionCandidates.FromArray(PirateDb.GetDatabase().GetInternalPollCandidates(person, poll));
MeetingElectionCandidates.FromArray(PirateDb.GetDatabaseForReading().GetInternalPollCandidates(person, poll));
if (candidates.Count == 0)
{
@@ -51,7 +51,7 @@ namespace Activizr.Logic.Governance
public static MeetingElectionCandidate Create (MeetingElection poll, Person person, string candidacyStatement)
{
return FromIdentity (PirateDb.GetDatabase().CreateInternalPollCandidate(poll.Identity, person.Identity, candidacyStatement));
return FromIdentity (PirateDb.GetDatabaseForWriting().CreateInternalPollCandidate(poll.Identity, person.Identity, candidacyStatement));
}
private static Dictionary<int, MeetingElectionCandidate> cache;
@@ -121,12 +121,12 @@ namespace Activizr.Logic.Governance
public void SetSortOrder(string sortOrder)
{
PirateDb.GetDatabase().SetInternalPollCandidateSortOrder(this.Identity, sortOrder);
PirateDb.GetDatabaseForWriting().SetInternalPollCandidateSortOrder(this.Identity, sortOrder);
}
public void RandomizeSortOrder()
{
PirateDb.GetDatabase().SetInternalPollCandidateSortOrder(this.Identity, System.Guid.NewGuid().ToString());
PirateDb.GetDatabaseForWriting().SetInternalPollCandidateSortOrder(this.Identity, System.Guid.NewGuid().ToString());
}
public new string CandidacyStatement
@@ -137,7 +137,7 @@ namespace Activizr.Logic.Governance
{
base.CandidacyStatement = value;
cache[this.Identity] = this; // Replace cache instance
PirateDb.GetDatabase().SetInternalPollCandidateStatement(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetInternalPollCandidateStatement(this.Identity, value);
}
}
}
@@ -11,7 +11,7 @@ namespace Activizr.Logic.Governance
{
public static MeetingElectionCandidates ForPoll (MeetingElection poll)
{
return FromArray(PirateDb.GetDatabase().GetInternalPollCandidates(poll));
return FromArray(PirateDb.GetDatabaseForReading().GetInternalPollCandidates(poll));
}
}
}
+6 -6
View File
@@ -22,35 +22,35 @@ namespace Activizr.Logic.Governance
static public MeetingElectionVote FromIdentity (int internalPollVoteId)
{
return FromBasic(PirateDb.GetDatabase().GetInternalPollVote(internalPollVoteId));
return FromBasic(PirateDb.GetDatabaseForReading().GetInternalPollVote(internalPollVoteId));
}
static public MeetingElectionVote FromVerificationCode (string verificationCode)
{
return FromBasic(PirateDb.GetDatabase().GetInternalPollVote(verificationCode));
return FromBasic(PirateDb.GetDatabaseForReading().GetInternalPollVote(verificationCode));
}
static public MeetingElectionVote Create (MeetingElection poll, Geography voteGeography)
{
return
FromIdentity(PirateDb.GetDatabase().CreateInternalPollVote(poll.Identity, voteGeography.Identity,
FromIdentity(PirateDb.GetDatabaseForWriting().CreateInternalPollVote(poll.Identity, voteGeography.Identity,
Authentication.
CreateRandomPassword(12)));
}
public void AddDetail (int position, MeetingElectionCandidate candidate)
{
PirateDb.GetDatabase().CreateInternalPollVoteDetail(this.Identity, candidate.Identity, position);
PirateDb.GetDatabaseForWriting().CreateInternalPollVoteDetail(this.Identity, candidate.Identity, position);
}
public void Clear()
{
PirateDb.GetDatabase().ClearInternalPollVote(this.Identity);
PirateDb.GetDatabaseForWriting().ClearInternalPollVote(this.Identity);
}
public int[] SelectedCandidateIdsInOrder
{
get { return PirateDb.GetDatabase().GetInternalPollVoteDetails(this.Identity); }
get { return PirateDb.GetDatabaseForReading().GetInternalPollVoteDetails(this.Identity); }
}
/*
+3 -3
View File
@@ -25,11 +25,11 @@ namespace Activizr.Logic.Governance
{
if (includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetInternalPollVoters(poll));
return FromArray(PirateDb.GetDatabaseForReading().GetInternalPollVoters(poll));
}
else
{
return FromArray(PirateDb.GetDatabase().GetInternalPollVoters(poll, DatabaseCondition.OpenTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetInternalPollVoters(poll, DatabaseCondition.OpenTrue));
}
}
@@ -40,7 +40,7 @@ namespace Activizr.Logic.Governance
static public MeetingElectionVoters ForPollClosed (MeetingElection poll)
{
return FromArray(PirateDb.GetDatabase().GetInternalPollVoters(poll, DatabaseCondition.OpenFalse));
return FromArray(PirateDb.GetDatabaseForReading().GetInternalPollVoters(poll, DatabaseCondition.OpenFalse));
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Activizr.Logic.Governance
{
static public MeetingElectionVotes ForInternalPoll (MeetingElection poll)
{
return FromArray(PirateDb.GetDatabase().GetInternalPollVotes(poll));
return FromArray(PirateDb.GetDatabaseForReading().GetInternalPollVotes(poll));
}
}
}
+3 -3
View File
@@ -12,17 +12,17 @@ namespace Activizr.Logic.Governance
{
public static MeetingElections ForOrganization (Organization organization)
{
return FromArray(PirateDb.GetDatabase().GetInternalPolls(organization));
return FromArray(PirateDb.GetDatabaseForReading().GetInternalPolls(organization));
}
public static MeetingElections ForOrganizations (Organizations organizations)
{
return FromArray(PirateDb.GetDatabase().GetInternalPolls(organizations));
return FromArray(PirateDb.GetDatabaseForReading().GetInternalPolls(organizations));
}
public static MeetingElections GetAll()
{
return FromArray(PirateDb.GetDatabase().GetInternalPolls());
return FromArray(PirateDb.GetDatabaseForReading().GetInternalPolls());
}
}
}
+2 -2
View File
@@ -21,13 +21,13 @@ namespace Activizr.Logic.Governance
public static Motion FromIdentity (int motionId)
{
return FromBasic(PirateDb.GetDatabase().GetMotion(motionId));
return FromBasic(PirateDb.GetDatabaseForReading().GetMotion(motionId));
}
public static Motion Create (Meeting meeting, Person submittingPerson, Person creatingPerson, string title, string text, string decisionPoints)
{
return
Motion.FromIdentity(PirateDb.GetDatabase().CreateMotion(meeting.Identity, submittingPerson.Identity, creatingPerson.Identity, title, text, decisionPoints));
Motion.FromIdentity(PirateDb.GetDatabaseForWriting().CreateMotion(meeting.Identity, submittingPerson.Identity, creatingPerson.Identity, title, text, decisionPoints));
}
public MotionAmendments Amendments
+2 -2
View File
@@ -22,12 +22,12 @@ namespace Activizr.Logic.Governance
public static MotionAmendment FromIdentity (int motionAmendmentId)
{
return FromBasic(PirateDb.GetDatabase().GetMotionAmendment(motionAmendmentId));
return FromBasic(PirateDb.GetDatabaseForReading().GetMotionAmendment(motionAmendmentId));
}
public static MotionAmendment Create (Motion motion, string title, string text, string decisionPoint, Person submittingPerson, Person creatingPerson)
{
return FromIdentity(PirateDb.GetDatabase().CreateMotionAmendment (motion.Identity, submittingPerson.Identity, creatingPerson.Identity, title, text, decisionPoint));
return FromIdentity(PirateDb.GetDatabaseForWriting().CreateMotionAmendment (motion.Identity, submittingPerson.Identity, creatingPerson.Identity, title, text, decisionPoint));
}
public Motion Motion
+2 -2
View File
@@ -11,12 +11,12 @@ namespace Activizr.Logic.Governance
{
static public MotionAmendments ForMotion (Motion motion)
{
return MotionAmendments.FromArray(PirateDb.GetDatabase().GetMotionAmendments(motion));
return MotionAmendments.FromArray(PirateDb.GetDatabaseForReading().GetMotionAmendments(motion));
}
static public MotionAmendments ForMeeting (Meeting meeting)
{
return FromArray(PirateDb.GetDatabase().GetMotionAmendmentsForMeeting(meeting.Identity));
return FromArray(PirateDb.GetDatabaseForReading().GetMotionAmendmentsForMeeting(meeting.Identity));
}
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Activizr.Logic.Governance
{
static public Motions ForMeeting (Meeting meeting)
{
return Motions.FromArray(PirateDb.GetDatabase().GetMotions(meeting));
return Motions.FromArray(PirateDb.GetDatabaseForReading().GetMotions(meeting));
}
}
}
+2 -2
View File
@@ -27,12 +27,12 @@ namespace Activizr.Logic.Media
public static MediaCategories FromIdentities (int[] identities)
{
return FromArray (PirateDb.GetDatabase().GetMediaCategories (identities));
return FromArray (PirateDb.GetDatabaseForReading().GetMediaCategories (identities));
}
public static MediaCategories GetAll()
{
return FromArray(PirateDb.GetDatabase().GetMediaCategories());
return FromArray(PirateDb.GetDatabaseForReading().GetMediaCategories());
}
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Activizr.Logic.Media
public static MediaCategory FromName (string name)
{
return new MediaCategory (PirateDb.GetDatabase().GetMediaCategoryByName (name));
return new MediaCategory(PirateDb.GetDatabaseForReading().GetMediaCategoryByName(name));
}
public static MediaCategory FromBasic (BasicMediaCategory basic)
+9 -9
View File
@@ -31,32 +31,32 @@ namespace Activizr.Logic.Media
public static string[] GetBlogKeywords()
{
return PirateDb.GetDatabase().GetBlogKeywords();
return PirateDb.GetDatabaseForReading().GetBlogKeywords();
}
public static string[] GetOldMediaKeywords()
{
return PirateDb.GetDatabase().GetOldMediaKeywords();
return PirateDb.GetDatabaseForReading().GetOldMediaKeywords();
}
public static MediaEntries FromBlogKeyword (string keyword, DateTime minimumAge)
{
return FromArray (PirateDb.GetDatabase().GetBlogEntriesForKeyword (keyword, minimumAge));
return FromArray (PirateDb.GetDatabaseForReading().GetBlogEntriesForKeyword (keyword, minimumAge));
}
public static MediaEntries FromOldMediaKeyword (string keyword, DateTime minimumAge)
{
return FromArray (PirateDb.GetDatabase().GetOldMediaEntriesForKeyword (keyword, minimumAge));
return FromArray (PirateDb.GetDatabaseForReading().GetOldMediaEntriesForKeyword (keyword, minimumAge));
}
public static Dictionary<int, bool> GetMediaTypeTable()
{
return PirateDb.GetDatabase().GetMediaTypeTable();
return PirateDb.GetDatabaseForReading().GetMediaTypeTable();
}
public static Dictionary<int, string> GetMediaKeywordTable()
{
return PirateDb.GetDatabase().GetMediaKeywordTable();
return PirateDb.GetDatabaseForReading().GetMediaKeywordTable();
}
public static MediaEntries FromKeywordsSimplified (string[] keywords)
@@ -65,15 +65,15 @@ namespace Activizr.Logic.Media
foreach (string keyword in keywords)
{
keywordIds.Add (PirateDb.GetDatabase().GetMediaKeywordId (keyword));
keywordIds.Add (PirateDb.GetDatabaseForReading().GetMediaKeywordId (keyword));
}
return FromArray (PirateDb.GetDatabase().GetMediaEntriesForKeywordIdsSimplified (keywordIds.ToArray()));
return FromArray (PirateDb.GetDatabaseForReading().GetMediaEntriesForKeywordIdsSimplified (keywordIds.ToArray()));
}
public static int GetKeywordId (string keyword)
{
return PirateDb.GetDatabase().GetMediaKeywordId (keyword);
return PirateDb.GetDatabaseForReading().GetMediaKeywordId (keyword);
}
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ namespace Activizr.Logic.Media
public static bool CreateFromKeyword (string keyword, string mediaName, bool isBlog, string url, string title,
DateTime dateTime)
{
int id = PirateDb.GetDatabase().CreateMediaEntryFromKeyword (keyword, mediaName, isBlog, url, title,
int id = PirateDb.GetDatabaseForWriting().CreateMediaEntryFromKeyword (keyword, mediaName, isBlog, url, title,
dateTime);
if (id != 0)
+5 -5
View File
@@ -15,11 +15,11 @@ namespace Activizr.Logic.Media
public static Reporter Create (string name, string email, string[] categories)
{
Reporter reporter = FromIdentity(PirateDb.GetDatabase().CreateReporter(name, email));
Reporter reporter = FromIdentity(PirateDb.GetDatabaseForWriting().CreateReporter(name, email));
foreach (string category in categories)
{
PirateDb.GetDatabase().CreateReporterMediaCategory(reporter.Identity, category);
PirateDb.GetDatabaseForWriting().CreateReporterMediaCategory(reporter.Identity, category);
}
return reporter;
@@ -28,7 +28,7 @@ namespace Activizr.Logic.Media
public void Delete()
{
PirateDb.GetDatabase().DeleteReporter(this.Identity);
PirateDb.GetDatabaseForWriting().DeleteReporter(this.Identity);
// After this operation, the object is no longer valid.
}
@@ -40,7 +40,7 @@ namespace Activizr.Logic.Media
{
if (MediaCategoryIds == null)
{
MediaCategoryIds = PirateDb.GetDatabase().GetReporterMediaCategories (Identity);
MediaCategoryIds = PirateDb.GetDatabaseForReading().GetReporterMediaCategories (Identity);
}
if (this.mediaCategories == null)
@@ -67,7 +67,7 @@ namespace Activizr.Logic.Media
public static Reporter FromIdentity (int identity)
{
return Reporter.FromBasic(PirateDb.GetDatabase().GetReporter(identity));
return Reporter.FromBasic(PirateDb.GetDatabaseForReading().GetReporter(identity));
}
#region IComparable Members
+2 -2
View File
@@ -46,13 +46,13 @@ namespace Activizr.Logic.Pirates
{
Geographies geographies = geography.GetTree();
return PirateDb.GetDatabase().GetActivistCountForGeographies(geographies.Identities);
return PirateDb.GetDatabaseForReading().GetActivistCountForGeographies(geographies.Identities);
}
public static Activists FromGeography (Geography geography)
{
Geographies geographies = geography.GetTree();
return new Activists(PirateDb.GetDatabase().GetActivistPersonIds(geographies.Identities));
return new Activists(PirateDb.GetDatabaseForReading().GetActivistPersonIds(geographies.Identities));
}
public void SendPhoneMessage (string message)
+6 -6
View File
@@ -53,28 +53,28 @@ namespace Activizr.Logic.Pirates
/// <param name="organizationId">The organization churned from.</param>
public static void LogChurn (int personId, int organizationId)
{
PirateDb.GetDatabase().LogChurnData (personId, organizationId, true, DateTime.Now);
PirateDb.GetDatabaseForWriting().LogChurnData (personId, organizationId, true, DateTime.Now);
}
public static void LogRetention (int personId, int organizationId, DateTime expiry)
{
PirateDb.GetDatabase().LogChurnData (personId, organizationId, false, expiry);
PirateDb.GetDatabaseForWriting().LogChurnData (personId, organizationId, false, expiry);
}
public static void LogRetention (int personId, int organizationId, DateTime expiry, DateTime decisionDateTime)
{
PirateDb.GetDatabase().LogChurnData (personId, organizationId, false, expiry, decisionDateTime);
PirateDb.GetDatabaseForWriting().LogChurnData (personId, organizationId, false, expiry, decisionDateTime);
}
public static ChurnData ForOrganization (Organization organization)
{
return FromArray (PirateDb.GetDatabase().GetChurnData (organization));
return FromArray (PirateDb.GetDatabaseForReading().GetChurnData (organization));
}
public static ChurnData ForPerson (Person person)
{
return FromArray (PirateDb.GetDatabase().GetChurnData (person));
return FromArray (PirateDb.GetDatabaseForReading().GetChurnData (person));
}
@@ -85,7 +85,7 @@ namespace Activizr.Logic.Pirates
public static ChurnData GetByDate (Organization organization, DateTime dateLower, DateTime dateUpper)
{
return FromArray (PirateDb.GetDatabase().GetChurnDataForOrganization (organization, dateLower, dateUpper));
return FromArray (PirateDb.GetDatabaseForReading().GetChurnDataForOrganization (organization, dateLower, dateUpper));
}
+2 -2
View File
@@ -12,12 +12,12 @@ namespace Activizr.Logic.Pirates
{
public static ExternalActivities ForOrganization (Organization organization)
{
return FromArray(PirateDb.GetDatabase().GetExternalActivities(organization));
return FromArray(PirateDb.GetDatabaseForReading().GetExternalActivities(organization));
}
public static ExternalActivities ForOrganization (Organization organization, SortOrder sort, int count)
{
return FromArray(PirateDb.GetDatabase().GetExternalActivitiesSorted(sort.ToString(), count, organization));
return FromArray(PirateDb.GetDatabaseForReading().GetExternalActivitiesSorted(sort.ToString(), count, organization));
}
public enum SortOrder
+2 -2
View File
@@ -22,13 +22,13 @@ namespace Activizr.Logic.Pirates
public static ExternalActivity FromIdentity (int externalActivityId)
{
return FromBasic(PirateDb.GetDatabase().GetExternalActivity(externalActivityId));
return FromBasic(PirateDb.GetDatabaseForReading().GetExternalActivity(externalActivityId));
}
public static ExternalActivity Create (Organization organization, Geography geograpy, ExternalActivityType type, DateTime date, string description, Person createdByPerson)
{
return
FromIdentity(PirateDb.GetDatabase().CreateExternalActivity(organization.Identity, geograpy.Identity,
FromIdentity(PirateDb.GetDatabaseForWriting().CreateExternalActivity(organization.Identity, geograpy.Identity,
date, type, description,
createdByPerson.Identity));
}
+6 -6
View File
@@ -96,22 +96,22 @@ namespace Activizr.Logic.Pirates
public static ExternalIdentity FromIdentity (int externalIdentityId)
{
return FromBasic(PirateDb.GetDatabase().GetExternalIdentity(externalIdentityId));
return FromBasic(PirateDb.GetDatabaseForReading().GetExternalIdentity(externalIdentityId));
}
public static ExternalIdentity FromUserIdAndType (string userid, ExternalIdentityType type)
{
return FromBasic(PirateDb.GetDatabase().GetExternalIdentityFromUserIdAndType(userid, type));
return FromBasic(PirateDb.GetDatabaseForReading().GetExternalIdentityFromUserIdAndType(userid, type));
}
public static ExternalIdentity FromPersonIdAndType (int persId, ExternalIdentityType type)
{
return FromBasic(PirateDb.GetDatabase().GetExternalIdentityFromPersonIdAndType(persId, type));
return FromBasic(PirateDb.GetDatabaseForReading().GetExternalIdentityFromPersonIdAndType(persId, type));
}
public static List<ExternalIdentity> ExternalItentitiesForPerson (int persId)
{
List<BasicExternalIdentity> templist = PirateDb.GetDatabase().GetExternalIdentities(persId);
List<BasicExternalIdentity> templist = PirateDb.GetDatabaseForReading().GetExternalIdentities(persId);
List<ExternalIdentity> retlist = new List<ExternalIdentity>();
@@ -131,7 +131,7 @@ namespace Activizr.Logic.Pirates
int AttachedToPerson,
ExternalIdentityType TypeOfAccount)
{
return FromBasic(PirateDb.GetDatabase().SetExternalIdentity(
return FromBasic(PirateDb.GetDatabaseForWriting().SetExternalIdentity(
this.Identity, TypeOfAccount, ExternalSystem,
UserID, Password, AttachedToPerson));
@@ -146,7 +146,7 @@ namespace Activizr.Logic.Pirates
{
try
{
return FromBasic(PirateDb.GetDatabase().SetExternalIdentity(
return FromBasic(PirateDb.GetDatabaseForWriting().SetExternalIdentity(
0, TypeOfAccount, ExternalSystem,
UserID, Password, AttachedToPerson));
}
+9 -9
View File
@@ -60,7 +60,7 @@ namespace Activizr.Logic.Pirates
{
ChurnData.LogRetention(this.PersonId, this.OrganizationId, base.Expires);
}
PirateDb.GetDatabase().SetMembershipExpires(Identity, value);
PirateDb.GetDatabaseForWriting().SetMembershipExpires(Identity, value);
base.Expires = value;
}
}
@@ -68,7 +68,7 @@ namespace Activizr.Logic.Pirates
public void SetPaymentStatus (MembershipPaymentStatus status, DateTime dateTime)
{
PirateDb.GetDatabase().SetMembershipPaymentStatus(Identity, status, dateTime);
PirateDb.GetDatabaseForWriting().SetMembershipPaymentStatus(Identity, status, dateTime);
LoadPaymentStatus();
paymentStatus.Status = status;
paymentStatus.StatusDateTime = dateTime;
@@ -78,7 +78,7 @@ namespace Activizr.Logic.Pirates
{
if (paymentStatus == null)
{
paymentStatus = PirateDb.GetDatabase().GetMembershipPaymentStatus(this.Identity);
paymentStatus = PirateDb.GetDatabaseForReading().GetMembershipPaymentStatus(this.Identity);
}
}
@@ -87,7 +87,7 @@ namespace Activizr.Logic.Pirates
public static void LoadPaymentStatuses (Memberships mss)
{
Dictionary<int, BasicMembershipPaymentStatus> statuses =
PirateDb.GetDatabase().GetMembershipPaymentStatuses(mss.Identities);
PirateDb.GetDatabaseForReading().GetMembershipPaymentStatuses(mss.Identities);
foreach (Membership ms in mss)
{
if (ms.paymentStatus == null && statuses.ContainsKey(ms.Identity))
@@ -139,17 +139,17 @@ namespace Activizr.Logic.Pirates
public static Membership FromIdentity (int membershipId)
{
return FromBasic(PirateDb.GetDatabase().GetMembership(membershipId));
return FromBasic(PirateDb.GetDatabaseForReading().GetMembership(membershipId));
}
public static Membership FromPersonAndOrganization (int personId, int organizationId)
{
return FromBasic(PirateDb.GetDatabase().GetActiveMembership(personId, organizationId));
return FromBasic(PirateDb.GetDatabaseForReading().GetActiveMembership(personId, organizationId));
}
public static Membership Create (int personId, int organizationId, DateTime expires)
{
int membershipId = PirateDb.GetDatabase().CreateMembership(personId, organizationId, expires);
int membershipId = PirateDb.GetDatabaseForWriting().CreateMembership(personId, organizationId, expires);
return FromIdentity(membershipId);
}
@@ -163,7 +163,7 @@ namespace Activizr.Logic.Pirates
DateTime expires)
{
return
FromIdentity(PirateDb.GetDatabase().ImportMembership(person.Identity, organization.Identity, memberSince,
FromIdentity(PirateDb.GetDatabaseForWriting().ImportMembership(person.Identity, organization.Identity, memberSince,
expires));
}
@@ -244,7 +244,7 @@ namespace Activizr.Logic.Pirates
{
ChurnData.LogChurn(this.PersonId, this.OrganizationId);
}
PirateDb.GetDatabase().TerminateMembership(Identity);
PirateDb.GetDatabaseForWriting().TerminateMembership(Identity);
base.Active = false;
base.DateTerminated = DateTime.Now;
+2 -2
View File
@@ -25,7 +25,7 @@ namespace Activizr.Logic.Pirates
// In the person-gathering phase, we use BasicPerson in order to avoid the unneeded translation to Person.
BasicPerson[] allPeople = PirateDb.GetDatabase().GetAllPeople();
BasicPerson[] allPeople = PirateDb.GetDatabaseForReading().GetAllPeople();
var geoLookup = new Dictionary<int, int>();
var genderLookup = new Dictionary<int, PersonGender>();
@@ -40,7 +40,7 @@ namespace Activizr.Logic.Pirates
// Second phase, load all memberships
BasicMembership[] allMemberships = PirateDb.GetDatabase().GetMemberships();
BasicMembership[] allMemberships = PirateDb.GetDatabaseForReading().GetMemberships();
// Third phase - for every membership, generate one or two membership events
+11 -11
View File
@@ -37,12 +37,12 @@ namespace Activizr.Logic.Pirates
public static int GetMemberCountForOrganization (Organization organization)
{
return PirateDb.GetDatabase().GetMembershipCountForOrganizations(new[] {organization.Identity});
return PirateDb.GetDatabaseForReading().GetMembershipCountForOrganizations(new[] {organization.Identity});
}
public static int GetMemberCountForOrganizations (int[] organizationIds)
{
return PirateDb.GetDatabase().GetMembershipCountForOrganizations(organizationIds);
return PirateDb.GetDatabaseForReading().GetMembershipCountForOrganizations(organizationIds);
}
public static int GetMemberCountForOrganizationSince (Organization org, DateTime sinceDateTime)
@@ -52,7 +52,7 @@ namespace Activizr.Logic.Pirates
public static int GetMemberCountForOrganizationSince (int orgId, DateTime sinceDateTime)
{
return PirateDb.GetDatabase().GetMembershipCountForOrganizationsSince(new[] {orgId}, sinceDateTime);
return PirateDb.GetDatabaseForReading().GetMembershipCountForOrganizationsSince(new[] {orgId}, sinceDateTime);
}
public static int GetMemberCountForOrganizations (Organizations organizations)
@@ -79,12 +79,12 @@ namespace Activizr.Logic.Pirates
return ForOrganization(organization);
}
return FromArray(PirateDb.GetDatabase().GetMemberships(organization));
return FromArray(PirateDb.GetDatabaseForReading().GetMemberships(organization));
}
public static Memberships ForOrganization (Organization organization)
{
return FromArray(PirateDb.GetDatabase().GetMemberships(organization, DatabaseCondition.ActiveTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetMemberships(organization, DatabaseCondition.ActiveTrue));
}
public static Memberships ForOrganizations (Organizations organizations, bool includeTerminated)
@@ -94,12 +94,12 @@ namespace Activizr.Logic.Pirates
return ForOrganizations(organizations);
}
return FromArray(PirateDb.GetDatabase().GetMemberships(organizations));
return FromArray(PirateDb.GetDatabaseForReading().GetMemberships(organizations));
}
public static Memberships ForOrganizations (Organizations organizations)
{
return FromArray(PirateDb.GetDatabase().GetMemberships(organizations, DatabaseCondition.ActiveTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetMemberships(organizations, DatabaseCondition.ActiveTrue));
}
public static Memberships GetExpiring (Organization organization, DateTime dateExpiry)
@@ -110,23 +110,23 @@ namespace Activizr.Logic.Pirates
public static Memberships GetExpired (Organization organization)
{
return
FromArray(PirateDb.GetDatabase().GetExpiringMemberships(organization, DateTime.MinValue,
FromArray(PirateDb.GetDatabaseForReading().GetExpiringMemberships(organization, DateTime.MinValue,
DateTime.Now));
}
public static Memberships GetExpired (Organization organization, DateTime lowerBound, DateTime upperBound)
{
return FromArray(PirateDb.GetDatabase().GetExpiringMemberships(organization, lowerBound, upperBound, DatabaseCondition.None));
return FromArray(PirateDb.GetDatabaseForReading().GetExpiringMemberships(organization, lowerBound, upperBound, DatabaseCondition.None));
}
public static Memberships GetExpiring (Organization organization, DateTime lowerBound, DateTime upperBound)
{
return FromArray(PirateDb.GetDatabase().GetExpiringMemberships(organization, lowerBound, upperBound));
return FromArray(PirateDb.GetDatabaseForReading().GetExpiringMemberships(organization, lowerBound, upperBound));
}
public static Dictionary<int, List<BasicMembership>> GetMembershipsForPeople (int[] personIds, int gracePeriod)
{
return PirateDb.GetDatabase().GetMembershipsForPeople(personIds, gracePeriod);
return PirateDb.GetDatabaseForReading().GetMembershipsForPeople(personIds, gracePeriod);
}
}
+7 -7
View File
@@ -24,13 +24,13 @@ namespace Activizr.Logic.Pirates
public static Parley FromIdentity (int parleyId)
{
return FromBasic(PirateDb.GetDatabase().GetParley(parleyId));
return FromBasic(PirateDb.GetDatabaseForReading().GetParley(parleyId));
}
public static Parley Create (Organization organization, Person person, FinancialAccount budgetInitial, string name, Geography geography, string description, string informationUrl, DateTime startDate, DateTime endDate, Int64 budgetCents, Int64 guaranteeCents, Int64 attendanceFeeCents)
{
Parley newParley =
FromIdentity(PirateDb.GetDatabase().CreateParley(organization.Identity, person.Identity,
FromIdentity(PirateDb.GetDatabaseForWriting().CreateParley(organization.Identity, person.Identity,
-(budgetInitial.Identity), name, geography.Identity,
description, informationUrl, startDate, endDate,
budgetCents, guaranteeCents, attendanceFeeCents));
@@ -105,7 +105,7 @@ namespace Activizr.Logic.Pirates
if (base.Open != value)
{
base.Open = value;
PirateDb.GetDatabase().SetParleyOpen(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetParleyOpen(this.Identity, value);
}
}
}
@@ -133,8 +133,8 @@ namespace Activizr.Logic.Pirates
}
base.Attested = true;
PirateDb.GetDatabase().SetParleyAttested(this.Identity, true);
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Attestation,
PirateDb.GetDatabaseForWriting().SetParleyAttested(this.Identity, true);
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation,
FinancialDependencyType.Parley, this.Identity,
DateTime.Now, attester.Identity, (double)(this.GuaranteeDecimal));
@@ -156,7 +156,7 @@ namespace Activizr.Logic.Pirates
parentBudget.SetBudget(DateTime.Today.Year,
(double) parentBudget.GetBudget(year) + (double) this.BudgetDecimal); // cost budgets are negative
PirateDb.GetDatabase().SetParleyBudget(this.Identity, newBudget.Identity);
PirateDb.GetDatabaseForWriting().SetParleyBudget(this.Identity, newBudget.Identity);
}
// Reserve the guarantee money
@@ -177,7 +177,7 @@ namespace Activizr.Logic.Pirates
throw new NotImplementedException();
/*
base.Attested = false;
PirateDb.GetDatabase().CreateFinancialValidation(FinancialValidationType.Deattestation,
PirateDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Deattestation,
FinancialDependencyType.Parley, this.Identity,
DateTime.Now, deattester.Identity, (double)(this.GuaranteeDecimal+this.BudgetDecimal));*/
+5 -5
View File
@@ -24,17 +24,17 @@ namespace Activizr.Logic.Pirates
public static ParleyAttendee FromIdentity (int parleyAttendeeId)
{
return FromBasic(PirateDb.GetDatabase().GetParleyAttendee(parleyAttendeeId));
return FromBasic(PirateDb.GetDatabaseForReading().GetParleyAttendee(parleyAttendeeId));
}
public static ParleyAttendee Create (Parley parley, Person person, bool asGuest)
{
return FromIdentity(PirateDb.GetDatabase().CreateParleyAttendee(parley.Identity, person.Identity, asGuest));
return FromIdentity(PirateDb.GetDatabaseForWriting().CreateParleyAttendee(parley.Identity, person.Identity, asGuest));
}
public void AddOption (ParleyOption option)
{
PirateDb.GetDatabase().AddParleyAttendeeOption(this.Identity, option.Identity);
PirateDb.GetDatabaseForWriting().AddParleyAttendeeOption(this.Identity, option.Identity);
}
public ParleyOptions Options
@@ -54,7 +54,7 @@ namespace Activizr.Logic.Pirates
{
if (value != base.Active)
{
PirateDb.GetDatabase().SetParleyAttendeeActive(this.Identity, value);
PirateDb.GetDatabaseForWriting().SetParleyAttendeeActive(this.Identity, value);
base.Active = value;
}
}
@@ -120,7 +120,7 @@ namespace Activizr.Logic.Pirates
base.Invoiced = true;
base.OutboundInvoiceId = invoice.Identity;
PirateDb.GetDatabase().SetParleyAttendeeInvoiced(this.Identity, invoice.Identity);
PirateDb.GetDatabaseForWriting().SetParleyAttendeeInvoiced(this.Identity, invoice.Identity);
}
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ namespace Activizr.Logic.Pirates
{
public static ParleyAttendees ForParley (Parley parley)
{
return FromArray(PirateDb.GetDatabase().GetParleyAttendees(parley));
return FromArray(PirateDb.GetDatabaseForReading().GetParleyAttendees(parley));
}
}
}
+2 -2
View File
@@ -20,12 +20,12 @@ namespace Activizr.Logic.Pirates
public static ParleyOption FromIdentity (int parleyOptionId)
{
return FromBasic(PirateDb.GetDatabase().GetParleyOption(parleyOptionId));
return FromBasic(PirateDb.GetDatabaseForReading().GetParleyOption(parleyOptionId));
}
public static ParleyOption Create (Parley parley, string description, Int64 amountCents)
{
return FromIdentity(PirateDb.GetDatabase().CreateParleyOption(parley.Identity, description, amountCents));
return FromIdentity(PirateDb.GetDatabaseForWriting().CreateParleyOption(parley.Identity, description, amountCents));
}
public decimal AmountDecimal
+3 -3
View File
@@ -18,17 +18,17 @@ namespace Activizr.Logic.Pirates
{
if (includeInactive)
{
return FromArray(PirateDb.GetDatabase().GetParleyOptions(parley));
return FromArray(PirateDb.GetDatabaseForReading().GetParleyOptions(parley));
}
else
{
return FromArray(PirateDb.GetDatabase().GetParleyOptions(parley, DatabaseCondition.ActiveTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetParleyOptions(parley, DatabaseCondition.ActiveTrue));
}
}
public static ParleyOptions ForParleyAttendee (ParleyAttendee attendee)
{
int[] parleyOptionIds = PirateDb.GetDatabase().GetParleyAttendeeOptions(attendee.Identity);
int[] parleyOptionIds = PirateDb.GetDatabaseForReading().GetParleyAttendeeOptions(attendee.Identity);
return FromIdentities(parleyOptionIds);
}
+4 -4
View File
@@ -19,11 +19,11 @@ namespace Activizr.Logic.Pirates
{
if (includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetParleys(organization));
return FromArray(PirateDb.GetDatabaseForReading().GetParleys(organization));
}
else
{
return FromArray(PirateDb.GetDatabase().GetParleys(organization, DatabaseCondition.OpenTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetParleys(organization, DatabaseCondition.OpenTrue));
}
}
@@ -36,11 +36,11 @@ namespace Activizr.Logic.Pirates
{
if (includeClosed)
{
return FromArray(PirateDb.GetDatabase().GetParleys(person));
return FromArray(PirateDb.GetDatabaseForReading().GetParleys(person));
}
else
{
return FromArray(PirateDb.GetDatabase().GetParleys(person, DatabaseCondition.OpenTrue));
return FromArray(PirateDb.GetDatabaseForReading().GetParleys(person, DatabaseCondition.OpenTrue));
}
}
}
+4 -4
View File
@@ -35,7 +35,7 @@ namespace Activizr.Logic.Pirates
public static PaymentCode FromCode (string paymentCode)
{
return FromBasic(PirateDb.GetDatabase().GetPaymentCode(paymentCode));
return FromBasic(PirateDb.GetDatabaseForReading().GetPaymentCode(paymentCode));
}
@@ -49,9 +49,9 @@ namespace Activizr.Logic.Pirates
try
{
int codeId = PirateDb.GetDatabase().CreatePaymentCode(randomCode, phoneNumber, personId);
int codeId = PirateDb.GetDatabaseForWriting().CreatePaymentCode(randomCode, phoneNumber, personId);
success = true;
return FromBasic(PirateDb.GetDatabase().GetPaymentCode(randomCode));
return FromBasic(PirateDb.GetDatabaseForReading().GetPaymentCode(randomCode));
}
catch (Exception)
{
@@ -72,7 +72,7 @@ namespace Activizr.Logic.Pirates
public void Claim (int claimingPersonId)
{
PirateDb.GetDatabase().ClaimPaymentCode(Identity, claimingPersonId);
PirateDb.GetDatabaseForWriting().ClaimPaymentCode(Identity, claimingPersonId);
}
private static string CreateRandomCode (int length)
+18 -18
View File
@@ -42,7 +42,7 @@ namespace Activizr.Logic.Pirates
lookup[key] = true;
}
BasicPerson[] basicArray = PirateDb.GetDatabase().GetAllPeople();
BasicPerson[] basicArray = PirateDb.GetDatabaseForReading().GetAllPeople();
var result = new People();
for (int index = 0; index < basicArray.Length; index++)
@@ -57,13 +57,13 @@ namespace Activizr.Logic.Pirates
}
else
{
return People.FromArray(PirateDb.GetDatabase().GetPeople(personIds));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeople(personIds));
}
}
public static People GetAll ()
{
return People.FromArray(PirateDb.GetDatabase().GetAllPeople());
return People.FromArray(PirateDb.GetDatabaseForReading().GetAllPeople());
}
public static People FromNamePattern (string namePattern)
@@ -85,7 +85,7 @@ namespace Activizr.Logic.Pirates
namePattern = "%" + namePattern;
}
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromNamePattern(namePattern));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromNamePattern(namePattern));
}
return null; // If no valid search string was supplied
@@ -93,7 +93,7 @@ namespace Activizr.Logic.Pirates
public static People FromBirtDatePattern (DateTime fromdate, DateTime todate)
{
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromBirthdate(fromdate, todate));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromBirthdate(fromdate, todate));
}
public static People FromEmailPattern (string emailPattern)
@@ -105,7 +105,7 @@ namespace Activizr.Logic.Pirates
{
emailPattern = "%" + emailPattern + "%";
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromEmailPattern(emailPattern));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromEmailPattern(emailPattern));
}
return null; // If no valid search string was supplied
@@ -120,7 +120,7 @@ namespace Activizr.Logic.Pirates
{
cityPattern = "%" + cityPattern + "%";
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromCityPattern(cityPattern));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromCityPattern(cityPattern));
}
return null; // If no valid search string was supplied
@@ -135,7 +135,7 @@ namespace Activizr.Logic.Pirates
{
pcPattern = pcPattern + "%";
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromPostalCodePattern(pcPattern));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromPostalCodePattern(pcPattern));
}
return null; // If no valid search string was supplied
@@ -147,7 +147,7 @@ namespace Activizr.Logic.Pirates
if (pcodes.Length > 0)
{
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromPostalCodes(pcodes));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromPostalCodes(pcodes));
}
return null; // If no valid search string was supplied
@@ -157,7 +157,7 @@ namespace Activizr.Logic.Pirates
{
if (email.Length > 0)
{
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromEmail(email));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromEmail(email));
}
return null; // If no valid search string was supplied
@@ -275,7 +275,7 @@ namespace Activizr.Logic.Pirates
// First, get list of people in the geography, then filter on memberships
BasicPerson[] people = PirateDb.GetDatabase().GetPeopleInGeographies(geoTree.Identities);
BasicPerson[] people = PirateDb.GetDatabaseForReading().GetPeopleInGeographies(geoTree.Identities);
// Filter on memberships
@@ -297,7 +297,7 @@ namespace Activizr.Logic.Pirates
// Get the list of all memberships
Dictionary<int, List<BasicMembership>> memberships =
PirateDb.GetDatabase().GetMembershipsForPeople(LogicServices.ObjectsToIdentifiers(people));
PirateDb.GetDatabaseForReading().GetMembershipsForPeople(LogicServices.ObjectsToIdentifiers(people));
var result = new People();
@@ -331,7 +331,7 @@ namespace Activizr.Logic.Pirates
// First, get list of people in the geography, then filter on memberships
BasicPerson[] people = PirateDb.GetDatabase().GetPeopleInGeographies(geoTree.Identities);
BasicPerson[] people = PirateDb.GetDatabaseForReading().GetPeopleInGeographies(geoTree.Identities);
var result = new People();
@@ -383,17 +383,17 @@ namespace Activizr.Logic.Pirates
public static People FromOptionalData (ObjectOptionalDataType dataType, string data)
{
return People.FromIdentities(PirateDb.GetDatabase().GetObjectsByOptionalData(ObjectType.Person, dataType, data));
return People.FromIdentities(PirateDb.GetDatabaseForReading().GetObjectsByOptionalData(ObjectType.Person, dataType, data));
}
public static People FromPhoneNumber (int countryId, string phoneNumber)
{
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromPhoneNumber(countryId, phoneNumber));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromPhoneNumber(countryId, phoneNumber));
}
public static People FromPhoneNumber (string countryCode, string phoneNumber)
{
return People.FromArray(PirateDb.GetDatabase().GetPeopleFromPhoneNumber(countryCode, phoneNumber));
return People.FromArray(PirateDb.GetDatabaseForReading().GetPeopleFromPhoneNumber(countryCode, phoneNumber));
}
public People GetVisiblePeopleByAuthority (Authority authority)
@@ -467,7 +467,7 @@ namespace Activizr.Logic.Pirates
public static People FromNewsletterFeed (int feedId)
{
int[] subscriberIds = PirateDb.GetDatabase().GetSubscribersForNewsletterFeed(2);
int[] subscriberIds = PirateDb.GetDatabaseForReading().GetSubscribersForNewsletterFeed(2);
return FromIdentities(subscriberIds);
}
@@ -487,7 +487,7 @@ namespace Activizr.Logic.Pirates
public static Dictionary<int, int> GetPeopleGeographies ()
{
return PirateDb.GetDatabase().GetPeopleGeographies();
return PirateDb.GetDatabaseForReading().GetPeopleGeographies();
}
public static People FromIdentities (int[] personIds, bool preserveOrder)
+31 -31
View File
@@ -56,20 +56,20 @@ namespace Activizr.Logic.Pirates
public bool IsActivist
{
get { return PirateDb.GetDatabase().GetActivistStatus(Identity); }
get { return PirateDb.GetDatabaseForReading().GetActivistStatus(Identity); }
}
public new virtual string Name
{
get { return base.Name.Replace("|", " "); }
set { PirateDb.GetDatabase().SetPersonName(Identity, value); }
set { PirateDb.GetDatabaseForWriting().SetPersonName(Identity, value); }
}
public new virtual string Street
{
get { return base.Street; }
set { PirateDb.GetDatabase().SetPersonStreet(Identity, value); }
set { PirateDb.GetDatabaseForWriting().SetPersonStreet(Identity, value); }
}
@@ -78,7 +78,7 @@ namespace Activizr.Logic.Pirates
get { return base.PostalCode; }
set
{
PirateDb.GetDatabase().SetPersonPostalCode(Identity, value);
PirateDb.GetDatabaseForWriting().SetPersonPostalCode(Identity, value);
base.PostalCode = value;
ResolveGeography();
}
@@ -90,7 +90,7 @@ namespace Activizr.Logic.Pirates
get { return base.CityName; }
set
{
PirateDb.GetDatabase().SetPersonCity(Identity, value);
PirateDb.GetDatabaseForWriting().SetPersonCity(Identity, value);
base.CityName = value;
ResolveGeography();
}
@@ -102,7 +102,7 @@ namespace Activizr.Logic.Pirates
get { return Country.FromIdentity(base.CountryId); }
set
{
PirateDb.GetDatabase().SetPersonCountry(Identity, value.Identity);
PirateDb.GetDatabaseForWriting().SetPersonCountry(Identity, value.Identity);
base.CountryId = value.Identity;
ResolveGeography();
}
@@ -147,14 +147,14 @@ namespace Activizr.Logic.Pirates
{
if (GeographyId == 0)
{
PirateDb.GetDatabase().SetPersonGeography (this.Identity, ResolveGeography());
PirateDb.GetDatabaseForWriting().SetPersonGeography (this.Identity, ResolveGeography());
}
return Geography.FromIdentity(GeographyId);
}
set
{
PirateDb.GetDatabase().SetPersonGeography(Identity, value.Identity);
PirateDb.GetDatabaseForWriting().SetPersonGeography(Identity, value.Identity);
base.GeographyId = value.Identity;
}
}
@@ -165,7 +165,7 @@ namespace Activizr.Logic.Pirates
{
if (base.GeographyId == 0)
{
PirateDb.GetDatabase().SetPersonGeography(this.Identity, ResolveGeography());
PirateDb.GetDatabaseForWriting().SetPersonGeography(this.Identity, ResolveGeography());
}
return base.GeographyId;
@@ -176,27 +176,27 @@ namespace Activizr.Logic.Pirates
public new virtual string Email
{
get { return base.Email; }
set { PirateDb.GetDatabase().SetPersonEmail(Identity, value); }
set { PirateDb.GetDatabaseForWriting().SetPersonEmail(Identity, value); }
}
public new virtual string Phone
{
get { return base.Phone; }
set { PirateDb.GetDatabase().SetPersonPhone(Identity, value); }
set { PirateDb.GetDatabaseForWriting().SetPersonPhone(Identity, value); }
}
public new virtual DateTime Birthdate
{
get { return base.Birthdate; }
set { PirateDb.GetDatabase().SetPersonBirthdate(Identity, value); }
set { PirateDb.GetDatabaseForWriting().SetPersonBirthdate(Identity, value); }
}
public new virtual PersonGender Gender
{
get { return base.Gender; }
set { PirateDb.GetDatabase().SetPersonGender(Identity, value); }
set { PirateDb.GetDatabaseForWriting().SetPersonGender(Identity, value); }
}
@@ -362,7 +362,7 @@ namespace Activizr.Logic.Pirates
public static Person FromIdentity (int personId)
{
return FromBasic(PirateDb.GetDatabase().GetPerson(personId));
return FromBasic(PirateDb.GetDatabaseForReading().GetPerson(personId));
}
public Authority GetAuthority ()
@@ -377,12 +377,12 @@ namespace Activizr.Logic.Pirates
return GetMemberships();
}
return Memberships.FromArray(PirateDb.GetDatabase().GetMemberships(this));
return Memberships.FromArray(PirateDb.GetDatabaseForReading().GetMemberships(this));
}
public Memberships GetMemberships ()
{
return Memberships.FromArray(PirateDb.GetDatabase().GetMemberships(this, DatabaseCondition.ActiveTrue));
return Memberships.FromArray(PirateDb.GetDatabaseForReading().GetMemberships(this, DatabaseCondition.ActiveTrue));
}
@@ -494,7 +494,7 @@ namespace Activizr.Logic.Pirates
string postal, string city, string countryCode, DateTime dateOfBirth,
PersonGender gender)
{
BasicCountry country = PirateDb.GetDatabase().GetCountry(countryCode);
BasicCountry country = PirateDb.GetDatabaseForReading().GetCountry(countryCode);
// Clean data
@@ -508,7 +508,7 @@ namespace Activizr.Logic.Pirates
phone = LogicServices.CleanNumber(phone);
postal = postal.Replace(" ", "").Trim();
int personId = PirateDb.GetDatabase().CreatePerson(name, email, phone, street, postal, city,
int personId = PirateDb.GetDatabaseForWriting().CreatePerson(name, email, phone, street, postal, city,
country.Identity, dateOfBirth, gender);
@@ -547,7 +547,7 @@ namespace Activizr.Logic.Pirates
{
if (null == this.subscriptions)
{
this.subscriptions = PirateDb.GetDatabase().GetNewsletterFeedsForSubscriber(PersonId);
this.subscriptions = PirateDb.GetDatabaseForReading().GetNewsletterFeedsForSubscriber(PersonId);
}
if (this.subscriptions.ContainsKey(newsletterFeedId))
@@ -586,14 +586,14 @@ namespace Activizr.Logic.Pirates
bool? subscription = HasExplicitSubscription(newsletterFeedId);
if (subscription != null && subscription != subscribe)
{
PirateDb.GetDatabase().SetNewsletterSubscription(PersonId, newsletterFeedId, subscribe);
PirateDb.GetDatabaseForWriting().SetNewsletterSubscription(PersonId, newsletterFeedId, subscribe);
}
else
{
NewsletterFeed feed = NewsletterFeed.FromIdentity(newsletterFeedId);
if (subscribe != feed.DefaultSubscribed)
{
PirateDb.GetDatabase().SetNewsletterSubscription(PersonId, newsletterFeedId, subscribe);
PirateDb.GetDatabaseForWriting().SetNewsletterSubscription(PersonId, newsletterFeedId, subscribe);
}
}
this.subscriptions[newsletterFeedId] = subscribe;
@@ -602,7 +602,7 @@ namespace Activizr.Logic.Pirates
public void DeleteSubscriptionData ()
{
PirateDb.GetDatabase().DeletePersonNewsletterSubscriptions(Identity);
PirateDb.GetDatabaseForWriting().DeletePersonNewsletterSubscriptions(Identity);
}
@@ -627,7 +627,7 @@ namespace Activizr.Logic.Pirates
public virtual void SetPassword (string newPassword)
{
string hash = Authentication.GeneratePasswordHash(Identity, newPassword);
PirateDb.GetDatabase().SetPersonPasswordHash(Identity, hash);
PirateDb.GetDatabaseForWriting().SetPersonPasswordHash(Identity, hash);
base.PasswordHash = hash;
}
@@ -637,7 +637,7 @@ namespace Activizr.Logic.Pirates
get { return base.PasswordHash; }
set
{
PirateDb.GetDatabase().SetPersonPasswordHash(Identity, value);
PirateDb.GetDatabaseForWriting().SetPersonPasswordHash(Identity, value);
base.PasswordHash = value;
}
}
@@ -651,13 +651,13 @@ namespace Activizr.Logic.Pirates
private void SendNotice (string subject, string body, int organizationId, bool asOfficer)
{
int mailId = PirateDb.GetDatabase().CreateOutboundMail(
int mailId = PirateDb.GetDatabaseForWriting().CreateOutboundMail(
asOfficer ? MailAuthorType.PirateWeb : MailAuthorType.Service, 0, subject,
body, OutboundMail.PriorityNormal, 0, GeographyId, organizationId, DateTime.Now);
PirateDb.GetDatabase().CreateOutboundMailRecipient(mailId, Identity, asOfficer, (int)OutboundMailRecipient.RecipientType.Person);
PirateDb.GetDatabase().SetOutboundMailRecipientCount(mailId, 1);
PirateDb.GetDatabase().SetOutboundMailResolved(mailId);
PirateDb.GetDatabase().SetOutboundMailReadyForPickup(mailId);
PirateDb.GetDatabaseForWriting().CreateOutboundMailRecipient(mailId, Identity, asOfficer, (int)OutboundMailRecipient.RecipientType.Person);
PirateDb.GetDatabaseForWriting().SetOutboundMailRecipientCount(mailId, 1);
PirateDb.GetDatabaseForWriting().SetOutboundMailResolved(mailId);
PirateDb.GetDatabaseForWriting().SetOutboundMailReadyForPickup(mailId);
}
public void SendNotice (string subject, string body, int organizationId)
@@ -697,12 +697,12 @@ namespace Activizr.Logic.Pirates
public void CreateActivist (bool isPublic, bool isConfirmed)
{
PirateDb.GetDatabase().CreateActivist(Identity, isPublic, isConfirmed);
PirateDb.GetDatabaseForWriting().CreateActivist(Identity, isPublic, isConfirmed);
}
public void TerminateActivist ()
{
PirateDb.GetDatabase().TerminateActivist(Identity);
PirateDb.GetDatabaseForWriting().TerminateActivist(Identity);
}
public PersonRole AddRole (RoleType roleType, Organization organization, Geography geography)
+3 -3
View File
@@ -19,7 +19,7 @@ namespace Activizr.Logic.Pirates
public static PersonRole Create (int personId, RoleType roleType, int organizationId, int nodeId)
{
return FromIdentity(PirateDb.GetDatabase().CreateRole(personId, roleType, organizationId, nodeId));
return FromIdentity(PirateDb.GetDatabaseForWriting().CreateRole(personId, roleType, organizationId, nodeId));
}
public static PersonRole FromBasic (BasicPersonRole basic)
@@ -29,7 +29,7 @@ namespace Activizr.Logic.Pirates
public static PersonRole FromIdentity (int roleId)
{
return FromBasic(PirateDb.GetDatabase().GetRole(roleId));
return FromBasic(PirateDb.GetDatabaseForReading().GetRole(roleId));
}
#endregion
@@ -53,7 +53,7 @@ namespace Activizr.Logic.Pirates
public void Delete()
{
PirateDb.GetDatabase().DeleteRole(Identity);
PirateDb.GetDatabaseForWriting().DeleteRole(Identity);
// After this call, the role will be invalid.
}
+2 -2
View File
@@ -40,7 +40,7 @@ namespace Activizr.Logic.Pirates
public static RoleLookup FromOrganization (int organizationId)
{
Roles roles =
Roles.FromArray(PirateDb.GetDatabase().GetRolesForOrganization(organizationId));
Roles.FromArray(PirateDb.GetDatabaseForReading().GetRolesForOrganization(organizationId));
return new RoleLookup(roles);
}
@@ -48,7 +48,7 @@ namespace Activizr.Logic.Pirates
public static RoleLookup FromGeographyAndOrganization (int geographyId, int organizationId)
{
Roles roles =
Roles.FromArray(PirateDb.GetDatabase().GetRolesForOrganizationGeography(organizationId, geographyId));
Roles.FromArray(PirateDb.GetDatabaseForReading().GetRolesForOrganizationGeography(organizationId, geographyId));
return new RoleLookup(roles);
}
+9 -9
View File
@@ -53,7 +53,7 @@ namespace Activizr.Logic.Pirates
foreach (Organization org in orgLine)
{
BasicPersonRole[] upwardPersonRoles = PirateDb.GetDatabase().GetRolesForOrganizationGeographies(org.Identity,
BasicPersonRole[] upwardPersonRoles = PirateDb.GetDatabaseForReading().GetRolesForOrganizationGeographies(org.Identity,
nodeIds);
foreach (BasicPersonRole role in upwardPersonRoles)
@@ -102,7 +102,7 @@ namespace Activizr.Logic.Pirates
foreach (Organization org in orgTree)
{
BasicPersonRole[] downwardPersonRoles = PirateDb.GetDatabase().GetRolesForOrganizationGeographies(org.Identity,
BasicPersonRole[] downwardPersonRoles = PirateDb.GetDatabaseForReading().GetRolesForOrganizationGeographies(org.Identity,
nodeIds);
foreach (BasicPersonRole role in downwardPersonRoles)
@@ -144,7 +144,7 @@ namespace Activizr.Logic.Pirates
nodeIds = new int[0];
}
return PirateDb.GetDatabase().GetRolesForOrganizationsGeographies(orgIds, nodeIds);;
return PirateDb.GetDatabaseForReading().GetRolesForOrganizationsGeographies(orgIds, nodeIds);;
}
@@ -156,7 +156,7 @@ namespace Activizr.Logic.Pirates
public static Roles FromOrganization (int organizationId)
{
BasicPersonRole[] basicPersonRoles = PirateDb.GetDatabase().GetRolesForOrganization (organizationId);
BasicPersonRole[] basicPersonRoles = PirateDb.GetDatabaseForReading().GetRolesForOrganization (organizationId);
return FromArray(basicPersonRoles);
}
@@ -168,7 +168,7 @@ namespace Activizr.Logic.Pirates
public static Person GetLocalLead(int organizationId, int geographyId)
{
BasicPersonRole[] personRoles = PirateDb.GetDatabase().GetRolesForOrganizationGeography(organizationId, geographyId);
BasicPersonRole[] personRoles = PirateDb.GetDatabaseForReading().GetRolesForOrganizationGeography(organizationId, geographyId);
foreach (BasicPersonRole role in personRoles)
{
@@ -183,7 +183,7 @@ namespace Activizr.Logic.Pirates
public static Person GetChairman (Organization organization)
{
BasicPersonRole[] personRoles = PirateDb.GetDatabase().GetRolesForOrganization(organization.Identity);
BasicPersonRole[] personRoles = PirateDb.GetDatabaseForReading().GetRolesForOrganization(organization.Identity);
foreach (BasicPersonRole role in personRoles)
{
@@ -203,7 +203,7 @@ namespace Activizr.Logic.Pirates
public static People GetLocalDeputies(int organizationId, int geographyId)
{
BasicPersonRole[] personRoles = PirateDb.GetDatabase().GetRolesForOrganizationGeography(organizationId, geographyId);
BasicPersonRole[] personRoles = PirateDb.GetDatabaseForReading().GetRolesForOrganizationGeography(organizationId, geographyId);
People result = new People();
foreach (BasicPersonRole role in personRoles)
@@ -224,7 +224,7 @@ namespace Activizr.Logic.Pirates
// Expensive op:
BasicPersonRole[] basicPersonRoles =
PirateDb.GetDatabase().GetRolesForOrganizationsGeographies(organization.GetTree().Identities,
PirateDb.GetDatabaseForReading().GetRolesForOrganizationsGeographies(organization.GetTree().Identities,
geography.GetTree().Identities);
var lookup = new Dictionary<int, bool>();
@@ -248,7 +248,7 @@ namespace Activizr.Logic.Pirates
public static Roles GetAll()
{
return FromArray(PirateDb.GetDatabase().GetRoles());
return FromArray(PirateDb.GetDatabaseForReading().GetRoles());
}
}
}
+6 -6
View File
@@ -24,7 +24,7 @@ namespace Activizr.Logic.Pirates
public static Volunteer FromIdentity (int volunteerId)
{
return FromBasic(PirateDb.GetDatabase().GetVolunteer(volunteerId));
return FromBasic(PirateDb.GetDatabaseForReading().GetVolunteer(volunteerId));
}
public static Volunteer FromBasic (BasicVolunteer basic)
@@ -39,7 +39,7 @@ namespace Activizr.Logic.Pirates
public static Volunteer Create (int personId, int ownerPersonId)
{
return FromIdentity(PirateDb.GetDatabase().CreateVolunteer(personId, ownerPersonId));
return FromIdentity(PirateDb.GetDatabaseForWriting().CreateVolunteer(personId, ownerPersonId));
}
#endregion
@@ -67,7 +67,7 @@ namespace Activizr.Logic.Pirates
set
{
this.ownerPerson = value;
PirateDb.GetDatabase().SetVolunteerOwnerPersonId(Identity, value.Identity);
PirateDb.GetDatabaseForWriting().SetVolunteerOwnerPersonId(Identity, value.Identity);
}
}
@@ -120,7 +120,7 @@ namespace Activizr.Logic.Pirates
public VolunteerRoles Roles
{
get { return VolunteerRoles.FromArray(PirateDb.GetDatabase().GetVolunteerRolesByVolunteer(Identity)); }
get { return VolunteerRoles.FromArray(PirateDb.GetDatabaseForReading().GetVolunteerRolesByVolunteer(Identity)); }
}
public void AddRole (Organization organization, Geography geography, RoleType roleType)
@@ -130,12 +130,12 @@ namespace Activizr.Logic.Pirates
public void AddRole (int organizationId, int geographyId, RoleType roleType)
{
PirateDb.GetDatabase().CreateVolunteerRole(Identity, organizationId, geographyId, roleType);
PirateDb.GetDatabaseForWriting().CreateVolunteerRole(Identity, organizationId, geographyId, roleType);
}
public void Close (string comments)
{
PirateDb.GetDatabase().CloseVolunteer(Identity, comments);
PirateDb.GetDatabaseForWriting().CloseVolunteer(Identity, comments);
}
private void PopulateCache ()
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Activizr.Logic.Pirates
public static VolunteerRole FromIdentity (int identity)
{
return FromBasic(PirateDb.GetDatabase().GetVolunteerRole(identity));
return FromBasic(PirateDb.GetDatabaseForReading().GetVolunteerRole(identity));
}
public void Close (bool wasAssigned)
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Activizr.Logic.Pirates
{
public static Volunteers GetOpen()
{
return FromArray(PirateDb.GetDatabase().GetOpenVolunteers());
return FromArray(PirateDb.GetDatabaseForReading().GetOpenVolunteers());
}
public static Volunteers FromArray (BasicVolunteer[] basicArray)
+3 -7
View File
@@ -46,8 +46,6 @@ namespace Activizr.Logic.Security
/// <exception cref="UnauthorizedAccessException">This function will throw an UnauthorizedAccessException if the user cannot be authenticated using the supplied credentials.</exception>
public static Person Authenticate (string loginToken, string password)
{
PirateDb database = PirateDb.GetDatabase();
// Get the list of people that match the login token.
People candidatePeople = GetPeopleByLoginToken(loginToken);
@@ -199,7 +197,7 @@ namespace Activizr.Logic.Security
{
People result = new People();
PirateDb database = PirateDb.GetDatabase();
PirateDb database = PirateDb.GetDatabaseForReading();
// First, is the login token numeric? If so, add it as is and is a valid person.
@@ -254,14 +252,13 @@ namespace Activizr.Logic.Security
public static Person RequestNewPasswordProcess (string eMail, string URL)
{
PirateDb database = PirateDb.GetDatabase();
int personID = 0;
int.TryParse(eMail, out personID);
Person authenticatedUser = null;
People candidatePeople = null;
if (personID == 0)
{
BasicPerson[] people = database.GetPeopleFromEmailPattern(eMail.ToLower().Replace("%", "").Trim());
BasicPerson[] people = PirateDb.GetDatabaseForReading().GetPeopleFromEmailPattern(eMail.ToLower().Replace("%", "").Trim());
candidatePeople = People.FromArray(people);
// if multiple people share same e-mail, suppose the last one registered is the one to change.
@@ -435,7 +432,6 @@ namespace Activizr.Logic.Security
public static Person RequestActivistSignoffProcess (string eMail, string URL)
{
PirateDb database = PirateDb.GetDatabase();
int personID = 0;
int.TryParse(eMail, out personID);
Person authenticatedUser = null;
@@ -443,7 +439,7 @@ namespace Activizr.Logic.Security
bool personIsActivist = false;
if (personID == 0)
{
BasicPerson[] people = database.GetPeopleFromEmailPattern(eMail.ToLower().Replace("%", "").Trim());
BasicPerson[] people = PirateDb.GetDatabaseForReading().GetPeopleFromEmailPattern(eMail.ToLower().Replace("%", "").Trim());
candidatePeople = People.FromArray(people);
// if multiple people share same e-mail, suppose the last one registered is the one to change.
+7 -7
View File
@@ -127,7 +127,7 @@ namespace Activizr.Logic.Security
Dictionary<Permission, List<RoleType>> tempDict
= new Dictionary<Permission, List<RoleType>>();
_PermissonsPerRoleTypeDict = new Dictionary<RoleType, Dictionary<Permission, bool>>();
BasicPermission[] allPermissions = PirateDb.GetDatabase().GetPermissionsTable();
BasicPermission[] allPermissions = PirateDb.GetDatabaseForReading().GetPermissionsTable();
foreach (BasicPermission bp in allPermissions)
{
RoleType role = bp.RoleType;
@@ -166,7 +166,7 @@ namespace Activizr.Logic.Security
public static Authority GetPersonAuthority (int personId)
{
return Authority.FromBasic(PirateDb.GetDatabase().GetPersonAuthority(Person.FromIdentity(personId)));
return Authority.FromBasic(PirateDb.GetDatabaseForReading().GetPersonAuthority(Person.FromIdentity(personId)));
}
@@ -441,13 +441,13 @@ namespace Activizr.Logic.Security
return people;
}
PirateDb database = PirateDb.GetDatabase();
PirateDb databaseRead = PirateDb.GetDatabaseForReading();
if (gracePeriod == -1)
gracePeriod = Membership.GracePeriod;
Dictionary<int, List<BasicMembership>> membershipTable = database.GetMembershipsForPeople(people.Identities, gracePeriod);
Dictionary<int, int> geographyTable = database.GetPeopleGeographies(people.Identities);
Dictionary<int, List<BasicMembership>> membershipTable = databaseRead.GetMembershipsForPeople(people.Identities, gracePeriod);
Dictionary<int, int> geographyTable = databaseRead.GetPeopleGeographies(people.Identities);
var clearedPeople = new Dictionary<int, Person>();
@@ -570,7 +570,7 @@ namespace Activizr.Logic.Security
// Get ALL unlisted people from database. They're not that many. Build a hashtable with them.
int[] anonymousPersonIds = PirateDb.GetDatabase().GetObjectsByOptionalData(ObjectType.Person, ObjectOptionalDataType.Anonymous, "1");
int[] anonymousPersonIds = PirateDb.GetDatabaseForReading().GetObjectsByOptionalData(ObjectType.Person, ObjectOptionalDataType.Anonymous, "1");
foreach (int anonymousPersonId in anonymousPersonIds)
{
@@ -736,7 +736,7 @@ namespace Activizr.Logic.Security
line.Add(Organization.FromIdentity(p));
BasicPersonRole[] basPersons
= PirateDb.GetDatabase().GetPeopleWithRoleType(roleType, line.Identities, new int[] { });
= PirateDb.GetDatabaseForReading().GetPeopleWithRoleType(roleType, line.Identities, new int[] { });
List<int> retList = new List<int>();
+3 -3
View File
@@ -32,17 +32,17 @@ namespace Activizr.Logic.Structure
public static Cities FromPostalCode (string postalCode, int countryId)
{
return FromArray(PirateDb.GetDatabase().GetCitiesByCountryAndPostalCode(countryId, postalCode));
return FromArray(PirateDb.GetDatabaseForReading().GetCitiesByCountryAndPostalCode(countryId, postalCode));
}
public static Cities FromName (string cityName, int countryId)
{
return FromArray(PirateDb.GetDatabase().GetCitiesByName(cityName, countryId));
return FromArray(PirateDb.GetDatabaseForReading().GetCitiesByName(cityName, countryId));
}
public static Cities ForCountry (string countryCode)
{
return FromArray(PirateDb.GetDatabase().GetCitiesByCountry (countryCode));
return FromArray(PirateDb.GetDatabaseForReading().GetCitiesByCountry (countryCode));
}
}
}
+2 -2
View File
@@ -32,12 +32,12 @@ namespace Activizr.Logic.Structure
public static City FromName (string cityName, int countryId)
{
return FromBasic(PirateDb.GetDatabase().GetCityByName(cityName, countryId));
return FromBasic(PirateDb.GetDatabaseForReading().GetCityByName(cityName, countryId));
}
public static City FromName (string cityName, string countryCode)
{
return FromBasic(PirateDb.GetDatabase().GetCityByName(cityName, countryCode));
return FromBasic(PirateDb.GetDatabaseForReading().GetCityByName(cityName, countryCode));
}
}
}
+2 -2
View File
@@ -9,12 +9,12 @@ namespace Activizr.Logic.Structure
{
public static Countries GetAll ()
{
return FromArray(PirateDb.GetDatabase().GetAllCountries());
return FromArray(PirateDb.GetDatabaseForReading().GetAllCountries());
}
public static Countries GetInUse ()
{
return FromArray(PirateDb.GetDatabase().GetCountriesInUse());
return FromArray(PirateDb.GetDatabaseForReading().GetCountriesInUse());
}
public static Countries FromArray (BasicCountry[] basicArray)
+2 -2
View File
@@ -28,12 +28,12 @@ namespace Activizr.Logic.Structure
public static Country FromIdentity (int identity)
{
return FromBasic(PirateDb.GetDatabase().GetCountry(identity));
return FromBasic(PirateDb.GetDatabaseForReading().GetCountry(identity));
}
public static Country FromCode (string countryCode)
{
return FromBasic(PirateDb.GetDatabase().GetCountry(countryCode));
return FromBasic(PirateDb.GetDatabaseForReading().GetCountry(countryCode));
}
public Geography Geography
+2 -2
View File
@@ -36,7 +36,7 @@ namespace Activizr.Logic.Structure
public static Geographies FromIdentities (int[] geoIds)
{
return FromArray(GeographyCache.GetGeographies(geoIds));
// return FromArray(PirateDb.GetDatabase().GetGeographies(geoIds));
// return FromArray(PirateDb.GetDatabaseForReading().GetGeographies(geoIds));
}
@@ -47,7 +47,7 @@ namespace Activizr.Logic.Structure
public static Geographies FromLevel (int countryId, GeographyLevel level)
{
return FromIdentities(PirateDb.GetDatabase().GetGeographyIdsFromLevel(countryId, level));
return FromIdentities(PirateDb.GetDatabaseForReading().GetGeographyIdsFromLevel(countryId, level));
}
#endregion
+7 -7
View File
@@ -35,7 +35,7 @@ namespace Activizr.Logic.Structure
public static Geography FromIdentity (int geographyId)
{
return FromBasic(GeographyCache.GetGeography(geographyId));
//return FromBasic(PirateDb.GetDatabase().GetGeography(geographyId));
//return FromBasic(PirateDb.GetDatabaseForReading().GetGeography(geographyId));
}
public static Geography FromName (string geographyName)
@@ -43,7 +43,7 @@ namespace Activizr.Logic.Structure
// TODO: Possible dupes here, need resolution once we see the extent of the problem
return FromBasic(GeographyCache.GetGeographyByName(geographyName));
//return FromBasic(PirateDb.GetDatabase().GetGeographyByName(geographyName));
//return FromBasic(PirateDb.GetDatabaseForReading().GetGeographyByName(geographyName));
}
@@ -55,7 +55,7 @@ namespace Activizr.Logic.Structure
public static Geography FromOfficialDesignation (int countryId, GeographyLevel level, string designation)
{
return
FromIdentity(PirateDb.GetDatabase().GetGeographyIdFromOfficialDesignation(countryId, level,
FromIdentity(PirateDb.GetDatabaseForReading().GetGeographyIdFromOfficialDesignation(countryId, level,
designation));
}
@@ -134,13 +134,13 @@ namespace Activizr.Logic.Structure
public Geographies GetTree ()
{
return Geographies.FromArray(GeographyCache.GetGeographyTree(Identity));
// return Geographies.FromArray(PirateDb.GetDatabase().GetGeographyTree(Identity));
// return Geographies.FromArray(PirateDb.GetDatabaseForReading().GetGeographyTree(Identity));
}
public Geographies GetLine ()
{
return Geographies.FromArray(GeographyCache.GetGeographyLine(Identity));
//return Geographies.FromArray(PirateDb.GetDatabase().GetGeographyLine(Identity));
//return Geographies.FromArray(PirateDb.GetDatabaseForReading().GetGeographyLine(Identity));
}
public bool Inherits (Geography prospectiveParent)
@@ -168,7 +168,7 @@ namespace Activizr.Logic.Structure
public bool AtLevel (GeographyLevel level)
{
GeographyLevel[] levels = PirateDb.GetDatabase().GetGeographyLevelsAtGeographyId(Identity);
GeographyLevel[] levels = PirateDb.GetDatabaseForReading().GetGeographyLevelsAtGeographyId(Identity);
foreach (GeographyLevel potentialMatch in levels)
{
@@ -183,7 +183,7 @@ namespace Activizr.Logic.Structure
public BasicGeographyDesignation[] GetGeographyDesignations ()
{
return PirateDb.GetDatabase().GetGeographyDesignationsForGeographyId(Identity);
return PirateDb.GetDatabaseForReading().GetGeographyDesignationsForGeographyId(Identity);
}
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ namespace Activizr.Logic.Structure
public static GeographyStatistics GeneratePresent (int[] memberCountForOrganizations)
{
Dictionary<int, int> voterCounts = PirateDb.GetDatabase().GetGeographyVoterCounts();
Dictionary<int, int> voterCounts = PirateDb.GetDatabaseForReading().GetGeographyVoterCounts();
var result = new GeographyStatistics();
// Step 1 - tally the leaf nodes
+7 -7
View File
@@ -40,7 +40,7 @@ namespace Activizr.Logic.Structure
{
return FromBasic(OrganizationCache.GetOrganization(identity));
//return FromBasic(PirateDb.GetDatabase().GetOrganization(identity));
//return FromBasic(PirateDb.GetDatabaseForReading().GetOrganization(identity));
}
public static Organization FromBasic (BasicOrganization basic)
@@ -107,13 +107,13 @@ namespace Activizr.Logic.Structure
{
return Organizations.FromArray(OrganizationCache.GetOrganizationLine(Identity));
//return Organizations.FromArray(PirateDb.GetDatabase().GetOrganizationLine(Identity));
//return Organizations.FromArray(PirateDb.GetDatabaseForReading().GetOrganizationLine(Identity));
}
public Organizations GetTree ()
{
return Organizations.FromArray(OrganizationCache.GetOrganizationTree(Identity));
//return Organizations.FromArray(PirateDb.GetDatabase().GetOrganizationTree(Identity));
//return Organizations.FromArray(PirateDb.GetDatabaseForReading().GetOrganizationTree(Identity));
}
public int GetMemberCount ()
@@ -123,7 +123,7 @@ namespace Activizr.Logic.Structure
public NewsletterFeeds GetNewsletterFeeds ()
{
return NewsletterFeeds.FromArray(PirateDb.GetDatabase().GetNewsletterFeedsForOrganization(Identity));
return NewsletterFeeds.FromArray(PirateDb.GetDatabaseForReading().GetNewsletterFeedsForOrganization(Identity));
}
@@ -262,7 +262,7 @@ namespace Activizr.Logic.Structure
if (this.uptakeGeographies == null)
{
this.uptakeGeographies =
Geographies.FromIdentities(PirateDb.GetDatabase().GetOrganizationUptakeGeographyIds(Identity));
Geographies.FromIdentities(PirateDb.GetDatabaseForReading().GetOrganizationUptakeGeographyIds(Identity));
}
return this.uptakeGeographies.AsReadOnly();
@@ -271,7 +271,7 @@ namespace Activizr.Logic.Structure
public UptakeGeography[] GetUptakeGeographies (bool others)
{
BasicUptakeGeography[] basics = PirateDb.GetDatabase().GetOrganizationUptakeGeographies(Identity, others);
BasicUptakeGeography[] basics = PirateDb.GetDatabaseForReading().GetOrganizationUptakeGeographies(Identity, others);
List<UptakeGeography> retVal = new List<UptakeGeography>();
foreach (BasicUptakeGeography b in basics)
{
@@ -579,7 +579,7 @@ namespace Activizr.Logic.Structure
{
Organizations line = GetLine();
BasicPersonRole[] treasurers
= PirateDb.GetDatabase().GetPeopleWithRoleType(RoleType.OrganizationTreasurer, line.Identities, new int[] { });
= PirateDb.GetDatabaseForReading().GetPeopleWithRoleType(RoleType.OrganizationTreasurer, line.Identities, new int[] { });
if (treasurers.Length == 0)
throw new Exception("No Treasurer Found");

Some files were not shown because too many files have changed in this diff Show More