75 lines
2.1 KiB
C#
75 lines
2.1 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
|
|||
|
|
namespace SOH.JianYan.YiQi.Base
|
|||
|
|
{
|
|||
|
|
public class Lis_RiZhi
|
|||
|
|
{
|
|||
|
|
public static void log(string nr)
|
|||
|
|
{
|
|||
|
|
// using(StreamWriter sw=new StreamWriter())
|
|||
|
|
string logpath = Application.StartupPath + "\\log\\";
|
|||
|
|
if(!Directory.Exists(logpath))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(logpath);
|
|||
|
|
}
|
|||
|
|
string logfile = logpath + "\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
|
|||
|
|
int count = 0;
|
|||
|
|
redo:
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
FileStream fs = new FileStream(logfile, FileMode.Append, FileAccess.Write, FileShare.None);
|
|||
|
|
StreamWriter sw = new StreamWriter(fs);
|
|||
|
|
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\t" + nr);
|
|||
|
|
sw.Close();
|
|||
|
|
sw.Dispose();
|
|||
|
|
fs.Close();
|
|||
|
|
fs.Dispose();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
count++;
|
|||
|
|
if (count == 10)
|
|||
|
|
return;
|
|||
|
|
goto redo;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void resultlog(string nr)
|
|||
|
|
{
|
|||
|
|
string logpath = Application.StartupPath + "\\result\\";
|
|||
|
|
if (!Directory.Exists(logpath))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(logpath);
|
|||
|
|
}
|
|||
|
|
string logfile = logpath + "\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
|
|||
|
|
int count = 0;
|
|||
|
|
redo:
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
FileStream fs = new FileStream(logfile, FileMode.Append, FileAccess.Write, FileShare.None);
|
|||
|
|
StreamWriter sw = new StreamWriter(fs);
|
|||
|
|
sw.WriteLine(nr);
|
|||
|
|
sw.Close();
|
|||
|
|
sw.Dispose();
|
|||
|
|
fs.Close();
|
|||
|
|
fs.Dispose();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
count++;
|
|||
|
|
if (count == 10)
|
|||
|
|
return;
|
|||
|
|
goto redo;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|