コード例 #1
0
        private void Handle(IService iService)
        {
            IConnectionResponse connectionResponse = null;

            try
            {
                connectionResponse = ConnectionManager.GetInstance().Handle(iService);
            }
            catch (ConnectionException se)
            {
                Log.Error(typeof(AsyncServiceWorker).Name, "Handle", "SiminovException caught while invoking connection, " + se.GetMessage());

                iService.OnTerminate(new ServiceException(se.GetClassName(), se.GetMethodName(), se.GetMessage()));
                return;
            }

            iService.OnRequestFinish(connectionResponse);

            IDatabase serviceRequest = serviceUtils.Convert(iService);

            try
            {
                serviceRequest.Delete().Execute();
            }
            catch (DatabaseException de)
            {
                Log.Error(typeof(AsyncServiceWorker).Name, "Handle", "Database Exception caught while deleting service request from database, " + de.GetMessage());
                throw new SiminovCriticalException(typeof(AsyncServiceWorker).Name, "Handle", "Database Exception caught while deleting service request from database, " + de.GetMessage());
            }
        }
コード例 #2
0
        public async Task <int> Handle(PrivateSession session, UpdateUserRequest request, Func <PrivateConnection> connectionFactory)
        {
            using (var connection = connectionFactory().ApiName(USER).Method(PrivateConnectionMethod.Update))
            {
                IConnectionResponse response = await connection.SendAsync(request.Data);

                return(response.Code);
            }
        }
コード例 #3
0
        public async Task <IdModel> Handle(PrivateSession session, CreateFieldRequest request, Func <PrivateConnection> connectionFactory)
        {
            using (var connection = connectionFactory().ApiName(FIELD).Method(PrivateConnectionMethod.Create))
            {
                IConnectionResponse response = await connection.SendAsync(request.Data);

                return(await response.ReadAsync <IdModel>());
            }
        }
コード例 #4
0
        public async Task <bool> Handle(PrivateSession session, UpdateFieldRequest requestData, Func <PrivateConnection> connectionFactory)
        {
            using (var connection = connectionFactory().ApiName(CreateFieldHandler.FIELD).Method(PrivateConnectionMethod.Update))
            {
                IConnectionResponse response = await connection.SendAsync(requestData.Data);

                return(response.Code == 204);
            }
        }
コード例 #5
0
ファイル: GetUserHandler.cs プロジェクト: tranxuannam/bk_data
        public async Task <Json.User> Handle(PrivateSession session, GetUserRequest urlParameters, Func <PrivateConnection> connectionFactory)
        {
            using (var connection = connectionFactory().ApiName(USER).Method(PrivateConnectionMethod.Read))
            {
                IConnectionResponse response = await connection.SendAsync(urlParameters.Data);

                return(await response.ReadAsync <Json.User>());
            }
        }
コード例 #6
0
        public async Task <bool> Handle(PrivateSession session, List <string> idList, Func <PrivateConnection> connectionFactory)
        {
            using (var connection = connectionFactory().ApiName(CreateFieldHandler.FIELD).Method(PrivateConnectionMethod.Delete))
            {
                IConnectionResponse response = await connection.SendAsync(new DeleteFieldRequestData(idList));

                return(response.Code == 204);
            }
        }
コード例 #7
0
        public async Task <SearchFieldResponseData> Handle(PrivateSession session, SearchFieldRequest request, Func <PrivateConnection> connectionFactory)
        {
            using (var connection = connectionFactory().ApiName(FIELD_SEARCH).Method(PrivateConnectionMethod.Read))
            {
                IConnectionResponse response = await connection.SendAsync(request.Data);

                return(await response.ReadAsync <SearchFieldResponseData>());
            }
        }
