清理ColorPicker,进度条。修复UI问题
This commit is contained in:
@@ -231,5 +231,51 @@ namespace ShrlAlgoToolkit.RevitCore.Extensions
|
||||
options.SetFailuresPreprocessor(failuresPreprocessor);
|
||||
ts.SetFailureHandlingOptions(options);
|
||||
}
|
||||
/// <summary>
|
||||
/// 封装普通事务
|
||||
/// </summary>
|
||||
public static void InvokeInTransaction(this Document doc, Action action, string transactionName = "DefaultTransaction")
|
||||
{
|
||||
using (Transaction t = new Transaction(doc, transactionName))
|
||||
{
|
||||
t.Start();
|
||||
try
|
||||
{
|
||||
action();
|
||||
t.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (t.GetStatus() == TransactionStatus.Started)
|
||||
t.RollBack();
|
||||
throw; // 将异常向上抛出
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 封装事务组 (TransactionGroup)
|
||||
/// </summary>
|
||||
public static void InvokeInTransactionGroup(this Document doc, Action action, string groupName = "DefaultGroup", bool assimilate = true)
|
||||
{
|
||||
using (TransactionGroup tg = new TransactionGroup(doc, groupName))
|
||||
{
|
||||
tg.Start();
|
||||
try
|
||||
{
|
||||
action();
|
||||
if (assimilate)
|
||||
tg.Assimilate(); // 融合所有子事务
|
||||
else
|
||||
tg.Commit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (tg.GetStatus() == TransactionStatus.Started)
|
||||
tg.RollBack();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user