コード例 #1
0
        /// <summary>
        /// [异步async]查询日志列表,获取日志的下载外链
        /// </summary>
        /// <param name="request">“日志查询”请求,详情请参阅该类型的说明</param>
        /// <returns>日志查询的结果</returns>
        public async Task <LogListResult> GetCdnLogListAsync(LogListRequest request)
        {
            LogListResult result = new LogListResult();

            try
            {
                string url   = logListEntry();
                string body  = request.ToJsonStr();
                string token = auth.CreateManageToken(url);

                HttpResult hr = await httpManager.PostJsonAsync(url, body, token);

                result.Shadow(hr);
            }
            catch (Exception ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("[{0}] [LogList] 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);
        }
コード例 #2
0
        /// <summary>
        /// 查询日志列表,获取日志的下载外链
        /// </summary>
        /// <param name="domains">域名列表</param>
        /// <param name="day">具体日期,例如2017-08-12</param>
        /// <returns>日志查询的结果</returns>
        public LogListResult GetCdnLogList(string[] domains, string day)
        {
            LogListRequest request = new LogListRequest();

            request.Domains = string.Join(";", domains);
            request.Day     = day;
            LogListResult result = new LogListResult();

            try
            {
                string url   = logListEntry();
                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}] [loglist] 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.INVALID_ARGUMENT;
                result.RefText += sb.ToString();
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        ///     查询日志列表,获取日志的下载外链
        /// </summary>
        /// <param name="domains">域名列表</param>
        /// <param name="day">具体日期,例如2017-08-12</param>
        /// <returns>日志查询的结果</returns>
        public async Task <LogListResult> GetCdnLogList(string[] domains, string day)
        {
            var request = new LogListRequest
            {
                Domains = string.Join(";", domains),
                Day     = day
            };
            var result = new LogListResult();

            try
            {
                var url   = LogListEntry;
                var body  = request.ToJsonStr();
                var token = _auth.CreateManageToken(url);

                var hr = await _httpManager.PostJsonAsync(url, body, token);

                result.Shadow(hr);
            }
            catch (Exception ex)
            {
                var sb = new StringBuilder();
                sb.Append($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.ffff}] [loglist] 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);
        }