Beispiel #1
0
        private static object Create(Type objectType, object criteria)
        {
            Server.DataPortalResult result;

            MethodInfo method =
                MethodCaller.GetMethod(objectType, "DataPortal_Create", criteria);

            DataPortalClient.IDataPortalProxy proxy;
            proxy = GetDataPortalProxy(RunLocal(method));

            Server.DataPortalContext dpContext =
                new Dothan.Server.DataPortalContext(GetPrincipal(), proxy.IsServerRemote);

            OnDataPortalInvoke(new DataPortalEventArgs(dpContext));

            try
            {
                result = proxy.Create(objectType, criteria, dpContext);
            }
            catch (Server.DataPortalException ex)
            {
                result = ex.Result;
                if (proxy.IsServerRemote)
                {
                    ApplicationContext.SetGlobalContext(result.GlobalContext);
                }
                throw new DataPortalException(
                          "DataPortal.Create " + Resources.Failed, ex.InnerException, result.ReturnObject);
            }

            if (proxy.IsServerRemote)
            {
                ApplicationContext.SetGlobalContext(result.GlobalContext);
            }

            OnDataPortalInvokeComplete(new DataPortalEventArgs(dpContext));

            return(result.ReturnObject);
        }
Beispiel #2
0
 public static object Create(object criteria)
 {
     return(Create(MethodCaller.GetObjectType(criteria), criteria));
 }
Beispiel #3
0
        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);
        }