|
|
|
@ -9,6 +9,7 @@ using System.Drawing;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
@ -49,22 +50,53 @@ namespace Rs.MotionPlat
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int fileIndex = 1;
|
|
|
|
|
string logFileName = "";
|
|
|
|
|
string regstr = tf.Index+"_(\\d{0,10}).txt";
|
|
|
|
|
//打印日志
|
|
|
|
|
string logDir = $"d:\\log\\debug\\{DateTime.Now.ToString("yyyyMMdd")}";
|
|
|
|
|
if (!Directory.Exists(logDir))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(logDir);
|
|
|
|
|
}
|
|
|
|
|
string logFileName = $"{logDir}\\{tf.Index}.txt";
|
|
|
|
|
string[] files = Directory.GetFiles(logDir);
|
|
|
|
|
if(files!=null && files.Length>0)
|
|
|
|
|
{
|
|
|
|
|
foreach (string f in files)
|
|
|
|
|
{
|
|
|
|
|
string fname = System.IO.Path.GetFileName(f);
|
|
|
|
|
if(Regex.IsMatch(fname,regstr))
|
|
|
|
|
{
|
|
|
|
|
Match mh = Regex.Match(fname, regstr);
|
|
|
|
|
int tempIndex = int.Parse(mh.Groups[1].Value);
|
|
|
|
|
if(tempIndex>fileIndex)
|
|
|
|
|
{
|
|
|
|
|
fileIndex= tempIndex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
logFileName = $"{logDir}\\{tf.Index}_{fileIndex}.txt";
|
|
|
|
|
|
|
|
|
|
FileInfo fi = new FileInfo(logFileName);
|
|
|
|
|
if(fi.Exists && fi.Length<=1024 * 1024 *1)
|
|
|
|
|
if(fi.Exists && fi.Length<=1024 * 1024 * 5)
|
|
|
|
|
{
|
|
|
|
|
File.AppendAllText(logFileName, $"{msg}");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(fi.Exists)
|
|
|
|
|
{
|
|
|
|
|
logFileName = $"{logDir}\\{tf.Index}_{++fileIndex}.txt";
|
|
|
|
|
//换名称
|
|
|
|
|
File.WriteAllText(logFileName, $"{msg}");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
File.WriteAllText(logFileName, $"{msg}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (label5.BackColor != Color.Lime)
|
|
|
|
|
{
|
|
|
|
|
label5.BackColor = Color.Lime;
|
|
|
|
|