72 lines
1.6 KiB
C#
72 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
|
|
namespace JD.ElasticSearch
|
|
{
|
|
public class ElasticSearchLog
|
|
{
|
|
|
|
#region Variables
|
|
public string Index { get; set; }
|
|
public string Type { get; set; }
|
|
|
|
public string Id { get; set; }
|
|
|
|
private Dictionary<string, object> _store;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
private static void IfNull(object obj, string objName)
|
|
{
|
|
Debug.Assert(!string.IsNullOrEmpty(objName), "Invalid value name.");
|
|
|
|
if (obj == null)
|
|
{
|
|
throw new ArgumentNullException(objName);
|
|
}
|
|
}
|
|
|
|
public ElasticSearchLog(string index, string type, IDictionary<string, object> store)
|
|
{
|
|
Index = index;
|
|
Type = type;
|
|
|
|
Id = Guid.NewGuid().ToString();
|
|
|
|
_store = store as Dictionary<string, object>;
|
|
|
|
if(_store["DateTime"] == null)
|
|
{
|
|
_store["DateTime"] = DateTime.Now;
|
|
}
|
|
}
|
|
|
|
public ElasticSearchLog(string index, string type, string id, IDictionary<string, object> store)
|
|
{
|
|
Index = index;
|
|
Type = type;
|
|
Id = id;
|
|
|
|
_store = store as Dictionary<string, object>;
|
|
|
|
if (_store["DateTime"] == null)
|
|
{
|
|
_store["DateTime"] = DateTime.Now;
|
|
}
|
|
}
|
|
|
|
public IDictionary<string, object> Values
|
|
{
|
|
get
|
|
{
|
|
return _store;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|