protected virtual IEnumerable selectedItems() { EMailAccountSyncFilter filter = Filter.Current; BqlCommand cmd = SelectedItems.View.BqlSelect; if (filter != null && filter.ServerID != null) { cmd = cmd.WhereAnd <Where <EMailSyncAccount.serverID, Equal <Current <EMailAccountSyncFilter.serverID> > > >(); } if (filter != null && !String.IsNullOrEmpty(filter.PolicyName)) { cmd = cmd.WhereAnd <Where <EMailSyncAccount.policyName, Equal <Current <EMailAccountSyncFilter.policyName> > > >(); } int totalRows = 0; int startRow = PXView.StartRow; PXView view = new PXView(this, false, cmd); view.Clear( ); foreach (PXResult <EMailSyncAccount, EMailSyncServer, EPEmployee, Contact> item in view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows)) { Contact contact = item; EMailSyncAccount account = item; account.Address = (contact != null ? contact.EMail : null) ?? account.Address; //SelectedItems.Cache.SetStatus(account, PXEntryStatus.Notchanged); yield return(item); } }
public override void Record_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert && ((FSAddress)e.Row).IsDefaultAddress == true) { PXView view = sender.Graph.TypedViews.GetView(_DuplicateSelect, true); view.Clear(); FSAddress previousAddress = (FSAddress)view.SelectSingle(((FSAddress)e.Row).BAccountID, ((FSAddress)e.Row).BAccountAddressID, ((FSAddress)e.Row).RevisionID); if (previousAddress != null) { _KeyToAbort = sender.GetValue(e.Row, _RecordID); object newKey = sender.Graph.Caches[typeof(FSAddress)].GetValue(previousAddress, _RecordID); PXCache cache = sender.Graph.Caches[_ItemType]; foreach (object data in cache.Updated) { object dataKey = cache.GetValue(data, _FieldOrdinal); if (Equals(_KeyToAbort, dataKey)) { cache.SetValue(data, _FieldOrdinal, newKey); } } _KeyToAbort = null; e.Cancel = true; return; } } base.Record_RowPersisting(sender, e); }
public override void SetCurrentYearSetup(object[] key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (key.Length < 1) { throw new ArgumentOutOfRangeException(nameof(key)); } if (key[0] == null) { throw new ArgumentNullException(nameof(key)); } int bookID = (int)key[0]; // TODO: Refactor to call FABookPeriodRepository.FindFABookYearSetup PXView view = new PXView( this, false, new Select < FABookYearSetup, Where <FABookYearSetup.bookID, Equal <Required <FABook.bookID> > > >()); view.Clear(); FiscalYearSetup.Current = FiscalYearSetup.Current ?? view.SelectSingle(bookID) as FABookYearSetup; }
public static PXView CreateView(this BqlCommand command, PXGraph graph, bool clearQueryCache = false, bool mergeCache = false) { PXView view = new PXView(graph, !mergeCache, command); if (clearQueryCache) { view.Clear(); } return(view); }
public IYearSetup FindFABookYearSetup(FABook book, bool clearQueryCache = false) { BqlCommand selectCommand; if (book.UpdateGL == true) { selectCommand = new Select <FinYearSetup>(); } else { selectCommand = new Select < FABookYearSetup, Where <FABookYearSetup.bookID, Equal <Required <FABook.bookID> > > >(); } PXView view = new PXView(Graph, true, selectCommand); if (clearQueryCache) { view.Clear(); } return(view.SelectSingle(book.BookID) as IYearSetup); }
public override void RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { object key = sender.GetValue(e.Row, _FieldOrdinal); if (key != null) { PXCache cache = sender.Graph.Caches[_RecordType]; if (Convert.ToInt32(key) < 0) { foreach (object data in cache.Inserted) { object dataKey = cache.GetValue(data, _RecordID); if (Equals(key, dataKey)) { if (((FSAddress)data).IsDefaultAddress == true) { PXView view = sender.Graph.TypedViews.GetView(_DuplicateSelect, true); view.Clear(); FSAddress previousAddress = (FSAddress)view.SelectSingle(((FSAddress)data).BAccountID, ((FSAddress)data).BAccountAddressID, ((FSAddress)data).RevisionID); if (previousAddress != null) { _KeyToAbort = sender.GetValue(e.Row, _FieldOrdinal); object id = sender.Graph.Caches[typeof(FSAddress)].GetValue(previousAddress, _RecordID); sender.SetValue(e.Row, _FieldOrdinal, id); } } break; } } } } base.RowPersisting(sender, e); }
public IEnumerable <IPeriodSetup> FindFABookPeriodSetup(FABook book, bool clearQueryCache = false) { BqlCommand selectCommand; if (book.UpdateGL == true) { selectCommand = new Select3 <FinPeriodSetup, OrderBy <Asc <FinPeriodSetup.periodNbr> > >(); } else { selectCommand = new Select < FABookPeriodSetup, Where <FABookPeriodSetup.bookID, Equal <Required <FABook.bookID> > >, OrderBy <Asc <FABookPeriodSetup.periodNbr> > >(); } PXView view = new PXView(Graph, true, selectCommand); if (clearQueryCache) { view.Clear(); } return(view.SelectMulti(book.BookID).Cast <IPeriodSetup>()); }
private static void ProcessValidation(ValidationFilter Filter, Contact record) { PXPrimaryGraphCollection primaryGraph = new PXPrimaryGraphCollection(new PXGraph()); PXGraph graph = primaryGraph[record]; if (graph == null) { throw new PXException(Messages.UnableToFindGraph); } PXView view = graph.Views[graph.PrimaryView]; int startRow = 0, totalRows = 0; List <object> list_contact = view.Select(null, null, new object[] { record.ContactID }, new string[] { typeof(Contact.contactID).Name }, null, null, ref startRow, 1, ref totalRows); if (list_contact == null || list_contact.Count < 1) { throw new PXException(Messages.ContactNotFound); } Contact contact = PXResult.Unwrap <Contact>(list_contact[0]); contact.DuplicateFound = true; //Find duplicates view PXView viewDuplicates = graph.Views.ToArray().First(v => v.Value.Cache.GetItemType() == typeof(CRDuplicateRecord)).Value; if (viewDuplicates == null) { throw new PXException(Messages.DuplicateViewNotFound); } viewDuplicates.Clear(); List <object> duplicates = viewDuplicates.SelectMulti(); contact = (Contact)view.Cache.CreateCopy(contact); string prevStatus = contact.DuplicateStatus; contact.DuplicateStatus = DuplicateStatusAttribute.Validated; Decimal?score = 0; contact.DuplicateFound = duplicates.Count > 0; foreach (PXResult <CRDuplicateRecord, Contact, Contact2> r in duplicates) { Contact2 duplicate = r; CRDuplicateRecord contactScore = r; int duplicateWeight = ContactMaint.GetContactWeight(duplicate); int currentWeight = ContactMaint.GetContactWeight(contact); if (duplicateWeight > currentWeight || (duplicateWeight == currentWeight && duplicate.ContactID < contact.ContactID)) { contact.DuplicateStatus = DuplicateStatusAttribute.PossibleDuplicated; if (contactScore.Score > score) { score = contactScore.Score; } } } view.Cache.Update(contact); if (contact.DuplicateStatus == DuplicateStatusAttribute.PossibleDuplicated && contact.ContactType == ContactTypesAttribute.Lead && contact.Status == LeadStatusesAttribute.New && Filter.CloseNoActivityLeads == true && score > Filter.CloseThreshold) { CRActivity activity = PXSelect <CRActivity, Where <CRActivity.contactID, Equal <Required <Contact.contactID> > > > .SelectWindowed(graph, 0, 1, contact.ContactID); if (activity == null) { PXAction action = graph.Actions["Action"]; PXAdapter adapter = new PXAdapter(view); adapter.StartRow = 0; adapter.MaximumRows = 1; adapter.Searches = new object[] { contact.ContactID }; adapter.Menu = Messages.CloseAsDuplicate; adapter.SortColumns = new[] { typeof(Contact.contactID).Name }; foreach (Contact c in action.Press(adapter)) { ; } prevStatus = null; } } view.Cache.RestoreCopy(record, view.Cache.Current); if (prevStatus != contact.DuplicateStatus) { graph.Actions.PressSave(); } }
private static void ProcessValidation(ValidationFilter filter, Contact record) { BusinessAccountMaint graph = PXGraph.CreateInstance <BusinessAccountMaint>(); PXView view = graph.BAccount.View; int startRow = 0, totalRows = 0; BAccount baccount = null; Contact contact = null; if (record.ContactType == ContactTypesAttribute.BAccountProperty && record.BAccountID != null) { List <object> list_baccount = view.Select(null, null, new object[] { record.BAccountID }, new string[] { typeof(BAccount.bAccountID).Name }, null, null, ref startRow, 1, ref totalRows); if (list_baccount != null && list_baccount.Count >= 1) { baccount = PXResult.Unwrap <BAccount>(list_baccount[0]); } } if (baccount == null || baccount.DefContactID != record.ContactID) { throw new PXException(Messages.ContactNotFound); } contact = graph.DefContact.Current = graph.DefContact.SelectWindowed(0, 1); contact.DuplicateFound = true; PXView viewDuplicates = graph.Duplicates.View; if (viewDuplicates == null) { throw new PXException(Messages.DuplicateViewNotFound); } viewDuplicates.Clear(); List <object> duplicates = viewDuplicates.SelectMulti(); contact = (Contact)graph.DefContact.Cache.CreateCopy(contact); contact.DuplicateStatus = DuplicateStatusAttribute.Validated; Decimal?score = 0; foreach (PXResult <CRDuplicateRecord, Contact, CRLeadContactValidationProcess.Contact2> r in duplicates) { CRLeadContactValidationProcess.Contact2 duplicate = r; CRDuplicateRecord contactScore = r; int duplicateWeight = ContactMaint.GetContactWeight(duplicate); int currentWeight = ContactMaint.GetContactWeight(contact); if (duplicateWeight > currentWeight || (duplicateWeight == currentWeight && duplicate.ContactID < contact.ContactID)) { contact.DuplicateStatus = DuplicateStatusAttribute.PossibleDuplicated; if (contactScore.Score > score) { score = contactScore.Score; } } } graph.DefContact.Cache.Update(contact); graph.DefContact.Cache.RestoreCopy(record, contact); graph.Actions.PressSave(); }
private void ResetView(PXView view) { view.Cache.Current = null; view.Clear(); }