protected virtual IEnumerable entityItems([PXString] string parent) { if (MassMails.Current == null) { return(new CacheEntityItem[0]); } var graphType = new EntityHelper(this).GetPrimaryGraphType(typeof(Contact), null, true); return(graphType != null ? EMailSourceHelper.TemplateEntity(this, parent, PXSubstManager.Substitute(typeof(Contact), graphType).FullName, graphType.FullName) : EMailSourceHelper.TemplateEntity(this, parent, typeof(Contact).FullName, null)); }
public virtual IEnumerable relate(PXAdapter adapter) { bool lint = entityFilter.AskExt() == WebDialogResult.OK && entityFilter.VerifyRequired(); if (lint) { PXCache cache = this.Caches <CRSMEmail>(); RelatedEntity relatedEntity = entityFilter.Current; EntityHelper helper = new EntityHelper(this); Type entityType = PXBuildManager.GetType(relatedEntity.Type, false); object row = helper.GetEntityRow(entityType, relatedEntity.RefNoteID); Type graphType = helper.GetPrimaryGraphType(row, false); Type actualEntityType = PXSubstManager.Substitute(entityType, graphType); object actualRow = helper.GetEntityRow(actualEntityType, relatedEntity.RefNoteID); PXGraph graph = PXGraph.CreateInstance(graphType); graph.Caches[actualEntityType].Current = actualRow; foreach (PXResult <CRSMEmail, EMailAccount, EPView> email in SelectedList()) { ((CRSMEmail)email).Selected = false; CRSMEmail copy = PXCache <CRSMEmail> .CreateCopy(email); CRActivity newActivity = (CRActivity)graph.Caches[typeof(CRActivity)].Insert(); copy.BAccountID = newActivity.BAccountID; copy.ContactID = newActivity.ContactID; copy.RefNoteID = newActivity.RefNoteID; copy.MPStatus = MailStatusListAttribute.Processed; copy.Exception = null; PXRefNoteSelectorAttribute.EnsureNotePersistence(this, entityFilter.Current.Type, entityFilter.Current.RefNoteID); copy = (CRSMEmail)cache.Update(copy); } Save.Press(); } else { entityFilter.Ask(Messages.Warning, Messages.SelectRecord, MessageButtons.OK); } Emails.Cache.IsDirty = false; Emails.Cache.Clear(); Emails.Cache.ClearQueryCacheObsolete(); Emails.View.RequestRefresh(); return(adapter.Get()); }