大量更新

This commit is contained in:
GG Z
2025-12-23 21:37:02 +08:00
parent 3fc465959b
commit b611efeed9
105 changed files with 5814 additions and 371 deletions

View File

@@ -1,69 +1,9 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text;
namespace Szmedi.Toolkit.Assists
{
public static class LogAssists
{
private static string GetCurrentMethodFullName()
{
string str1;
try
{
var num = 2;
StackTrace stackTrace = new();
var length = stackTrace.GetFrames().Length;
StackFrame frame;
string str;
bool flag;
do
{
var num1 = num;
num = num1 + 1;
frame = stackTrace.GetFrame(num1);
str = frame.GetMethod().DeclaringType.ToString();
flag = str.EndsWith("Exception") && num < length;
} while (flag);
var name = frame.GetMethod().Name;
str1 = string.Concat(str, ".", name);
}
catch
{
str1 = null;
}
return str1;
}
public static void ToLog(this string strLog, string logFolder = default)
{
if (logFolder == default)
{
var assemblyPath = typeof(LogAssists).Assembly.Location;
var directory = Path.GetDirectoryName(assemblyPath);
logFolder = Path.Combine(directory, "Logs");
}
if (!Directory.Exists(logFolder))
{
Directory.CreateDirectory(logFolder);
}
//logFolder = Directory.GetCurrentDirectory();返回是Revit目录
var logFile = Path.Combine(logFolder, DateTime.Now.ToString("yyyy-MM-dd") + ".log");
var fs = File.Exists(logFile)
? new FileStream(logFile, FileMode.Append, FileAccess.Write)
: new FileStream(logFile, FileMode.Create, FileAccess.Write);
using StreamWriter sw = new(fs);
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss-ffff : ") + strLog);
sw.Close();
fs.Close();
}
public static void WriteLog(string strLog, string logFolder = default)
{
try
@@ -116,7 +56,7 @@ namespace Szmedi.Toolkit.Assists
string filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) +
$"\\{fileName}.csv";
File.WriteAllText(filePath, message, Encoding.UTF8);
//System.Diagnostics.Process.Start(filePath);
System.Diagnostics.Process.Start(filePath);
}
}
}

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
@@ -219,5 +216,21 @@ namespace Szmedi.Toolkit.Assists
};
window.Show();
}
public static void ShowDialog<TWindow, TViewModel>(params object[] viewModelParams)
where TWindow : Window, new()
where TViewModel : class
{
var window = new TWindow();
if (viewModelParams.Length == 0)
{
window.DataContext = Activator.CreateInstance(typeof(TViewModel));
}
else
{
window.DataContext = Activator.CreateInstance(typeof(TViewModel), viewModelParams);
}
_ = new WindowInteropHelper(window) { Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle };
window.ShowDialog();
}
}
}