修改日志文件函数调用逻辑
This commit is contained in:
commit
6a706ea804
8 files changed
+86
-64
No files matched your search
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace formula_manage.UserClass
|
||||
{
|
||||
internal class DataTableToObservableCollection
|
||||
internal class DataTableToObservableCollection //数据表到可观察集合
|
||||
{
|
||||
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Windows.Media;
|
||||
|
||||
namespace formula_manage.UserClass
|
||||
{
|
||||
public static class Log
|
||||
public static class LogDataRead
|
||||
{
|
||||
private const int MaxCount = 1000;
|
||||
private static int Count = 0;
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace formula_manage.UserClass
|
||||
{
|
||||
public class LogGing
|
||||
{
|
||||
public static void LogGingDATA(string dat)
|
||||
{
|
||||
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
||||
string logPath = "" + System.Environment.CurrentDirectory + "\\Log\\"+ DateTime.Now.ToString("yyyy-MM-dd") + ".txt";//日志文件
|
||||
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:";
|
||||
|
||||
System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
|
||||
if (!File.Exists(logPath))//检查日志文件并写入启动日志
|
||||
{
|
||||
FileStream fs = new FileStream(logPath, FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + dat);
|
||||
wr.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + dat);
|
||||
wr.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace formula_manage.UserClass
|
||||
{
|
||||
public class get_local_ip_address
|
||||
{
|
||||
public static string getLocalIPAddressWithNetworkInterface(NetworkInterfaceType _type)//获取本机ip并以字符串方式返回
|
||||
{
|
||||
string output = "";
|
||||
foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
if (item.NetworkInterfaceType == _type && item.OperationalStatus == OperationalStatus.Up)
|
||||
{
|
||||
foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses)
|
||||
{
|
||||
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
output = ip.Address.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user