From 8a4608b2cb703e91b2b54787718cac3b3201353b Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 6 Nov 2012 07:37:48 +0000 Subject: [PATCH] Committing split of dbops into read/write/admin ops, for security and multi-db deployments. THIS BREAKS THE INSTALLATION. --- Backend/OneOffs.cs | 6 +- Database/Database-Constructors.cs | 24 +++++++ Logic/Cache/GeographyCache.cs | 10 +-- Logic/Cache/MailTemplateCache.cs | 2 +- Logic/Cache/OrganizationCache.cs | 16 ++--- Logic/Communications/AutoMail.cs | 8 +-- .../Communications/CommunicationTurnaround.cs | 8 +-- .../CommunicationTurnarounds.cs | 4 +- Logic/Communications/MailTemplate.cs | 8 +-- Logic/Communications/NewsletterFeed.cs | 2 +- Logic/Communications/OutboundMail.cs | 32 +++++----- Logic/Communications/OutboundMailRecipient.cs | 4 +- Logic/Communications/OutboundMails.cs | 2 +- Logic/Communications/PaperLetter.cs | 4 +- Logic/Communications/PaperLetters.cs | 4 +- Logic/Communications/PhoneMessageReceiver.cs | 2 +- .../Communications/PhoneMessageTransmitter.cs | 2 +- Logic/DataObjects/MembershipsDataObject.cs | 2 +- Logic/Financial/ExpenseClaim.cs | 40 ++++++------ Logic/Financial/ExpenseClaims.cs | 10 +-- Logic/Financial/FinancialAccount.cs | 30 ++++----- Logic/Financial/FinancialAccounts.cs | 18 +++--- Logic/Financial/FinancialTransaction.cs | 20 +++--- Logic/Financial/FinancialTransactionRow.cs | 2 +- Logic/Financial/FinancialTransactions.cs | 8 +-- Logic/Financial/FinancialValidations.cs | 4 +- Logic/Financial/InboundInvoice.cs | 20 +++--- Logic/Financial/InboundInvoices.cs | 2 +- Logic/Financial/OutboundInvoice.cs | 14 ++--- Logic/Financial/OutboundInvoiceItem.cs | 2 +- Logic/Financial/OutboundInvoiceItems.cs | 2 +- Logic/Financial/OutboundInvoices.cs | 4 +- Logic/Financial/Payment.cs | 10 +-- Logic/Financial/PaymentGroup.cs | 12 ++-- Logic/Financial/PaymentGroups.cs | 4 +- Logic/Financial/PaymentInformation.cs | 2 +- Logic/Financial/Payments.cs | 2 +- Logic/Financial/Payout.cs | 32 +++++----- Logic/Financial/Payouts.cs | 4 +- Logic/Financial/Payroll.cs | 4 +- Logic/Financial/PayrollAdjustment.cs | 6 +- Logic/Financial/PayrollAdjustments.cs | 4 +- Logic/Financial/PayrollItem.cs | 2 +- Logic/Financial/Refund.cs | 4 +- Logic/Financial/Salaries.cs | 2 +- Logic/Financial/Salary.cs | 14 ++--- Logic/Financial/TaxLevels.cs | 6 +- Logic/Governance/Ballot.cs | 14 ++--- Logic/Governance/Ballots.cs | 4 +- Logic/Governance/Election.cs | 4 +- Logic/Governance/Meeting.cs | 2 +- Logic/Governance/MeetingElection.cs | 18 +++--- Logic/Governance/MeetingElectionCandidate.cs | 12 ++-- Logic/Governance/MeetingElectionCandidates.cs | 2 +- Logic/Governance/MeetingElectionVote.cs | 12 ++-- Logic/Governance/MeetingElectionVoters.cs | 6 +- Logic/Governance/MeetingElectionVotes.cs | 2 +- Logic/Governance/MeetingElections.cs | 6 +- Logic/Governance/Motion.cs | 4 +- Logic/Governance/MotionAmendment.cs | 4 +- Logic/Governance/MotionAmendments.cs | 4 +- Logic/Governance/Motions.cs | 2 +- Logic/Media/MediaCategories.cs | 4 +- Logic/Media/MediaCategory.cs | 2 +- Logic/Media/MediaEntries.cs | 18 +++--- Logic/Media/MediaEntry.cs | 2 +- Logic/Media/Reporter.cs | 10 +-- Logic/Pirates/Activists.cs | 4 +- Logic/Pirates/ChurnData.cs | 12 ++-- Logic/Pirates/ExternalActivities.cs | 4 +- Logic/Pirates/ExternalActivity.cs | 4 +- Logic/Pirates/ExternalIdentity.cs | 12 ++-- Logic/Pirates/Membership.cs | 18 +++--- Logic/Pirates/MembershipEvents.cs | 4 +- Logic/Pirates/Memberships.cs | 22 +++---- Logic/Pirates/Parley.cs | 14 ++--- Logic/Pirates/ParleyAttendee.cs | 10 +-- Logic/Pirates/ParleyAttendees.cs | 2 +- Logic/Pirates/ParleyOption.cs | 4 +- Logic/Pirates/ParleyOptions.cs | 6 +- Logic/Pirates/Parleys.cs | 8 +-- Logic/Pirates/PaymentCode.cs | 8 +-- Logic/Pirates/People.cs | 36 +++++------ Logic/Pirates/Person.cs | 62 +++++++++---------- Logic/Pirates/PersonRole.cs | 6 +- Logic/Pirates/RoleLookup.cs | 4 +- Logic/Pirates/Roles.cs | 18 +++--- Logic/Pirates/Volunteer.cs | 12 ++-- Logic/Pirates/VolunteerRole.cs | 2 +- Logic/Pirates/Volunteers.cs | 2 +- Logic/Security/Authentication.cs | 10 +-- Logic/Security/Authorization.cs | 14 ++--- Logic/Structure/Cities.cs | 6 +- Logic/Structure/City.cs | 4 +- Logic/Structure/Countries.cs | 4 +- Logic/Structure/Country.cs | 4 +- Logic/Structure/Geographies.cs | 4 +- Logic/Structure/Geography.cs | 14 ++--- Logic/Structure/GeographyStatistics.cs | 2 +- Logic/Structure/Organization.cs | 14 ++--- Logic/Structure/Organizations.cs | 8 +-- Logic/Structure/PostalCodes.cs | 2 +- Logic/Support/Document.cs | 8 +-- Logic/Support/Documents.cs | 2 +- Logic/Support/ObjectOptionalData.cs | 6 +- Logic/Support/Optimizations.cs | 6 +- Logic/Support/PWEvents.cs | 14 ++--- Logic/Support/PWLog.cs | 6 +- Logic/Support/Persistence.cs | 6 +- Logic/Support/TemporaryIdentity.cs | 2 +- Logic/Support/UrlTranslations.cs | 6 +- Utility/BotCode/BlogTop50Scraper.cs | 2 +- Utility/BotCode/TurnaroundTracker.cs | 2 +- 113 files changed, 498 insertions(+), 478 deletions(-) diff --git a/Backend/OneOffs.cs b/Backend/OneOffs.cs index e6014899..8b7767ba 100644 --- a/Backend/OneOffs.cs +++ b/Backend/OneOffs.cs @@ -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..."); diff --git a/Database/Database-Constructors.cs b/Database/Database-Constructors.cs index 377ceaeb..ebf54f2c 100644 --- a/Database/Database-Constructors.cs +++ b/Database/Database-Constructors.cs @@ -15,6 +15,23 @@ namespace Activizr.Database /// 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; diff --git a/Logic/Cache/GeographyCache.cs b/Logic/Cache/GeographyCache.cs index 873155a4..884ecf2e 100644 --- a/Logic/Cache/GeographyCache.cs +++ b/Logic/Cache/GeographyCache.cs @@ -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> 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); } ************************/ diff --git a/Logic/Cache/MailTemplateCache.cs b/Logic/Cache/MailTemplateCache.cs index c73d2deb..7454129c 100644 --- a/Logic/Cache/MailTemplateCache.cs +++ b/Logic/Cache/MailTemplateCache.cs @@ -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 tmplList = new List(basicTemplates); __MailTemplateCache[templateName] = tmplList; diff --git a/Logic/Cache/OrganizationCache.cs b/Logic/Cache/OrganizationCache.cs index e3cf647e..b6418e2f 100644 --- a/Logic/Cache/OrganizationCache.cs +++ b/Logic/Cache/OrganizationCache.cs @@ -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; diff --git a/Logic/Communications/AutoMail.cs b/Logic/Communications/AutoMail.cs index a7e22a52..a10ea4d6 100644 --- a/Logic/Communications/AutoMail.cs +++ b/Logic/Communications/AutoMail.cs @@ -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(); } } } \ No newline at end of file diff --git a/Logic/Communications/CommunicationTurnaround.cs b/Logic/Communications/CommunicationTurnaround.cs index 52ccfd5c..914744fe 100644 --- a/Logic/Communications/CommunicationTurnaround.cs +++ b/Logic/Communications/CommunicationTurnaround.cs @@ -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; } diff --git a/Logic/Communications/CommunicationTurnarounds.cs b/Logic/Communications/CommunicationTurnarounds.cs index 0ccd2c7d..36004b1e 100644 --- a/Logic/Communications/CommunicationTurnarounds.cs +++ b/Logic/Communications/CommunicationTurnarounds.cs @@ -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)); } } diff --git a/Logic/Communications/MailTemplate.cs b/Logic/Communications/MailTemplate.cs index 4b64934e..5b01dfcd 100644 --- a/Logic/Communications/MailTemplate.cs +++ b/Logic/Communications/MailTemplate.cs @@ -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 GetAll () { - BasicMailTemplate[] basic = PirateDb.GetDatabase().GetAllMailTemplates(); + BasicMailTemplate[] basic = PirateDb.GetDatabaseForReading().GetAllMailTemplates(); List resultlist = new List(); 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; } diff --git a/Logic/Communications/NewsletterFeed.cs b/Logic/Communications/NewsletterFeed.cs index 18f9084a..1019d5fa 100644 --- a/Logic/Communications/NewsletterFeed.cs +++ b/Logic/Communications/NewsletterFeed.cs @@ -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) diff --git a/Logic/Communications/OutboundMail.cs b/Logic/Communications/OutboundMail.cs index a7935fae..352a1cbb 100644 --- a/Logic/Communications/OutboundMail.cs +++ b/Logic/Communications/OutboundMail.cs @@ -58,7 +58,7 @@ namespace Activizr.Logic.Communications /// An OutboundMail from the database 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 retList = new List(); 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++; } diff --git a/Logic/Communications/OutboundMailRecipient.cs b/Logic/Communications/OutboundMailRecipient.cs index 46ea3473..92e462b0 100644 --- a/Logic/Communications/OutboundMailRecipient.cs +++ b/Logic/Communications/OutboundMailRecipient.cs @@ -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); } } } \ No newline at end of file diff --git a/Logic/Communications/OutboundMails.cs b/Logic/Communications/OutboundMails.cs index 176fdd2d..57ff4e93 100644 --- a/Logic/Communications/OutboundMails.cs +++ b/Logic/Communications/OutboundMails.cs @@ -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); } diff --git a/Logic/Communications/PaperLetter.cs b/Logic/Communications/PaperLetter.cs index 9755dd66..5656eabc 100644 --- a/Logic/Communications/PaperLetter.cs +++ b/Logic/Communications/PaperLetter.cs @@ -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) diff --git a/Logic/Communications/PaperLetters.cs b/Logic/Communications/PaperLetters.cs index 99e6b32c..09c7dddb 100644 --- a/Logic/Communications/PaperLetters.cs +++ b/Logic/Communications/PaperLetters.cs @@ -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)); } } } diff --git a/Logic/Communications/PhoneMessageReceiver.cs b/Logic/Communications/PhoneMessageReceiver.cs index 99a0395a..f41f313f 100644 --- a/Logic/Communications/PhoneMessageReceiver.cs +++ b/Logic/Communications/PhoneMessageReceiver.cs @@ -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. diff --git a/Logic/Communications/PhoneMessageTransmitter.cs b/Logic/Communications/PhoneMessageTransmitter.cs index 2d8e5a60..a3c155c2 100644 --- a/Logic/Communications/PhoneMessageTransmitter.cs +++ b/Logic/Communications/PhoneMessageTransmitter.cs @@ -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); diff --git a/Logic/DataObjects/MembershipsDataObject.cs b/Logic/DataObjects/MembershipsDataObject.cs index 84296d87..e884237d 100644 --- a/Logic/DataObjects/MembershipsDataObject.cs +++ b/Logic/DataObjects/MembershipsDataObject.cs @@ -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__ diff --git a/Logic/Financial/ExpenseClaim.cs b/Logic/Financial/ExpenseClaim.cs index e16cdabb..1168c33f 100644 --- a/Logic/Financial/ExpenseClaim.cs +++ b/Logic/Financial/ExpenseClaim.cs @@ -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; diff --git a/Logic/Financial/ExpenseClaims.cs b/Logic/Financial/ExpenseClaims.cs index fb962b25..22140e3c 100644 --- a/Logic/Financial/ExpenseClaims.cs +++ b/Logic/Financial/ExpenseClaims.cs @@ -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)); } } diff --git a/Logic/Financial/FinancialAccount.cs b/Logic/Financial/FinancialAccount.cs index a33ef90d..4a1b940d 100644 --- a/Logic/Financial/FinancialAccount.cs +++ b/Logic/Financial/FinancialAccount.cs @@ -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 () diff --git a/Logic/Financial/FinancialAccounts.cs b/Logic/Financial/FinancialAccounts.cs index 530c03a1..784a78aa 100644 --- a/Logic/Financial/FinancialAccounts.cs +++ b/Logic/Financial/FinancialAccounts.cs @@ -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 result = new Dictionary(); - 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. diff --git a/Logic/Financial/FinancialTransaction.cs b/Logic/Financial/FinancialTransaction.cs index 17603471..72dd2011 100644 --- a/Logic/Financial/FinancialTransaction.cs +++ b/Logic/Financial/FinancialTransaction.cs @@ -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) diff --git a/Logic/Financial/FinancialTransactionRow.cs b/Logic/Financial/FinancialTransactionRow.cs index ab7551c7..064ad34e 100644 --- a/Logic/Financial/FinancialTransactionRow.cs +++ b/Logic/Financial/FinancialTransactionRow.cs @@ -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 diff --git a/Logic/Financial/FinancialTransactions.cs b/Logic/Financial/FinancialTransactions.cs index 82a7ac01..b5edfd2a 100644 --- a/Logic/Financial/FinancialTransactions.cs +++ b/Logic/Financial/FinancialTransactions.cs @@ -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)); } diff --git a/Logic/Financial/FinancialValidations.cs b/Logic/Financial/FinancialValidations.cs index fcb49f1d..0c547b6a 100644 --- a/Logic/Financial/FinancialValidations.cs +++ b/Logic/Financial/FinancialValidations.cs @@ -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)); } } diff --git a/Logic/Financial/InboundInvoice.cs b/Logic/Financial/InboundInvoice.cs index 94960039..c0973134 100644 --- a/Logic/Financial/InboundInvoice.cs +++ b/Logic/Financial/InboundInvoice.cs @@ -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; diff --git a/Logic/Financial/InboundInvoices.cs b/Logic/Financial/InboundInvoices.cs index 9b98c9e6..9a135d1c 100644 --- a/Logic/Financial/InboundInvoices.cs +++ b/Logic/Financial/InboundInvoices.cs @@ -28,7 +28,7 @@ namespace Activizr.Logic.Financial /// The list of inbound invoices. 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)); diff --git a/Logic/Financial/OutboundInvoice.cs b/Logic/Financial/OutboundInvoice.cs index af937771..b9539f54 100644 --- a/Logic/Financial/OutboundInvoice.cs +++ b/Logic/Financial/OutboundInvoice.cs @@ -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; } } diff --git a/Logic/Financial/OutboundInvoiceItem.cs b/Logic/Financial/OutboundInvoiceItem.cs index e520d9cc..4432e9bc 100644 --- a/Logic/Financial/OutboundInvoiceItem.cs +++ b/Logic/Financial/OutboundInvoiceItem.cs @@ -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 diff --git a/Logic/Financial/OutboundInvoiceItems.cs b/Logic/Financial/OutboundInvoiceItems.cs index d4bd056f..cddd0694 100644 --- a/Logic/Financial/OutboundInvoiceItems.cs +++ b/Logic/Financial/OutboundInvoiceItems.cs @@ -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)); } } } diff --git a/Logic/Financial/OutboundInvoices.cs b/Logic/Financial/OutboundInvoices.cs index 5606fa97..0a3a120f 100644 --- a/Logic/Financial/OutboundInvoices.cs +++ b/Logic/Financial/OutboundInvoices.cs @@ -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)); } } } diff --git a/Logic/Financial/Payment.cs b/Logic/Financial/Payment.cs index c273600a..df1def94 100644 --- a/Logic/Financial/Payment.cs +++ b/Logic/Financial/Payment.cs @@ -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); } } diff --git a/Logic/Financial/PaymentGroup.cs b/Logic/Financial/PaymentGroup.cs index 9e5b4fbd..64b35ddc 100644 --- a/Logic/Financial/PaymentGroup.cs +++ b/Logic/Financial/PaymentGroup.cs @@ -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); } } diff --git a/Logic/Financial/PaymentGroups.cs b/Logic/Financial/PaymentGroups.cs index 7826ad10..69abcb55 100644 --- a/Logic/Financial/PaymentGroups.cs +++ b/Logic/Financial/PaymentGroups.cs @@ -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)); } } } diff --git a/Logic/Financial/PaymentInformation.cs b/Logic/Financial/PaymentInformation.cs index df52f583..bc3b0bd1 100644 --- a/Logic/Financial/PaymentInformation.cs +++ b/Logic/Financial/PaymentInformation.cs @@ -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); } diff --git a/Logic/Financial/Payments.cs b/Logic/Financial/Payments.cs index 4eafe471..c3d385a2 100644 --- a/Logic/Financial/Payments.cs +++ b/Logic/Financial/Payments.cs @@ -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)); } } } diff --git a/Logic/Financial/Payout.cs b/Logic/Financial/Payout.cs index 637a835c..5429dfd2 100644 --- a/Logic/Financial/Payout.cs +++ b/Logic/Financial/Payout.cs @@ -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; } diff --git a/Logic/Financial/Payouts.cs b/Logic/Financial/Payouts.cs index 5d66e360..a324ff01 100644 --- a/Logic/Financial/Payouts.cs +++ b/Logic/Financial/Payouts.cs @@ -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)); } } diff --git a/Logic/Financial/Payroll.cs b/Logic/Financial/Payroll.cs index ffd434c7..f928f74d 100644 --- a/Logic/Financial/Payroll.cs +++ b/Logic/Financial/Payroll.cs @@ -29,7 +29,7 @@ namespace Activizr.Logic.Financial /// The payroll. 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 /// The payroll. 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)); } } } diff --git a/Logic/Financial/PayrollAdjustment.cs b/Logic/Financial/PayrollAdjustment.cs index 47c8bc9f..fe0f5b51 100644 --- a/Logic/Financial/PayrollAdjustment.cs +++ b/Logic/Financial/PayrollAdjustment.cs @@ -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); } diff --git a/Logic/Financial/PayrollAdjustments.cs b/Logic/Financial/PayrollAdjustments.cs index d3c35eaf..f605f1a3 100644 --- a/Logic/Financial/PayrollAdjustments.cs +++ b/Logic/Financial/PayrollAdjustments.cs @@ -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)); } } } diff --git a/Logic/Financial/PayrollItem.cs b/Logic/Financial/PayrollItem.cs index 8967a177..b8290b8a 100644 --- a/Logic/Financial/PayrollItem.cs +++ b/Logic/Financial/PayrollItem.cs @@ -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)); } diff --git a/Logic/Financial/Refund.cs b/Logic/Financial/Refund.cs index 3012172f..c236ca42 100644 --- a/Logic/Financial/Refund.cs +++ b/Logic/Financial/Refund.cs @@ -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); diff --git a/Logic/Financial/Salaries.cs b/Logic/Financial/Salaries.cs index 5e8481dd..97ee7330 100644 --- a/Logic/Financial/Salaries.cs +++ b/Logic/Financial/Salaries.cs @@ -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)); } diff --git a/Logic/Financial/Salary.cs b/Logic/Financial/Salary.cs index 46985f9e..9627a742 100644 --- a/Logic/Financial/Salary.cs +++ b/Logic/Financial/Salary.cs @@ -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) diff --git a/Logic/Financial/TaxLevels.cs b/Logic/Financial/TaxLevels.cs index eb6a5c5b..77f71dd3 100644 --- a/Logic/Financial/TaxLevels.cs +++ b/Logic/Financial/TaxLevels.cs @@ -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); } } diff --git a/Logic/Governance/Ballot.cs b/Logic/Governance/Ballot.cs index 474ed19b..28890171 100644 --- a/Logic/Governance/Ballot.cs +++ b/Logic/Governance/Ballot.cs @@ -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; } diff --git a/Logic/Governance/Ballots.cs b/Logic/Governance/Ballots.cs index 9519e38f..0fce2a08 100644 --- a/Logic/Governance/Ballots.cs +++ b/Logic/Governance/Ballots.cs @@ -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 GetBallotsForPerson (Person person) { - return PirateDb.GetDatabase().GetBallotsForPerson(person.Identity); + return PirateDb.GetDatabaseForReading().GetBallotsForPerson(person.Identity); } } } diff --git a/Logic/Governance/Election.cs b/Logic/Governance/Election.cs index b638cde3..a56c9a09 100644 --- a/Logic/Governance/Election.cs +++ b/Logic/Governance/Election.cs @@ -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); } } diff --git a/Logic/Governance/Meeting.cs b/Logic/Governance/Meeting.cs index dca73b10..f8f6c580 100644 --- a/Logic/Governance/Meeting.cs +++ b/Logic/Governance/Meeting.cs @@ -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)); } } } \ No newline at end of file diff --git a/Logic/Governance/MeetingElection.cs b/Logic/Governance/MeetingElection.cs index 458c4892..a6391033 100644 --- a/Logic/Governance/MeetingElection.cs +++ b/Logic/Governance/MeetingElection.cs @@ -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 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; } } diff --git a/Logic/Governance/MeetingElectionCandidate.cs b/Logic/Governance/MeetingElectionCandidate.cs index 2c966ffb..29f84cb9 100644 --- a/Logic/Governance/MeetingElectionCandidate.cs +++ b/Logic/Governance/MeetingElectionCandidate.cs @@ -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 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); } } } diff --git a/Logic/Governance/MeetingElectionCandidates.cs b/Logic/Governance/MeetingElectionCandidates.cs index 3dd69ac9..d3745d2b 100644 --- a/Logic/Governance/MeetingElectionCandidates.cs +++ b/Logic/Governance/MeetingElectionCandidates.cs @@ -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)); } } } \ No newline at end of file diff --git a/Logic/Governance/MeetingElectionVote.cs b/Logic/Governance/MeetingElectionVote.cs index 44ba754d..48bdb4c3 100644 --- a/Logic/Governance/MeetingElectionVote.cs +++ b/Logic/Governance/MeetingElectionVote.cs @@ -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); } } /* diff --git a/Logic/Governance/MeetingElectionVoters.cs b/Logic/Governance/MeetingElectionVoters.cs index 800fb861..35653084 100644 --- a/Logic/Governance/MeetingElectionVoters.cs +++ b/Logic/Governance/MeetingElectionVoters.cs @@ -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)); } } diff --git a/Logic/Governance/MeetingElectionVotes.cs b/Logic/Governance/MeetingElectionVotes.cs index e46c220f..c50f068c 100644 --- a/Logic/Governance/MeetingElectionVotes.cs +++ b/Logic/Governance/MeetingElectionVotes.cs @@ -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)); } } } \ No newline at end of file diff --git a/Logic/Governance/MeetingElections.cs b/Logic/Governance/MeetingElections.cs index 9647e293..1afa6461 100644 --- a/Logic/Governance/MeetingElections.cs +++ b/Logic/Governance/MeetingElections.cs @@ -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()); } } } \ No newline at end of file diff --git a/Logic/Governance/Motion.cs b/Logic/Governance/Motion.cs index bd3e0865..e7d62abf 100644 --- a/Logic/Governance/Motion.cs +++ b/Logic/Governance/Motion.cs @@ -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 diff --git a/Logic/Governance/MotionAmendment.cs b/Logic/Governance/MotionAmendment.cs index 68ccd30b..fce023ab 100644 --- a/Logic/Governance/MotionAmendment.cs +++ b/Logic/Governance/MotionAmendment.cs @@ -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 diff --git a/Logic/Governance/MotionAmendments.cs b/Logic/Governance/MotionAmendments.cs index 74400064..ab863694 100644 --- a/Logic/Governance/MotionAmendments.cs +++ b/Logic/Governance/MotionAmendments.cs @@ -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)); } } } \ No newline at end of file diff --git a/Logic/Governance/Motions.cs b/Logic/Governance/Motions.cs index ade2beeb..fa727057 100644 --- a/Logic/Governance/Motions.cs +++ b/Logic/Governance/Motions.cs @@ -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)); } } } \ No newline at end of file diff --git a/Logic/Media/MediaCategories.cs b/Logic/Media/MediaCategories.cs index 3c954d5a..e89149a6 100644 --- a/Logic/Media/MediaCategories.cs +++ b/Logic/Media/MediaCategories.cs @@ -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()); } } } \ No newline at end of file diff --git a/Logic/Media/MediaCategory.cs b/Logic/Media/MediaCategory.cs index a8304119..67e39687 100644 --- a/Logic/Media/MediaCategory.cs +++ b/Logic/Media/MediaCategory.cs @@ -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) diff --git a/Logic/Media/MediaEntries.cs b/Logic/Media/MediaEntries.cs index 8c8cf988..820ddd50 100644 --- a/Logic/Media/MediaEntries.cs +++ b/Logic/Media/MediaEntries.cs @@ -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 GetMediaTypeTable() { - return PirateDb.GetDatabase().GetMediaTypeTable(); + return PirateDb.GetDatabaseForReading().GetMediaTypeTable(); } public static Dictionary 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); } } } \ No newline at end of file diff --git a/Logic/Media/MediaEntry.cs b/Logic/Media/MediaEntry.cs index 779a0ed5..604539d1 100644 --- a/Logic/Media/MediaEntry.cs +++ b/Logic/Media/MediaEntry.cs @@ -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) diff --git a/Logic/Media/Reporter.cs b/Logic/Media/Reporter.cs index 7793908f..55d1d016 100644 --- a/Logic/Media/Reporter.cs +++ b/Logic/Media/Reporter.cs @@ -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 diff --git a/Logic/Pirates/Activists.cs b/Logic/Pirates/Activists.cs index 32ea9e79..5eb12410 100644 --- a/Logic/Pirates/Activists.cs +++ b/Logic/Pirates/Activists.cs @@ -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) diff --git a/Logic/Pirates/ChurnData.cs b/Logic/Pirates/ChurnData.cs index 9aba462a..b35618fd 100644 --- a/Logic/Pirates/ChurnData.cs +++ b/Logic/Pirates/ChurnData.cs @@ -53,28 +53,28 @@ namespace Activizr.Logic.Pirates /// The organization churned from. 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)); } diff --git a/Logic/Pirates/ExternalActivities.cs b/Logic/Pirates/ExternalActivities.cs index f4dbea20..2072467e 100644 --- a/Logic/Pirates/ExternalActivities.cs +++ b/Logic/Pirates/ExternalActivities.cs @@ -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 diff --git a/Logic/Pirates/ExternalActivity.cs b/Logic/Pirates/ExternalActivity.cs index e2f7130f..4cf5cd8e 100644 --- a/Logic/Pirates/ExternalActivity.cs +++ b/Logic/Pirates/ExternalActivity.cs @@ -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)); } diff --git a/Logic/Pirates/ExternalIdentity.cs b/Logic/Pirates/ExternalIdentity.cs index 8a4abb13..9df15fa0 100644 --- a/Logic/Pirates/ExternalIdentity.cs +++ b/Logic/Pirates/ExternalIdentity.cs @@ -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 ExternalItentitiesForPerson (int persId) { - List templist = PirateDb.GetDatabase().GetExternalIdentities(persId); + List templist = PirateDb.GetDatabaseForReading().GetExternalIdentities(persId); List retlist = new List(); @@ -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)); } diff --git a/Logic/Pirates/Membership.cs b/Logic/Pirates/Membership.cs index a68d7b44..b17aae44 100644 --- a/Logic/Pirates/Membership.cs +++ b/Logic/Pirates/Membership.cs @@ -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 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; diff --git a/Logic/Pirates/MembershipEvents.cs b/Logic/Pirates/MembershipEvents.cs index dfa3d097..0ec16abe 100644 --- a/Logic/Pirates/MembershipEvents.cs +++ b/Logic/Pirates/MembershipEvents.cs @@ -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(); var genderLookup = new Dictionary(); @@ -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 diff --git a/Logic/Pirates/Memberships.cs b/Logic/Pirates/Memberships.cs index 9f325431..4071762c 100644 --- a/Logic/Pirates/Memberships.cs +++ b/Logic/Pirates/Memberships.cs @@ -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> GetMembershipsForPeople (int[] personIds, int gracePeriod) { - return PirateDb.GetDatabase().GetMembershipsForPeople(personIds, gracePeriod); + return PirateDb.GetDatabaseForReading().GetMembershipsForPeople(personIds, gracePeriod); } } diff --git a/Logic/Pirates/Parley.cs b/Logic/Pirates/Parley.cs index 21ef851e..896da24b 100644 --- a/Logic/Pirates/Parley.cs +++ b/Logic/Pirates/Parley.cs @@ -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));*/ diff --git a/Logic/Pirates/ParleyAttendee.cs b/Logic/Pirates/ParleyAttendee.cs index 1bf98b0c..332ae3f0 100644 --- a/Logic/Pirates/ParleyAttendee.cs +++ b/Logic/Pirates/ParleyAttendee.cs @@ -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); } } } diff --git a/Logic/Pirates/ParleyAttendees.cs b/Logic/Pirates/ParleyAttendees.cs index d99f91ac..382af2b0 100644 --- a/Logic/Pirates/ParleyAttendees.cs +++ b/Logic/Pirates/ParleyAttendees.cs @@ -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)); } } } diff --git a/Logic/Pirates/ParleyOption.cs b/Logic/Pirates/ParleyOption.cs index 3f205a37..3f5cf95c 100644 --- a/Logic/Pirates/ParleyOption.cs +++ b/Logic/Pirates/ParleyOption.cs @@ -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 diff --git a/Logic/Pirates/ParleyOptions.cs b/Logic/Pirates/ParleyOptions.cs index 3c40ce56..6330536d 100644 --- a/Logic/Pirates/ParleyOptions.cs +++ b/Logic/Pirates/ParleyOptions.cs @@ -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); } diff --git a/Logic/Pirates/Parleys.cs b/Logic/Pirates/Parleys.cs index 3aeab0b9..9f55ee75 100644 --- a/Logic/Pirates/Parleys.cs +++ b/Logic/Pirates/Parleys.cs @@ -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)); } } } diff --git a/Logic/Pirates/PaymentCode.cs b/Logic/Pirates/PaymentCode.cs index 36b26272..573a9ae9 100644 --- a/Logic/Pirates/PaymentCode.cs +++ b/Logic/Pirates/PaymentCode.cs @@ -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) diff --git a/Logic/Pirates/People.cs b/Logic/Pirates/People.cs index 5bb39ce6..ca0d4952 100644 --- a/Logic/Pirates/People.cs +++ b/Logic/Pirates/People.cs @@ -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> 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 GetPeopleGeographies () { - return PirateDb.GetDatabase().GetPeopleGeographies(); + return PirateDb.GetDatabaseForReading().GetPeopleGeographies(); } public static People FromIdentities (int[] personIds, bool preserveOrder) diff --git a/Logic/Pirates/Person.cs b/Logic/Pirates/Person.cs index d918e319..df7ac421 100644 --- a/Logic/Pirates/Person.cs +++ b/Logic/Pirates/Person.cs @@ -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) diff --git a/Logic/Pirates/PersonRole.cs b/Logic/Pirates/PersonRole.cs index eedab0a5..5064509d 100644 --- a/Logic/Pirates/PersonRole.cs +++ b/Logic/Pirates/PersonRole.cs @@ -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. } diff --git a/Logic/Pirates/RoleLookup.cs b/Logic/Pirates/RoleLookup.cs index 5ab15c70..0aafa8b5 100644 --- a/Logic/Pirates/RoleLookup.cs +++ b/Logic/Pirates/RoleLookup.cs @@ -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); } diff --git a/Logic/Pirates/Roles.cs b/Logic/Pirates/Roles.cs index 56723be7..fd9576ff 100644 --- a/Logic/Pirates/Roles.cs +++ b/Logic/Pirates/Roles.cs @@ -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(); @@ -248,7 +248,7 @@ namespace Activizr.Logic.Pirates public static Roles GetAll() { - return FromArray(PirateDb.GetDatabase().GetRoles()); + return FromArray(PirateDb.GetDatabaseForReading().GetRoles()); } } } \ No newline at end of file diff --git a/Logic/Pirates/Volunteer.cs b/Logic/Pirates/Volunteer.cs index acdc5dc9..8ba3579c 100644 --- a/Logic/Pirates/Volunteer.cs +++ b/Logic/Pirates/Volunteer.cs @@ -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 () diff --git a/Logic/Pirates/VolunteerRole.cs b/Logic/Pirates/VolunteerRole.cs index 367c3159..b2d994bf 100644 --- a/Logic/Pirates/VolunteerRole.cs +++ b/Logic/Pirates/VolunteerRole.cs @@ -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) diff --git a/Logic/Pirates/Volunteers.cs b/Logic/Pirates/Volunteers.cs index 2a070b63..998ffc5c 100644 --- a/Logic/Pirates/Volunteers.cs +++ b/Logic/Pirates/Volunteers.cs @@ -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) diff --git a/Logic/Security/Authentication.cs b/Logic/Security/Authentication.cs index 0b16f37a..1f280d6f 100644 --- a/Logic/Security/Authentication.cs +++ b/Logic/Security/Authentication.cs @@ -46,8 +46,6 @@ namespace Activizr.Logic.Security /// This function will throw an UnauthorizedAccessException if the user cannot be authenticated using the supplied credentials. 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. diff --git a/Logic/Security/Authorization.cs b/Logic/Security/Authorization.cs index 038a0b30..633c70ea 100644 --- a/Logic/Security/Authorization.cs +++ b/Logic/Security/Authorization.cs @@ -127,7 +127,7 @@ namespace Activizr.Logic.Security Dictionary> tempDict = new Dictionary>(); _PermissonsPerRoleTypeDict = new Dictionary>(); - 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> membershipTable = database.GetMembershipsForPeople(people.Identities, gracePeriod); - Dictionary geographyTable = database.GetPeopleGeographies(people.Identities); + Dictionary> membershipTable = databaseRead.GetMembershipsForPeople(people.Identities, gracePeriod); + Dictionary geographyTable = databaseRead.GetPeopleGeographies(people.Identities); var clearedPeople = new Dictionary(); @@ -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 retList = new List(); diff --git a/Logic/Structure/Cities.cs b/Logic/Structure/Cities.cs index 23da1424..1048ab90 100644 --- a/Logic/Structure/Cities.cs +++ b/Logic/Structure/Cities.cs @@ -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)); } } } \ No newline at end of file diff --git a/Logic/Structure/City.cs b/Logic/Structure/City.cs index 14ad30d9..851e7cfa 100644 --- a/Logic/Structure/City.cs +++ b/Logic/Structure/City.cs @@ -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)); } } } \ No newline at end of file diff --git a/Logic/Structure/Countries.cs b/Logic/Structure/Countries.cs index 7962f140..ec044188 100644 --- a/Logic/Structure/Countries.cs +++ b/Logic/Structure/Countries.cs @@ -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) diff --git a/Logic/Structure/Country.cs b/Logic/Structure/Country.cs index 005091d9..582cadb6 100644 --- a/Logic/Structure/Country.cs +++ b/Logic/Structure/Country.cs @@ -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 diff --git a/Logic/Structure/Geographies.cs b/Logic/Structure/Geographies.cs index b4541dfe..a14be671 100644 --- a/Logic/Structure/Geographies.cs +++ b/Logic/Structure/Geographies.cs @@ -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 diff --git a/Logic/Structure/Geography.cs b/Logic/Structure/Geography.cs index b327828c..6653cb74 100644 --- a/Logic/Structure/Geography.cs +++ b/Logic/Structure/Geography.cs @@ -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); } } } \ No newline at end of file diff --git a/Logic/Structure/GeographyStatistics.cs b/Logic/Structure/GeographyStatistics.cs index 27dc3bc6..8e5341f8 100644 --- a/Logic/Structure/GeographyStatistics.cs +++ b/Logic/Structure/GeographyStatistics.cs @@ -21,7 +21,7 @@ namespace Activizr.Logic.Structure public static GeographyStatistics GeneratePresent (int[] memberCountForOrganizations) { - Dictionary voterCounts = PirateDb.GetDatabase().GetGeographyVoterCounts(); + Dictionary voterCounts = PirateDb.GetDatabaseForReading().GetGeographyVoterCounts(); var result = new GeographyStatistics(); // Step 1 - tally the leaf nodes diff --git a/Logic/Structure/Organization.cs b/Logic/Structure/Organization.cs index f2102225..767fbc20 100644 --- a/Logic/Structure/Organization.cs +++ b/Logic/Structure/Organization.cs @@ -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 retVal = new List(); 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"); diff --git a/Logic/Structure/Organizations.cs b/Logic/Structure/Organizations.cs index ba0bc565..90a268a8 100644 --- a/Logic/Structure/Organizations.cs +++ b/Logic/Structure/Organizations.cs @@ -287,12 +287,12 @@ namespace Activizr.Logic.Structure public int GetMemberCount () { - return PirateDb.GetDatabase().GetMemberCountForOrganizations(Identities); + return PirateDb.GetDatabaseForReading().GetMemberCountForOrganizations(Identities); } public int GetMemberCountForGeographies (Geographies geographies) { - return PirateDb.GetDatabase().GetMemberCountForOrganizationsAndGeographies(Identities, + return PirateDb.GetDatabaseForReading().GetMemberCountForOrganizationsAndGeographies(Identities, geographies.Identities); } @@ -300,7 +300,7 @@ namespace Activizr.Logic.Structure { var result = new Dictionary(); - BasicPersonRole[] personRoles = PirateDb.GetDatabase().GetRolesForOrganizationsGeographies(Identities, + BasicPersonRole[] personRoles = PirateDb.GetDatabaseForReading().GetRolesForOrganizationsGeographies(Identities, geographies.Identities); foreach (BasicPersonRole role in personRoles) @@ -316,7 +316,7 @@ namespace Activizr.Logic.Structure { var result = new Dictionary(); - BasicPersonRole[] personRoles = PirateDb.GetDatabase().GetRolesForOrganizationsGeographies(Identities, + BasicPersonRole[] personRoles = PirateDb.GetDatabaseForReading().GetRolesForOrganizationsGeographies(Identities, geographies.Identities); foreach (BasicPersonRole role in personRoles) diff --git a/Logic/Structure/PostalCodes.cs b/Logic/Structure/PostalCodes.cs index 2482c19d..7879acea 100644 --- a/Logic/Structure/PostalCodes.cs +++ b/Logic/Structure/PostalCodes.cs @@ -24,7 +24,7 @@ namespace Activizr.Logic.Structure public static PostalCodes ForCountry (string countryCode) { - return FromArray(PirateDb.GetDatabase().GetPostalCodesForCountry (countryCode)); + return FromArray(PirateDb.GetDatabaseForReading().GetPostalCodesForCountry (countryCode)); } } } diff --git a/Logic/Support/Document.cs b/Logic/Support/Document.cs index 6ac5af5a..b69817bc 100644 --- a/Logic/Support/Document.cs +++ b/Logic/Support/Document.cs @@ -20,7 +20,7 @@ namespace Activizr.Logic.Support public static Document FromIdentity (int documentId) { - return FromBasic(PirateDb.GetDatabase().GetDocument(documentId)); + return FromBasic(PirateDb.GetDatabaseForReading().GetDocument(documentId)); } public static Document FromBasic (BasicDocument basicDocument) @@ -31,7 +31,7 @@ namespace Activizr.Logic.Support public static Document Create (string serverFileName, string clientFileName, Int64 fileSize, string description, IHasIdentity identifiableObject, Person uploader) { - int newDocumentId = PirateDb.GetDatabase(). + int newDocumentId = PirateDb.GetDatabaseForWriting(). CreateDocument(serverFileName, clientFileName, fileSize, description, GetDocumentTypeForObject(identifiableObject), identifiableObject.Identity, uploader.Identity); return FromIdentity(newDocumentId); @@ -78,14 +78,14 @@ namespace Activizr.Logic.Support get { return base.ServerFileName; } set { - PirateDb.GetDatabase().SetDocumentServerFileName(this.Identity, value); + PirateDb.GetDatabaseForWriting().SetDocumentServerFileName(this.Identity, value); base.ServerFileName = value; } } public void SetForeignObject (IHasIdentity foreignObject) { - PirateDb.GetDatabase().SetDocumentForeignObject(this.Identity, GetDocumentTypeForObject(foreignObject), foreignObject.Identity); + PirateDb.GetDatabaseForWriting().SetDocumentForeignObject(this.Identity, GetDocumentTypeForObject(foreignObject), foreignObject.Identity); } diff --git a/Logic/Support/Documents.cs b/Logic/Support/Documents.cs index d2ff68b8..a894ba40 100644 --- a/Logic/Support/Documents.cs +++ b/Logic/Support/Documents.cs @@ -15,7 +15,7 @@ namespace Activizr.Logic.Support { Documents newInstance = FromArray( - PirateDb.GetDatabase().GetDocumentsForForeignObject( + PirateDb.GetDatabaseForReading().GetDocumentsForForeignObject( Document.GetDocumentTypeForObject(identifiableObject), identifiableObject.Identity)); newInstance.sourceObject = identifiableObject; diff --git a/Logic/Support/ObjectOptionalData.cs b/Logic/Support/ObjectOptionalData.cs index 9eefc0ca..f0f5cf48 100644 --- a/Logic/Support/ObjectOptionalData.cs +++ b/Logic/Support/ObjectOptionalData.cs @@ -28,7 +28,7 @@ namespace Activizr.Logic.Support public static ObjectOptionalData ForObject (IHasIdentity identifiableObject) { - ObjectOptionalData thisObject = FromBasic(PirateDb.GetDatabase().GetObjectOptionalData((IHasIdentity)identifiableObject)); + ObjectOptionalData thisObject = FromBasic(PirateDb.GetDatabaseForReading().GetObjectOptionalData((IHasIdentity)identifiableObject)); thisObject.forObject = identifiableObject; return thisObject; } @@ -58,7 +58,7 @@ namespace Activizr.Logic.Support } set { - PirateDb.GetDatabase().SetObjectOptionalData((IHasIdentity)forObject, dataType, value); + PirateDb.GetDatabaseForWriting().SetObjectOptionalData((IHasIdentity)forObject, dataType, value); this.OptionalData[dataType] = value; } } @@ -135,7 +135,7 @@ namespace Activizr.Logic.Support public void SetOptionalData (ObjectOptionalDataType dataType, string data) { - PirateDb.GetDatabase().SetObjectOptionalData((IHasIdentity)forObject, dataType, data); + PirateDb.GetDatabaseForWriting().SetObjectOptionalData((IHasIdentity)forObject, dataType, data); if (data == null && this.OptionalData.ContainsKey(dataType)) this.OptionalData.Remove(dataType); diff --git a/Logic/Support/Optimizations.cs b/Logic/Support/Optimizations.cs index bce615bb..cd102e7b 100644 --- a/Logic/Support/Optimizations.cs +++ b/Logic/Support/Optimizations.cs @@ -11,17 +11,17 @@ namespace Activizr.Logic.Support { public static Dictionary GetPeopleWhoDeclineLocalMail (int[] personIds) { - return PirateDb.GetDatabase().GetPeopleWhoDeclineLocalMail (personIds); + return PirateDb.GetDatabaseForReading().GetPeopleWhoDeclineLocalMail (personIds); } public static Dictionary GetGeographyVoterCounts() { - return PirateDb.GetDatabase().GetGeographyVoterCounts(); + return PirateDb.GetDatabaseForReading().GetGeographyVoterCounts(); } public static Dictionary GetInternalPollVoteCountsPerGeography(int pollId) { - return PirateDb.GetDatabase().GetInternalPollVoteCountsPerGeography(pollId); + return PirateDb.GetDatabaseForReading().GetInternalPollVoteCountsPerGeography(pollId); } } } \ No newline at end of file diff --git a/Logic/Support/PWEvents.cs b/Logic/Support/PWEvents.cs index 29f11e9e..aa7dc81b 100644 --- a/Logic/Support/PWEvents.cs +++ b/Logic/Support/PWEvents.cs @@ -14,38 +14,38 @@ namespace Activizr.Logic.Support //TODO: organizationId comes in hardcoded as 1 from a lot of places, should probably be changed based on affected person // to the party for that country if not swedish. - return PirateDb.GetDatabase().CreateEvent(eventSource, eventType, actingPersonId, organizationId, + return PirateDb.GetDatabaseForWriting().CreateEvent(eventSource, eventType, actingPersonId, organizationId, geographyId, affectedPersonId, parameterInt, parameterText); } public static BasicPWEvent[] GetTopUnprocessedEvents () { - return PirateDb.GetDatabase().GetTopUnprocessedEvents(); + return PirateDb.GetDatabaseForReading().GetTopUnprocessedEvents(); } public static BasicPWEvent[] ForPerson (int personId) { - return PirateDb.GetDatabase().GetEventsForPerson(personId); + return PirateDb.GetDatabaseForReading().GetEventsForPerson(personId); } public static Dictionary> ForPersons (int[] personIds) { - return PirateDb.GetDatabase().GetEventsForPersons(personIds, new EventType[] { }); + return PirateDb.GetDatabaseForReading().GetEventsForPersons(personIds, new EventType[] { }); } public static Dictionary> ForPersons (int[] personIds, EventType[] eventTypes) { - return PirateDb.GetDatabase().GetEventsForPersons(personIds, eventTypes); + return PirateDb.GetDatabaseForReading().GetEventsForPersons(personIds, eventTypes); } public static BasicPWEvent[] ByType (EventType eventType) { - return PirateDb.GetDatabase().GetEventsOfType(eventType); + return PirateDb.GetDatabaseForReading().GetEventsOfType(eventType); } public static void SetEventProcessed (int eventId) { - PirateDb.GetDatabase().SetEventProcessed(eventId); + PirateDb.GetDatabaseForWriting().SetEventProcessed(eventId); } } } \ No newline at end of file diff --git a/Logic/Support/PWLog.cs b/Logic/Support/PWLog.cs index b6640cdf..49d35dcb 100644 --- a/Logic/Support/PWLog.cs +++ b/Logic/Support/PWLog.cs @@ -17,7 +17,7 @@ namespace Activizr.Logic.Support PWLogAction actionType, string actionDescription, string comment, string changedField, string valueBefore, string valueAfter) { - PirateDb.GetDatabase().CreatePWLogEntry(dateTimeUtc, actingPersonId, affectedItem.ToString(), + PirateDb.GetDatabaseForWriting().CreatePWLogEntry(dateTimeUtc, actingPersonId, affectedItem.ToString(), affectedItemId, actionType.ToString(), actionDescription, changedField, valueBefore, valueAfter, comment, GetCurrentIp()); } @@ -103,7 +103,7 @@ namespace Activizr.Logic.Support public static DateTime CheckLatest (PWLogItem affectedItemType, int affectedItemId, PWLogAction actionType) { - return PirateDb.GetDatabase().CheckLogEntry(affectedItemType.ToString(), affectedItemId, actionType.ToString()); + return PirateDb.GetDatabaseForReading().CheckLogEntry(affectedItemType.ToString(), affectedItemId, actionType.ToString()); } public static BasicPWLog[] GetLatestEvents (PWLogItem affectedItemType, DateTime beforeDate, int[] affectedIds, PWLogAction[] actionTypes) @@ -113,7 +113,7 @@ namespace Activizr.Logic.Support foreach (var at in actionTypes) actionTypeList.Add(at.ToString()); - return PirateDb.GetDatabase().GetLatestEvents(affectedItemType.ToString(), beforeDate, affectedIds, actionTypeList.ToArray()); + return PirateDb.GetDatabaseForReading().GetLatestEvents(affectedItemType.ToString(), beforeDate, affectedIds, actionTypeList.ToArray()); } private static string hostIp = "";//Used in batch programs diff --git a/Logic/Support/Persistence.cs b/Logic/Support/Persistence.cs index e62d4b57..fdea3a20 100644 --- a/Logic/Support/Persistence.cs +++ b/Logic/Support/Persistence.cs @@ -10,9 +10,9 @@ namespace Activizr.Logic.Support public string this [string key] { - get { return PirateDb.GetDatabase().GetKeyValue (key); } + get { return PirateDb.GetDatabaseForReading().GetKeyValue (key); } - set { PirateDb.GetDatabase().SetKeyValue (key, value); } + set { PirateDb.GetDatabaseForWriting().SetKeyValue (key, value); } } public static Persistence Key @@ -23,7 +23,7 @@ namespace Activizr.Logic.Support /* -- Obsolete, used only once in migration MSSQL => MySQL public static Dictionary All { - get { return PirateDb.GetDatabase().GetOldKeyValues(); } // Migration-only function -- returns all key/value pairs + get { return PirateDb.GetDatabaseForReading().GetOldKeyValues(); } // Migration-only function -- returns all key/value pairs }*/ } } \ No newline at end of file diff --git a/Logic/Support/TemporaryIdentity.cs b/Logic/Support/TemporaryIdentity.cs index 29a88698..0bc83c8b 100644 --- a/Logic/Support/TemporaryIdentity.cs +++ b/Logic/Support/TemporaryIdentity.cs @@ -15,7 +15,7 @@ namespace Activizr.Logic.Support static public TemporaryIdentity GetNew() { - return new TemporaryIdentity (PirateDb.GetDatabase().GetTemporaryIdentity()); + return new TemporaryIdentity (PirateDb.GetDatabaseForWriting().GetTemporaryIdentity()); // This is actually an Insert, not a Select } private int temporaryId; diff --git a/Logic/Support/UrlTranslations.cs b/Logic/Support/UrlTranslations.cs index cfda9b48..d1840cc6 100644 --- a/Logic/Support/UrlTranslations.cs +++ b/Logic/Support/UrlTranslations.cs @@ -6,7 +6,7 @@ namespace Activizr.Logic.Support { public static bool Create (string url) { - int id = PirateDb.GetDatabase().CreateUrlTranslation(url); + int id = PirateDb.GetDatabaseForWriting().CreateUrlTranslation(url); if (id > 0) { @@ -20,12 +20,12 @@ namespace Activizr.Logic.Support public static void Set (string originalUrl, string translatedUrl) { - PirateDb.GetDatabase().SetUrlTranslation(originalUrl, translatedUrl); + PirateDb.GetDatabaseForWriting().SetUrlTranslation(originalUrl, translatedUrl); } public static string[] GetUntranslated (int maxCount) { - return PirateDb.GetDatabase().GetUntranslatedUrls(maxCount); + return PirateDb.GetDatabaseForReading().GetUntranslatedUrls(maxCount); } } } \ No newline at end of file diff --git a/Utility/BotCode/BlogTop50Scraper.cs b/Utility/BotCode/BlogTop50Scraper.cs index de207de6..a4997d11 100644 --- a/Utility/BotCode/BlogTop50Scraper.cs +++ b/Utility/BotCode/BlogTop50Scraper.cs @@ -16,7 +16,7 @@ namespace Activizr.Utility.BotCode // Every hour of the day, we check that this has been recorded for the day. This is just in case // the bot isn't running at midnight, to make sure that we get one entry per day. - if (PirateDb.GetDatabase().GetBlogTopList(DateTime.Today) == null) + if (PirateDb.GetDatabaseForReading().GetBlogTopList(DateTime.Today) == null) { ScrapeAndStore(); } diff --git a/Utility/BotCode/TurnaroundTracker.cs b/Utility/BotCode/TurnaroundTracker.cs index f88c4456..649e29a4 100644 --- a/Utility/BotCode/TurnaroundTracker.cs +++ b/Utility/BotCode/TurnaroundTracker.cs @@ -100,7 +100,7 @@ namespace Activizr.Utility.BotCode dateTimeClosed = turnaround.DateTimeOpened; } - PirateDb.GetDatabase().SetCommunicationTurnaroundClosed(Organization.PPSEid, 1, turnaround.CommunicationId, (DateTime) dateTimeClosed, 0); + PirateDb.GetDatabaseForWriting().SetCommunicationTurnaroundClosed(Organization.PPSEid, 1, turnaround.CommunicationId, (DateTime) dateTimeClosed, 0); } } }