Beispiel #1
0
        public StochasticRecurringWorker()
        {
            _log   = ClassLogger.Create(GetType());
            _dblog = DebugOnlyLogger.Create(_log);

            var rand = GoodSeedRandom.Create();

            _baseTime = DateTime.UtcNow + TimeSpan.FromMinutes(rand.Next(_delay));
        }
Beispiel #2
0
        protected SleepyWorkerEntryPoint()
        {
            MinThreadSleep     = 100;
            MaxThreadSleep     = 2200;
            CurrentThreadSleep = MinThreadSleep;
            _log   = ClassLogger.Create(typeof(SleepyWorkerEntryPoint));
            _dblog = DebugOnlyLogger.Create(_log);

            _log.InfoFormat("Creating new {0}", GetType());
        }
        //the way a code is encrypted may be changed by class inheritors
        //but adding the _magic is unique using the | separator and _magic
        protected static string GenerateCode(string plainText)
        {
            var log   = ClassLogger.Create(typeof(AuthorizationCode));
            var dblog = DebugOnlyLogger.Create(log);

            var cryptText = PWCrypto.Encrypt(plainText, _pwd);

            dblog.InfoFormat(GeneratedCodeMsgFormat, plainText);

            return(cryptText);
        }
Beispiel #4
0
 public Recurrence()
 {
     DaysOfMonth  = null;
     DaysOfWeek   = null;
     MonthsLater  = 0;
     DaysLater    = 0;
     HoursLater   = 0;
     MinutesLater = 0;
     AtFixedTime  = DateTime.MinValue;
     _log         = ClassLogger.Create(GetType());
     _dblog       = DebugOnlyLogger.Create(_log);
 }
        public InMemoryCachedData()
        {
            _log   = ClassLogger.Create(GetType());
            _dblog = DebugOnlyLogger.Create(_log);

            var config = Catalog.Factory.Resolve <IConfig>(SpecialFactoryContexts.Routed);

            ExpireItems       = config.Get(CachedDataLocalConfig.OptionalGroomExpiredData, false);
            RenewOnCacheHit   = config.Get(CachedDataLocalConfig.OptionalCacheHitRenewsExpiration, false);
            DisposeOfData     = config.Get(CachedDataLocalConfig.OptionalDisposeData, false);
            DefaultExpireTime =
                TimeSpan.FromSeconds(config.Get(CachedDataLocalConfig.OptionalDefaultExpirationTimeSeconds, 3600));
            MaximumCacheItemsCount = config.Get(CachedDataLocalConfig.OptionalMaximumCacheSize, 0);
            NotifyExpiredWithData  = config.Get(CachedDataLocalConfig.OptionalNotifyExpiredWithData, true);

            _nextGroomSchedule = DateTime.UtcNow + _groomScheduleTimeOut;
        }
        //validates an auth code
        public static bool IsGoodAuthCode(string authCode)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(authCode));

            var log   = ClassLogger.Create(typeof(AuthorizationCode));
            var dblog = DebugOnlyLogger.Create(log);

            try
            {
                var plain = DecryptCode(authCode);

                dblog.InfoFormat(DecryptedAuthCodeFormat, plain);

                var parts = plain.Split(Separator);
                if (parts.Length != 2)
                {
                    log.ErrorFormat(AuthCodeFailedFormat, plain);
                    return(false);
                }

                var goodGuid = GuidEncoder.Decode(parts[0]);
                if (Guid.Empty != goodGuid && parts[1].Contains(_magic))
                {
                    dblog.InfoFormat(AuthCodeAuthorizedFormat, plain);
                    return(true);
                }

                //when not in right format
                log.ErrorFormat(AuthCodeFailedFormat, plain);
                return(false);
            }
            catch (Exception exception)
            {
                log.Error("IsGoodAuthCode", exception);
                log.ErrorFormat(AuthCodeFailedFormat, authCode);
                return(false);
            }
        }