You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.6 KiB
102 lines
2.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
using System.Configuration;
|
|
|
|
namespace QMAPP.WinForm
|
|
{
|
|
public static class WriteLog
|
|
{
|
|
public static void Write(string info)
|
|
{
|
|
string filePath = ConfigurationManager.AppSettings["logFilePath"];
|
|
|
|
if (string.IsNullOrEmpty(filePath))
|
|
{
|
|
filePath = System.AppDomain.CurrentDomain.BaseDirectory;
|
|
}
|
|
|
|
if (Directory.Exists(filePath) == false)
|
|
{
|
|
Directory.CreateDirectory(filePath);
|
|
|
|
}
|
|
|
|
string logfile = filePath + @"\logtxt" + System.DateTime.Now.ToString("yyyyMMdd") + ".txt";
|
|
if (File.Exists(logfile) == false)
|
|
{
|
|
File.Create(logfile).Close();
|
|
}
|
|
|
|
StreamWriter sw = File.AppendText(logfile);
|
|
sw.WriteLine(info);
|
|
|
|
sw.Flush();
|
|
|
|
sw.Close();
|
|
|
|
}
|
|
|
|
public static void WriteShipmentLog(string info)
|
|
{
|
|
string filePath = ConfigurationManager.AppSettings["logFilePath"];
|
|
|
|
if (string.IsNullOrEmpty(filePath))
|
|
{
|
|
filePath = System.AppDomain.CurrentDomain.BaseDirectory;
|
|
}
|
|
filePath += "\\shipmentlog\\";
|
|
if (Directory.Exists(filePath) == false)
|
|
{
|
|
Directory.CreateDirectory(filePath);
|
|
|
|
}
|
|
|
|
string logfile = filePath + @"\Log-" + System.DateTime.Now.ToString("yyyyMMdd") + ".txt";
|
|
if (File.Exists(logfile) == false)
|
|
{
|
|
File.Create(logfile).Close();
|
|
}
|
|
|
|
StreamWriter sw = File.AppendText(logfile);
|
|
sw.WriteLine(info);
|
|
|
|
sw.Flush();
|
|
|
|
sw.Close();
|
|
|
|
}
|
|
|
|
public static void WriteError(string info)
|
|
{
|
|
string filePath = ConfigurationManager.AppSettings["logFilePath"];
|
|
|
|
if (string.IsNullOrEmpty(filePath))
|
|
{
|
|
filePath = System.AppDomain.CurrentDomain.BaseDirectory;
|
|
}
|
|
|
|
if (Directory.Exists(filePath) == false)
|
|
{
|
|
Directory.CreateDirectory(filePath);
|
|
|
|
}
|
|
|
|
string logfile = filePath + @"\Errortxt" + System.DateTime.Now.ToString("yyyyMMdd") + ".txt";
|
|
if (File.Exists(logfile) == false)
|
|
{
|
|
File.Create(logfile).Close();
|
|
}
|
|
|
|
StreamWriter sw = File.AppendText(logfile);
|
|
sw.WriteLine(info);
|
|
|
|
sw.Flush();
|
|
|
|
sw.Close();
|
|
|
|
}
|
|
}
|
|
}
|
|
|