public IXApplication StartApplication(IXVersion vers, StartupOptions_e opts, CancellationToken cancellationToken) { var app = SwApplicationFactory.PreCreate(); app.State = ApplicationState_e.Default; app.Version = (ISwVersion)vers; app.CustomServices = m_CustomServices; List <string> forceDisabledAddIns = null; if (opts.HasFlag(StartupOptions_e.Safe)) { app.State |= ApplicationState_e.Safe; TryDisableAddIns(out forceDisabledAddIns); } if (opts.HasFlag(StartupOptions_e.Background)) { app.State |= ApplicationState_e.Background; } if (opts.HasFlag(StartupOptions_e.Silent)) { app.State |= ApplicationState_e.Silent; } if (opts.HasFlag(StartupOptions_e.Hidden)) { app.State |= ApplicationState_e.Hidden; } try { app.Commit(cancellationToken); } finally { if (forceDisabledAddIns != null) { TryEnableAddIns(forceDisabledAddIns); } } app.Sw.UserControlBackground = true; app.Sw.CommandInProgress = true; //Note. By some reasons the process from IXApplication::Process does not fire exited event var prc = Process.GetProcessById(app.Process.Id); prc.EnableRaisingEvents = true; prc.Exited += OnProcessExited; m_ForceDisabledAddIns.Add(prc, forceDisabledAddIns); return(app); }
public int CompareTo(IXVersion other) { if (other is SwDmVersion) { return(((int)Major).CompareTo((int)((SwDmVersion)other).Major)); } else { throw new InvalidCastException("Can only compare SOLIDWORKS versions"); } }
private IXApplication AttemptStartApplication(IXVersion versionInfo, StartupOptions_e opts, CancellationToken cancellationToken, TimeSpan?timeout) { int curAttempt = 1; CancellationTokenSource appStartCancellationTokenSrc = null; while (curAttempt <= MAX_ATTEMPTS) { try { var appStartTimeout = timeout.HasValue ? timeout.Value : TimeSpan.FromMinutes(5); if (cancellationToken != default) { appStartCancellationTokenSrc = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); } else { appStartCancellationTokenSrc = new CancellationTokenSource(); } appStartCancellationTokenSrc.CancelAfter(appStartTimeout); m_UserLogger.WriteLine($"Starting host application: {versionInfo.DisplayName}"); var app = m_AppProvider.StartApplication(versionInfo, opts, appStartCancellationTokenSrc.Token); TryAddProcessToJob(app); return(app); } catch { if (cancellationToken.IsCancellationRequested) { throw new JobCancelledException(); } m_UserLogger.WriteLine($"Failed to start application from attempt {curAttempt}"); curAttempt++; } finally { appStartCancellationTokenSrc?.Dispose(); } } throw new UserMessageException("Failed to start application. Operation is aborted"); }
private IXApplication StartApplication(IXVersion versionInfo, StartupOptions_e opts, CancellationToken cancellationToken) { m_JournalWriter.WriteLine($"Starting host application: {versionInfo.DisplayName}"); IXApplication app; try { app = m_AppProvider.StartApplication(versionInfo, opts, p => TryAddProcessToJob(p), cancellationToken); if (opts.HasFlag(StartupOptions_e.Silent)) { m_PopupKiller.Start(app.Process, TimeSpan.FromSeconds(POPUP_KILLER_PING_SECS)); } } catch (Exception ex) { throw new UserException("Failed to start host application", ex); } return(app); }
public string GetVersionId(IXVersion value) => m_AppProvider.GetVersionId(value);
public bool Equals(IXVersion other) => Equals((object)other);
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { return(IXVersion.Equals(values[0], values[1])); }
public string GetVersionId(IXVersion value) => (value as ISwVersion)?.Major.ToString();
public VersionVM(IXVersion vers) { Version = vers; }