LogAnalyzeManager.cs
5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using TSA_V.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TSA_V.DeviceLibrary
{
public class LogAnalyzeManager
{
public static List<TempLog> getWeldLog(DateTime startTime, DateTime endTime)
{
//查找文件夹
string dic = Application.StartupPath + @"\logs\temp\";
string[] files = Directory.GetFiles(dic);
List<TempLog> tempList = new List<TempLog>();
List<string> lines = new List<string>();
foreach (string f in files)
{
DateTime time = LogUtil.GetFileTime(f);
DateTime logEndTime = time.AddDays(1);
if (time != null && ((startTime <= time && time <= endTime) || (time <= startTime && startTime <= logEndTime)))
{
//读取文件内容
string[] fileValue = File.ReadAllLines(f);
foreach (string s in fileValue)
{
TempLog log = TempLog.GetLog(s);
if (log != null)
{
if (log.LogTime >= startTime && log.LogTime <= endTime)
{
tempList.Add(log);
lines.Add(s);
}
}
}
}
}
LogUtil.info("查询结果:共【" + tempList.Count + "】条记录");
int i = 1;
return tempList;
}
public static List<BoardLog> getBoardLogList(DateTime startTime, DateTime endTime, BoardInfo board, out List<string> lines)
{
if (board.boardId <= 0)
{
board = null;
}
//查找文件夹
string dic = Application.StartupPath + @"\logs\soldering\";
List<BoardLog> boardLogList = new List<BoardLog>();
string[] files = Directory.GetFiles(dic);
lines = new List<string>();
foreach (string f in files)
{
DateTime time = LogUtil.GetFileTime(f);
DateTime logEndTime = time.AddDays(1);
if (time != null && ((startTime <= time && time <= endTime)||(time<=startTime&&startTime<=logEndTime)))
{
//读取文件内容
string[] fileValue = File.ReadAllLines(f);
foreach (string s in fileValue)
{
BoardLog log = BoardLog.GetLog(s);
if (log != null)
{
if (log.LogTime >= startTime && log.LogTime <= endTime && (board == null || board.boardId <= 0 || log.BoardName.Equals(board.boardName)))
{
List<SMTPointInfo> list = new List<SMTPointInfo>();
if (board == null || board.boardId <= 0)
{
BoardInfo theBorad = BoardManager.getBoardByName(log.BoardName);
if (theBorad != null)
{
list = (from m in theBorad.smtList where m.pointName.Equals(log.BoardPoint) select m).ToList<SMTPointInfo>();
}
}
else
{
list = (from m in board.smtList where m.pointName.Equals(log.BoardPoint) select m).ToList<SMTPointInfo>();
}
if (list != null && list.Count > 0)
{
SMTPointInfo point = list[0];
//if (log.PreTemp <= 0)
//{
// log.PreTemp = point.preheatTemperature;
//} if (log.WeldTemp <= 0)
//{
// log.WeldTemp = point.weldTemperature;
//}
//if (log.PreSendWire <= 0)
//{
// log.PreSendWire = point.startSendWireSpeed * point.startSendWireTime;
//} if (log.SendWire <= 0)
//{
// log.SendWire = point.sendWireSpeed * point.sendWireTime;
//}
boardLogList.Add(log);
lines.Add(log.ToCSVString());
}
}
}
}
}
}
lines.Insert(0, BoardLog.CSVTitleString());
return boardLogList;
}
}
}