예제 #1
0
 public async void AddBlockSegment(BlockSegmentVm blockSegment)
 {
     try
     {
         await cacheRepository.AddObject(LIST_BLOCK_SEGMENTS_KEY, blockSegment).ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         Logger.WriteLog(ex);
     }
 }
예제 #2
0
        public async Task <short> CreateVerificationCodeAsync(long currentTime, string id, long?userId = null)
        {
            VerificationCodeInfo existingCode = await GetUserVerificationCodeAsync(userId?.ToString() ?? id).ConfigureAwait(false);

            VerificationCodeInfo vCodeInfo;

            if (existingCode == null)
            {
                short verificationCode;
                verificationCode = (short)RandomExtensions.NextInt32(1000, 9999);
                vCodeInfo        = new VerificationCodeInfo(verificationCode, currentTime, id, 30, userId);
            }
            else
            {
                short extendedTime = (existingCode.WaitingSeconds * 2) < short.MaxValue
                    ? (short)(existingCode.WaitingSeconds * 2)
                    : existingCode.WaitingSeconds;
                vCodeInfo = new VerificationCodeInfo(existingCode.VCode, currentTime, id, extendedTime, userId);
            }
            await cacheRepository.AddObject(string.Format(VERIFICATIONCODE_KEY_FORMAT, userId?.ToString() ?? id), vCodeInfo).ConfigureAwait(false);

            return(vCodeInfo.VCode);
        }