95 lines
2.8 KiB
C#
95 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace TellmePdmsPluging.Models
|
|
{
|
|
public class ExportIfcRequest
|
|
{
|
|
public string ExecutionId { get; set; }
|
|
public string execution_id { get { return ExecutionId; } set { ExecutionId = value; } }
|
|
|
|
public string ExportPath { get; set; }
|
|
public string FileName { get; set; }
|
|
public string ExportSystem { get; set; }
|
|
public bool? Overwrite { get; set; }
|
|
public List<string> Selections { get; set; }
|
|
public List<string> SelectionCommands { get; set; }
|
|
|
|
public void ApplyDefaults()
|
|
{
|
|
if (string.IsNullOrEmpty(ExportPath))
|
|
{
|
|
ExportPath = @"C:\temp";
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(FileName))
|
|
{
|
|
FileName = string.Format("pdms_export_{0:yyyyMMdd_HHmmss}.rvm", DateTime.Now);
|
|
}
|
|
|
|
if (!Overwrite.HasValue)
|
|
{
|
|
Overwrite = true;
|
|
}
|
|
}
|
|
|
|
public string GetFullPath()
|
|
{
|
|
return System.IO.Path.Combine(ExportPath, FileName);
|
|
}
|
|
|
|
public List<string> GetEffectiveSelections()
|
|
{
|
|
var raw = new List<string>();
|
|
if (Selections != null && Selections.Count > 0)
|
|
{
|
|
raw.AddRange(Selections);
|
|
}
|
|
if (SelectionCommands != null && SelectionCommands.Count > 0)
|
|
{
|
|
raw.AddRange(SelectionCommands);
|
|
}
|
|
|
|
if (raw.Count == 0)
|
|
{
|
|
// 采用文档示例中的常见选择语句作为默认项
|
|
raw.Add("/EQUIP");
|
|
raw.Add("/PIPES");
|
|
}
|
|
|
|
var normalized = new List<string>();
|
|
foreach (var item in raw)
|
|
{
|
|
var text = (item ?? string.Empty).Trim();
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (!text.StartsWith("EXPORT ", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
text = "EXPORT " + text;
|
|
}
|
|
|
|
normalized.Add(text);
|
|
}
|
|
|
|
return normalized.Distinct(StringComparer.OrdinalIgnoreCase).ToList();
|
|
}
|
|
}
|
|
|
|
public class ExportIfcResult
|
|
{
|
|
public bool Success { get; set; }
|
|
public string Message { get; set; }
|
|
public string ExportPath { get; set; }
|
|
public string FileName { get; set; }
|
|
public string FullPath { get; set; }
|
|
public long FileSizeBytes { get; set; }
|
|
public DateTime StartedAt { get; set; }
|
|
public DateTime CompletedAt { get; set; }
|
|
public double DurationSeconds { get; set; }
|
|
}
|
|
}
|