コード例 #1
0
ファイル: WcfPortal.cs プロジェクト: BiYiTuan/csla
    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);

    }
コード例 #2
0
ファイル: WcfPortal.cs プロジェクト: zuiwanting/csla
        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));
        }
コード例 #3
0
ファイル: WcfPortal.cs プロジェクト: zuiwanting/csla
        public async Task <WcfResponse> Update(UpdateRequest request)
#endif
        {
            var result = new WcfResponse();

            try
            {
                request = ConvertRequest(request);
                // unpack object
                object obj = GetCriteria(request.ObjectData);

                var processor     = new MobileRequestProcessor();
                var updateRequest = new MobileUpdateRequest(
                    obj,
                    (IPrincipal)MobileFormatter.Deserialize(request.Principal),
                    (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext),
                    (ContextDictionary)MobileFormatter.Deserialize(request.ClientContext),
                    request.ClientCulture,
                    request.ClientUICulture);

#if NET40
                var updateResponse = processor.Update(updateRequest);
#else
                var updateResponse = await processor.Update(updateRequest).ConfigureAwait(false);
#endif
                if (updateResponse.Error != null)
                {
                    result.ErrorData = new WcfErrorInfo(updateResponse.Error);
                }
                result.GlobalContext = MobileFormatter.Serialize(updateResponse.GlobalContext);
                result.ObjectData    = MobileFormatter.Serialize(updateResponse.Object);
            }
            catch (Exception ex)
            {
                result.ErrorData = new WcfErrorInfo(ex);
            }
            finally
            {
                MobileRequestProcessor.ClearContext();
            }
            return(ConvertResponse(result));
        }
コード例 #4
0
ファイル: WcfPortal.cs プロジェクト: eugene-h-lin/csla-svn
        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));
        }
コード例 #5
0
ファイル: WcfPortal.cs プロジェクト: BiYiTuan/csla
    public async Task<WcfResponse> Update(UpdateRequest request)
#endif
    {
      var result = new WcfResponse();
      try
      {
        request = ConvertRequest(request);
        // unpack object
        object obj = GetCriteria(request.ObjectData);

        var processor = new MobileRequestProcessor();
        var updateRequest = new MobileUpdateRequest(
          obj,
          (IPrincipal)MobileFormatter.Deserialize(request.Principal),
          (ContextDictionary)MobileFormatter.Deserialize(request.GlobalContext),
          (ContextDictionary)MobileFormatter.Deserialize(request.ClientContext),
          request.ClientCulture,
          request.ClientUICulture);

#if NET40
        var updateResponse = processor.Update(updateRequest);
#else
        var updateResponse = await processor.Update(updateRequest).ConfigureAwait(false);
#endif
        if (updateResponse.Error != null)
        {
          result.ErrorData = new WcfErrorInfo(updateResponse.Error);
        }
        result.GlobalContext = MobileFormatter.Serialize(updateResponse.GlobalContext);
        result.ObjectData = MobileFormatter.Serialize(updateResponse.Object);
      }
      catch (Exception ex)
      {
        result.ErrorData = new WcfErrorInfo(ex);
      }
      finally
      {
        MobileRequestProcessor.ClearContext();
      }
      return ConvertResponse(result);
    }
コード例 #6
0
ファイル: WcfPortal.cs プロジェクト: nschonni/csla-svn
    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);
    }