using System; using System.Windows.Interop; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Sai.Database.Shared; using Sai.RvKits.IO; using Sai.RvKits.Operation; using SZBIM.StandardTools; namespace Sai.Common.Shared.ParameterManager { [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] public class ArchiParamsManagerCmd : IExternalCommand { private static readonly string DbString = $"Data Source={RelativePaths.DirAssembly}\\Database\\SZBIM.DeliveryStandard.db"; private readonly DapperUtil dapperUtil = new(DbString); public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { if (WinIntPtr.IsVisible("建筑参数管理")) { WinIntPtr.ShowAndActive("建筑参数管理"); } else { dapperUtil.CreateConnect(); ArchiParamManagerViewModel viewModel = new ArchiParamManagerViewModel(dapperUtil); try { var win = new ArchiParamsManagerWin(viewModel); _ = new WindowInteropHelper(win) { Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle }; win.Show(); } catch (Exception ex) { LogUtil.WriteLog(ex.Message, RelativePaths.LogFolder); } finally { dapperUtil.CloseConnect(); } } return Result.Succeeded; } } }