35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
|
|
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());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|