48 lines
1.3 KiB
C#
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"));
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|