public async Task <ProcessStartResponsePayload> StartProcessInstance <TInputValues>( IIdentity identity, string processModelId, string startEventId, ProcessStartRequestPayload <TInputValues> processStartRequestPayload, StartCallbackType callbackType = StartCallbackType.CallbackOnProcessInstanceCreated, string endEventId = "") where TInputValues : new() { if (identity == null) { throw new UnauthorizedAccessException(nameof(identity)); } var noEndEventIdProvided = callbackType == StartCallbackType.CallbackOnEndEventReached && String.IsNullOrEmpty(endEventId); if (noEndEventIdProvided) { throw new ArgumentNullException(nameof(endEventId)); } var endpoint = RestSettings.Paths.StartProcessInstance .Replace(RestSettings.Params.ProcessModelId, processModelId); var urlWithEndpoint = this.ApplyBaseUrl(endpoint); var urlWithParams = $"{RestSettings.Endpoints.ConsumerAPI}{endpoint}?start_callback_type={(int)callbackType}"; var startEventIdProvided = !String.IsNullOrEmpty(startEventId); if (startEventIdProvided) { urlWithParams = $"{urlWithParams}&start_event_id={startEventId}"; } var attachEndEventId = callbackType == StartCallbackType.CallbackOnEndEventReached; if (attachEndEventId) { urlWithParams = $"{urlWithParams}&end_event_id={endEventId}"; } var jsonResult = ""; var jsonPayload = SerializeForProcessEngine(processStartRequestPayload); var requestContent = new StringContent(jsonPayload, Encoding.UTF8, "application/json"); var request = this.CreateRequestMessage(identity, HttpMethod.Post, urlWithParams, requestContent); var result = await this.httpClient.SendAsync(request); if (result.IsSuccessStatusCode) { jsonResult = await result.Content.ReadAsStringAsync(); var parsedResult = JsonConvert.DeserializeObject <ProcessStartResponsePayload>(jsonResult); return(parsedResult); } throw new Exception("Process could not be started."); }
public async Task <ProcessStartResponse <TResponsePayload> > StartProcessInstance <TResponsePayload>( string processModelId, string startEventId, StartCallbackType startCallbackType = StartCallbackType.CallbackOnProcessInstanceCreated, string endEventId = "") where TResponsePayload : new() { var request = new ProcessStartRequest <object>(); return(await this.StartProcessInstance <object, TResponsePayload>(processModelId, startEventId, request, startCallbackType, endEventId)); }
public async Task <ProcessStartResponse <TResponsePayload> > StartProcessInstance <TRequestPayload, TResponsePayload>( string processModelId, string startEventId, ProcessStartRequest <TRequestPayload> request, StartCallbackType startCallbackType = StartCallbackType.CallbackOnProcessInstanceCreated, string endEventId = "" ) where TRequestPayload : new() where TResponsePayload : new() { var noEndEventIdProvided = startCallbackType == StartCallbackType.CallbackOnEndEventReached && String.IsNullOrEmpty(endEventId); if (noEndEventIdProvided) { throw new ArgumentNullException(nameof(endEventId), "Must provide an EndEventId, when using callback type 'CallbackOnEndEventReached'!"); } var payload = new ProcessStartRequestPayload <TRequestPayload>(); payload.CallerId = request.ParentProcessInstanceId; payload.CorrelationId = request.CorrelationId; payload.InputValues = request.Payload; var url = this.BuildStartProcessInstanceUrl(processModelId, startEventId, endEventId, startCallbackType); var response = await this.HttpFacade.SendRequestAndExpectResult <ProcessStartRequestPayload <TRequestPayload>, ProcessStartResponsePayload>(HttpMethod.Post, url, payload); var parsedResponse = new ProcessStartResponse <TResponsePayload>( response.ProcessInstanceId, response.CorrelationId, response.EndEventId, (TResponsePayload)response.TokenPayload ); return(parsedResponse); }
static extern IntPtr sfSoundStream_Create(StartCallbackType OnStart, GetDataCallbackType OnGetData, uint ChannelsCount, uint SampleRate, IntPtr UserData);
//////////////////////////////////////////////////////////// /// <summary> /// Set the audio stream parameters, you must call it before Play() /// </summary> /// <param name="sampleRate">Number of channels</param> /// <param name="channelsCount">Sample rate, in samples per second</param> //////////////////////////////////////////////////////////// protected void Initialize(uint channelsCount, uint sampleRate) { myStartCallback = new StartCallbackType(Start); myGetDataCallback = new GetDataCallbackType(GetData); SetThis(sfSoundStream_Create(myStartCallback, myGetDataCallback, channelsCount, sampleRate, IntPtr.Zero)); }
private string BuildStartProcessInstanceUrl(string processModelId, string startEventId, string endEventId, StartCallbackType startCallbackType) { var endpoint = ConsumerApiRestSettings.Paths.StartProcessInstance .Replace(ConsumerApiRestSettings.Params.ProcessModelId, processModelId); var url = $"{endpoint}?start_callback_type={(int)startCallbackType}"; if (!String.IsNullOrEmpty(startEventId)) { url = $"{url}&start_event_id={startEventId}"; } if (startCallbackType == StartCallbackType.CallbackOnEndEventReached) { url = $"{url}&end_event_id={endEventId}"; } return(url); }