日常更新
This commit is contained in:
@@ -53,9 +53,9 @@ namespace Szmedi.RvKits.InfoManager.EAMTools
|
||||
SelectedStation = result;
|
||||
}
|
||||
}
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
|
||||
{
|
||||
MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
|
||||
MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行或多余文字。", ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -192,9 +192,9 @@ public partial class EAMCodingViewModel : ObservableObject
|
||||
IsComparison = false;
|
||||
Instances.ForEach(ins => ins.IsMapped = false);
|
||||
}
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
|
||||
{
|
||||
System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
|
||||
System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行或多余文字。", ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -525,9 +525,9 @@ public partial class EAMCodingViewModel : ObservableObject
|
||||
LogAssists.WriteTxtFile("EAM编码写入失败", sb.ToString());
|
||||
}
|
||||
}
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
|
||||
{
|
||||
System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行。");
|
||||
System.Windows.MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行或多余文字。", ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -319,9 +319,9 @@ public partial class WriteParametersViewModel : ObservableObject
|
||||
//IsComparison = false;
|
||||
//Instances.ForEach(ins => ins.IsMapped = false);
|
||||
}
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
|
||||
{
|
||||
System.Windows.MessageBox.Show("列名不存在或不匹配或检查表头是否存在换行。");
|
||||
System.Windows.MessageBox.Show("列名不存在或不匹配或检查表头是否存在换行或多余文字。", ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace Szmedi.RvKits.MEPTools
|
||||
{
|
||||
public override void Execute()
|
||||
{
|
||||
#if DEBUG
|
||||
GlobalVariables.UIApplication=this.UiApplication;
|
||||
#endif
|
||||
WinDialogAssists.ShowOrActivate<FacilityInfoProcessView, FacilityInfoProcessViewModel>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="设备信息"
|
||||
Width="800"
|
||||
Height="450"
|
||||
Width="900"
|
||||
Height="600"
|
||||
d:DataContext="{d:DesignInstance Type=local:FacilityInfoProcessViewModel}"
|
||||
mc:Ignorable="d">
|
||||
<controls:MaterialWindow.Resources>
|
||||
@@ -34,13 +34,15 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="200" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="300" MinWidth="100" />
|
||||
<ColumnDefinition Width="250" MinWidth="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Header="设备表">
|
||||
<GroupBox materialDesign:GroupBoxAssist.HeaderPadding="4" Header="设备表">
|
||||
<DataGrid
|
||||
x:Name="Facilities"
|
||||
Margin="-4"
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
materialDesign:DataGridAssist.CellPadding="8,0"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="6"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
FrozenColumnCount="2"
|
||||
@@ -59,24 +61,19 @@
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.RowDetailsTemplate>
|
||||
<DataTemplate>
|
||||
<GroupBox Header="参数列表">
|
||||
<ItemsControl ItemsSource="{Binding Parameters}">
|
||||
<DataTemplate DataType="local:FacilityItem">
|
||||
<GroupBox materialDesign:GroupBoxAssist.HeaderPadding="4" Header="参数列表">
|
||||
<ItemsControl d:ItemsSource="{d:SampleData ItemCount=5}" ItemsSource="{Binding Parameters}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Margin="2" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Width="250"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding Name}" />
|
||||
<TextBox
|
||||
Padding="3"
|
||||
VerticalContentAlignment="Center"
|
||||
materialDesign:HintAssist.IsFloating="False"
|
||||
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</StackPanel>
|
||||
<DataTemplate DataType="local:ParameterItem">
|
||||
<TextBox
|
||||
Padding="2"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalContentAlignment="Center"
|
||||
materialDesign:HintAssist.IsFloating="False"
|
||||
materialDesign:TextFieldAssist.PrefixText="{Binding Name, StringFormat={}{0}:}"
|
||||
Style="{StaticResource MaterialDesignTextBox}"
|
||||
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
@@ -87,9 +84,10 @@
|
||||
|
||||
<DataGridCheckBoxColumn Binding="{Binding IsSelected}">
|
||||
<DataGridCheckBoxColumn.Header>
|
||||
<Border Background="Transparent">
|
||||
<CheckBox Content="全选" IsChecked="{Binding DataContext.IsAllItemsSelected, RelativeSource={RelativeSource AncestorType=DataGrid}}" />
|
||||
</Border>
|
||||
<CheckBox
|
||||
VerticalContentAlignment="Center"
|
||||
Content="全选"
|
||||
IsChecked="{Binding DataContext.IsAllItemsSelected, RelativeSource={RelativeSource AncestorType=DataGrid}}" />
|
||||
</DataGridCheckBoxColumn.Header>
|
||||
<DataGridCheckBoxColumn.HeaderStyle>
|
||||
<Style BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}" TargetType="{x:Type DataGridColumnHeader}">
|
||||
@@ -224,6 +222,7 @@
|
||||
<GroupBox
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
materialDesign:GroupBoxAssist.HeaderPadding="4"
|
||||
Header="构件实例表">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -234,6 +233,8 @@
|
||||
x:Name="InstancesDG"
|
||||
Margin="-4"
|
||||
d:ItemsSource="{d:SampleData ItemCount=5}"
|
||||
materialDesign:DataGridAssist.CellPadding="8,0"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="6"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
ItemsSource="{Binding ElementName=Facilities, Path=SelectedItem.Instances}"
|
||||
@@ -310,7 +311,6 @@
|
||||
</Button>
|
||||
<GridSplitter Width="2" Background="Gray" />
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
Margin="2,0"
|
||||
Command="{Binding RepickInstancesByRectangleCommand}"
|
||||
CommandParameter="{Binding SelectedFacility.MappedFamily}"
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Szmedi.RvKits.MEPTools
|
||||
public ICollectionView InstancesCollectionView { get; set; }
|
||||
public FacilityInfoProcessViewModel()
|
||||
{
|
||||
GlobalVariables.UIApplication.ViewActivated += UIApplication_ViewActivated;
|
||||
GlobalVariables.UIApplication?.ViewActivated += UIApplication_ViewActivated;
|
||||
handler = new ActionEventHandler();
|
||||
}
|
||||
[RelayCommand]
|
||||
@@ -63,12 +63,11 @@ namespace Szmedi.RvKits.MEPTools
|
||||
AppDomain.CurrentDomain.AssemblyResolve += ResolveHelper.ResolveAssembly;
|
||||
try
|
||||
{
|
||||
|
||||
Items = package.ToList<FacilityItem>(1, configuration => configuration.SkipCastingErrors());
|
||||
}
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException)
|
||||
catch (EPPlus.Core.Extensions.Exceptions.ExcelValidationException ex)
|
||||
{
|
||||
MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行或多余文字。");
|
||||
MessageBox.Show("列名不存在或不匹配,请检查表头是否存在换行或多余文字。", ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -128,16 +127,14 @@ namespace Szmedi.RvKits.MEPTools
|
||||
{
|
||||
// 获取类型元素 (FamilySymbol)
|
||||
Element typeElem = doc.GetElement(typeId);
|
||||
FamilySymbol symbol = typeElem as FamilySymbol;
|
||||
|
||||
if (symbol != null)
|
||||
if (typeElem is FamilySymbol symbol)
|
||||
{
|
||||
Family family = symbol.Family;
|
||||
|
||||
// 确保族存在且未被添加过
|
||||
if (family != null && !usedFamilyIds.Contains(family.Id))
|
||||
if (family != null && usedFamilyIds.Add(family.Id))
|
||||
{
|
||||
usedFamilyIds.Add(family.Id);
|
||||
resultFamilies.Add(family);
|
||||
}
|
||||
}
|
||||
@@ -153,7 +150,6 @@ namespace Szmedi.RvKits.MEPTools
|
||||
return;
|
||||
}
|
||||
var families = GetUsedFamilies(doc)
|
||||
.Cast<Family>()
|
||||
.Where(
|
||||
fam => fam.FamilyCategory.AllowsBoundParameters &&
|
||||
fam.IsEditable &&
|
||||
@@ -180,6 +176,10 @@ namespace Szmedi.RvKits.MEPTools
|
||||
GetFamilies();
|
||||
ExcelPath = ofd.FileName;
|
||||
ProcessExcel(ofd.FileName);
|
||||
if (Items == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FuzzyMatch();
|
||||
FacilitiesCollectionView = CollectionViewSource.GetDefaultView(Items);
|
||||
|
||||
@@ -206,7 +206,6 @@ namespace Szmedi.RvKits.MEPTools
|
||||
}
|
||||
foreach (var item in Items)
|
||||
{
|
||||
string resultName = string.Empty;
|
||||
double minRatio = 30;
|
||||
|
||||
foreach (var family in Families)
|
||||
@@ -354,126 +353,120 @@ namespace Szmedi.RvKits.MEPTools
|
||||
MessageBox.Show("未选择任何有效的设备项进行处理。", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
handler.Raise(
|
||||
uiapp =>
|
||||
|
||||
handler.Raise(
|
||||
uiapp =>
|
||||
{
|
||||
var doc = uiapp.ActiveUIDocument.Document;
|
||||
if (doc.IsFamilyDocument)
|
||||
{
|
||||
var doc = uiapp.ActiveUIDocument.Document;
|
||||
if (doc.IsFamilyDocument)
|
||||
return;
|
||||
}
|
||||
doc.InvokeGroup(
|
||||
_ =>
|
||||
{
|
||||
return;
|
||||
}
|
||||
doc.InvokeGroup(
|
||||
ts =>
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var allInstances = Items.Where(i => i.IsSelected).SelectMany(i => i.Instances).ToList();
|
||||
string message = ValidateDuplicatesWithDisplay(allInstances, s => s.Id, s => $"{s.Symbol.FamilyName}:{s.Name}");
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var allInstances = Items.Where(i => i.IsSelected).SelectMany(i => i.Instances).ToList();
|
||||
string message = ValidateDuplicatesWithDisplay(allInstances, s => s.Id, s => $"{s.Symbol.FamilyName}:{s.Name}");
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
MessageBox.Show(message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
foreach (var item in processItems)
|
||||
{
|
||||
var family = item.MappedFamily;
|
||||
if (!family.IsValidObject)
|
||||
{
|
||||
MessageBox.Show(message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
sb.AppendLine($"<{item.Name}>因文档手动修改导致匹配族失效,请重新匹配,跳过该族。");
|
||||
continue;
|
||||
}
|
||||
foreach (var item in processItems)
|
||||
if (!family.IsEditable)
|
||||
{
|
||||
var family = item.MappedFamily;
|
||||
if (!family.IsEditable)
|
||||
{
|
||||
sb.AppendLine($"{family.Name} 族不可编辑,跳过该族。");
|
||||
}
|
||||
Document famdoc = null;
|
||||
try
|
||||
{
|
||||
famdoc = doc.EditFamily(family);
|
||||
famdoc.Invoke(
|
||||
ts =>
|
||||
{
|
||||
foreach (var paramItem in item.Parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
var familyParameters = famdoc.FamilyManager.GetParameters().Where(p => p.Definition.Name == paramItem.Name);
|
||||
if (familyParameters.Any())
|
||||
{
|
||||
var parameter = familyParameters.FirstOrDefault();
|
||||
|
||||
if (parameter.Definition is InternalDefinition def && def.BuiltInParameter == BuiltInParameter.INVALID)
|
||||
{
|
||||
famdoc.FamilyManager.RemoveParameter(parameter);
|
||||
famdoc.Regenerate();
|
||||
}
|
||||
|
||||
famdoc.FamilyManager.AddParameter(paramItem.Name, BuiltInParameterGroup.PG_TEXT, ParameterType.Text, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
famdoc.FamilyManager
|
||||
.AddParameter(
|
||||
paramItem.Name,
|
||||
BuiltInParameterGroup.PG_TEXT,
|
||||
ParameterType.Text,
|
||||
true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sb.AppendLine($"{family.Name} 族参数 {paramItem.Name} 添加失败,{ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
"添加缺失的族参数属性条目");
|
||||
|
||||
var loadedFamily = famdoc.LoadFamily(doc, new FamilyLoadOption());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sb.AppendLine($"{family.Name} 族加载到项目中失败,原因:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
famdoc?.Close(false);
|
||||
}
|
||||
doc.Invoke(
|
||||
ts =>
|
||||
sb.AppendLine($"{family.Name} 族不可编辑,跳过该族。");
|
||||
continue;
|
||||
}
|
||||
Document famdoc = null;
|
||||
try
|
||||
{
|
||||
famdoc = doc.EditFamily(family);
|
||||
famdoc.Invoke(
|
||||
_ =>
|
||||
{
|
||||
foreach (var instance in item.Instances)
|
||||
foreach (var paramItem in item.Parameters)
|
||||
{
|
||||
foreach (var paramItem in item.Parameters)
|
||||
try
|
||||
{
|
||||
Parameter param = instance.GetParameters(paramItem.Name)?.FirstOrDefault();
|
||||
if (param != null && !param.IsReadOnly)
|
||||
var familyParameters = famdoc.FamilyManager.GetParameters()
|
||||
.Where(p => p.Definition.Name == paramItem.Name).ToList();
|
||||
if (familyParameters.Count > 0)
|
||||
{
|
||||
param.Set(paramItem.Value);
|
||||
var parameter = familyParameters.FirstOrDefault();
|
||||
|
||||
if (parameter.Definition is InternalDefinition def && def.BuiltInParameter == BuiltInParameter.INVALID)
|
||||
{
|
||||
famdoc.FamilyManager.RemoveParameter(parameter);
|
||||
famdoc.Regenerate();
|
||||
}
|
||||
|
||||
famdoc.FamilyManager.AddParameter(paramItem.Name, BuiltInParameterGroup.PG_TEXT, ParameterType.Text, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine($"{instance.Id} - {instance.Name} 未找到参数 {paramItem.Name} 或参数只读,未设置其值。");
|
||||
famdoc.FamilyManager
|
||||
.AddParameter(
|
||||
paramItem.Name,
|
||||
BuiltInParameterGroup.PG_TEXT,
|
||||
ParameterType.Text,
|
||||
true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sb.AppendLine($"{family.Name} 族参数 {paramItem.Name} 添加失败,{ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
MessageBox.Show(sb.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("添加完成!");
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
},
|
||||
"添加缺失的族参数属性条目");
|
||||
|
||||
throw;
|
||||
}
|
||||
item.MappedFamily = famdoc.LoadFamily(doc, new FamilyLoadOption());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sb.AppendLine($"{family.Name} 族加载到项目中失败,原因:{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
famdoc?.Close(false);
|
||||
}
|
||||
doc.Invoke(
|
||||
ts =>
|
||||
{
|
||||
foreach (var instance in item.Instances)
|
||||
{
|
||||
foreach (var paramItem in item.Parameters)
|
||||
{
|
||||
Parameter param = instance.GetParameters(paramItem.Name)?.FirstOrDefault();
|
||||
if (param is { IsReadOnly: false })
|
||||
{
|
||||
param.Set(paramItem.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine($"{instance.Id} - {instance.Name} 未找到参数 {paramItem.Name} 或参数只读,未设置其值。");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MessageBox.Show(sb.Length > 0 ? sb.ToString() : "添加完成!");
|
||||
}, "处理设备信息");
|
||||
|
||||
});
|
||||
}
|
||||
[ObservableProperty]
|
||||
public partial FacilityItem SelectedFacility { get; set; }
|
||||
@@ -645,7 +638,9 @@ namespace Szmedi.RvKits.MEPTools
|
||||
[ObservableProperty]
|
||||
public partial string Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Excel表里的设备项
|
||||
/// </summary>
|
||||
public partial class FacilityItem : ObservableObject
|
||||
{
|
||||
public FacilityItem()
|
||||
2
Szmedi.RvKits/Properties/Settings.Designer.cs
generated
2
Szmedi.RvKits/Properties/Settings.Designer.cs
generated
@@ -253,7 +253,7 @@ namespace Szmedi.RvKits.Properties {
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<ArrayOfString xmlns:xsd=\"http://www.w3." +
|
||||
"org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <s" +
|
||||
"tring>rvt文档比较工具</string>\r\n</ArrayOfString>")]
|
||||
"tring>修复设备信息在添加有错误的表格后崩溃的情况及优化添加设备信息操作</string>\r\n</ArrayOfString>")]
|
||||
public global::System.Collections.Specialized.StringCollection UpdateNotes {
|
||||
get {
|
||||
return ((global::System.Collections.Specialized.StringCollection)(this["UpdateNotes"]));
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<Setting Name="UpdateNotes" Type="System.Collections.Specialized.StringCollection" Scope="Application">
|
||||
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<string>rvt文档比较工具</string>
|
||||
<string>修复设备信息在添加有错误的表格后崩溃的情况及优化添加设备信息操作</string>
|
||||
</ArrayOfString></Value>
|
||||
</Setting>
|
||||
<Setting Name="APIKey" Type="System.String" Scope="User">
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ColorCodeBlockRenderer : WpfObjectRenderer<CodeBlock>
|
||||
var code = new StringBuilder();
|
||||
var lines = leafBlock.Lines.Lines;
|
||||
//var totalLines = lines.Length;
|
||||
var totalLines = lines == null ? 0 : lines.Length;
|
||||
var totalLines = lines?.Length ?? 0;
|
||||
for (var index = 0; index < totalLines; index++)
|
||||
{
|
||||
var line = lines[index];
|
||||
|
||||
BIN
Szmedi.RvKits/Setup/SzmediTools2.2.3.83.exe
Normal file
BIN
Szmedi.RvKits/Setup/SzmediTools2.2.3.83.exe
Normal file
Binary file not shown.
32
Szmedi.RvKits/Szmedi.RvKits.crproj
Normal file
32
Szmedi.RvKits/Szmedi.RvKits.crproj
Normal file
@@ -0,0 +1,32 @@
|
||||
<project outputDir="." baseDir="." xmlns="http://confuser.codeplex.com">
|
||||
<!--
|
||||
1. 全局规则:开启常规混淆
|
||||
preset="normal" 包含了:控制流混淆、参数重命名、资源加密等。
|
||||
它也会默认开启重命名(rename)。
|
||||
-->
|
||||
<rule pattern="true" preset="normal">
|
||||
<!-- 可以在这里微调全局设置,比如加强控制流 -->
|
||||
<protection id="ctrl flow" />
|
||||
<!-- 关键:禁止重命名 BAML 文件名,保证 "WPFUI.xaml" 依然叫 "wpfui.baml" -->
|
||||
<protection id="rename">
|
||||
<argument name="renXaml" value="false" />
|
||||
</protection>
|
||||
</rule>
|
||||
<!--
|
||||
2. 关键规则:保留所有类名(不重命名类)
|
||||
pattern="member-type('type')" 意思是指:匹配所有的“类型”定义(Class/Interface/Struct)。
|
||||
action="remove" 意思是指:对匹配到的这些项,移除指定的保护。
|
||||
-->
|
||||
<rule pattern="member-type('type')">
|
||||
<protection id="rename" action="remove" />
|
||||
</rule>
|
||||
|
||||
<!-- 4. 指定模块 -->
|
||||
<module path="Szmedi.RvKits.dll" />
|
||||
|
||||
<!-- 5. 引用路径 (非常重要) -->
|
||||
<!-- 为了让ConfuserEx知道哪些方法是接口实现(从而不重命名它们),它需要找到 RevitAPI.dll -->
|
||||
<!-- 请根据您的Revit安装路径修改,或者确保RevitAPI.dll在编译输出目录中 -->
|
||||
<!-- <probePath>C:\Program Files\Autodesk\Revit 2020</probePath>-->
|
||||
|
||||
</project>
|
||||
@@ -16,7 +16,7 @@
|
||||
<AssemblyName>Szmedi.RvKits</AssemblyName>
|
||||
<RootNamespace>$(AssemblyName)</RootNamespace>
|
||||
<Company>Szmedi</Company>
|
||||
<AssemblyVersion>2.2.3.82</AssemblyVersion>
|
||||
<AssemblyVersion>2.2.3.83</AssemblyVersion>
|
||||
<ProductVersion>$(AssemblyVersion)</ProductVersion>
|
||||
<FileVersion>$(AssemblyVersion)</FileVersion>
|
||||
</PropertyGroup>
|
||||
@@ -81,6 +81,15 @@
|
||||
<DebugType>None</DebugType>
|
||||
<OutputPath>..\bin\Release\$(RevitVersion)</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(Configuration.Contains('Release'))">
|
||||
<Obfuscate>true</Obfuscate>
|
||||
<ConfuserReplaceOutput>true</ConfuserReplaceOutput>
|
||||
<ConfuserProject>$(MSBuildProjectDirectory)\$(MSBuildProjectName).crproj</ConfuserProject>
|
||||
<ConfuserKeyFile>$(AssemblyOriginatorKeyFile)</ConfuserKeyFile>
|
||||
<ConfuserIntermediateOutputPath>$(IntermediateOutputPath)</ConfuserIntermediateOutputPath>
|
||||
<ConfuserOutDir>$(OutDir)</ConfuserOutDir>
|
||||
<ConfuserSymbolFileName>symbols.map</ConfuserSymbolFileName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="ScriptPad\**" />
|
||||
<EmbeddedResource Remove="ScriptPad\**" />
|
||||
@@ -126,7 +135,7 @@
|
||||
<PackageReference Include="Dirkster.AvalonDock.Themes.VS2013" Version="4.72.1" />
|
||||
<PackageReference Include="EPPlus.Core.Extensions" Version="2.4.0" />
|
||||
<PackageReference Include="FreeSpire.Doc" Version="12.2.0" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.12.3" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.12.4" />
|
||||
<!--<PackageReference Include="MaterialDesignBoxes" Version="1.0.4" />-->
|
||||
<!--<PackageReference Include="Markdig" Version="0.40.0" />-->
|
||||
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
||||
@@ -138,6 +147,10 @@
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122">
|
||||
<TreatAsUsed>True</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Confuser.MSBuild" Version="1.6.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Nice3point.Revit.Toolkit" Version="2019.*" />
|
||||
|
||||
183
Szmedi.RvKits/Szmedi.Rvkits.iss
Normal file
183
Szmedi.RvKits/Szmedi.Rvkits.iss
Normal file
@@ -0,0 +1,183 @@
|
||||
; 脚本由 Inno Setup 脚本向导生成。
|
||||
; 有关创建 Inno Setup 脚本文件的详细信息,请参阅帮助文档!
|
||||
|
||||
; 定义应用程序的名称
|
||||
#define MyAppName "SzmediTools"
|
||||
; 定义应用程序的版本号
|
||||
#define MyAppVersion "2.2.3.83"
|
||||
; 定义应用程序的发布者
|
||||
#define MyAppPublisher "SZMEDI"
|
||||
; 定义应用程序的网址
|
||||
#define MyAppURL "https://www.szmedi.com.cn/"
|
||||
; 定义应用程序的可执行文件名
|
||||
#define MyAppExeName "MyProg-x64.exe"
|
||||
#define MyDllName "Szmedi.RvKits"
|
||||
|
||||
[Setup]
|
||||
; 注意:AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。
|
||||
; (若要生成新的 GUID,请在 IDE 中单击 "工具|生成 GUID"。)
|
||||
AppId={{C7E6D9E9-B211-428D-A429-D23DD5B56DE6}
|
||||
; 程序名称
|
||||
AppName={#MyAppName}
|
||||
; 版本
|
||||
AppVersion={#MyAppVersion}
|
||||
; AppVerName={#MyAppName} {#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
AppPublisherURL={#MyAppURL}
|
||||
AppSupportURL={#MyAppURL}
|
||||
AppUpdatesURL={#MyAppURL}
|
||||
;控制面板显示的名称
|
||||
UninstallDisplayName={#MyAppName}
|
||||
;安装包构建模型
|
||||
ArchitecturesInstallIn64BitMode=x64os
|
||||
;管理员权限
|
||||
PrivilegesRequired=admin
|
||||
; 是否创建应用程序目录
|
||||
CreateAppDir=no
|
||||
; 许可证文件路径
|
||||
;LicenseFile=.\bin\Release\2018\license.txt
|
||||
; 安装前显示的信息文件路径
|
||||
;InfoBeforeFile=.\bin\Release\2018\Readme.txt
|
||||
; 安装后显示的信息文件路径
|
||||
;InfoAfterFile=.\bin\Release\2018\Readme.txt
|
||||
; 取消对以下行的注释以在非管理安装模式下运行(仅针对当前用户进行安装)。
|
||||
; PrivilegesRequired=lowest
|
||||
; exe输出目录
|
||||
OutputDir=.\Setup
|
||||
; 输出文件名
|
||||
OutputBaseFilename={#MyAppName}{#MyAppVersion}
|
||||
; 密码
|
||||
;Password=SZMEDI
|
||||
; 是否加密
|
||||
|
||||
;Encryption=yes
|
||||
; 压缩方式
|
||||
Compression=lzma
|
||||
;Compression=zip
|
||||
; 是否使用固体压缩
|
||||
SolidCompression=yes
|
||||
; 向导样式
|
||||
WizardStyle=modern
|
||||
|
||||
[Files]
|
||||
; 源文件路径和目标目录
|
||||
Source: "..\bin\Release\2018\*"; DestDir: "C:\ProgramData\Autodesk\ApplicationPlugins\Szmedi.RvKits.bundle\Contents\2018"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; Source: "I:\04 程序开发\Revit Dev\Szmedi.RvKit\bin\Release\2019\*"; DestDir: "C:\ProgramData\Autodesk\ApplicationPlugins\Szmedi.RvKits.bundle\Contents\2019"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
Source: "..\bin\Release\2020\*"; DestDir: "C:\ProgramData\Autodesk\ApplicationPlugins\Szmedi.RvKits.bundle\Contents\2020"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
Source: "..\bin\Szmedi.RvKits.bundle\*"; DestDir: "C:\ProgramData\Autodesk\ApplicationPlugins\Szmedi.RvKits.bundle"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; 注意:不要在任何共享系统文件上使用 "Flags: ignoreversion"
|
||||
|
||||
[Code]
|
||||
[Code]
|
||||
const
|
||||
AddinFileName = 'Szmedi.RvKits.addin';
|
||||
|
||||
// 日志函数,用于调试
|
||||
procedure Log(const Msg: string);
|
||||
begin
|
||||
MsgBox(Msg, mbInformation, MB_OK);
|
||||
end;
|
||||
|
||||
// 检查目录是否存在,如果不存在则创建
|
||||
procedure CreateDirectoryIfNotExists(const Dir: string);
|
||||
begin
|
||||
if not DirExists(Dir) then
|
||||
begin
|
||||
if not CreateDir(Dir) then
|
||||
begin
|
||||
Log('目录创建失败: ' + Dir);
|
||||
Exit;
|
||||
end;
|
||||
Log('目录创建成功: ' + Dir);
|
||||
end;
|
||||
end;
|
||||
|
||||
// 检查文件是否可写
|
||||
function IsFileWritable(const FileName: string): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
try
|
||||
if FileExists(FileName) then
|
||||
begin
|
||||
// 尝试写入文件
|
||||
SaveStringToFile(FileName, 'test', False);
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
begin
|
||||
// 文件不存在,可以创建
|
||||
Result := True;
|
||||
end;
|
||||
except
|
||||
Log('文件不可写: ' + FileName);
|
||||
end;
|
||||
end;
|
||||
|
||||
// 覆写或创建 .addin 文件
|
||||
procedure ReplaceAddinFileContentForVersion(Version: String);
|
||||
var
|
||||
AddinFile: TStringList;
|
||||
FullPath: string;
|
||||
DirPath: string;
|
||||
begin
|
||||
FullPath := ExpandConstant('{commonappdata}\Autodesk\ApplicationPlugins\Szmedi.RvKits.bundle\Contents\' + Version + '\' + AddinFileName);
|
||||
//Log('addin文件路径: ' + FullPath);
|
||||
|
||||
// 检查目录是否存在,如果不存在则创建
|
||||
DirPath := ExtractFilePath(FullPath);
|
||||
CreateDirectoryIfNotExists(DirPath);
|
||||
|
||||
// 检查文件是否可写
|
||||
if not IsFileWritable(FullPath) then
|
||||
begin
|
||||
Log('文件不可写: ' + FullPath);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// 创建并写入文件内容
|
||||
AddinFile := TStringList.Create;
|
||||
try
|
||||
AddinFile.Add('<?xml version="1.0" encoding="utf-8" standalone="no"?>');
|
||||
AddinFile.Add('<RevitAddIns>');
|
||||
AddinFile.Add(' <AddIn Type="Application">');
|
||||
AddinFile.Add(' <Name>{#MyAppName}</Name>');
|
||||
AddinFile.Add(' <Assembly>{#MyDllName}.dll</Assembly>');
|
||||
AddinFile.Add(' <AddInId>A4158476-0BF7-4E42-84B3-30B4423E8B8A</AddInId>');
|
||||
AddinFile.Add(' <FullClassName>{#MyDllName}.UIApp.UIRibbon</FullClassName>');
|
||||
AddinFile.Add(' <VendorId>{#MyAppPublisher}</VendorId>');
|
||||
AddinFile.Add(' <VendorDescription>{#MyAppPublisher},{#MyAppURL}</VendorDescription>');
|
||||
AddinFile.Add(' </AddIn>');
|
||||
AddinFile.Add('</RevitAddIns>');
|
||||
|
||||
// 保存文件
|
||||
AddinFile.SaveToFile(FullPath);
|
||||
//Log('文件成功写入: ' + FullPath);
|
||||
except
|
||||
Log('文件写入失败: ' + FullPath + ' - ' + GetExceptionMessage);
|
||||
finally
|
||||
AddinFile.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
// 在安装完成后调用
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
var
|
||||
RevitVersions: TArrayOfString; // 动态数组
|
||||
i: Integer;
|
||||
begin
|
||||
if CurStep = ssPostInstall then
|
||||
begin
|
||||
// 初始化 Revit 版本数组
|
||||
SetArrayLength(RevitVersions, 2); // 设置数组长度
|
||||
RevitVersions[0] := '2018';
|
||||
//RevitVersions[1] := '2019';
|
||||
RevitVersions[1] := '2020';
|
||||
//RevitVersions[3] := '2021';
|
||||
|
||||
// 遍历每个版本并处理
|
||||
for i := 0 to GetArrayLength(RevitVersions) - 1 do
|
||||
begin
|
||||
ReplaceAddinFileContentForVersion(RevitVersions[i]);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@@ -115,7 +115,7 @@
|
||||
<setting name="UpdateNotes" serializeAs="Xml">
|
||||
<value>
|
||||
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<string>rvt文档比较工具</string>
|
||||
<string>修复设备信息在添加有错误的表格后崩溃的情况及优化添加设备信息操作</string>
|
||||
</ArrayOfString>
|
||||
</value>
|
||||
</setting>
|
||||
|
||||
Reference in New Issue
Block a user