public async Task <IActionResult> Logout(string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            await _signInManager.SignOutAsync();

            var endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            var utime   = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;

            System.DateTime startTime       = CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            DateTime        translateDate   = startTime.AddSeconds(utime);
            var             res             = _dbHelper.ExecSqlStoredProcedure("call login_time_length('" + translateDate.ToString("yyyy-MM-dd HH:mm:ss") + "'," + _user.Id + ",@s);");
            var             userOnLineTimes = "";

            if (res != null && res.Tables.Count > 0)
            {
                userOnLineTimes = res.Tables[0].Rows[0].ItemArray[0].ToString();
            }
            _memoryCache.Remove(_user.Name + "_" + _user.Id); //注销时移除client 连接id
            _logger.LogCustomerInfo($"{_user.Name} 注销登录,在线时长:{userOnLineTimes}", nameof(LoginAsync), nameof(AccountController), null);
            if (returnUrl != null)
            {
                return(LocalRedirect(returnUrl));
            }
            else
            {
                return(RedirectToAction("HomePage", "Home"));
            }
        }
 /// <summary>
 /// Loads the object from the data specified
 /// </summary>
 /// <param name="Data">Data to load into the object</param>
 protected override void LoadFromData(string Data)
 {
     foreach (Match TempMatch in Regex.Matches(Data, "(?<Title>[^\r\n:]+):(?<Value>[^\r\n]*)"))
     {
         if (TempMatch.Groups["Title"].Value.ToUpperInvariant() == "DTSTART")
         {
             StartTime = CurrentTimeZone.ToLocalTime(DateTime.Parse(TempMatch.Groups["Value"].Value.ToString(@"####/##/## ##:##")));
         }
         else if (TempMatch.Groups["Title"].Value.ToUpperInvariant() == "DTEND")
         {
             EndTime = CurrentTimeZone.ToLocalTime(DateTime.Parse(TempMatch.Groups["Value"].Value.ToString(@"####/##/## ##:##")));
         }
         else if (TempMatch.Groups["Title"].Value.ToUpperInvariant() == "LOCATION")
         {
             this.Location = TempMatch.Groups["Value"].Value;
         }
         else if (TempMatch.Groups["Title"].Value.ToUpperInvariant() == "SUMMARY;LANGUAGE=EN-US")
         {
             Subject = TempMatch.Groups["Value"].Value;
         }
         else if (TempMatch.Groups["Title"].Value.ToUpperInvariant() == "DESCRIPTION" && string.IsNullOrEmpty(Description))
         {
             Description = TempMatch.Groups["Value"].Value;
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 将本地时间转换为时间戳--毫秒级
        /// </summary>
        /// <param name="datetime"></param>
        /// <returns></returns>
        public static long ToUnixTime(this DateTime date)
        {
            var startTime = CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区

            return(Convert.ToInt64((date - startTime).TotalSeconds * 1000));

            //var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            //return Convert.ToInt64((date - epoch).TotalSeconds * 1000);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到13位时间戳
        /// </summary>
        /// <param name="time"></param>
        /// <param name="dateTimeKind"></param>
        /// <returns></returns>
        public static long GetTimeSpan(this DateTime?time, DateTimeKind dateTimeKind = DateTimeKind.Utc)
        {
            if (time == null)
            {
                time = DateTime.Now;
            }
            var  startTime = CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, 0, dateTimeKind));
            long t         = (time.Value.Ticks - startTime.Ticks) / 10000; //除10000调整为13位

            return(t);
        }
Exemplo n.º 5
0
        /// <summary>
        /// DateTime时间格式转换为10位不带毫秒的Unix时间戳
        /// </summary>
        /// <param name="time"> DateTime时间格式</param>
        /// <param name="dateTimeKind"></param>
        /// <returns>Unix时间戳格式</returns>
        public static int ConvertDateTimeInt(this DateTime time, DateTimeKind dateTimeKind = DateTimeKind.Utc)
        {
            DateTime startTime = CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, dateTimeKind));

            return((int)(time - startTime).TotalSeconds);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     取时间戳生成随即数,替换交易单号中的后10位流水号
        /// </summary>
        /// <returns></returns>
        internal uint UnixStamp()
        {
            var ts = DateTime.Now - CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));

            return(Convert.ToUInt32(ts.TotalSeconds));
        }
Exemplo n.º 7
0
        public static long ToTimeStamp(this DateTime dateTime)
        {
            var startTime = CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));

            return((long)(dateTime - startTime).TotalMilliseconds);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 将本地时间转换为时间戳
        /// </summary>
        /// <param name="datetime"></param>
        /// <returns></returns>
        public static double ToTimeStamp(this DateTime datetime)
        {
            var startTime = CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区

            return((datetime - startTime).TotalSeconds);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 将时间戳转换为本地时间
        /// </summary>
        /// <param name="timeStamp"></param>
        /// <returns></returns>
        public static DateTime ToDateTimeByTimeStamp(this double timeStamp)
        {
            var startTime = CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区

            return(startTime.AddSeconds(timeStamp));
        }