Ejemplo n.º 1
0
        public async Task <WcfResponse> Create(CriteriaRequest request)
#endif
        {
            var result = new WcfResponse();

            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 processor     = new MobileRequestProcessor();
                var createRequest = new MobileCriteriaRequest(
                    request.TypeName,
                    criteria,
                    (IPrincipal)MobileFormatter.Deserialize(request.Principal),
                    (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext),
                    (ContextDictionary)MobileFormatter.Deserialize(request.ClientContext),
                    request.ClientCulture,
                    request.ClientUICulture);

#if NET40
                var createResponse = processor.Create(createRequest);
#else
                var createResponse = await processor.Create(createRequest).ConfigureAwait(false);
#endif
                if (createResponse.Error != null)
                {
                    result.ErrorData = new WcfErrorInfo(createResponse.Error);
                }
                result.GlobalContext = MobileFormatter.Serialize(createResponse.GlobalContext);
                result.ObjectData    = MobileFormatter.Serialize(createResponse.Object);
            }
            catch (Exception ex)
            {
                result.ErrorData = new WcfErrorInfo(ex);
            }
            finally
            {
                MobileRequestProcessor.ClearContext();
            }
            return(ConvertResponse(result));
        }
Ejemplo n.º 2
0
    public async Task<WcfResponse> Create(CriteriaRequest request)
#endif
    {
      var result = new WcfResponse();
      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 processor = new MobileRequestProcessor();
        var createRequest = new MobileCriteriaRequest(
          request.TypeName,
          criteria,
          (IPrincipal)MobileFormatter.Deserialize(request.Principal),
          (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext),
          (ContextDictionary)MobileFormatter.Deserialize(request.ClientContext),
          request.ClientCulture,
          request.ClientUICulture);

#if NET40
        var createResponse = processor.Create(createRequest);
#else
        var createResponse = await processor.Create(createRequest).ConfigureAwait(false);
#endif
        if (createResponse.Error != null)
        {
          result.ErrorData = new WcfErrorInfo(createResponse.Error);
        }
        result.GlobalContext = MobileFormatter.Serialize(createResponse.GlobalContext);
        result.ObjectData = MobileFormatter.Serialize(createResponse.Object);
      }
      catch (Exception ex)
      {
        result.ErrorData = new WcfErrorInfo(ex);
      }
      finally
      {
        MobileRequestProcessor.ClearContext();
      }
      return ConvertResponse(result);

    }
Ejemplo n.º 3
0
        public WcfResponse Fetch(CriteriaRequest request)
        {
            var result = new WcfResponse();

            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 processor    = new MobileRequestProcessor();
                var fetchRequest = new MobileCriteriaRequest(
                    request.TypeName,
                    criteria,
                    (IPrincipal)MobileFormatter.Deserialize(request.Principal),
                    (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext),
                    (ContextDictionary)MobileFormatter.Deserialize(request.ClientContext),
                    request.ClientCulture,
                    request.ClientUICulture);

                var fetchResponse = processor.Fetch(fetchRequest);
                if (fetchResponse.Error != null)
                {
                    result.ErrorData = new WcfErrorInfo(fetchResponse.Error);
                }
                result.GlobalContext = MobileFormatter.Serialize(fetchResponse.GlobalContext);
                result.ObjectData    = MobileFormatter.Serialize(fetchResponse.Object);
            }
            catch (Exception ex)
            {
                result.ErrorData = new WcfErrorInfo(ex);
            }
            finally
            {
                MobileRequestProcessor.ClearContext();
            }
            return(ConvertResponse(result));
        }
Ejemplo n.º 4
0
    public WcfResponse Fetch(CriteriaRequest request)
    {
      var result = new WcfResponse();
      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 processor = new MobileRequestProcessor();
        var fetchRequest = new MobileCriteriaRequest(
          request.TypeName,
          criteria,
          (IPrincipal)MobileFormatter.Deserialize(request.Principal),
          (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext),
          (ContextDictionary)MobileFormatter.Deserialize(request.ClientContext),
          request.ClientCulture,
          request.ClientUICulture);

        var fetchResponse = processor.Fetch(fetchRequest);
        if (fetchResponse.Error != null)
        {
          result.ErrorData = new WcfErrorInfo(fetchResponse.Error);
        }
        result.GlobalContext = MobileFormatter.Serialize(fetchResponse.GlobalContext);
        result.ObjectData = MobileFormatter.Serialize(fetchResponse.Object);
      }
      catch (Exception ex)
      {
        result.ErrorData = new WcfErrorInfo(ex);
      }
      finally
      {
        MobileRequestProcessor.ClearContext();
      }
      return ConvertResponse(result);
    }
Ejemplo n.º 5
0
 public WcfResponse Fetch(CriteriaRequest request)
Ejemplo n.º 6
0
 public WcfResponse Create(CriteriaRequest request)
Ejemplo n.º 7
0
 /// <summary>
 /// Override to convert the request data before it
 /// is transferred over the network.
 /// </summary>
 /// <param name="request">Request object.</param>
 protected virtual CriteriaRequest ConvertRequest(CriteriaRequest request)
 {
   return request;
 }
Ejemplo n.º 8
0
 public WcfResponse Delete(CriteriaRequest request)
Ejemplo n.º 9
0
 public WcfResponse Fetch(CriteriaRequest request)
Ejemplo n.º 10
0
 public WcfResponse Create(CriteriaRequest request)
Ejemplo n.º 11
0
 /// <summary>
 /// Override to convert the request data before it
 /// is transferred over the network.
 /// </summary>
 /// <param name="request">Request object.</param>
 protected virtual CriteriaRequest ConvertRequest(CriteriaRequest request)
 {
     return(request);
 }
Ejemplo n.º 12
0
 public WcfResponse Delete(CriteriaRequest request)