添加项目文件。
This commit is contained in:
34
Mstn.Toolkit/Helpers/LogHelper.cs
Normal file
34
Mstn.Toolkit/Helpers/LogHelper.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Bentley.DgnPlatformNET.Elements;
|
||||
|
||||
namespace Mstn.Toolkit.Helpers
|
||||
{
|
||||
public class LogHelper
|
||||
{
|
||||
[DllImport("ustation.dll")]
|
||||
private static extern void mdlDialog_dmsgsPrint(byte[] wMsg);
|
||||
|
||||
public static void WriteLine(string message)
|
||||
{
|
||||
mdlDialog_dmsgsPrint(Encoding.Unicode.GetBytes(message));
|
||||
}
|
||||
public static void LogInfos(List<Element> elements, string fileName)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < elements.Count; i++)
|
||||
{
|
||||
var element = elements[i];
|
||||
stringBuilder.AppendLine($"{i + 1},{element.GetType().FullName},元素id={element.ElementId},元素类型={element.ElementType}");
|
||||
}
|
||||
File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), $"{fileName}.csv"), stringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user