Beispiel #1
0
        private void OnPageClosed(PageCloseReasons_e reason)
        {
            if (reason == PageCloseReasons_e.Okay)
            {
                try
                {
                    IXDocument[] docs    = null;
                    var          rootDoc = m_Data.Input.Document;

                    switch (m_Data.Input.Scope)
                    {
                    case InputScope_e.AllReferences:
                        docs = m_Data.Input.AllDocuments.References
                               .Where(d => d.IsChecked).Select(d => d.Document).ToArray();
                        break;

                    case InputScope_e.Selection:
                        docs = m_Data.Input.Components
                               .Distinct(new ComponentDocumentSafeEqualityComparer())
                               .Select(c => c.ReferencedDocument).ToArray();
                        break;

                    default:
                        throw new NotSupportedException();
                    }

                    var input = docs.ToList();
                    ProcessInput?.Invoke(m_Host.Extension.Application, input);

                    var exec = new AssemblyBatchRunJobExecutor(m_Host.Extension.Application, m_MacroRunnerSvc,
                                                               input.ToArray(), m_Logger, m_Data.Macros.Macros.Macros.Select(x => x.Data).ToArray(),
                                                               m_Data.Options.ActivateDocuments, m_Data.Options.AllowReadOnly,
                                                               m_Data.Options.AllowRapid, m_Data.Options.AutoSave);

                    var vm = new JobResultVM(rootDoc.Title, exec, m_CadDesc, m_Logger);

                    using (var cancelHandler = new EscapeBatchExecutorCancelHandler(exec, m_Host.Extension.Application, m_Dispatcher))
                    {
                        vm.TryRunBatch();
                    }

                    var wnd = m_Host.Extension.CreatePopupWindow <ResultsWindow>();
                    wnd.Control.Title       = $"{rootDoc.Title} batch job result";
                    wnd.Control.DataContext = vm;
                    wnd.Show();
                }
                catch (OperationCanceledException)
                {
                }
                catch (Exception ex)
                {
                    m_Msg.ShowError(ex);
                    m_Logger.Log(ex);
                }
            }
        }
Beispiel #2
0
        private void OnPageClosed(PageCloseReasons_e reason)
        {
            if (reason == PageCloseReasons_e.Okay)
            {
                try
                {
                    IXDocument[] docs = null;
                    var          assm = m_Host.Extension.Application.Documents.Active as IXAssembly;

                    if (m_Data.ProcessAllFiles)
                    {
                        docs = assm.Dependencies;
                    }
                    else
                    {
                        docs = m_Data.Components.Select(c => c.Document)
                               .Distinct(new DocumentEqualityComparer()).ToArray();
                    }

                    var exec = new AssemblyBatchRunJobExecutor(m_Host.Extension.Application, m_MacroRunnerSvc,
                                                               docs, m_Data.Macros.Macros, m_Data.ActivateDocuments);

                    var vm = new JobResultVM(assm.Title, exec);

                    exec.ExecuteAsync().Wait();

                    var wnd = m_Host.Extension.CreatePopupWindow <ResultsWindow>();
                    wnd.Control.Title       = $"{assm.Title} batch job result";
                    wnd.Control.DataContext = vm;
                    wnd.Show();
                }
                catch (Exception ex)
                {
                    m_Msg.ShowError(ex.ParseUserError(out string callStack));
                    m_Logger.Log(callStack);
                }
            }
        }