Exemplo n.º 1
0
        /// <summary>
        /// Delete a business object.
        /// </summary>
        /// <param name="objectType">Type of business object to create.</param>
        /// <param name="criteria">Criteria object describing business object.</param>
        /// <param name="context">
        /// <see cref="Server.DataPortalContext" /> object passed to the server.
        /// </param>
        public DataPortalResult Delete(Type objectType, object criteria, DataPortalContext context)
        {
            try
            {
                SetContext(context);

                Authorize(new AuthorizeRequest(objectType, criteria, DataPortalOperations.Delete));

                DataPortalResult result;

                var method = DataPortalMethodCache.GetMethodInfo(objectType, "DataPortal_Delete", criteria);

                IDataPortalServer portal;
                switch (method.TransactionalType)
                {
                case TransactionalTypes.EnterpriseServices:
                    portal = new ServicedDataPortal();
                    try
                    {
                        result = portal.Delete(objectType, criteria, context);
                    }
                    finally
                    {
                        ((ServicedDataPortal)portal).Dispose();
                    }
                    break;

                case TransactionalTypes.TransactionScope:
                    portal = new TransactionalDataPortal();
                    result = portal.Delete(objectType, criteria, context);
                    break;

                default:
                    portal = new DataPortalSelector();
                    result = portal.Delete(objectType, criteria, context);
                    break;
                }
                return(result);
            }
            catch (Csla.Server.DataPortalException ex)
            {
                Exception tmp = ex;
                throw;
            }
            catch (Exception ex)
            {
                throw new DataPortalException(
                          "DataPortal.Delete " + Resources.FailedOnServer,
                          new DataPortalExceptionHandler().InspectException(objectType, criteria, "DataPortal.Delete", ex),
                          new DataPortalResult());
            }
            finally
            {
                ClearContext(context);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Delete a business object.
 /// </summary>
 /// <param name="objectType">Type of business object to create.</param>
 /// <param name="criteria">Criteria object describing business object.</param>
 /// <param name="context">
 /// <see cref="Server.DataPortalContext" /> object passed to the server.
 /// </param>
 /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
 public Task <DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
     if (DataPortalServer != null)
     {
         return(DataPortalServer.Delete(objectType, criteria, context, isSync));
     }
     else
     {
         return(DataPortalSelector.Delete(objectType, criteria, context, isSync));
     }
 }
        /// <summary>
        /// Called by the client-side DataPortal to delete an object.
        /// </summary>
        /// <remarks>
        /// This method delegates to
        /// <see cref="SimpleDataPortal">SimpleDataPortal</see>
        /// but wraps that call within a
        /// <see cref="TransactionScope">TransactionScope</see>
        /// to provide transactional support via
        /// System.Transactions.
        /// </remarks>
        /// <param name="objectType">Type of business object to create.</param>
        /// <param name="criteria">Object-specific criteria.</param>
        /// <param name="context">Context data from the client.</param>
        public DataPortalResult Delete(Type objectType, object criteria, DataPortalContext context)
        {
            DataPortalResult result;

            using (TransactionScope tr = new TransactionScope())
            {
                var portal = new DataPortalSelector();
                result = portal.Delete(objectType, criteria, context);
                tr.Complete();
            }
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Called by the client-side DataPortal to delete an object.
        /// </summary>
        /// <remarks>
        /// This method delegates to
        /// <see cref="SimpleDataPortal">SimpleDataPortal</see>
        /// but wraps that call within a
        /// <see cref="TransactionScope">TransactionScope</see>
        /// to provide transactional support via
        /// System.Transactions.
        /// </remarks>
        /// <param name="objectType">Type of business object to create.</param>
        /// <param name="criteria">Object-specific criteria.</param>
        /// <param name="context">Context data from the client.</param>
        /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
        public async Task <DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
        {
            DataPortalResult result;

            using (TransactionScope tr = CreateTransactionScope())
            {
                var portal = new DataPortalSelector();
                result = await portal.Delete(objectType, criteria, context, isSync).ConfigureAwait(false);

                tr.Complete();
            }
            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Delete a business object.
        /// </summary>
        /// <param name="objectType">Type of business object to create.</param>
        /// <param name="criteria">Criteria object describing business object.</param>
        /// <param name="context">
        /// <see cref="Server.DataPortalContext" /> object passed to the server.
        /// </param>
        /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
        public async Task <DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
        {
            try
            {
                SetContext(context);

                Initialize(new InterceptArgs {
                    ObjectType = objectType, Parameter = criteria, Operation = DataPortalOperations.Delete, IsSync = isSync
                });

                AuthorizeRequest(new AuthorizeRequest(objectType, criteria, DataPortalOperations.Delete));
                DataPortalResult     result;
                DataPortalMethodInfo method;
                var factoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType);
                if (factoryInfo != null)
                {
                    var    factoryType = FactoryDataPortal.FactoryLoader.GetFactoryType(factoryInfo.FactoryTypeName);
                    string methodName  = factoryInfo.DeleteMethodName;
                    method = Server.DataPortalMethodCache.GetMethodInfo(factoryType, methodName, criteria);
                }
                else
                {
                    method = DataPortalMethodCache.GetMethodInfo(objectType, "DataPortal_Delete", criteria);
                }

                IDataPortalServer portal;
#if !SILVERLIGHT && !NETFX_CORE
                switch (method.TransactionalAttribute.TransactionType)
                {
#if !MONO
                case TransactionalTypes.EnterpriseServices:
                    portal = GetServicedComponentPortal(method.TransactionalAttribute);
                    try
                    {
                        result = await portal.Delete(objectType, criteria, context, isSync);
                    }
                    finally
                    {
                        ((System.EnterpriseServices.ServicedComponent)portal).Dispose();
                    }
                    break;
#endif
                case TransactionalTypes.TransactionScope:
                    portal = new TransactionalDataPortal(method.TransactionalAttribute);
                    result = await portal.Delete(objectType, criteria, context, isSync);

                    break;

                default:
                    portal = new DataPortalSelector();
                    result = await portal.Delete(objectType, criteria, context, isSync);

                    break;
                }
#else
                portal = new DataPortalSelector();
                result = await portal.Delete(objectType, criteria, context, isSync);
#endif
                Complete(new InterceptArgs {
                    ObjectType = objectType, Parameter = criteria, Result = result, Operation = DataPortalOperations.Delete, IsSync = isSync
                });
                return(result);
            }
            catch (Csla.Server.DataPortalException ex)
            {
                Complete(new InterceptArgs {
                    ObjectType = objectType, Parameter = criteria, Exception = ex, Operation = DataPortalOperations.Delete, IsSync = isSync
                });
                throw;
            }
            catch (AggregateException ex)
            {
                Exception error = null;
                if (ex.InnerExceptions.Count > 0)
                {
                    error = ex.InnerExceptions[0].InnerException;
                }
                else
                {
                    error = ex;
                }
                var fex = DataPortal.NewDataPortalException(
                    "DataPortal.Delete " + Resources.FailedOnServer,
                    new DataPortalExceptionHandler().InspectException(objectType, criteria, "DataPortal.Delete", error),
                    null);
                Complete(new InterceptArgs {
                    ObjectType = objectType, Parameter = criteria, Exception = fex, Operation = DataPortalOperations.Delete, IsSync = isSync
                });
                throw fex;
            }
            catch (Exception ex)
            {
                var fex = DataPortal.NewDataPortalException(
                    "DataPortal.Delete " + Resources.FailedOnServer,
                    new DataPortalExceptionHandler().InspectException(objectType, criteria, "DataPortal.Delete", ex),
                    null);
                Complete(new InterceptArgs {
                    ObjectType = objectType, Parameter = criteria, Exception = fex, Operation = DataPortalOperations.Delete, IsSync = isSync
                });
                throw fex;
            }
            finally
            {
                ClearContext(context);
            }
        }
Exemplo n.º 6
0
        public async Task <DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
        {
            var portal = new DataPortalSelector();

            return(await portal.Delete(objectType, criteria, context, isSync));
        }
 public async Task<DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
   var portal = new DataPortalSelector();
   return await portal.Delete(objectType, criteria, context, isSync).ConfigureAwait(false);
 }
Exemplo n.º 8
0
    /// <summary>
    /// Delete a business object.
    /// </summary>
    /// <param name="objectType">Type of business object to create.</param>
    /// <param name="criteria">Criteria object describing business object.</param>
    /// <param name="context">
    /// <see cref="Server.DataPortalContext" /> object passed to the server.
    /// </param>
    /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
    public async Task<DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
    {
      try
      {
        SetContext(context);

        Initialize(new InterceptArgs { ObjectType = objectType, Parameter = criteria, Operation = DataPortalOperations.Delete, IsSync = isSync });

        AuthorizeRequest(new AuthorizeRequest(objectType, criteria, DataPortalOperations.Delete));
        DataPortalResult result;
        DataPortalMethodInfo method;
        var factoryInfo = ObjectFactoryAttribute.GetObjectFactoryAttribute(objectType);
        if (factoryInfo != null)
        {
          var factoryType = FactoryDataPortal.FactoryLoader.GetFactoryType(factoryInfo.FactoryTypeName);
          string methodName = factoryInfo.DeleteMethodName;
          method = Server.DataPortalMethodCache.GetMethodInfo(factoryType, methodName, criteria);
        }
        else
        {
          method = DataPortalMethodCache.GetMethodInfo(objectType, "DataPortal_Delete", criteria);
        }

        IDataPortalServer portal;
#if !SILVERLIGHT && !NETFX_CORE
        switch (method.TransactionalAttribute.TransactionType)
        {
#if !MONO
          case TransactionalTypes.EnterpriseServices:
            portal = GetServicedComponentPortal(method.TransactionalAttribute);
            try
            {
              result = await portal.Delete(objectType, criteria, context, isSync).ConfigureAwait(false);
            }
            finally
            {
              ((System.EnterpriseServices.ServicedComponent)portal).Dispose();
            }
            break;
#endif
          case TransactionalTypes.TransactionScope:
            portal = new TransactionalDataPortal(method.TransactionalAttribute);
            result = await portal.Delete(objectType, criteria, context, isSync).ConfigureAwait(false);
            break;
          default:
            portal = new DataPortalSelector();
            result = await portal.Delete(objectType, criteria, context, isSync).ConfigureAwait(false);
            break;
        }
#else
        portal = new DataPortalSelector();
        result = await portal.Delete(objectType, criteria, context, isSync).ConfigureAwait(false);
#endif
        Complete(new InterceptArgs { ObjectType = objectType, Parameter = criteria, Result = result, Operation = DataPortalOperations.Delete, IsSync = isSync });
        return result;
      }
      catch (Csla.Server.DataPortalException ex)
      {
        Complete(new InterceptArgs { ObjectType = objectType, Parameter = criteria, Exception = ex, Operation = DataPortalOperations.Delete, IsSync = isSync });
        throw;
      }
      catch (AggregateException ex)
      {
        Exception error = null;
        if (ex.InnerExceptions.Count > 0)
          error = ex.InnerExceptions[0].InnerException;
        else
          error = ex;
        var fex = DataPortal.NewDataPortalException(
            "DataPortal.Delete " + Resources.FailedOnServer,
            new DataPortalExceptionHandler().InspectException(objectType, criteria, "DataPortal.Delete", error),
            null);
        Complete(new InterceptArgs { ObjectType = objectType, Parameter = criteria, Exception = fex, Operation = DataPortalOperations.Delete, IsSync = isSync });
        throw fex;
      }
      catch (Exception ex)
      {
        var fex = DataPortal.NewDataPortalException(
            "DataPortal.Delete " + Resources.FailedOnServer,
            new DataPortalExceptionHandler().InspectException(objectType, criteria, "DataPortal.Delete", ex),
            null);
        Complete(new InterceptArgs { ObjectType = objectType, Parameter = criteria, Exception = fex, Operation = DataPortalOperations.Delete, IsSync = isSync });
        throw fex;
      }
      finally
      {
        ClearContext(context);
      }
    }
Exemplo n.º 9
0
 /// <summary>
 /// Called by the client-side DataPortal to delete an object.
 /// </summary>
 /// <remarks>
 /// This method delegates to 
 /// <see cref="SimpleDataPortal">SimpleDataPortal</see>
 /// but wraps that call within a
 /// <see cref="TransactionScope">TransactionScope</see>
 /// to provide transactional support via
 /// System.Transactions.
 /// </remarks>
 /// <param name="objectType">Type of business object to create.</param>
 /// <param name="criteria">Object-specific criteria.</param>
 /// <param name="context">Context data from the client.</param>
 /// <param name="isSync">True if the client-side proxy should synchronously invoke the server.</param>
 public async Task<DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
   DataPortalResult result;
   using (TransactionScope tr = CreateTransactionScope())
   {
     var portal = new DataPortalSelector();
     result = await portal.Delete(objectType, criteria, context, isSync);
     tr.Complete();
   }
   return result;
 }
Exemplo n.º 10
0
        public DataPortalResult Delete(Type objectType, object criteria, DataPortalContext context)
        {
            var portal = new DataPortalSelector();

            return(portal.Delete(objectType, criteria, context));
        }