/// <summary> /// Tries to perform a redirect to the original AR or AP document of a given /// <see cref="DRSchedule"/> record. /// </summary> /// <param name="sourceGraph"> /// A graph through which the redirect will be processed. /// </param> /// <param name="scheduleDetail"> /// The <see cref="DRSchedule"/> record containing the document type and /// document reference number necessary for the redirect. /// </param> public static void NavigateToOriginalDocument( PXGraph sourceGraph, DRSchedule schedule) { IBqlTable originalDocument = null; if (schedule.Module == BatchModule.AR) { originalDocument = (ARRegister) PXSelect < ARRegister, Where <ARRegister.docType, Equal <Required <DRSchedule.docType> >, And <ARRegister.refNbr, Equal <Required <DRSchedule.refNbr> > > > > .Select(sourceGraph, schedule.DocType, schedule.RefNbr); } else if (schedule.Module == BatchModule.AP) { originalDocument = (APRegister) PXSelect < APRegister, Where <APRegister.docType, Equal <Required <DRSchedule.docType> >, And <APRegister.refNbr, Equal <Required <DRSchedule.refNbr> > > > > .Select(sourceGraph, schedule.DocType, schedule.RefNbr); } if (originalDocument != null) { PXRedirectHelper.TryRedirect( sourceGraph.Caches[originalDocument.GetType()], originalDocument, "ViewDocument", PXRedirectHelper.WindowMode.NewWindow); } }
private bool IsItemRuleTrue(IBqlTable item, EPAssignmentRule rule) { if (item is EPEmployee && rule.FieldName.Equals(typeof(EPEmployee.workgroupID).Name, StringComparison.InvariantCultureIgnoreCase)) { return(IsEmployeeInWorkgroup((EPEmployee)item, rule)); } currentItem = item; Type viewType = BqlCommand.Compose(typeof(Select <>), item.GetType()); PXView itemView = new PXView(this, false, BqlCommand.CreateInstance(viewType), (PXSelectDelegate)getItemRecord); if (rule.Condition == null) { return(false); } PXFilterRow filter = new PXFilterRow( rule.FieldName, (PXCondition)rule.Condition.Value, GetFieldValue(item, rule.FieldName, rule.FieldValue), null); int startRow = 0; int totalRows = 0; List <object> result = itemView.Select(null, null, null, null, null, new PXFilterRow[] { filter }, ref startRow, 1, ref totalRows); return(result.Count > 0); }
//Refactor - Generalize if possible!!! private IBqlTable GetItemRecord(EPAssignmentRule rule, IBqlTable item) { PXGraph graph = this.processGraph; Type itemType = item.GetType(); Type ruleType = GraphHelper.GetType(rule.Entity); if (ruleType.IsAssignableFrom(itemType)) { return(item); } if (processMapType.IsAssignableFrom(ruleType) && graph != null) { return(graph.Caches[processMapType].Current as IBqlTable); } if (graph != null) { foreach (CacheEntityItem entry in EMailSourceHelper.TemplateEntity(this, null, item.GetType().FullName, graph.GetType().FullName)) { Type entityType = GraphHelper.GetType(entry.SubKey); if (ruleType.IsAssignableFrom(entityType) && graph.Views.ContainsKey(entry.Key)) { PXView view = graph.Views[entry.Key]; object result = view.SelectSingleBound(new object[] { item }); return((result is PXResult ? ((PXResult)result)[0] : result) as IBqlTable); } } } return(item); }
private void RunCallbacks(IBqlTable table, CCTranType tranType, bool success) { foreach (var callback in afterProcessCallbacks) { callback(table, tranType, success); } }
private void OpenEntityScreen(IBqlTable entity, PXRedirectHelper.WindowMode windowMode) { if (entity == null) { return; } PXPrimaryGraphCollection primaryGraph = new PXPrimaryGraphCollection(Base); PXRedirectHelper.TryRedirect(primaryGraph[entity], entity, windowMode); }
public static void ReleaseARDocument(IBqlTable aTable) { ARRegister toProc = (ARRegister)aTable; if (!(toProc.Released ?? false)) { List <ARRegister> list = new List <ARRegister>(1); list.Add(toProc); ARDocumentRelease.ReleaseDoc(list, false); } }
public PXGraph this[IBqlTable row] { get { Type itemType = row.GetType(); PXCache cache = Graph.Caches[itemType]; Type graphType; object copy = cache.CreateCopy(row); PXPrimaryGraphAttribute.FindPrimaryGraph(cache, ref copy, out graphType); return(this[graphType]); } }
public static void ReleaseARDocument(IBqlTable aTable) { AR.ARRegister toProc = (AR.ARRegister)aTable; using (PXTimeStampScope scope = new PXTimeStampScope(null)) { if (!(toProc.Released ?? false)) { List <AR.ARRegister> list = new List <AR.ARRegister>(1); list.Add(toProc); ARDocumentRelease.ReleaseDoc(list, false); } } }
/// <summary> /// Update a record with the values in another one. /// </summary> /// <param name="cacheTo">The cache of the record to be updated.</param> /// <param name="rowTo">The record to be updated.</param> /// <param name="cacheFrom">The cache of the record to be read.</param> /// <param name="rowFrom">The record to be read.</param> /// <returns>Returns true if some value changes, otherwise it returns false.</returns> private static bool CopyEPEquipmentFields(PXCache cacheTo, IBqlTable rowTo, PXCache cacheFrom, IBqlTable rowFrom) { string fieldTo; string fieldFrom; string tempSwap; bool someValueChanged = false; string stringValue; //// Copy Status fieldTo = typeof(FSEquipment.status).Name; fieldFrom = typeof(EPEquipment.status).Name; if (rowTo is EPEquipment) { tempSwap = fieldTo; fieldTo = fieldFrom; fieldFrom = tempSwap; } stringValue = (string)cacheFrom.GetValue(rowFrom, fieldFrom); if (string.Equals(stringValue, cacheTo.GetValue(rowTo, fieldTo)) == false) { cacheTo.SetValueExt(rowTo, fieldTo, stringValue); someValueChanged = true; } //// Copy Description fieldTo = typeof(FSEquipment.descr).Name; fieldFrom = typeof(EPEquipment.description).Name; if (rowTo is EPEquipment) { tempSwap = fieldTo; fieldTo = fieldFrom; fieldFrom = tempSwap; } stringValue = (string)cacheFrom.GetValue(rowFrom, fieldFrom); if (string.Equals(stringValue, cacheTo.GetValue(rowTo, fieldTo)) == false) { cacheTo.SetValueExt(rowTo, fieldTo, stringValue); someValueChanged = true; } return(someValueChanged); }
public static void CheckForHeldForReviewStatusAfterProc(IBqlTable aTable, CCTranType procTran, bool success) { ICCPayment doc = aTable as ICCPayment; if (doc != null && success) { var graph = PXGraph.CreateInstance <ARPaymentEntry>(); var query = new PXSelect <ExternalTransaction, Where <ExternalTransaction.docType, Equal <Required <ExternalTransaction.docType> >, And <ExternalTransaction.refNbr, Equal <Required <ExternalTransaction.refNbr> > > >, OrderBy <Desc <ExternalTransaction.transactionID> > >(graph); var result = query.Select(doc.DocType, doc.RefNbr); ExternalTransactionState state = ExternalTranHelper.GetActiveTransactionState(graph, result.RowCast <ExternalTransaction>()); if (state.IsOpenForReview) { throw new PXSetPropertyException(AR.Messages.CCProcessingTranHeldWarning, PXErrorLevel.RowWarning); } } }
public static string GetRowMessage(PXCache cache, IBqlTable row, bool getErrors, bool getWarnings) { List <string> errors = null; List <string> warnings = null; if (getErrors) { errors = new List <string>(); } if (getWarnings) { warnings = new List <string>(); } GetRowMessages(cache, row, errors, warnings, false); StringBuilder messageBuilder = new StringBuilder(); if (errors != null) { foreach (string message in errors) { if (messageBuilder.Length > 0) { messageBuilder.Append(Environment.NewLine); } messageBuilder.Append(message); } } if (warnings != null) { foreach (string message in warnings) { if (messageBuilder.Length > 0) { messageBuilder.Append(Environment.NewLine); } messageBuilder.Append(message); } } return(messageBuilder.ToString()); }
private object GetFieldValue(IBqlTable item, string fieldname, string fieldvalue = null) { PXCache sourceCache = this.Caches[item.GetType()]; object copy = sourceCache.CreateCopy(item); if (fieldvalue != null) { sourceCache.SetValueExt(copy, fieldname, fieldvalue); } else { object newValue; sourceCache.RaiseFieldDefaulting(fieldname, copy, out newValue); sourceCache.SetValue(copy, fieldname, newValue); } return(sourceCache.GetValueExt(copy, fieldname)); }
/// <summary> /// For the specified BQL field, returns the label defined for the field value /// by an item-level instance of <see cref="PXStringListAttribute"/> residing /// on the field. /// </summary> /// <remarks> /// This method can be used when the string list is changed dynamically /// for individual records. /// </remarks> public static string For <TField>(PXCache cache, IBqlTable record) where TField : IBqlField { if (cache == null) { throw new ArgumentNullException(nameof(cache)); } if (record == null) { throw new ArgumentNullException(nameof(record)); } string fieldValue = cache.GetValue <TField>(record) as string; if (fieldValue == null) { throw new PXException(Messages.FieldIsNotOfStringType, typeof(TField).FullName); } PXStringListAttribute stringListAttribute = cache .GetAttributesReadonly <TField>(record) .OfType <PXStringListAttribute>() .SingleOrDefault(); if (stringListAttribute == null) { throw new PXException( Messages.FieldDoesNotHaveItemOrCacheLevelAttribute, typeof(TField).FullName, nameof(PXStringListAttribute)); } string label; if (!stringListAttribute.ValueLabelDic.TryGetValue(fieldValue, out label)) { throw new PXException( Messages.StringListAttributeDoesNotDefineLabelForValue, fieldValue); } return(label); }
protected static string GenerateSearchInfo(PXGraph processingGraph, IBqlTable entity) { PXSearchableAttribute attr = processingGraph .Caches[entity.GetType()] .GetAttributes(nameof(INotable.NoteID)) .OfType <PXSearchableAttribute>() .FirstOrDefault(); if (attr == null && entity.GetType() == typeof(CRContact)) { attr = new PXSearchableAttribute(SM.SearchCategory.CR, Messages.ContactOPTypeForIndex, new Type[] { typeof(CRContact.displayName) }, new Type[] { typeof(CRContact.email), typeof(CRContact.phone1), typeof(CRContact.phone2), typeof(CRContact.phone3), typeof(CRContact.webSite) }) { Line1Format = "{0}{1}{2}", Line1Fields = new Type[] { typeof(CRContact.salutation), typeof(CRContact.phone1), typeof(CRContact.email) } }; } return(attr?.BuildContent(processingGraph.Caches[entity.GetType()], entity, null)); }
public static List <ErrorInfo> GetErrorInfo <TranType>(PXCache headerCache, IBqlTable headerRow, PXSelectBase <TranType> detailView) where TranType : class, IBqlTable, new() { List <ErrorInfo> errorList = new List <ErrorInfo>(); ErrorInfo errorInfo = null; string headerErrorMessage = MessageHelper.GetRowMessage(headerCache, headerRow, true, false); if (string.IsNullOrEmpty(headerErrorMessage) == false) { errorInfo = new ErrorInfo() { HeaderError = true, SOID = null, AppointmentID = null, ErrorMessage = headerErrorMessage }; errorList.Add(errorInfo); } foreach (TranType row in detailView.Select()) { string errorMessage = MessageHelper.GetRowMessage(detailView.Cache, row, true, false); if (string.IsNullOrEmpty(errorMessage) == false) { errorInfo = new ErrorInfo() { HeaderError = false, SOID = null, AppointmentID = null, ErrorMessage = errorMessage + ", " }; errorList.Add(errorInfo); } } return(errorList); }
public static void ReleaseARDocument(IBqlTable aTable, CCTranType procTran, bool success) { AR.ARRegister doc = aTable as AR.ARRegister; if (doc != null && success) { ExternalTransaction tran = null; PXGraph graph = null; if (doc.DocType == ARDocType.CashSale || doc.DocType == ARDocType.CashReturn) { ARCashSaleEntry cashSaleGraph = PXGraph.CreateInstance <ARCashSaleEntry>(); cashSaleGraph.Document.Current = PXSelect <ARCashSale, Where <ARCashSale.docType, Equal <Required <ARCashSale.docType> >, And <ARCashSale.refNbr, Equal <Required <ARCashSale.refNbr> > > > > .SelectWindowed(cashSaleGraph, 0, 1, doc.DocType, doc.RefNbr); tran = cashSaleGraph.ExternalTran.SelectSingle(doc.DocType, doc.RefNbr); graph = cashSaleGraph; } else { ARPaymentEntry paymentGraph = PXGraph.CreateInstance <ARPaymentEntry>(); paymentGraph.Document.Current = PXSelect <AR.ARPayment, Where <AR.ARPayment.docType, Equal <Required <AR.ARPayment.docType> >, And <AR.ARPayment.refNbr, Equal <Required <AR.ARPayment.refNbr> > > > > .SelectWindowed(paymentGraph, 0, 1, doc.DocType, doc.RefNbr); tran = paymentGraph.ExternalTran.SelectSingle(doc.DocType, doc.RefNbr); graph = paymentGraph; } if (tran != null) { ExternalTransactionState state = ExternalTranHelper.GetTransactionState(graph, tran); if (!state.IsDeclined && !state.IsOpenForReview) { ReleaseARDocument(aTable); } } } }
public static FSServiceOrder GetRelatedServiceOrder(PXGraph graph, PXCache chache, IBqlTable crTable, int?soID) { FSServiceOrder fsServiceOrderRow = null; if (soID != null && chache.GetStatus(crTable) != PXEntryStatus.Inserted) { fsServiceOrderRow = PXSelect <FSServiceOrder, Where < FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> > > > .Select(graph, soID); } return(fsServiceOrderRow); }
public static void UpdateSOInvoiceState(IBqlTable aDoc, PX.CCProcessing.CCTranType aLastOperation) { SOInvoiceEntry graph = PXGraph.CreateInstance<SOInvoiceEntry>(); graph.UpdateDocState(aDoc as SOInvoice, aLastOperation); }