Files
01-Siyuan-MesProject/MisData_3.0_2022.08.23.1622.LLX/MisDataBak/MisMenuFunction/Start/SavePLCMessage.cs
2026-05-29 10:07:05 +08:00

48 lines
1.3 KiB
C#

using DataLinkMesWork;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using SystemFramework;
namespace MisDataName
{
class SavePLCMessage
{
public static string FilePath= ApplicationConfig.TraceFolderPath + "PlcMessage";
void SavePlcMessage(object Text )
{
try
{
if (!Directory.Exists(FilePath))
{
Directory.CreateDirectory(FilePath);
}
DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
StreamWriter Write_PlcMessage = new StreamWriter(FilePath + "\\PlcMessage_" + currentTime.ToString().Replace(" ", "").Replace("/", "").Replace(":", "") + ".txt", true);//实例化创建文件
Write_PlcMessage.Write((string)Text);
Write_PlcMessage.Close();
Write_PlcMessage.Dispose();
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
public void SavePlcMessage_Thread(string Text)
{
Thread t = new Thread(new ParameterizedThreadStart(SavePlcMessage));
t.Start(Text.Replace ("MIS", "\r\nMIS"));
}
}
}