コード例 #1
0
        public IEnumerable <ConsoleLine> GetLines(ConsoleId consoleId, int start, int end)
        {
            if (consoleId == null)
            {
                throw new ArgumentNullException(nameof(consoleId));
            }

            var useOldKeys = false;
            var items      = _connection.GetRangeFromSet(consoleId.GetSetKey(), start, end);

            if (items == null || items.Count == 0)
            {
                // Read operations should be backwards compatible and use
                // old keys, if new one don't contain any data.
                items      = _connection.GetRangeFromSet(consoleId.GetOldConsoleKey(), start, end);
                useOldKeys = true;
            }

            foreach (var item in items)
            {
                var line = JobHelper.FromJson <ConsoleLine>(item);

                if (line.IsReference)
                {
                    if (useOldKeys)
                    {
                        try
                        {
                            line.Message = _connection.GetValueFromHash(consoleId.GetOldConsoleKey(), line.Message);
                        }
                        catch
                        {
                            // This may happen, when using Hangfire.Redis storage and having
                            // background job, whose console session was stored using old key
                            // format.
                        }
                    }
                    else
                    {
                        line.Message = _connection.GetValueFromHash(consoleId.GetHashKey(), line.Message);
                    }

                    line.IsReference = false;
                }

                yield return(line);
            }
        }
コード例 #2
0
        public static List <RecurringJobDto> GetRecurringJobs(
            [NotNull] this JobStorageConnection connection,
            int startingFrom,
            int endingAt)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }

            var ids = connection.GetRangeFromSet("recurring-jobs", startingFrom, endingAt);

            return(GetRecurringJobDtos(connection, ids));
        }
コード例 #3
0
        public IEnumerable <ConsoleLine> GetLines(ConsoleId consoleId, int start, int end)
        {
            if (consoleId == null)
            {
                throw new ArgumentNullException(nameof(consoleId));
            }

            foreach (var item in _connection.GetRangeFromSet(consoleId.ToString(), start, end))
            {
                var line = JobHelper.FromJson <ConsoleLine>(item);

                if (line.IsReference)
                {
                    line.Message     = _connection.GetValueFromHash(consoleId.ToString(), line.Message);
                    line.IsReference = false;
                }

                yield return(line);
            }
        }
コード例 #4
0
 public override List <string> GetRangeFromSet(string key, int startingFrom, int endingAt)
 {
     return(_sqlServerConnection.GetRangeFromSet(key, startingFrom, endingAt));
 }