123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ST_CUBE_MES.Service
- {
- public class FileRrecordService
- {
- private static string LogFolder = "Log";
- //private string serialNumber;
- private string fileName;
- private string FilePath
- {
- get
- {
- if (string.IsNullOrEmpty(fileName))
- {
- return null;
- }
- return Path.Combine(Directory.GetCurrentDirectory(), LogFolder, fileName);
- }
- }
- public void Start(string serialNumber)
- {
- fileName = String.Format("{0}_{1}.txt", serialNumber, DateTime.Now.ToString("yyyyMMddHHmmss"));
- //MessageBox.Show(FilePath);
- //File.Create(FilePath);
- }
- public void Log(string logString)
- {
- if (string.IsNullOrEmpty(fileName))
- {
- return;
- }
- logString += Environment.NewLine;
- File.AppendAllText(FilePath, logString);
- }
- public void Complete()
- {
- fileName = null;
- }
- }
- }
|