public static void Delete(object criteria) { Server.DataPortalResult result; MethodInfo method = MethodCaller.GetMethod( MethodCaller.GetObjectType(criteria), "DataPortal_Delete", criteria); DataPortalClient.IDataPortalProxy proxy; proxy = GetDataPortalProxy(RunLocal(method)); Server.DataPortalContext dpContext = new Server.DataPortalContext(GetPrincipal(), proxy.IsServerRemote); OnDataPortalInvoke(new DataPortalEventArgs(dpContext)); try { result = proxy.Delete(criteria, dpContext); } catch (Server.DataPortalException ex) { result = ex.Result; if (proxy.IsServerRemote) { ApplicationContext.SetGlobalContext(result.GlobalContext); } throw new DataPortalException("DataPortal.Delete " + Resources.Failed, ex.InnerException, result.ReturnObject); } if (proxy.IsServerRemote) { ApplicationContext.SetGlobalContext(result.GlobalContext); } OnDataPortalInvokeComplete(new DataPortalEventArgs(dpContext)); }
public static object Update(object obj) { Server.DataPortalResult result; MethodInfo method; string methodName; if (obj is CommandBase) { methodName = "DataPortal_Execute"; } else if (obj is Core.BusinessBase) { Core.BusinessBase tmp = (Core.BusinessBase)obj; if (tmp.IsDeleted) { methodName = "DataPortal_DeleteSelf"; } else if (tmp.IsNew) { methodName = "DataPortal_Insert"; } else { methodName = "DataPortal_Update"; } } else { methodName = "DataPortal_Update"; } method = MethodCaller.GetMethod(obj.GetType(), methodName); DataPortalClient.IDataPortalProxy proxy; proxy = GetDataPortalProxy(RunLocal(method)); Server.DataPortalContext dpContext = new Server.DataPortalContext(GetPrincipal(), proxy.IsServerRemote); OnDataPortalInvoke(new DataPortalEventArgs(dpContext)); try { result = proxy.Update(obj, dpContext); } catch (Server.DataPortalException ex) { result = ex.Result; if (proxy.IsServerRemote) { ApplicationContext.SetGlobalContext(result.GlobalContext); } throw new DataPortalException("DataPortal.Update " + Resources.Failed, ex.InnerException, result.ReturnObject); } if (proxy.IsServerRemote) { ApplicationContext.SetGlobalContext(result.GlobalContext); } OnDataPortalInvokeComplete(new DataPortalEventArgs(dpContext)); return(result.ReturnObject); }