初始化

This commit is contained in:
2025-12-11 11:39:02 +08:00
commit 156d6ccb06
1708 changed files with 1162911 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) Alibaba Cloud Computing
* All rights reserved.
*
* 版权所有 C阿里云计算有限公司
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Aliyun.Api.LOG.Utilities;
namespace Aliyun.Api.LOG.Data
{
/// <summary>
/// The log status(histogram info)
/// </summary>
public class Histogram
{
private UInt32 _from;
private UInt32 _to;
private Int64 _count;
private String _progress;
/// <summary>
/// The begin timestamp of time range
/// </summary>
public UInt32 From
{
get { return _from; }
set { _from = value; }
}
/// <summary>
/// The end timestamp of time range
/// </summary>
public UInt32 To
{
get { return _to; }
set { _to = value; }
}
/// <summary>
/// The log count
/// </summary>
public Int64 Count
{
get { return _count; }
set { _count = value; }
}
/// <summary>
/// detect whether histogram is complete or not.
/// </summary>
/// <returns>true if return histogram is complete. otherwise return false</returns>
public bool IsCompleted()
{
return _progress == LogConsts.STATUS_COMPLETE;
}
/// <summary>
/// default constructor
/// </summary>
public Histogram()
{
}
internal static List<Histogram> DeserializeFromJson(JArray json)
{
List<Histogram> hlst = new List<Histogram>();
if (json != null)
{
for (int i = 0; i < json.Count; ++i)
{
Histogram htg = new Histogram();
htg._from = (UInt32)json[i][LogConsts.NAME_GETSTATUS_FROM];
htg._to = (UInt32)json[i][LogConsts.NAME_GETSTATUS_TO];
htg._count = (UInt32)json[i][LogConsts.NAME_GETSTATUS_COUNT];
htg._progress = (String)json[i][LogConsts.NAME_GETSTATUS_PROGRESS];
hlst.Add(htg);
}
}
return hlst;
}
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (C) Alibaba Cloud Computing
* All rights reserved.
*
* 版权所有 C阿里云计算有限公司
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Aliyun.Api.LOG.Data
{
/// <summary>
/// This class presents one log content in logItem
/// </summary>
public class LogContent
{
private String _key = String.Empty;
private String _value = String.Empty;
/// <summary>
/// default constructor
/// </summary>
public LogContent()
{
}
/// <summary>
/// constructure with specified parameters
/// </summary>
/// <param name="key">log content's key </param>
/// <param name="value">log content's value </param>
public LogContent(String key, String value)
{
_key = key;
_value = value;
}
/// <summary>
/// the logcontent's key
/// </summary>
public String Key
{
get { return _key; }
set { _key = value; }
}
/// <summary>
/// the logcontent's value
/// </summary>
public String Value
{
get { return _value; }
set { _value = value; }
}
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) Alibaba Cloud Computing
* All rights reserved.
*
* 版权所有 C阿里云计算有限公司
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace Aliyun.Api.LOG.Data
{
/// <summary>
/// This class presents one log event item that will put into SLS
/// </summary>
public class LogItem
{
private UInt32 _time;
private List<LogContent> _contents;
/// <summary>
/// the log's timestamp
/// </summary>
public UInt32 Time
{
get { return _time; }
set { _time = value; }
}
/// <summary>
/// logcontents in logs
/// </summary>
public List<LogContent> Contents
{
get { return _contents; }
set { _contents = value; }
}
/// <summary>
/// default constructor
/// </summary>
public LogItem()
{
_contents = new List<LogContent>();
}
/// <summary>
/// method to append log content by key/value pair
/// </summary>
/// <param name="key">user define field to name the value</param>
/// <param name="value">the value of field key</param>
public void PushBack(String key, String value)
{
_contents.Add(new LogContent(key, value));
}
/// <summary>
/// method to append log content by key/value pair
/// </summary>
/// <param name="content">log content</param>
public void PushBack(LogContent content)
{
_contents.Add(content);
}
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (C) Alibaba Cloud Computing
* All rights reserved.
*
* 版权所有 C阿里云计算有限公司
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Aliyun.Api.LOG.Utilities;
namespace Aliyun.Api.LOG.Data
{
/// <summary>
/// QuriedLog used to present a log in query result. It contains log time, log source(ip/hostname,e.g),
/// and multiple of key/value pairs to present the log content
/// </summary>
public class QueriedLog
{
private UInt32 _time;
private String _source = String.Empty;
private List<LogContent> _contents = new List<LogContent>();
/// <summary>
/// The log timestamp
/// </summary>
public UInt32 Time
{
get { return _time; }
set { _time = value; }
}
/// <summary>
/// The log source
/// </summary>
public String Source
{
get { return _source; }
set { _source = value; }
}
/// <summary>
/// List of key/value pair to present the log content
/// </summary>
public List<LogContent> Contents
{
get { return _contents; }
set { _contents = value; }
}
/// <summary>
/// default constructor
/// </summary>
public QueriedLog()
{
}
internal static List<QueriedLog> DeserializeFromJson(JArray json)
{
List<QueriedLog> logs = new List<QueriedLog>();
for (int i = 0; i < json.Count; ++i)
{
QueriedLog log = new QueriedLog();
log._time = (UInt32)json[i][LogConsts.NAME_GETDATA_TIME];
log._source = (String)json[i][LogConsts.NAME_GETDATA_SOURCE];
log._contents = new List<LogContent>();
foreach (var item in json[i].Children<JProperty>())
{
if (item.Name.CompareTo(LogConsts.NAME_GETDATA_TIME) != 0 && item.Name.CompareTo(LogConsts.NAME_GETDATA_SOURCE) != 0)
{
log._contents.Add(new LogContent(item.Name, (String)json[i][item.Name]));
}
}
logs.Add(log);
}
return logs;
}
//used only in testing project
internal String Print()
{
StringBuilder strBuilder = new StringBuilder();
if (_contents != null)
{
for (int i = 0; i < _contents.Count; ++i)
{
strBuilder.Append("(" + _contents[i].Key + "," + _contents[i].Value + ")");
}
}
return strBuilder.ToString();
}
}
}