/// <summary> /// 缓存刷新-刷新URL和URL目录 /// </summary> /// <param name="urls">要刷新的URL列表</param> /// <param name="dirs">要刷新的URL目录列表</param> /// <returns>缓存刷新的结果</returns> public async Task <RefreshResult> RefreshUrlsAndDirs(string[] urls, string[] dirs) { var request = new RefreshRequest(urls, dirs); var result = new RefreshResult(); try { var url = RefreshEntry; var body = request.ToJsonStr(); var token = _auth.CreateManageToken(url); var hr = await _httpManager.PostJsonAsync(RefreshEntry, body, token); result.Shadow(hr); } catch (Exception ex) { var sb = new StringBuilder(); sb.Append($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.ffff}] [refresh] Error: "); var e = ex; while (e != null) { sb.Append(e.Message + " "); e = e.InnerException; } sb.AppendLine(); result.RefCode = (int)HttpCode.INVALID_ARGUMENT; result.RefText += sb.ToString(); } return(result); }
/// <summary> /// 缓存刷新-刷新URL和URL目录 /// </summary> /// <param name="request">“缓存刷新”请求,详情请参见该类型的说明</param> /// <returns>缓存刷新的结果</returns> public RefreshResult RefreshUrlsAndDirs(RefreshRequest request) { RefreshResult result = new RefreshResult(); try { string url = refreshEntry(); string body = request.ToJsonStr(); string token = auth.CreateManageToken(url); HttpResult hr = httpManager.PostJson(url, body, token); result.Shadow(hr); } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("[{0}] [refresh] Error: ", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")); Exception e = ex; while (e != null) { sb.Append(e.Message + " "); e = e.InnerException; } sb.AppendLine(); result.RefCode = (int)HttpCode.USER_EXCEPTION; result.RefText += sb.ToString(); } return(result); }
/// <summary> /// [异步async]缓存刷新-刷新URL和URL目录 /// </summary> /// <param name="urls">要刷新的URL列表</param> /// <param name="dirs">要刷新的URL目录列表</param> /// <returns>缓存刷新的结果</returns> public async Task <RefreshResult> RefreshUrlsAndDirsAsync(string[] urls, string[] dirs) { RefreshRequest request = new RefreshRequest(urls, dirs); return(await RefreshUrlsAndDirsAsync(request)); }
/// <summary> /// 缓存刷新-刷新URL和URL目录 /// </summary> /// <param name="urls">要刷新的URL列表</param> /// <param name="dirs">要刷新的URL目录列表</param> /// <returns>缓存刷新的结果</returns> public RefreshResult RefreshUrlsAndDirs(string[] urls, string[] dirs) { RefreshRequest request = new RefreshRequest(urls, dirs); return(RefreshUrlsAndDirs(request)); }