/// <summary>
 /// 從Cookie 中取得使用者資料
 /// </summary>
 /// <returns></returns>
 public override ManagerCurrentUser GetCookie()
 {
     if (!Cookie.IsExist(HttpContext.Current.Request.Url.Authority))
     {
         return(null);
     }
     try
     {
         // var ticket = FormsAuthentication.Decrypt(Cookie.Get(DbName.AgmOfficial));
         var infoString = AzDG.Decrypt(Cookie.Get(HttpContext.Current.Request.Url.Authority));
         var info       = infoString.Split(new[] { CookieSplittor }, StringSplitOptions.None);
         //20131203 加入快取機制
         var principal = CacheProvider.Get <IPrincipal>(info[1]);
         return(principal != null
             ? ((ManagerIdentity)(principal).Identity).CurrentUser
             : User.FetchAdminUserDetail(info[1]));
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
        /// <summary>
        /// 從 Cookie 或快取中取得使用者資料
        /// </summary>
        /// <returns></returns>
        public static IPrincipal GetUser()
        {
            if (!Cookie.IsExist(HttpContext.Current.Request.Url.Authority))
            {
                return(null);
            }

            if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
            {
                //return CacheProvider.Get<IPrincipal>(HttpContext.Current.User.Identity.Name);
                //重設過期時間
                AddCookie(HttpContext.Current.User);
                CacheProvider.Insert(HttpContext.Current.User.Identity.Name, HttpContext.Current.User);
                return(HttpContext.Current.User);
            }
            try
            {
                var infoString = AzDG.Decrypt(Cookie.Get(HttpContext.Current.Request.Url.Authority));
                var info       = infoString.Split(new[] { CookieSplittor }, StringSplitOptions.None);
                //20131203 加入快取機制
                var principal = CacheProvider.Get <IPrincipal>(info[1]);
                if (principal != null)
                {
                    AddCookie(principal);
                    CacheProvider.Insert(principal.Identity.Name, principal);
                    return(principal);
                }
                principal = new ManagerPrincipal(info[1]);
                //重設過期時間
                AddCookie(principal);
                CacheProvider.Insert(info[1], principal);
                return(principal);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }