大量更新
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
@@ -14,23 +12,16 @@ using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
using OfficeOpenXml;
|
||||
|
||||
using Szmedi.RvKits.InfoManager.EAMTools;
|
||||
|
||||
namespace Szmedi.RvKits.InfoManager
|
||||
namespace Szmedi.RvKits.InfoManager.EAMTools
|
||||
{
|
||||
public partial class EAMCodeCheckViewModel : ObservableObject
|
||||
{
|
||||
private readonly ActionEventHandler handler;
|
||||
[ObservableProperty]
|
||||
private List<EAMData> currentFacilities;
|
||||
[ObservableProperty]
|
||||
private List<InstanceFacility> instances;
|
||||
[ObservableProperty]
|
||||
private string selectedStation;
|
||||
[ObservableProperty]
|
||||
private List<string> facilitySystems;
|
||||
[ObservableProperty]
|
||||
private string selectedSystem;
|
||||
[ObservableProperty] private List<EAMData> currentFacilities;
|
||||
[ObservableProperty] private List<InstanceFacility> instances;
|
||||
[ObservableProperty] private string selectedStation;
|
||||
[ObservableProperty] private List<string> facilitySystems;
|
||||
[ObservableProperty] private string selectedSystem;
|
||||
|
||||
public EAMCodeCheckViewModel(Document doc)
|
||||
{
|
||||
@@ -44,12 +35,10 @@ namespace Szmedi.RvKits.InfoManager
|
||||
try
|
||||
{
|
||||
var list = doc.OfClass<FamilyInstance>()
|
||||
.Where(
|
||||
e => e.Category.AllowsBoundParameters &&
|
||||
e.Category.CategoryType == CategoryType.Model &&
|
||||
!Enum.GetName(typeof(BuiltInCategory), e.Category.Id.IntegerValue)!.Contains("Fitting") &&
|
||||
e.Category.CategoryType == CategoryType.Model &&
|
||||
e.Category.Id.IntegerValue != -2008013) //风道末端
|
||||
.Where(e => e.Category.AllowsBoundParameters &&
|
||||
!Enum.GetName(typeof(BuiltInCategory), e.Category.Id.IntegerValue)!.Contains("Fitting") &&
|
||||
e.Category.CategoryType == CategoryType.Model &&
|
||||
e.Category.Id.IntegerValue != -2008013) //风道末端
|
||||
.Cast<FamilyInstance>()
|
||||
.OrderBy(ins => ins.Name)
|
||||
.Select(ins => new InstanceFacility(ins));
|
||||
@@ -57,7 +46,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
Facilities = package.ToList<EAMData>(1, configuration => configuration.SkipCastingErrors());
|
||||
var group = Facilities.GroupBy(fa => fa.StationName).OrderBy(g => g.Key);
|
||||
Stations = [.. group.Select(g => g.Key)];
|
||||
Regex regex = new Regex(@"-(\D+站|所|段|场)-");
|
||||
var regex = new Regex(@"-(\D+站|所|段|场)-");
|
||||
var result = regex.Matches(doc.PathName).Cast<Match>().Select(m => m.Groups[1].Value).FirstOrDefault();
|
||||
if (result != null && Stations.Contains(result))
|
||||
{
|
||||
@@ -66,13 +55,12 @@ namespace Szmedi.RvKits.InfoManager
|
||||
}
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
|
||||
{
|
||||
System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
|
||||
MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
|
||||
}
|
||||
finally
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomainOnAssemblyResolve;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
@@ -82,6 +70,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var EAMData in CurrentFacilities)
|
||||
{
|
||||
//var b = Instances.Any(ins => ins.Number.Contains(EAMData.EAMCode));
|
||||
@@ -95,9 +84,11 @@ namespace Szmedi.RvKits.InfoManager
|
||||
}
|
||||
}
|
||||
}
|
||||
CurrentFacilities = [.. CurrentFacilities.OrderBy(fa => fa.IsMapped)];
|
||||
Instances = [.. Instances.OrderBy(ins => ins.IsMapped)];
|
||||
|
||||
CurrentFacilities = [.. Enumerable.OrderBy<EAMData, bool?>(CurrentFacilities, fa => fa.IsMapped)];
|
||||
Instances = [.. Enumerable.OrderBy<InstanceFacility, bool?>(Instances, ins => ins.IsMapped)];
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ShowFacility(object obj)
|
||||
{
|
||||
@@ -109,7 +100,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
handler.Raise(uiapp =>
|
||||
{
|
||||
var uidoc = uiapp.ActiveUIDocument;
|
||||
Document doc = uidoc.Document;
|
||||
var doc = uidoc.Document;
|
||||
|
||||
if (!model.Instance.IsValidObject)
|
||||
{
|
||||
@@ -140,15 +131,19 @@ namespace Szmedi.RvKits.InfoManager
|
||||
uidoc.Selection.SetElementIds([model.Instance.Id]);
|
||||
});
|
||||
}
|
||||
|
||||
private static bool IsVisible(ElementId viewId, Element elem)
|
||||
{
|
||||
if (FilteredElementCollector.IsViewValidForElementIteration(elem.Document, viewId)) // 某类视图不能使用 FilteredElementCollector
|
||||
if (FilteredElementCollector.IsViewValidForElementIteration(elem.Document,
|
||||
viewId)) // 某类视图不能使用 FilteredElementCollector
|
||||
{
|
||||
var fec = new FilteredElementCollector(elem.Document, viewId).ToElementIds();
|
||||
return fec.Any(id => id == elem.Id);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args)
|
||||
{
|
||||
if (!args.Name.Contains("ComponentModel.Annotations"))
|
||||
@@ -156,7 +151,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
return null;
|
||||
}
|
||||
|
||||
string assemblyFile = Path.Combine(GlobalVariables.DirAssembly, "System.ComponentModel.Annotations.dll");
|
||||
var assemblyFile = Path.Combine(GlobalVariables.DirAssembly, "System.ComponentModel.Annotations.dll");
|
||||
return File.Exists(assemblyFile) ? Assembly.LoadFrom(assemblyFile) : null;
|
||||
}
|
||||
|
||||
@@ -165,12 +160,13 @@ namespace Szmedi.RvKits.InfoManager
|
||||
if (!string.IsNullOrEmpty(newValue))
|
||||
{
|
||||
CurrentFacilities = Facilities.Where(fa => fa.StationName == newValue).ToList();
|
||||
var group = CurrentFacilities.GroupBy(fa => fa.System);
|
||||
var group = Enumerable.GroupBy<EAMData, string>(CurrentFacilities, fa => fa.System);
|
||||
|
||||
FacilitySystems = [.. group.Select(g => g.Key)];
|
||||
FacilitySystems.Insert(0, "<请选择系统>");
|
||||
}
|
||||
}
|
||||
|
||||
partial void OnSelectedSystemChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (newValue == "<请选择系统>")
|
||||
@@ -178,15 +174,15 @@ namespace Szmedi.RvKits.InfoManager
|
||||
CurrentFacilities = Facilities.Where(fa => fa.System == newValue).ToList();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(newValue))
|
||||
{
|
||||
CurrentFacilities = CurrentFacilities.Where(fa => fa.System == newValue).ToList();
|
||||
CurrentFacilities = Enumerable.Where<EAMData>(CurrentFacilities, fa => fa.System == newValue).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<EAMData> Facilities { get; }
|
||||
public List<string> Stations { get; }
|
||||
|
||||
}
|
||||
|
||||
public class EAMData : ObservableObject
|
||||
@@ -195,6 +191,7 @@ namespace Szmedi.RvKits.InfoManager
|
||||
|
||||
[ExcelTableColumn("是否匹配", true)]
|
||||
public bool? IsMapped { get => isMapped; set => SetProperty(ref isMapped, value); }
|
||||
|
||||
/// <summary>
|
||||
/// 线路名称
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user