SuperDesign/Source/开发辅助工具/Tools/UpLog/FrmUpdateLog.cs

91 lines
3.5 KiB
C#
Raw Normal View History

using Newtonsoft.Json.Linq;
using ryCommon;
using ryControls.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
namespace SuperDesign.Tools
{
public partial class FrmUpdateLog : Form
{
public FrmUpdateLog()
{
InitializeComponent();
}
public void ShowLog(string LogJson)
{
try
{
JArray jarr = JArray.Parse(LogJson);
for (int i = 0; i < jarr.Count; i++)
{
var item = jarr[i];
var ProjectName = item.GetJsonValue("ProjectChsName", "");
if(ProjectName.Length==0)
{
ProjectName = item.GetJsonValue("ProjectName", "");
}
TabPage tab = new TabPage()
{
Text = ProjectName
};
Label label = new Label
{
Parent = tab,
Location = new Point(1, 4),
AutoSize = true,
Text = "版本号:" + item.GetJsonValue("VerStr", "")
};
var LogTime = item.GetJsonValue("LogTime", "");
var now_jarr = LogTime.Length==0? new JArray(): JArray.Parse(LogTime);
Dictionary<string, long> dict = new Dictionary<string, long>();
for (int j = 0; j < now_jarr.Count; j++)
{
var item_jarr = now_jarr[j];
dict[item_jarr.GetJsonValue("text", "")] = item_jarr.GetJsonValue("time", 0L);
}
var LogText_lines = item.GetJsonValue("LogText", "").Replace("\r", "\n").Replace("\n\n", "\n").Split('\n');
var LogText = "";
for (int l = 0; l < LogText_lines.Length; l++)
{
if (LogText_lines[l].Length == 0) { continue; }
if (LogText.Length > 0) { LogText += "\n"; }
if(dict.ContainsKey(LogText_lines[l]))
{
LogText += LogText_lines[l] + "=>" + dict[LogText_lines[l]].ToDateTime().ToString("yyyy-MM-dd HH:mm");
}
else
{
LogText += LogText_lines[l];
}
}
RichTextBox2 rich = new RichTextBox2
{
Parent = tab,
Dock = DockStyle.Fill,
Font = new Font("微软雅黑", 11),
ReadOnly=true,
BackColor=Color.White,
ScrollBars= RichTextBoxScrollBars.Both,
WordWrap=false,
Location = new Point(label.Left, label.Top + label.Height + 4),
Size = new Size(tab.ClientSize.Width, tab.ClientSize.Height - (label.Top + label.Height + 4)),
Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom,
Text= LogText
};
tabControl1.TabPages.Add(tab);
}
}
catch { }
}
}
}