Пример #1
0
        public WcfResponse Delete(CriteriaRequest request)
        {
            Csla.Server.DataPortal portal     = new Csla.Server.DataPortal();
            Exception               error     = null;
            DataPortalResult        result    = null;
            WcfResponse             response  = null;
            ISerializationFormatter formatter = SerializationFormatterFactory.GetFormatter();

            try
            {
                request = ConvertRequest(request);
                DataPortalContext context = new DataPortalContext(
                    formatter.Deserialize(request.Principal) as IPrincipal,
                    true,
                    request.ClientCulture,
                    request.ClientUICulture,
                    formatter.Deserialize(request.ClientContext) as ContextDictionary,
                    formatter.Deserialize(request.GlobalContext) as ContextDictionary);
                result   = portal.Delete(Type.GetType(request.TypeName), formatter.Deserialize(request.CriteriaData), context);
                response = new WcfResponse(
                    formatter.Serialize(result.ReturnObject),
                    formatter.Serialize(error),
                    formatter.Serialize(Csla.ApplicationContext.GlobalContext));
            }
            catch (Exception ex)
            {
                error    = ex;
                response = new WcfResponse(
                    null,
                    formatter.Serialize(error),
                    formatter.Serialize(Csla.ApplicationContext.GlobalContext));
            }
            return(ConvertResponse(response));
        }
        public async Task <WcfResponse> Delete(DeleteRequest request)
        {
            Csla.Server.DataPortal portal = new Csla.Server.DataPortal();

            object result;

            try
            {
                result = await portal.Delete(request.ObjectType, request.Criteria, request.Context, true);
            }
            catch (Exception ex)
            {
                result = ex;
            }

            return(new WcfResponse(result));
        }
Пример #3
0
        /// <summary>
        /// Delete a business object.
        /// </summary>
        /// <param name="request">The request parameter object.</param>
        public async Task <HttpResponse> Delete(CriteriaRequest request)
        {
            var result = new HttpResponse();

            try
            {
                request = ConvertRequest(request);

                // unpack criteria data into object
                object criteria = GetCriteria(request.CriteriaData);
                if (criteria is Csla.DataPortalClient.PrimitiveCriteria)
                {
                    criteria = ((Csla.DataPortalClient.PrimitiveCriteria)criteria).Value;
                }

                var objectType = Csla.Reflection.MethodCaller.GetType(AssemblyNameTranslator.GetAssemblyQualifiedName(request.TypeName), true);
                var context    = new DataPortalContext(
                    (IPrincipal)SerializationFormatterFactory.GetFormatter().Deserialize(request.Principal),
                    true,
                    request.ClientCulture,
                    request.ClientUICulture,
                    (ContextDictionary)SerializationFormatterFactory.GetFormatter().Deserialize(request.ClientContext),
                    (ContextDictionary)SerializationFormatterFactory.GetFormatter().Deserialize(request.GlobalContext));

                var prtl = new Csla.Server.DataPortal();
                var dpr  = await prtl.Delete(objectType, criteria, context, true);

                if (dpr.Error != null)
                {
                    result.ErrorData = new HttpErrorInfo(dpr.Error);
                }
                result.GlobalContext = SerializationFormatterFactory.GetFormatter().Serialize(dpr.GlobalContext);
                result.ObjectData    = SerializationFormatterFactory.GetFormatter().Serialize(dpr.ReturnObject);
            }
            catch (Exception ex)
            {
                result.ErrorData = new HttpErrorInfo(ex);
                throw;
            }
            finally
            {
                result = ConvertResponse(result);
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// Delete a business object.
        /// </summary>
        /// <param name="objectTypeName">Type of business object to create.</param>
        /// <param name="criteriaData">Criteria object describing business object.</param>
        /// <param name="contextData">
        /// Server.DataPortalContext object passed to the server.
        /// </param>
        public async Task <byte[]> Delete(string objectTypeName, byte[] criteriaData, byte[] contextData)
        {
            DataPortalResult result;

            try
            {
                var objectType = Csla.Reflection.MethodCaller.GetType(objectTypeName);
                var criteria   = Csla.Serialization.Mobile.MobileFormatter.Deserialize(criteriaData);
                var context    = (DataPortalContext)Csla.Serialization.Mobile.MobileFormatter.Deserialize(contextData);
                var portal     = new Csla.Server.DataPortal();
                result = await portal.Delete(objectType, criteria, context, false);
            }
            catch (Exception ex)
            {
                result = new DataPortalResult(null, ex, null);
            }
            var response   = GetDataPortalResult(result);
            var resultData = Csla.Serialization.Mobile.MobileFormatter.Serialize(response);

            return(resultData);
        }
Пример #5
0
 public WcfResponse Delete(CriteriaRequest request)
 {
   Csla.Server.DataPortal portal = new Csla.Server.DataPortal();
   Exception error = null;
   DataPortalResult result = null;
   WcfResponse response = null;
   ISerializationFormatter formatter = SerializationFormatterFactory.GetFormatter();
   try
   {
     request = ConvertRequest(request);
     DataPortalContext context = new DataPortalContext(
         formatter.Deserialize(request.Principal) as IPrincipal,
         true,
         request.ClientCulture,
         request.ClientUICulture,
         formatter.Deserialize(request.ClientContext) as ContextDictionary,
         formatter.Deserialize(request.GlobalContext) as ContextDictionary);
     result = portal.Delete(Type.GetType(request.TypeName), formatter.Deserialize(request.CriteriaData), context);
     response = new WcfResponse(
         formatter.Serialize(result.ReturnObject),
         formatter.Serialize(error),
         formatter.Serialize(Csla.ApplicationContext.GlobalContext));
   }
   catch (Exception ex)
   {
     error = ex;
     response = new WcfResponse(
         null,
         formatter.Serialize(error),
         formatter.Serialize(Csla.ApplicationContext.GlobalContext));
   }
   return ConvertResponse(response);
 }
Пример #6
0
 /// <summary>
 /// Delete a business object.
 /// </summary>
 /// <param name="objectTypeName">Type of business object to create.</param>
 /// <param name="criteriaData">Criteria object describing business object.</param>
 /// <param name="contextData">
 /// Server.DataPortalContext object passed to the server.
 /// </param>
 public async Task<byte[]> Delete(string objectTypeName, byte[] criteriaData, byte[] contextData)
 {
   DataPortalResult result;
   try
   {
     var objectType = Csla.Reflection.MethodCaller.GetType(objectTypeName);
     var criteria = Csla.Serialization.Mobile.MobileFormatter.Deserialize(criteriaData);
     var context = (DataPortalContext)Csla.Serialization.Mobile.MobileFormatter.Deserialize(contextData);
     var portal = new Csla.Server.DataPortal();
     result = await portal.Delete(objectType, criteria, context, false);
   }
   catch (Exception ex)
   {
     result = new DataPortalResult(null, ex, null);
   }
   var response = GetDataPortalResult(result);
   var resultData = Csla.Serialization.Mobile.MobileFormatter.Serialize(response);
   return resultData;
 }