private static T GetOriginal <T>(PXCache cache, object row) where T : class, IBqlTable, new() { if (cache.GetStatus(row) == PXEntryStatus.Inserted || cache.GetStatus(row) == PXEntryStatus.InsertedDeleted) { return(null); } T original = new T(); cache.Keys.ForEach(s => cache.SetValue(original, s, cache.GetValueOriginal(row, s))); if (cache.IsKeysFilled(original)) { cache.Fields.Except(cache.Keys).ForEach(s => cache.SetValue(original, s, cache.GetValueOriginal(row, s))); return(original); } return(null); }
private HashSet <T> GetItems(string range, Func <T, string> getValuePredicate, Action <T, string> prepareForLocatePredicate) { var items = new HashSet <T>(); string[] pairs = range.Split(RMReportConstants.RangeUnionChar); foreach (string pair in pairs) { string start, end; ParseRangeStartEndPair(pair, out start, out end); if (!String.IsNullOrEmpty(start)) { if (String.IsNullOrEmpty(end) || end == start) { string itemCode = String.Empty; if (_wildcardMode == RMReportConstants.WildcardMode.Fixed) { itemCode = RMReportWildcard.EnsureWildcardForFixed(start, _wildcard); } else if (_wildcardMode == RMReportConstants.WildcardMode.Normal) { itemCode = RMReportWildcard.EnsureWildcard(start, _wildcard); } else { throw new ArgumentException(Messages.InvalidWildcardMode); } if (itemCode.Contains(RMReportConstants.DefaultWildcardChar)) { items.UnionWith(from T x in _cache.Cached where RMReportWildcard.IsLike(itemCode, getValuePredicate(x)) select x); } else { prepareForLocatePredicate(_instance, itemCode); if (_cache.IsKeysFilled(_instance)) { T x = (T)_cache.Locate(_instance); if (x != null) { items.Add(x); } } else // composite key { items.UnionWith(from T x in _cache.Cached where String.Equals(itemCode, getValuePredicate(x), StringComparison.Ordinal) select x); } } } else { if (_betweenMode == RMReportConstants.BetweenMode.ByChar) { items.UnionWith(from T x in _cache.Cached where RMReportWildcard.IsBetweenByChar(start, end, getValuePredicate(x)) select x); } else if (_betweenMode == RMReportConstants.BetweenMode.Fixed) { items.UnionWith(RMReportWildcard.GetBetweenForFixed <T>(start, end, _wildcard, _cache.Cached, getValuePredicate)); } else { throw new ArgumentException(Messages.InvalidBetweenMode); } } } else { items.UnionWith(_cache.Cached.Cast <T>()); } } return(items); }