public override string ToString() { string value = IsValid ? AccessToken : "no valid access token"; value += IsExpired ? " (expired)" : $" (valid until {CreatedAt.AddSeconds(ExpiresInSeconds)})"; return(value); }
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); } }
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); }
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); } }
public UrlData(int expirationInSec) { CreatedAt = DateTime.Now; ExpireAt = CreatedAt.AddSeconds(expirationInSec); }
public bool IsExpired() { return(DateTime.Now >= CreatedAt.AddSeconds(expires_in - 60)); }
public OAuth2Token() { CreatedAt = DateTime.Now; ExpiresAt = CreatedAt.AddSeconds(-1); }