コード例 #1
0
 private void ChangeStatus(ApiHubStatus status, Exception e = null)
 {
     if (Status != status || e != null)
     {
         Status = status;
         Changed?.Invoke(status, e);
     }
 }
コード例 #2
0
ファイル: ApiHubService.cs プロジェクト: ScriptBox21/Money
        private void ChangeStatus(ApiHubStatus status, Exception e = null)
        {
            if (Status != status || e != null)
            {
                log.Debug($"Change status from '{Status}' to '{status}'.");

                Status = status;
                Changed?.Invoke(status, e);
            }
        }
コード例 #3
0
 private void OnServerStateChanged(ApiHubStatus status, Exception e)
 {
     log.Debug($"ApiHub update '{status}', '{e?.GetType()?.Name}'.");
     if (status == ApiHubStatus.Disconnected && e != null)
     {
         isHubConnected = false;
         RaiseChanged();
     }
     else if (status == ApiHubStatus.Connected)
     {
         isServerException = false;
         isHubConnected    = true;
         RaiseChanged();
     }
 }
コード例 #4
0
        private async Task SetNextPollStatusAsync(ApiHubStatus status)
        {
            try
            {
                var apiHubBlob = GetBlobReference();

                string statusLine;
                using (StringWriter stringWriter = new StringWriter())
                {
                    _serializer.Serialize(stringWriter, status);
                    statusLine = stringWriter.ToString();
                }

                await apiHubBlob.UploadTextAsync(statusLine);
            }
            catch (Exception e)
            {
                var errorText = string.Format("Encountered an exception while setting the next poll status to the blob storage. Path: {0}, Message: {1} ", this._folderSource.Path, e.Message);
                _trace.Error(errorText);
            }
        }
コード例 #5
0
 private void OnApiHubStateChanged(ApiHubStatus status, Exception e)
 => StateHasChanged();
コード例 #6
0
 private void OnStateChanged(ApiHubStatus status, Exception e)
 {
     UpdateState();
     StateHasChanged();
 }
コード例 #7
0
 private void OnApiHubStateChanged(ApiHubStatus status, Exception e)
 {
     Log.Debug("OnApiHubStateChanged, rerendering.");
     StateHasChanged();
 }
コード例 #8
0
        private async Task OnFileWatcher(IFileItem file, object obj)
        {
            ApiHubFile apiHubFile = new ApiHubFile(file);

            TriggeredFunctionData input = new TriggeredFunctionData
            {
                TriggerValue = apiHubFile
            };

            var functionResult = await _executor.TryExecuteAsync(input, CancellationToken.None);

            string pollStatus = null;
            var    uri        = obj as Uri;

            if (uri != null)
            {
                pollStatus = uri.AbsoluteUri;
            }
            else
            {
                pollStatus = obj.ToString();
            }

            if (functionResult.Succeeded)
            {
                // If function successfully completes then the next poll Uri will be logged in an Azure Blob.
                var status = new ApiHubStatus
                {
                    PollUrl    = pollStatus,
                    FilePath   = Path.GetDirectoryName(apiHubFile.Path),
                    Connection = this._connectionStringSetting
                };

                await SetNextPollStatusAsync(status);
            }
            else
            {
                var status = await GetLastPollStatusAsync();

                if (status == null)
                {
                    status = new ApiHubStatus
                    {
                        FilePath   = Path.GetDirectoryName(apiHubFile.Path),
                        Connection = this._connectionStringSetting
                    };
                }

                if (status.RetryCount < this._apiHubConfig.MaxFunctionExecutionRetryCount)
                {
                    status.RetryCount++;
                    _trace.Error(string.Format("Function {0} failed to successfully process file {1}. Number of retries: {2}. ", _functionName, apiHubFile.Path, status.RetryCount));

                    await SetNextPollStatusAsync(status);
                    await OnFileWatcher(file, obj);
                }
                else
                {
                    // The maximum retries for the function execution has reached. The file info will be added to the poison queue and the next poll status will be updated to skip the file.
                    status.PollUrl    = pollStatus;
                    status.RetryCount = 0;
                    _trace.Error(string.Format("Function {0} failed to successfully process file {1} after max allowed retries of {2}. The file info will be moved to queue {3}.", _functionName, apiHubFile.Path, this._apiHubConfig.MaxFunctionExecutionRetryCount, PoisonQueueName));

                    await MoveToPoisonQueueAsync(apiHubFile);
                    await SetNextPollStatusAsync(status);
                }
            }
        }