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()); } }
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); } }
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>()); } }
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); } }
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>()); } }
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); } }
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>()); } }
//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>()); } }
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); } }
/// <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); }
public virtual void OnRequestFinish(IConnectionResponse connectionResponse) { }
public ConnectionResponseException(IConnectionResponse response, string message, Exception innerException) : base(message, innerException) { this.Response = response; }
public ConnectionResponseException(IConnectionResponse response) : base() { this.Response = response; }
/// <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); }