private void Button_FusionLoglist_Click(object sender, RoutedEventArgs e) { if (!TryInit()) { return; } string domains = TextBox_FusionLoglistDomains.Text.Trim(); if (string.IsNullOrEmpty(domains)) { TextBox_FusionLogListResultText.Text = "请填写domain"; return; } string day = TextBox_FusionLoglistDay.Text.Trim(); if (string.IsNullOrEmpty(day)) { TextBox_FusionLogListResultText.Text = "请填写day"; return; } LogListRequest request = new LogListRequest(day, domains); var result = cdnManager.GetCdnLogList(request); TextBox_FusionLogListResultText.Text = result.Text; TextBox_FusionLogListResultString.Text = result.ToString(); }
/// <summary> /// 日志列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public LogListResult LogList(LogListRequest request) { LogListResult result = new LogListResult(); string url = loglistUrl(); string body = request.ToJsonStr(); byte[] data = Encoding.UTF8.GetBytes(body); string token = Auth.createManageToken(url, null, mac); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Authorization", token); httpMgr.postData(url, headers, data, HttpManager.FORM_MIME_JSON, new CompletionHandler(delegate(ResponseInfo respInfo, string respJson) { result = JsonConvert.DeserializeObject <LogListResult>(respJson); result.Code = respInfo.StatusCode; if (respInfo.StatusCode != 200) { Console.WriteLine(respInfo); } })); return(result); }
/// <summary> /// 日志查询 /// </summary> public static void loglist() { Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey); FusionManager fusionMgr = new FusionManager(mac); LogListRequest request = new LogListRequest(); request.Day = "DAY"; // "2016-09-01" request.Domains = "DOMAIN1"; // domains LogListResult result = fusionMgr.LogList(request); Console.WriteLine(result); }
/// <summary> /// 日志查询 /// </summary> public static void cdnLogList() { Mac mac = new Mac(Settings.AccessKey, Settings.SecretKey); CdnManager fusionMgr = new CdnManager(mac); LogListRequest request = new LogListRequest(); request.Day = "2016-09-01"; // date:which-day request.Domains = "DOMAIN1;DOMAIN2"; // domains LogListResult result = fusionMgr.GetCdnLogList(request); Console.WriteLine(result); }
public async Task <IActionResult> GetLogList([FromBody] LogListRequest request) { #region 筛选条件 List <DbWhere <LogInfoEntity> > dbWheres = new List <DbWhere <LogInfoEntity> >(); if (request.Id.HasValue && request.Id.Value > 0) { dbWheres.Add(new DbWhere <LogInfoEntity>(j => j.Id, request.Id.Value)); } if (request.JobId.HasValue && request.JobId.Value > 0) { dbWheres.Add(new DbWhere <LogInfoEntity>(j => j.JobId, request.JobId.Value)); } if (!string.IsNullOrWhiteSpace(request.JobName)) { dbWheres.Add(new DbWhere <LogInfoEntity>(j => j.JobName, request.JobName)); } if (request.FireTimeStart.HasValue) { dbWheres.Add(new DbWhere <LogInfoEntity>(j => j.FireTime, request.FireTimeStart.Value, OperateType.GreaterEqual)); } if (request.FireTimeEnd.HasValue) { dbWheres.Add(new DbWhere <LogInfoEntity>(j => j.FireTime, request.FireTimeEnd, OperateType.LessEqual)); } if (request.FireState.HasValue) { dbWheres.Add(new DbWhere <LogInfoEntity>(j => j.FireState, request.FireState)); } if (request.CreateTimeStart.HasValue) { dbWheres.Add(new DbWhere <LogInfoEntity>(j => j.CreateTime, request.CreateTimeStart, OperateType.GreaterEqual)); } if (request.CreateTimeEnd.HasValue) { dbWheres.Add(new DbWhere <LogInfoEntity>(j => j.CreateTime, request.CreateTimeEnd, OperateType.LessEqual)); } #endregion #region 排序和分页 string orderByFields = "a.Id,a.JobId,b.Name,a.FireTime,a.FireDuration,a.FireState,a.Content,a.CreateTime";//表格排序对应的字段 string orderByColumn = orderByFields.Split(',')[request.Order[0].Column]; bool isAsc = request.Order[0].Dir.Equals("asc", StringComparison.OrdinalIgnoreCase); int pageIndex = request.Start / request.Length;//从第0页开始 #endregion #region 获取数据 var(list, totals) = await _jobService.GetLogsAsync(pageIndex, request.Length, dbWheres, null, new DbOrderBy <LogInfoEntity>(orderByColumn, isAsc)); #endregion #region 返回数据 List <object[]> retTable = new List <object[]>(); if (list != null && list.Any()) { foreach (LogInfoEntity item in list) { #region 填充一行 List <object> retRow = new List <object>(); retRow.Add(item.Id); retRow.Add(item.JobId); retRow.Add(item.JobName); retRow.Add(item.FireTime); retRow.Add(item.FireDuration); switch (item.FireState) { case FireState.Success: retRow.Add(item.FireState.GetDescription().GetSpanHtml(SpanColor.Success)); break; case FireState.Failed: retRow.Add(item.FireState.GetDescription().GetSpanHtml(SpanColor.Warning)); break; case FireState.Error: retRow.Add(item.FireState.GetDescription().GetSpanHtml(SpanColor.Danger)); break; default: retRow.Add(item.FireState.GetDescription()); break; } retRow.Add(item.Content); retRow.Add(item.CreateTime); retRow.Add(string.Empty); retTable.Add(retRow.ToArray()); #endregion } } return(Json(new TableResult(retTable, request.Draw, totals))); #endregion }
public async Task <ActionResult <IEnumerable <LogList> > > List([FromQuery] LogListRequest request) { return(Ok(await _mediator.Send(request))); }