Exemple #1
0
        /// <summary>
        /// Gets the log paths.
        /// </summary>
        /// <returns></returns>
        private IEnumerable <string> GetLogPaths()
        {
            IEnumerable <string> logs = new List <string>();

            this.TryExecute(
                () =>
            {
                ILogsClient client = this.factory.Create <ILogsClient>();
                logs = client.GetLogNames();
                this.View.ClearException();
            },
                () =>
            {
                // If the service goes down, we still need to see the log files.
                string location = ApplicationSettings.Current.AlternateLogLocation;
                if (!string.IsNullOrWhiteSpace(location))
                {
                    logs = Directory.GetFiles(location);
                    this.View.ClearException();
                }
            },
                true);

            return(logs);
        }
Exemple #2
0
        /// <summary>
        /// Gets the entries.
        /// </summary>
        /// <param name="logFileName">Name of the log file.</param>
        /// <param name="page">The page.</param>
        /// <param name="searchQuery">The search query.</param>
        /// <returns></returns>
        public PagingResult <LogEntry> GetEntries(string logFileName, int?page = null, string searchQuery = null)
        {
            string location  = ApplicationSettings.Current.AlternateLogLocation;
            bool   showError = !string.IsNullOrWhiteSpace(location);
            PagingResult <LogEntry> entries = new PagingResult <LogEntry>();
            int pagingSize = ApplicationSettings.Current.DefaultPagingSize;

            this.TryExecute(
                () =>
            {
                ILogsClient client = this.factory.Create <ILogsClient>();
                entries            = client.GetLogEntries(logFileName, page, searchQuery, pagingSize);
            },
                () =>
            {
                if (!string.IsNullOrWhiteSpace(location))
                {
                    var logs = new List <LogEntry>();
                    logLoader.LoadLogs(logs, Path.Combine(ApplicationSettings.Current.AlternateLogLocation, logFileName));
                    entries = LogLoader.FilterLogs(logs, page, searchQuery, pagingSize);
                }
            },
                showError);

            return(entries);
        }
Exemple #3
0
        public iBanFirstClient(HttpClient httpClient,
                               string userName               = null,
                               string clientSecret           = null,
                               ILoggerFactory loggerFactory  = null,
                               TargetEnvironment environment = TargetEnvironment.SANDBOX)
            : base(httpClient, userName, clientSecret, loggerFactory)
        {
            SetBaseUri(environment == TargetEnvironment.PRODUCTION ? iBanFirstUrls.PRODUCTION : iBanFirstUrls.SANDBOX);

            _walletsClient              = new WalletsClient(this);
            _financialMovementsClient   = new FinancialMovementsClient(this);
            _externalBankAccountsClient = new ExternalBankAccountsClient(this);
            _paymentsClient             = new PaymentsClient(this);
            _tradesClient    = new TradesClient(this);
            _documentsClient = new DocumentsClient(this);
            _logsClient      = new LogsClient(this);
        }
Exemple #4
0
        public static async Task <LogEntryDto[]> WaitForLogEntriesAsync(this ILogsClient logsClient, string appId,
                                                                        Func <LogEntryDto, bool> condition, TimeSpan timeout)
        {
            var result = Array.Empty <LogEntryDto>();

            using (var cts = new CancellationTokenSource(timeout))
            {
                while (!cts.IsCancellationRequested)
                {
                    var response = await logsClient.GetLogsAsync(appId, cancellationToken : cts.Token);

                    if (response.Items.Count > 0 && (condition == null || response.Items.Any(condition)))
                    {
                        result = response.Items.ToArray();
                        break;
                    }

                    await Task.Delay(50);
                }
            }

            return(result);
        }
 public LogService(ILogsClient logsClient)
 {
     _logsClient = logsClient;
 }