コード例 #8
0
        //public const string FIELD_SEARCH = "/privateapi/field/field-search";
        public async Task <GetFieldResponseData> Handle(PrivateSession session, GetFieldRequest urlParameters, Func <PrivateConnection> connectionFactory)
        {
            StringBuilder relativeUrl = new StringBuilder(CreateFieldHandler.FIELD);

            using (var connection = connectionFactory().ApiName(CreateFieldHandler.FIELD).Method(PrivateConnectionMethod.Read))
            {
                IConnectionResponse response = await connection.SendAsync(urlParameters.Data);

                return(await response.ReadAsync <GetFieldResponseData>());
            }
        }
コード例 #9
0
        public async Task <bool> Handle(PrivateSession session, long id, Func <PrivateConnection> connectionFactory)
        {
            using (var connection = connectionFactory().Method(PrivateConnectionMethod.Read))
            {
                connection.AppendHook(PrivateConnectionHooks.ForceQuery(FileURL));
                IConnectionResponse response = await connection.SendAsync(new DeleteRequestData()
                {
                    Id = id
                });

                return(response.Code == 200);
            }
        }
コード例 #10
0
        /// <summary>
        /// It process the service request
        /// </summary>
        /// <param name="service">Service instance</param>
        public void Process(IService service)
        {
            IConnectionResponse connectionResponse = null;

            try
            {
                connectionResponse = ConnectionManager.GetInstance().Handle(service);
            }
            catch (ConnectionException ce)
            {
                Log.Error(typeof(SyncServiceWorker).Name, "Process", "ConnectionException caught while invoking connection, " + ce.GetMessage());

                service.OnTerminate(new ServiceException(ce.GetClassName(), ce.GetMethodName(), ce.GetMessage()));
                return;
            }

            service.OnRequestFinish(connectionResponse);
        }
コード例 #11
0
 public virtual void OnRequestFinish(IConnectionResponse connectionResponse)
 {
 }
コード例 #12
0
 public ConnectionResponseException(IConnectionResponse response, string message, Exception innerException) : base(message, innerException)
 {
     this.Response = response;
 }
コード例 #13
0
 public ConnectionResponseException(IConnectionResponse response) : base()
 {
     this.Response = response;
 }
コード例 #14
0
        /// <summary>
        /// It handles the service request
        /// </summary>
        /// <param name="service">Service instance</param>
        /// <returns>IConnectionResponse instance</returns>
        /// <exception cref="Siminov.Connect.Exception.ConnectionException">If any exception occur while executing service request</exception>
        public IConnectionResponse Handle(IService service)
        {
            IConnectionRequest connectionRequest = ConnectionHelper.PrepareConnectionRequest(service);

            /*
             * Service Event onServiceApiInvoke
             */
            service.OnRequestInvoke(connectionRequest);

            IConnection connection = null;

            if (connectionRequest.GetProtocol().Equals(Constants.SERVICE_DESCRIPTOR_HTTP_PROTOCOL, StringComparison.OrdinalIgnoreCase))
            {
                connection = httpConnection;
            }
            else if (connectionRequest.GetProtocol().Equals(Constants.SERVICE_DESCRIPTOR_HTTPS_PROTOCOL, StringComparison.OrdinalIgnoreCase))
            {
                connection = httpsConnection;
            }


            IConnectionResponse connectionResponse = null;

            if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_GET_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Get(connectionRequest);
            }
            else if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_HEAD_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Head(connectionRequest);
            }
            else if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_POST_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Post(connectionRequest);
            }
            else if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_PUT_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Put(connectionRequest);
            }
            else if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_DELETE_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Delete(connectionRequest);
            }
            else if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_TRACE_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Trace(connectionRequest);
            }
            else if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_OPTIONS_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Options(connectionRequest);
            }
            else if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_CONNECT_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Connect(connectionRequest);
            }
            else if (connectionRequest.GetType().Equals(Constants.SERVICE_DESCRIPTOR_REQUEST_PATCH_TYPE, StringComparison.OrdinalIgnoreCase))
            {
                connectionResponse = connection.Patch(connectionRequest);
            }

            return(connectionResponse);
        }
コード例 #15
0
ファイル: Service.cs プロジェクト: gitter-badger/connect-1
 public virtual void OnRequestFinish(IConnectionResponse connectionResponse) { }