private void InsertUpdateCustomerBillingSetup(PXCache cache, Customer customerRow, FSxCustomer fsxCustomerRow) { FSSetup fsSetupRow = PXSelect <FSSetup> .Select(Base); if (fsSetupRow != null && fsSetupRow.CustomerMultipleBillingOptions == false) { FSCustomerBillingSetup fsCustomerBillingSetupRow = CustomerBillingCycles.Select(); if (fsxCustomerRow.BillingCycleID == null) { CustomerBillingCycles.Delete(fsCustomerBillingSetupRow); return; } if (fsCustomerBillingSetupRow == null) { fsCustomerBillingSetupRow = CustomerBillingCycles.Insert(new FSCustomerBillingSetup()); fsCustomerBillingSetupRow.SrvOrdType = null; } fsCustomerBillingSetupRow.BillingCycleID = fsxCustomerRow.BillingCycleID; fsCustomerBillingSetupRow.SendInvoicesTo = fsxCustomerRow.SendInvoicesTo; fsCustomerBillingSetupRow.BillShipmentSource = fsxCustomerRow.BillShipmentSource; fsCustomerBillingSetupRow.FrequencyType = ID.Frequency_Type.NONE; CustomerBillingCycles.Update(fsCustomerBillingSetupRow); } }
protected virtual void INPIClass_SiteID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { foreach (PXResult <INPIClassLocation> r in Locations.View.SelectMultiBound(new object[] { e.Row })) { Locations.Delete(r); } }
public virtual void CATransfer_RowDeleted(PXCache sender, PXRowDeletedEventArgs e) { foreach (CATran item in TransferTran.Select()) { TransferTran.Delete(item); } }
public virtual void DeleteUnreleasedApplications(Action baseMethod) { baseMethod(); if (Base.Document.Current?.DocType != APDocType.Prepayment) { return; } new PXSelectJoin <POAdjust, LeftJoin <POOrder, On <POOrder.orderType, Equal <POAdjust.adjdOrderType>, And <POOrder.orderNbr, Equal <POAdjust.adjdOrderNbr> > > >, Where < POAdjust.adjgDocType, Equal <Current <APPayment.docType> >, And <POAdjust.adjgRefNbr, Equal <Current <APPayment.refNbr> >, And <POAdjust.released, Equal <False>, And <POAdjust.isRequest, Equal <False> > > > > >(Base) .SelectMain().ForEach( poadjust => POAdjustments.Delete(poadjust)); }
protected void Delete() { if (Claim.Current == null) { return; } if (Claim.Current.Released == true) { throw new PXException(Messages.ReleasedDocumentMayNotBeDeleted); } Claim.Delete(Claim.Current); Save.Press(); }
protected virtual void ARInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { ARInvoice row = (ARInvoice)e.Row; if (row != null && !String.IsNullOrEmpty(row.DocType) && !String.IsNullOrEmpty(row.RefNbr)) { CCPayments.Insert(row); CCPayments.Update(row); CCPayments.Delete(row); CCPayments.View.Insert(row); CCPayments.View.Update(row); CCPayments.View.Delete(row); } }
public virtual IEnumerable revoke(PXAdapter adapter) { if (Details.Current != null && Document.Current != null && Document.Current.Released == false && Document.Current.Voided == false) { ARInvoice doc = PXSelect <ARInvoice, Where <ARInvoice.refNbr, Equal <Required <ARDunningLetterDetail.refNbr> >, And <ARInvoice.docType, Equal <Required <ARDunningLetterDetail.docType> > > > > .Select(this, Details.Current.RefNbr, Details.Current.DocType); if (doc != null) { ARInvoiceEntry graph = PXGraph.CreateInstance <ARInvoiceEntry>(); graph.Document.Current = doc; doc.Revoked = true; graph.Document.Update(doc); graph.Save.Press(); Details.Delete(Details.Current); Save.Press(); } } return(adapter.Get()); }
public void ConvertCustomerPaymentMethod(bool processExpiredCards, CustomerPaymentMethod cpm, CCProcessingCenter newCCPC) { CustomerPM.Current = cpm; DateTime expiredDate; if (processExpiredCards && CheckCardIsExpired(cpm, out expiredDate) && !ProcCenterSupportTokenizing(cpm.CCProcessingCenterID)) { foreach (CustomerPaymentMethodDetail cpmd in CustomerPMDetails.Select().RowCast<CustomerPaymentMethodDetail>()) { CustomerPMDetails.Delete(cpmd); } cpm.IsActive = false; CustomerPM.Update(cpm); } else { DoConvert(cpm, newCCPC); } this.Save.Press(); }
public void RefreshRecordFileList(string screenID, string folderName, string folderID, Guid?refNoteID, bool isForcingSync) { var tokenHandler = PXGraph.CreateInstance <UserTokenHandler>(); //Get list of files contained in the record folder. RecurseDepth=0 will retrieve all subfolders List <BoxUtils.FileFolderInfo> boxFileList = BoxUtils.GetFileList(tokenHandler, folderID, (int)BoxUtils.RecursiveDepth.Unlimited).Result; // Remove files from cache if they don't exist on Box server foreach (PXResult <BoxFileCache, UploadFileRevisionNoData, UploadFile, NoteDoc> result in FilesByNoteID.Select(refNoteID)) { BoxUtils.FileFolderInfo boxFile = boxFileList.FirstOrDefault(f => f.ID == ((BoxFileCache)result).FileID); if (boxFile == null) { //File was deleted FilesByNoteID.Delete(result); UploadFiles.Delete(result); UploadFileRevisions.Delete(result); NoteDocs.Delete(result); } else { // File still exists, remove it from in-memory list // so we don't process it as a new file in the next loop boxFileList.Remove(boxFile); } } // Remove any files/folders coming from activities stored beneath the current record, they've been processed above var filesFoundOnlyOnServer = boxFileList.Where(x => !x.Name.StartsWith(Messages.ActivitiesFolderName)).ToList(); //Check for underlying activities records BoxFolderCache currentFolder = FoldersByFolderID.Select(folderID); if (currentFolder != null && boxFileList.Any(x => x.Name.StartsWith(Messages.ActivitiesFolderName))) { // If nullOrEmpty, Folder may have been created manually if (string.IsNullOrEmpty(currentFolder.ActivityFolderID)) { //Find actual folder ID and save in BoxFolderCache's ActivityFolderID field BoxUtils.FileFolderInfo activityFolderinfo = BoxUtils.FindFolder(tokenHandler, folderID, Messages.ActivitiesFolderName).Result; if (activityFolderinfo != null) { currentFolder.ActivityFolderID = activityFolderinfo?.ID; FoldersByFolderID.Update(currentFolder); } } if (currentFolder.ActivityFolderID != null) { SynchronizeFolderContentsWithScreen(ActivityMaintScreenId, currentFolder.ActivityFolderID, isForcingSync); } } //Remaining files aren't found in cache but are in Box server. if (filesFoundOnlyOnServer.Any()) { if (refNoteID == null) { // User may have created some folder manually with a name not matching to any record, or record // may have been deleted in Acumatica. We can safely ignore it, but let's write to trace. PXTrace.WriteWarning(string.Format("No record found for folder {0} (screen {1}, ID {2})", folderName, screenID, folderID)); return; } UploadFileMaintenance ufm = PXGraph.CreateInstance <UploadFileMaintenance>(); ufm.IgnoreFileRestrictions = true; ufm.RowInserting.AddHandler <UploadFileRevision>(delegate(PXCache sender, PXRowInsertingEventArgs e) { ((UploadFileRevision)e.Row).BlobHandler = Guid.NewGuid(); }); //Add files to the caches foreach (BoxUtils.FileFolderInfo boxFile in filesFoundOnlyOnServer) { ufm.Clear(); string fileName = string.Format("{0}\\{1}", folderName, boxFile.Name.Replace(Path.GetInvalidPathChars(), ' ')); FileInfo fileInfo = ufm.GetFileWithNoData(fileName); Guid? blobHandlerGuid; if (fileInfo == null) { fileInfo = new FileInfo(fileName, null, new byte[0]); //The SaveFile call will trigger a Load() on the BoxBlobStorageProvider which can be skipped PXContext.SetSlot <bool>("BoxDisableLoad", true); try { if (!ufm.SaveFile(fileInfo)) { throw new PXException(Messages.ErrorAddingFileSaveFileFailed, fileName); } } finally { PXContext.SetSlot <bool>("BoxDisableLoad", false); } if (!fileInfo.UID.HasValue) { throw new PXException(Messages.ErrorAddingFileUIDNull, fileName); } UploadFileMaintenance.SetAccessSource(fileInfo.UID.Value, null, screenID); NoteDoc noteDoc = (NoteDoc)NoteDocs.Cache.CreateInstance(); noteDoc.NoteID = refNoteID; noteDoc.FileID = fileInfo.UID; NoteDocs.Insert(noteDoc); blobHandlerGuid = ufm.Revisions.Current.BlobHandler; } else { //File already exists in the database, retrieve BlobHandler if (!fileInfo.UID.HasValue) { throw new PXException(Messages.GetFileWithNoDataReturnedUIDNull, fileName); } blobHandlerGuid = GetBlobHandlerForFileID(fileInfo.UID.Value); //Clear old references of this blob handler from cache; it will be reinserted with up-to-date info var bfcOrphan = (BoxFileCache)FilesByBlobHandler.Select(blobHandlerGuid); if (bfcOrphan != null) { FilesByBlobHandler.Delete(bfcOrphan); } //Update NoteDoc entry if existing file was moved to new NoteID or create it if not there NoteDoc nd = (NoteDoc)NoteDocsByFileID.Select(fileInfo.UID); if (nd == null) { nd = (NoteDoc)NoteDocs.Cache.CreateInstance(); nd.NoteID = refNoteID; nd.FileID = fileInfo.UID; NoteDocs.Insert(nd); } else if (nd.NoteID != refNoteID) { nd.NoteID = refNoteID; NoteDocs.Update(nd); } } var bfc = (BoxFileCache)FilesByBlobHandler.Cache.CreateInstance(); bfc.BlobHandler = blobHandlerGuid; bfc.FileID = boxFile.ID; bfc.ParentFolderID = boxFile.ParentFolderID; bfc = FilesByBlobHandler.Insert(bfc); } } }