/// <summary> ///Get PO Class Instance /// </summary> /// <param name="ctx">context for PO</param> /// <param name="rs">Datarow</param> /// <param name="trxName">trxName transaction</param> /// <returns>PO for Record or null</returns> public PO GetPO(Ctx ctx, DataRow rs, Trx trxName) { String tableName = GetTableName(); Type clazz = GetClass(tableName); if (clazz == null) { //log.log(Level.SEVERE, "(rs) - Class not found for " + tableName); //ErrorLog.FillErrorLog("MTable.GetPO", "(rs) - Class not found for " + tableName, "", VAdvantage.Framework.Message.MessageType.ERROR); //return null; //Updateby--Raghu //to run work flow with virtual M_ or X_ classes log.Log(Level.INFO, "Using GenericPO for " + tableName); GenericPO po = new GenericPO(tableName, ctx, rs, trxName); return(po); } bool errorLogged = false; try { ConstructorInfo constructor = clazz.GetConstructor(new Type[] { typeof(Ctx), typeof(DataRow), typeof(Trx) }); PO po = (PO)constructor.Invoke(new object[] { ctx, rs, trxName }); return(po); } catch (Exception e) { ////ErrorLog.FillErrorLog("MTable.GetPO", "(rs) - Table=" + tableName + ",Class=" + clazz, e.Message, VAdvantage.Framework.Message.MessageType.ERROR); log.Log(Level.SEVERE, "(rs) - Table=" + tableName + ",Class=" + clazz, e); errorLogged = true; log.SaveError("Error", "Table=" + tableName + ",Class=" + clazz); } if (!errorLogged) { ////ErrorLog.FillErrorLog("Mtable", "(rs) - Not found - Table=" + tableName, "", VAdvantage.Framework.Message.MessageType.INFORMATION); log.Log(Level.SEVERE, "(rs) - Not found - Table=" + tableName); } return(null); }
public PO GetPO(Ctx ctx, int Record_ID, Trx trxName, bool isNew) { //return GetPO(ctx, Record_ID, trxName, true); string tableName = GetTableName(); if (Record_ID != 0 && !IsSingleKey()) { log.Log(Level.WARNING, "(id) - Multi-Key " + tableName); return(null); //Updateby--Raghu //to run work flow with virtual M_ or X_ classes //log.Log(Level.INFO, "Using GenericPO for " + tableName); //GenericPO po = new GenericPO(tableName, ctx, Record_ID, trxName); //return po; } Type className = GetClass(tableName); if (className == null) { //log.log(Level.WARNING, "(id) - Class not found for " + tableName); //to run work flow with virtual M_ or X_ classes log.Log(Level.INFO, "Using GenericPO for " + tableName); GenericPO po = new GenericPO(tableName, ctx, Record_ID, trxName); return(po); } bool errorLogged = false; try { ConstructorInfo constructor = null; try { constructor = className.GetConstructor(new Type[] { typeof(Ctx), typeof(int), typeof(Trx) }); } catch (Exception e) { log.Warning("No transaction Constructor for " + className.FullName + " (" + e.ToString() + ")"); } if (constructor != null) { PO po = (PO)constructor.Invoke(new object[] { ctx, Record_ID, trxName }); // Load record 0 - valid for System/Client/Org/Role/User if (!isNew && Record_ID == 0) { po.Load(trxName); } // Check if loaded correctly if (po != null && po.Get_ID() != Record_ID && IsSingleKey()) { // Common.//ErrorLog.FillErrorLog("MTable", "", po.Get_TableName() + "_ID=" + po.Get_ID() + " <> requested=" + Record_ID, VAdvantage.Framework.Message.MessageType.INFORMATION); return(null); } return(po); } else { throw new Exception("No Std Constructor"); } } catch (Exception ex1) { log.Severe(ex1.ToString()); //exception handling } if (!errorLogged) { //log.log(Level.SEVERE, "(id) - Not found - Table=" + tableName // + ", Record_ID=" + Record_ID); } return(null); }