public void SetPaymentStatus(MembershipPaymentStatus status, DateTime dateTime) { SwarmDb.GetDatabaseForWriting().SetMembershipPaymentStatus(Identity, status, dateTime); LoadPaymentStatus(); paymentStatus.Status = status; paymentStatus.StatusDateTime = dateTime; }
public static Membership Import(Person person, Organization organization, DateTime memberSince, DateTime expires) { return (FromIdentity(SwarmDb.GetDatabaseForWriting().ImportMembership(person.Identity, organization.Identity, memberSince, expires))); }
public void AddInformation(PaymentInformationType type, string data) { if (!string.IsNullOrEmpty(data)) { SwarmDb.GetDatabaseForWriting().CreatePaymentInformation(Identity, type, data); } }
public static CommunicationTurnaround Create(Organization organization, int communicationId, DateTime dateTimeOpened) { SwarmDb.GetDatabaseForWriting() .CreateCommunicationTurnaround(organization.Identity, 1, communicationId, dateTimeOpened); return(FromIdentity(organization, 1, communicationId)); }
protected static VatReport FromIdentityAggressive(int vatReportId) { // "Open For Writing" is intentional - it bypasses the lag of replication-to-readonly // instances of large-deployment databases and reads at the write source return(FromBasic(SwarmDb.GetDatabaseForWriting().GetVatReport(vatReportId))); }
public static FinancialTransaction Create(int organizationId, DateTime dateTime, string description) { int transactionId = SwarmDb.GetDatabaseForWriting() .CreateFinancialTransaction(organizationId, dateTime, description); return(FromIdentityAggressive(transactionId)); }
public static void Create(FinancialValidationType validationType, IHasIdentity foreignObject, Person actingPerson, double amount) { SwarmDb.GetDatabaseForWriting() .CreateFinancialValidation(validationType, GetDependencyType(foreignObject), foreignObject.Identity, DateTime.Now, actingPerson.Identity, amount); }
public static PayrollAdjustment Create(PayrollItem item, PayrollAdjustmentType type, double amount, string description) { int id = SwarmDb.GetDatabaseForWriting().CreatePayrollAdjustment(item.Identity, type, amount, description); return(FromIdentity(id)); }
public void SetResponded(DateTime dateTime, Person person) { if (!Open) { return; } if (Responded) { return; } int personId = 0; if (person != null) { personId = person.Identity; } SwarmDb.GetDatabaseForWriting() .SetCommunicationTurnaroundResponded(OrganizationId, CommunicationTypeId, CommunicationId, dateTime, personId); base.Responded = true; }
public static HotBitcoinAddress CreateUnique(Organization organization, BitcoinChain chain, params int[] derivationPath) { ExtPubKey extPubKey = BitcoinUtility.BitcoinHotPublicRoot; extPubKey = extPubKey.Derive((uint)organization.Identity); string derivationPathString = string.Empty; foreach (int derivation in derivationPath) // requires that order is consistent from 0 to n-1 { extPubKey = extPubKey.Derive((uint)derivation); derivationPathString += " " + derivation.ToString(CultureInfo.InvariantCulture); } derivationPathString = derivationPathString.TrimStart(); int hotBitcoinAddressId = SwarmDb.GetDatabaseForWriting() .CreateHotBitcoinAddress(organization.Identity, chain, derivationPathString); HotBitcoinAddress addressTemp = FromIdentityAggressive(hotBitcoinAddressId); // Derive the last step with the now-assigned unique identifier, then set address, read again, and return extPubKey = extPubKey.Derive((uint)addressTemp.UniqueDerive); string bitcoinAddressString = extPubKey.PubKey.GetAddress(Network.Main).ToString(); SwarmDb.GetDatabaseForWriting().SetHotBitcoinAddressAddress(hotBitcoinAddressId, bitcoinAddressString); return(FromIdentityAggressive(hotBitcoinAddressId)); }
public MeetingElectionVote CreateVote(Person person, string ipAddress) { if (SwarmDb.GetDatabaseForReading().GetInternalPollVoterStatus(Identity, person.Identity) != InternalPollVoterStatus.CanVote) { throw new InvalidOperationException("Voter status is not open"); } Geography voteGeography = person.Geography; // Make sure that the vote geography is not at a lower level than ElectoralCircuit. while (voteGeography.ParentGeographyId != 0 && !voteGeography.AtLevel(GeographyLevel.ElectoralCircuit)) { voteGeography = voteGeography.Parent; } if (voteGeography.ParentGeographyId == 0) { voteGeography = person.Geography; } SwarmDb.GetDatabaseForWriting().CloseInternalPollVoter(Identity, person.Identity, ipAddress); return(MeetingElectionVote.Create(this, voteGeography)); }
public virtual void SetPassword(string newPassword) { string hash = Authentication.GenerateNewPasswordHash(this, newPassword); SwarmDb.GetDatabaseForWriting().SetPersonPasswordHash(Identity, hash); base.PasswordHash = hash; }
public void CloseFailed(string failReason) { SwarmDb.GetDatabaseForWriting().SetOutboundCommRecipientFailed(this.Identity, failReason); base.Success = false; base.Open = false; }
public void CloseSuccess() { SwarmDb.GetDatabaseForWriting().SetOutboundCommRecipientClosed(this.Identity); base.Success = true; base.Open = false; }
private static void ScrapeAndStore() { string scrapeData = string.Empty; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://knuff.se/topp50/knuffpoaeng/"); request.UserAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5"; using (Stream stream = request.GetResponse().GetResponseStream()) { using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(1252))) { scrapeData = reader.ReadToEnd(); } } Regex regex = new Regex("<h4 .*?><a href.*?>(?<blogname>.*?)</a>", RegexOptions.None); Match match = regex.Match(scrapeData); List <string> rankingList = new List <string>(); while (match.Success) { string blogName = match.Groups["blogname"].Value; rankingList.Add(blogName); match = match.NextMatch(); } SwarmDb.GetDatabaseForWriting().StoreBlogTopList(DateTime.Today, rankingList.ToArray()); }
private void AddRow(int financialAccountId, Int64 amountCents, int personId) { if (this.DateTime.Year <= FinancialAccount.FromIdentity(financialAccountId).Organization.Parameters.FiscalBooksClosedUntilYear) { // Recurse down into continuation transactions to write row in first nonclosed year FinancialTransaction transactionContinued = this.ContinuedTransaction; if (transactionContinued == null) { // No continuation; create one transactionContinued = FinancialTransaction.Create(this.OrganizationId, DateTime.Now, "Continued Tx #" + this.Identity.ToString()); transactionContinued.AddRow(financialAccountId, amountCents, personId); transactionContinued.Dependency = this; } else { // Recurse transactionContinued.AddRow(financialAccountId, amountCents, personId); } return; } SwarmDb.GetDatabaseForWriting().CreateFinancialTransactionRow(Identity, financialAccountId, amountCents, personId); }
static public void SetGeographyName(int geographyId, string name) { SwarmDb.GetDatabaseForWriting().SetGeographyName(geographyId, name); BasicGeography geo = SwarmDb.GetDatabaseForReading().GetGeography(geographyId); Dictionary <int, List <BasicGeography> > hashedGeographies = GetHashedGeographies(); hashedGeographies[geographyId][0] = geo; }
public static Ballot Create(Election election, Organization organization, Geography geography, string name, int ballotCount, string deliveryAddress) { return (FromIdentity(SwarmDb.GetDatabaseForWriting() .CreateBallot(election.Identity, name, organization.Identity, geography.Identity, ballotCount, deliveryAddress))); }
public static GeographyUpdate Create(string updateType, string updateSource, string guid, string countryCode, string changeDataXml, DateTime effectiveDateTime) { int identity = SwarmDb.GetDatabaseForWriting() .CreateGeographyUpdate(updateType, updateSource, guid, countryCode, changeDataXml, DateTime.UtcNow, effectiveDateTime); return(FromBasic(SwarmDb.GetDatabaseForWriting().GetGeographyUpdate(identity))); // "ForWriting" intentional to avoid db replication race conditions }
public static Document Create(string serverFileName, string clientFileName, Int64 fileSize, string description, IHasIdentity identifiableObject, Person uploader) { int newDocumentId = SwarmDb.GetDatabaseForWriting(). CreateDocument(serverFileName, clientFileName, fileSize, description, GetDocumentTypeForObject(identifiableObject), identifiableObject == null? 0: identifiableObject.Identity, uploader.Identity); return(FromIdentityAggressive(newDocumentId)); }
public void Delete() { // Unlink, actually SetForeignObject(new TemporaryIdentity(0)); File.Delete(StorageRoot + ServerFileName); SwarmDb.GetDatabaseForWriting().SetDocumentDescription(this.Identity, "Deleted"); }
public void RetractApproval(Person retractingPerson) { SwarmDb.GetDatabaseForWriting().SetInboundInvoiceAttested(Identity, false); SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.UndoApproval, FinancialDependencyType.InboundInvoice, Identity, DateTime.UtcNow, retractingPerson.Identity, BudgetAmountCents); base.Attested = false; }
public void Attest(Person attester) { SwarmDb.GetDatabaseForWriting().SetInboundInvoiceAttested(this.Identity, true); SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Attestation, FinancialDependencyType.InboundInvoice, this.Identity, DateTime.Now, attester.Identity, (double)this.Amount); base.Attested = true; }
internal static void DeleteOrgUptakeGeography(int p, int geoId) { SwarmDb.GetDatabaseForWriting().DeleteOrgUptakeGeography(p, geoId); lock (loadCacheLock) { __cachedUptakeGeographies = null; } }
public void Deattest(Person deattester) { SwarmDb.GetDatabaseForWriting().SetInboundInvoiceAttested(Identity, false); SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Deattestation, FinancialDependencyType.InboundInvoice, Identity, DateTime.Now, deattester.Identity, (double)Amount); base.Attested = false; }
public static MeetingElectionVote Create(MeetingElection poll, Geography voteGeography) { return (FromIdentity(SwarmDb.GetDatabaseForWriting() .CreateInternalPollVote(poll.Identity, voteGeography.Identity, Authentication. CreateRandomPassword(12)))); }
private static Salary Create(PayrollItem payrollItem, DateTime payoutDate, Int64 netSalaryCents, Int64 subtractiveTaxCents, Int64 additiveTaxCents) { return (FromIdentity(SwarmDb.GetDatabaseForWriting() .CreateSalary(payrollItem.Identity, payoutDate, payrollItem.BaseSalaryCents, netSalaryCents, subtractiveTaxCents, additiveTaxCents))); }
public void CreateTag(FinancialTransactionTagType tagType, Person creatingPerson) { // TODO: Verify that there isn't already a tag in this set in the transaction, and if so, delete it first SwarmDb.GetDatabaseForWriting().CreateFinancialTransactionTag(Identity, tagType.Identity); // TODO: Log that the tag was added (and by whom?) }
protected static FinancialAccount Create(int organizationId, string name, FinancialAccountType accountType, int parentFinancialAccountId) { int accountId = SwarmDb.GetDatabaseForWriting() .CreateFinancialAccount(organizationId, name, accountType, parentFinancialAccountId); return(FromIdentityAggressive(accountId)); }
public void Deattest(Person deattester) { SwarmDb.GetDatabaseForWriting().CreateFinancialValidation(FinancialValidationType.Deattestation, FinancialDependencyType.CashAdvance, this.Identity, DateTime.Now, deattester.Identity, this.AmountCents / 100.0); SwarmDb.GetDatabaseForWriting().SetCashAdvanceAttested(this.Identity, false, Person.NobodyId); OutboundComm.CreateNotificationOfFinancialValidation(this.Budget, this.Person, (double)this.AmountCents / 100.0, this.Description, NotificationResource.CashAdvance_Deattested); }