public static MStorageDetail GetCreate(Ctx ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, String type, Trx trx) { if (M_Locator_ID == 0) { throw new ArgumentException("M_Locator_ID=0"); } if (M_Product_ID == 0) { throw new ArgumentException("M_Product_ID=0"); } MStorageDetail retValue = GetForUpdate(ctx, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID, type, trx); if (retValue != null) { return(retValue); } // Insert row based on locator MLocator locator = new MLocator(ctx, M_Locator_ID, trx); if (locator.Get_ID() != M_Locator_ID) { throw new ArgumentException("Not found M_Locator_ID=" + M_Locator_ID); } // retValue = new MStorageDetail(locator, M_Product_ID, M_AttributeSetInstance_ID, type); retValue.Save(trx); s_log.Fine("New " + retValue); return(retValue); }
/// <summary> /// Get Locator from Cache /// </summary> /// <param name="ctx">context</param> /// <param name="M_Locator_ID">id</param> /// <returns>MLocator</returns> public static MLocator Get(Ctx ctx, int M_Locator_ID) { if (cache == null) { cache = new CCache <int, MLocator>("M_Locator", 20); } int key = M_Locator_ID; MLocator retValue = null; if (cache.ContainsKey(key)) { retValue = (MLocator)cache[key]; } if (retValue != null) { return(retValue); } retValue = new MLocator(ctx, M_Locator_ID, null); if (retValue.Get_ID() != 0) { cache.Add(key, retValue); } return(retValue); }