초기 커밋.
This commit is contained in:
107
lck_cl_data_solution/GameDataViewer/Form1.cs
Normal file
107
lck_cl_data_solution/GameDataViewer/Form1.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using MongoDB.Driver;
|
||||
using MongoDB.Bson;
|
||||
|
||||
namespace GameDataViewer
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
//public static string MONGODBÁÖ¼Ò = "mongodb://root:veryhardpassword123@211.53.30.8:50003";
|
||||
public static string MONGODBÁÖ¼Ò = "mongodb://root:veryhardpassword123@211.42.188.8:50003";
|
||||
|
||||
private void DisplayTreeView(JToken root, string rootName)
|
||||
{
|
||||
treeView1.BeginUpdate();
|
||||
try
|
||||
{
|
||||
treeView1.Nodes.Clear();
|
||||
var tNode = treeView1.Nodes[treeView1.Nodes.Add(new TreeNode(rootName))];
|
||||
tNode.Tag = root;
|
||||
|
||||
|
||||
AddNode(root, tNode);
|
||||
|
||||
treeView1.ExpandAll();
|
||||
}
|
||||
finally
|
||||
{
|
||||
treeView1.EndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private bool AddNode(JToken token, TreeNode inTreeNode)
|
||||
{
|
||||
if (token == null)
|
||||
return false;
|
||||
if (token is JValue)
|
||||
{
|
||||
var childNode = inTreeNode.Nodes[inTreeNode.Nodes.Add(new TreeNode(token.ToString()))];
|
||||
childNode.Tag = token;
|
||||
}
|
||||
else if (token is JObject)
|
||||
{
|
||||
var obj = (JObject)token;
|
||||
foreach (var property in obj.Properties())
|
||||
{
|
||||
var childNode = inTreeNode.Nodes[inTreeNode.Nodes.Add(new TreeNode(property.Name))];
|
||||
childNode.Tag = property;
|
||||
AddNode(property.Value, childNode);
|
||||
}
|
||||
}
|
||||
else if (token is JArray)
|
||||
{
|
||||
var array = (JArray)token;
|
||||
for (int i = 0; i < array.Count; i++)
|
||||
{
|
||||
var childNode = inTreeNode.Nodes[inTreeNode.Nodes.Add(new TreeNode(i.ToString()))];
|
||||
childNode.Tag = array[i];
|
||||
AddNode(array[i], childNode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine(string.Format("{0} not implemented", token.Type)); // JConstructor, JRaw
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
internal MongoClient mDBClient = null;
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
mDBClient = new MongoClient(MONGODBÁÖ¼Ò);
|
||||
|
||||
var database = mDBClient.GetDatabase("datalol");
|
||||
|
||||
var filter = Builders<BsonDocument>.Filter.Eq("RequestGameID", textBox1.Text);
|
||||
|
||||
var projection = Builders<BsonDocument>.Projection
|
||||
.Exclude("_id")
|
||||
.Include("eventDocument");
|
||||
|
||||
List<BsonDocument> documents = database.GetCollection<BsonDocument>("stats_update")
|
||||
.Find(filter)
|
||||
.SortByDescending(x => x["sequenceIndex"])
|
||||
.Project(projection)
|
||||
.Limit(1)
|
||||
.ToList();
|
||||
|
||||
|
||||
JToken root = (JToken)documents[0]["eventDocument"].ToString();
|
||||
DisplayTreeView(root, "root");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user