Beispiel #1
0
        public override string ToString()
        {
            string value = IsValid ? AccessToken : "no valid access token";

            value += IsExpired ? " (expired)" : $" (valid until {CreatedAt.AddSeconds(ExpiresInSeconds)})";
            return(value);
        }
Beispiel #2
0
        public DateTime?GetNextExecution()
        {
            var parts  = Cron.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            var format = CronFormat.Standard;

            try
            {
                if (parts.Length == 6)
                {
                    format |= CronFormat.IncludeSeconds;
                }
                else if (parts.Length != 5)
                {
                    throw new CronFormatException(
                              $"Wrong number of parts in the `{Cron}` cron expression, you can only use 5 or 6 (with seconds) part-based expressions.");
                }

                return(CronExpression.Parse(Cron, format).GetNextOccurrence(
                           LastExecution ?? CreatedAt.AddSeconds(-1),
                           TimeZone,
                           inclusive: false));
            }
            catch (Exception ex)
            {
                throw new ArgumentException("CRON expression is invalid. Please see the inner exception for details.", "cronExpression", ex);
            }
        }
Beispiel #3
0
 public TicketInfo(TicketUsage usage, string user_Agent, string userID, int timeout = 120)
 {
     Usage      = usage;
     User_Agent = user_Agent;
     UserID     = userID;
     CreatedAt  = DateTime.Now;
     ExpiresAt  = CreatedAt.AddSeconds(timeout);
 }
Beispiel #4
0
 public DateTime?GetNextExecution()
 {
     try
     {
         return(ParseCronExpression(Cron).GetNextOccurrence(
                    LastExecution ?? CreatedAt.AddSeconds(-1),
                    TimeZone,
                    inclusive: false));
     }
     catch (Exception)
     {
         return(null);
     }
 }
        private bool TryGetNextExecution(out DateTime?nextExecution, out Exception exception)
        {
            try
            {
                nextExecution = ParseCronExpression(Cron).GetNextOccurrence(
                    LastExecution ?? CreatedAt.AddSeconds(-1),
                    TimeZone,
                    inclusive: false);

                exception = null;
                return(true);
            }
            catch (Exception ex)
            {
                exception     = ex;
                nextExecution = null;
                return(false);
            }
        }
Beispiel #6
0
 public UrlData(int expirationInSec)
 {
     CreatedAt = DateTime.Now;
     ExpireAt  = CreatedAt.AddSeconds(expirationInSec);
 }
 public bool IsExpired()
 {
     return(DateTime.Now >= CreatedAt.AddSeconds(expires_in - 60));
 }
Beispiel #8
0
 public OAuth2Token()
 {
     CreatedAt = DateTime.Now;
     ExpiresAt = CreatedAt.AddSeconds(-1);
 }