public virtual void OnPersist(IEnumerable <Organization> organizations) { OrganizationMaint organizationMaint = CreateInstance <OrganizationMaint>(); PXCache organizationCache = organizationMaint.OrganizationView.Cache; PXDBTimestampAttribute timestampAttribute = organizationCache .GetAttributesOfType <PXDBTimestampAttribute>(null, nameof(Organization.tstamp)) .First(); timestampAttribute.RecordComesFirst = true; foreach (Organization organization in organizations) { organizationMaint.Clear(); organizationMaint.BAccount.Current = organizationMaint.BAccount.Search <OrganizationBAccount.bAccountID>(organization.BAccountID); organizationCache.Clear(); organizationCache.ClearQueryCache(); if (organization.ActualLedgerID < 0) { organization.ActualLedgerID = LedgerIDMap[organization.ActualLedgerID].LedgerID; } organizationCache.Current = organization; organizationCache.SetStatus(organizationMaint.OrganizationView.Current, PXEntryStatus.Updated); organizationMaint.Actions.PressSave(); } }
protected virtual void CheckDocumentUpdatedInDb(TPrimary doc) { PXEntryStatus status = Base.Caches[typeof(TPrimary)].GetStatus(doc); if (status == PXEntryStatus.Notchanged) { EntityHelper entityHelper = new EntityHelper(this.Base); object[] keys = entityHelper.GetEntityKey(typeof(TPrimary), doc); object storedRow = entityHelper.GetEntityRow(typeof(TPrimary), keys); if (storedRow != null) { byte[] ts = Base.Caches[typeof(TPrimary)].GetValue(doc, "tstamp") as byte[]; byte[] storedTs = Base.Caches[typeof(TPrimary)].GetValue(storedRow, "tstamp") as byte[]; if (PXDBTimestampAttribute.compareTimestamps(ts, storedTs) < 0) { throw new PXException(ErrorMessages.RecordUpdatedByAnotherProcess, typeof(TPrimary).Name); } } } }
private void LinkComplianceDocumentsToCheck(APPaymentEntry paymentEntry) { paymentEntry.Persist(); Base.Persist(); Base.Caches <ComplianceDocument>().ClearQueryCache(); Base.Caches <ComplianceDocument>().Clear(); PXDBTimestampAttribute timestampAttribute = Base.Caches <ComplianceDocument>() .GetAttributesOfType <PXDBTimestampAttribute>(null, nameof(ComplianceDocument.Tstamp)) .First(); timestampAttribute.RecordComesFirst = true; var complianceDocuments = complianceDocumentsService.GetComplianceDocumentsToLink(); complianceDocumentsService.UpdateComplianceDocumentsForVendorCheck(complianceDocuments, paymentEntry.Document.Current); complianceDocumentsService.ClearLinkToPaymentFlag(complianceDocuments); }