/// <summary> /// Get Conversion Multiplier Rate, try to derive it if not found directly /// </summary> /// <param name="ctx"></param> /// <param name="p">Point with from(x) - to(y) C_UOM_ID</param> /// <returns>conversion multiplier or null</returns> static private Decimal GetRate(Ctx ctx, Point p) { Decimal?retValue = null; if (Ini.IsClient()) { if (_conversions == null || _conversions.Keys.Count() == 0) { CreateRates(ctx); } decimal result; if (_conversions.TryGetValue(p, out result)) { retValue = result; } } else { retValue = GetRate(int.Parse(p.X.ToString()), int.Parse(p.Y.ToString())); } if (retValue != null) { return((Decimal)retValue); } // try to derive return((Decimal)DeriveRate(ctx, int.Parse(p.X.ToString()), int.Parse(p.Y.ToString()))); }
} // getColumns() // getColumns() /** * Get Table from Cache * @param ctx context * @param AD_Table_ID id * @return MTable */ public static MTable Get(Ctx ctx, int AD_Table_ID) { int key = AD_Table_ID; MTable retValue = null; s_cache.TryGetValue(key, out retValue); if (retValue != null) { return(retValue); } retValue = new MTable(ctx, AD_Table_ID, null); if (retValue.Get_ID() != 0) { s_cache.Add(key, retValue); } return(retValue); }
/// <summary> ///Load from Cache if applicable /// Called from MLookup constructor /// </summary> /// <param name="info"></param> /// <param name="lookupTarget">Target Dictionary</param> /// <returns></returns> public static bool LoadFromCache(VLookUpInfo info, Dictionary <Object, NamePair> lookupTarget, out bool allLoaded, out bool hasInActive) { String key = GetKey(info); Dictionary <object, NamePair> cache = null; allLoaded = false; hasInActive = false; s_loadedLookups.TryGetValue(key, out cache); if (cache == null) { return(false); } // Nothing cached if (cache.Count == 0) { s_loadedLookups.Remove(key); return(false); } // we can use iterator, as the lookup loading is complete (i.e. no additional entries) IEnumerator <Object> iterator = cache.Keys.GetEnumerator(); while (iterator.MoveNext()) { Object cacheKey = iterator.Current; NamePair cacheData = cache[cacheKey]; lookupTarget.Add(cacheKey, cacheData); } if (s_loadedLookupsParam.ContainsKey(key)) { KeyValuePair <bool, bool> o = s_loadedLookupsParam[key]; allLoaded = o.Key; hasInActive = o.Value; } _log.Fine("#" + lookupTarget.Count); return(true); }