/// <summary> /// get entity of TEntity by primary_key, return null if failed. /// </summary> /// <typeparam name="TEntity">indicate the type of entity to be retrieved.</typeparam> /// <param name="pPk">primary key of entity</param> /// <returns></returns> static public TEntity GetMisEntity <TEntity>(string pPk) where TEntity : class, new() { int orderId = -1; TEntity rslt = null; try { orderId = int.Parse(pPk); var wcfRslt = MangoWCF <TEntity> .GetEntity(orderId); if (null == wcfRslt || null == wcfRslt.Data) { C_WMS.Data.Utility.MyLog.Instance.Warning("failed in TEntity MisModelFactory.GetMisOrder<{0}>({1}), WCF run error: WCF={2}, WCF.RetInt={3}, WCF.DEBUG={4}" , typeof(TEntity), pPk, wcfRslt, wcfRslt?.RetInt, wcfRslt?.Debug); } else { rslt = wcfRslt.Data; } return(rslt); } catch (Exception ex) { C_WMS.Data.Utility.MyLog.Instance.Warning(ex, "!!Exception in TEntity MisModelFactory.GetMisOrder<{0}>({1}), return {2}", typeof(TEntity), pPk, rslt); return(rslt); } }
/// <summary> /// /// </summary> /// <param name="pEntity"></param> /// <param name="pWcfError"></param> /// <param name="pMsg"></param> /// <returns></returns> static public int UpdateRowA(Product_WMS_Interface pEntity, out int pWcfError, out string pMsg) { if (null == pEntity) { pMsg = string.Format("{0}.{1}, 非法空入参", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name); C_WMS.Data.Utility.MyLog.Instance.Warning(pMsg); return(pWcfError = TError.Post_ParamError.Int()); } else { try { DefaultResult <int> retRslt = null; var wcfRslt = MangoWCF <Product_WMS_Interface> .GetEntity(pEntity.WMS_InterfaceId.Int()); // update/add row in Dict709 if (null == wcfRslt) { pMsg = string.Format("{0}.{1}, WCF查找({2}, {3}, {4})返回null", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, pEntity.WMS_InterfaceId, pEntity.MapId1, pEntity.MapId2); C_WMS.Data.Utility.MyLog.Instance.Warning(pMsg); return(pWcfError = TError.Pro_HaveNoData.Int()); } // if (null == wcfRslt), return error else if (null == wcfRslt.Data) { pEntity.AddUserid = MangoMis.Frame.Frame.CommonFrame.userid; pEntity.AddTime = DateTime.Now; retRslt = MangoWCF <Product_WMS_Interface> .Add(pEntity); } // else if (null == wcfRslt.Data), insert new row when notfound else { pEntity.AddUserid = wcfRslt.Data.AddUserid; pEntity.AddTime = wcfRslt.Data.AddTime; retRslt = MangoWCF <Product_WMS_Interface> .Update(pEntity); } // else, update the existing row // handle updating/adding WCF result. if (null == retRslt) { pMsg = string.Format("{0}.{1}, WCF(wcfRslt.Data={2})返回null [WCF({3}, {4}, {5})查找结果: {6}, {7}]", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, wcfRslt.Data, pEntity.WMS_InterfaceId, pEntity.MapId1, pEntity.MapId2, wcfRslt.RetInt, wcfRslt.Debug); C_WMS.Data.Utility.MyLog.Instance.Warning(pMsg); return(pWcfError = TError.WCF_RunError.Int()); } // if (null == retRslt), WCF ERROR else if (0 >= retRslt.Data) { pMsg = string.Format("{0}.{1}, WCF(wcfRslt.Data={2})返回结果: {3}, {4}", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, wcfRslt.Data, wcfRslt.RetInt, wcfRslt.Debug); C_WMS.Data.Utility.MyLog.Instance.Warning(pMsg); return(pWcfError = retRslt.RetInt); } // else if (0 >= retRslt.Data), failed in updating/adding else { pMsg = string.Empty; pWcfError = retRslt.Data; return(retRslt.RetInt); } // else succeed in updating/adding } catch (Exception ex) { pMsg = ex.Message; C_WMS.Data.Utility.MyLog.Instance.Warning(ex, "{0}.{1}({2})发生异常", MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, pEntity); return(pWcfError = TError.Post_NoChange.Int()); } } }