public CrashPrompt(CrashPromptArgs args) { InitializeComponent(); if (args.HasDetails()) { this.details = args.Details; this.CrashDetailsContent.Text = args.Details; this.btnDetails.Visibility = Visibility.Visible; InstrumentationLogger.LogInfo("CrasphPrompt", args.Details); } else { InstrumentationLogger.LogInfo("CrasphPrompt", "No details"); } if (args.IsFilePath()) { folderPath = Path.GetDirectoryName(args.FilePath); btnOpenFolder.Visibility = Visibility.Visible; } if (args.IsDefaultTextOverridden()) { string overridingText = args.OverridingText; if (args.IsFilePath()) { overridingText = overridingText.Replace("[FILEPATH]", args.FilePath); } ConvertFormattedTextIntoTextblock(this.txtOverridingText, overridingText); } }
static internal void Main(string[] args) { try { var cmdLineArgs = StartupUtils.CommandLineArguments.Parse(args); var locale = Dynamo.Applications.StartupUtils.SetLocale(cmdLineArgs); var model = Dynamo.Applications.StartupUtils.MakeModel(true); var runner = new CommandLineRunner(model); runner.Run(cmdLineArgs); } catch (Exception e) { try { DynamoModel.IsCrashing = true; InstrumentationLogger.LogException(e); StabilityTracking.GetInstance().NotifyCrash(); } catch { } Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } }
/// <summary> /// Filters search items, if category was selected. /// </summary> internal void Filter() { var allowedCategories = SearchCategories.Where(cat => cat.IsSelected); FilteredResults = searchResults.Where(x => allowedCategories .Select(cat => cat.Name) .Contains(x.Category)); // Report selected categories to instrumentation StringBuilder strBuilder = new StringBuilder(); foreach (var category in SearchCategories) { strBuilder.Append(category.Name); strBuilder.Append(" : "); if (category.IsSelected) { strBuilder.Append("Selected"); } else { strBuilder.Append("Unselected"); } strBuilder.Append(", "); } InstrumentationLogger.LogPiiInfo("Filter-categories", strBuilder.ToString().Trim()); }
protected virtual void Evaluate(HomeWorkspaceModel workspace) { var dynamoModel = workspace.DynamoModel; var sw = new Stopwatch(); try { sw.Start(); dynamoModel.EngineController.GenerateGraphSyncData(workspace.Nodes); if (dynamoModel.EngineController.HasPendingGraphSyncData) { ExecutionEvents.OnGraphPreExecution(); Eval(workspace); } } catch (Exception ex) { //Catch unhandled exception if (ex.Message.Length > 0) { dynamoModel.Logger.Log(ex); } OnRunCancelled(true); if (DynamoModel.IsTestMode) // Throw exception for NUnit. { throw new Exception(ex.Message + ":" + ex.StackTrace); } } finally { sw.Stop(); InstrumentationLogger.LogAnonymousEvent("Run", "Eval"); InstrumentationLogger.LogAnonymousTimedEvent("Perf", "EvalTime", sw.Elapsed); dynamoModel.Logger.Log( string.Format("Evaluation completed in {0}", sw.Elapsed)); } // When evaluation is completed, we mark all // nodes as ForceReexecuteOfNode = false to prevent // cyclical graph updates. It is therefore the responsibility // of the node implementor to mark this flag = true, if they // want to require update. foreach (var n in workspace.Nodes) { n.ForceReExecuteOfNode = false; } dynamoModel.OnEvaluationCompleted(this, EventArgs.Empty); ExecutionEvents.OnGraphPostExecution(); }
protected virtual void OnClicked() { if (Clicked != null) { var nodeModel = Model.CreateNode(); Clicked(nodeModel, Position); InstrumentationLogger.LogPiiInfo("Search-NodeAdded", FullName); } }
private void ToggleCanNavigateBackground(object parameter) { if (!Active) { return; } CanNavigateBackground = !CanNavigateBackground; InstrumentationLogger.LogAnonymousScreen(CanNavigateBackground ? "Geometry" : "Nodes"); }
/// <summary> /// Log the message to the the correct path /// </summary> /// <param name="message"></param> private void Log(string message, LogLevel level, bool reportModification) { lock (this.guardMutex) { //Don't overwhelm the logging system if (dynSettings.Controller != null && !dynSettings.Controller.DebugSettings.VerboseLogging) { InstrumentationLogger.LogInfo("LogMessage-" + level.ToString(), message); } switch (level) { //write to the console case LogLevel.Console: if (ConsoleWriter != null) { try { ConsoleWriter.AppendLine(string.Format("{0}", message)); FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message)); FileWriter.Flush(); RaisePropertyChanged("ConsoleWriter"); } catch { // likely caught if the writer is closed } } break; //write to the file case LogLevel.File: if (FileWriter != null) { try { FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message)); FileWriter.Flush(); } catch { // likely caught if the writer is closed } } break; } if (reportModification) { RaisePropertyChanged("LogText"); } } }
public static void Main(string[] args) { DynamoViewModel viewModel = null; try { var cmdLineArgs = CommandLineArguments.FromArguments(args); if (!string.IsNullOrEmpty(cmdLineArgs.Locale)) { // Change the application locale, if a locale information is supplied. Thread.CurrentThread.CurrentUICulture = new CultureInfo(cmdLineArgs.Locale); Thread.CurrentThread.CurrentCulture = new CultureInfo(cmdLineArgs.Locale); } MakeStandaloneAndRun(cmdLineArgs.CommandFilePath, out viewModel); } catch (Exception e) { try { #if DEBUG // Display the recorded command XML when the crash happens, // so that it maybe saved and re-run later if (viewModel != null) { viewModel.SaveRecordedCommand.Execute(null); } #endif DynamoModel.IsCrashing = true; InstrumentationLogger.LogException(e); StabilityTracking.GetInstance().NotifyCrash(); if (viewModel != null) { // Show the unhandled exception dialog so user can copy the // crash details and report the crash if she chooses to. viewModel.Model.OnRequestsCrashPrompt(null, new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace)); // Give user a chance to save (but does not allow cancellation) viewModel.Exit(allowCancel: false); } } catch { } Debug.WriteLine(e.Message); Debug.WriteLine(e.StackTrace); } }
public Result ExecuteCommand(DynamoRevitCommandData commandData) { HandleDebug(commandData); InitializeCore(commandData); try { extCommandData = commandData; shouldShowUi = CheckJournalForUiDisplay(extCommandData); isAutomationMode = CheckJournalForAutomationMode(extCommandData); UpdateSystemPathForProcess(); // create core data models revitDynamoModel = InitializeCoreModel(extCommandData); dynamoViewModel = InitializeCoreViewModel(revitDynamoModel); revitDynamoModel.Logger.Log("SYSTEM", string.Format("Environment Path:{0}", Environment.GetEnvironmentVariable("PATH"))); // handle initialization steps after RevitDynamoModel is created. revitDynamoModel.HandlePostInitialization(); // show the window if (shouldShowUi) { InitializeCoreView().Show(); } TryOpenAndExecuteWorkspace(extCommandData); // Disable the Dynamo button to prevent a re-run DynamoRevitApp.DynamoButtonEnabled = false; } catch (Exception ex) { // notify instrumentation InstrumentationLogger.LogException(ex); StabilityTracking.GetInstance().NotifyCrash(); MessageBox.Show(ex.ToString()); DynamoRevitApp.DynamoButtonEnabled = true; return(Result.Failed); } return(Result.Succeeded); }
public static void Main(string[] args) { DynamoViewModel viewModel = null; try { var cmdLineArgs = StartupUtils.CommandLineArguments.Parse(args); var locale = Dynamo.Applications.StartupUtils.SetLocale(cmdLineArgs); _putenv(locale); MakeStandaloneAndRun(cmdLineArgs.CommandFilePath, out viewModel); } catch (Exception e) { try { #if DEBUG // Display the recorded command XML when the crash happens, // so that it maybe saved and re-run later if (viewModel != null) { viewModel.SaveRecordedCommand.Execute(null); } #endif DynamoModel.IsCrashing = true; InstrumentationLogger.LogException(e); StabilityTracking.GetInstance().NotifyCrash(); if (viewModel != null) { // Show the unhandled exception dialog so user can copy the // crash details and report the crash if she chooses to. viewModel.Model.OnRequestsCrashPrompt(null, new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace)); // Give user a chance to save (but does not allow cancellation) viewModel.Exit(allowCancel: false); } } catch { } Debug.WriteLine(e.Message); Debug.WriteLine(e.StackTrace); } }
/// <summary> /// Log the message to the the correct path /// </summary> /// <param name="message"></param> private void Log(string message, LogLevel level, bool reportModification) { InstrumentationLogger.LogInfo("LogMessage-" + level.ToString(), message); switch (level) { //write to the console case LogLevel.Console: if (ConsoleWriter != null) { try { ConsoleWriter.AppendLine(string.Format("{0}", message)); FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message)); FileWriter.Flush(); RaisePropertyChanged("ConsoleWriter"); } catch { // likely caught if the writer is closed } } break; //write to the file case LogLevel.File: if (FileWriter != null) { try { FileWriter.WriteLine(string.Format("{0} : {1}", DateTime.Now, message)); FileWriter.Flush(); } catch { // likely caught if the writer is closed } } break; } if (reportModification) { RaisePropertyChanged("LogText"); } }
protected virtual void Evaluate(HomeWorkspaceModel workspace) { var dynamoModel = workspace.DynamoModel; var sw = new Stopwatch(); try { sw.Start(); dynamoModel.EngineController.GenerateGraphSyncData(workspace.Nodes); //No additional work needed if (dynamoModel.EngineController.HasPendingGraphSyncData) { Eval(workspace); } } catch (Exception ex) { //Catch unhandled exception if (ex.Message.Length > 0) { dynamoModel.Logger.Log(ex); } OnRunCancelled(true); if (DynamoModel.IsTestMode) // Throw exception for NUnit. { throw new Exception(ex.Message + ":" + ex.StackTrace); } } finally { sw.Stop(); InstrumentationLogger.LogAnonymousEvent("Run", "Eval"); InstrumentationLogger.LogAnonymousTimedEvent("Perf", "EvalTime", sw.Elapsed); dynamoModel.Logger.Log( string.Format("Evaluation completed in {0}", sw.Elapsed)); } dynamoModel.OnEvaluationCompleted(this, EventArgs.Empty); }
/// <summary> /// Log visualization update timing and geometry data. /// </summary> /// <param name="rd">The aggregated render description for the model.</param> /// <param name="ellapsedTime">The ellapsed time of visualization as a string.</param> protected void LogVisualizationUpdateData(RenderDescription rd, string ellapsedTime) { var renderDict = new Dictionary <string, object>(); renderDict["points"] = rd.Points.Count; renderDict["line_segments"] = rd.Lines.Count / 2; renderDict["mesh_facets"] = rd.Meshes.Any() ? rd.Meshes.Select(x => x.TriangleIndices.Count / 3).Aggregate((a, b) => a + b) : 0; renderDict["time"] = ellapsedTime; renderDict["manager_type"] = this.GetType().ToString(); var renderData = JsonConvert.SerializeObject(renderDict); InstrumentationLogger.LogInfo("Perf-Latency-RenderGeometryGeneration", renderData); //Debug.WriteLine(renderData); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { HandleDebug(commandData); InitializeCore(commandData); try { #if ENABLE_DYNAMO_SCHEDULER extCommandData = commandData; commandData.Application.Idling += OnRevitIdleOnce; #else IdlePromise.ExecuteOnIdleAsync( delegate { // create core data models revitDynamoModel = InitializeCoreModel(commandData); dynamoViewModel = InitializeCoreViewModel(revitDynamoModel); // show the window InitializeCoreView().Show(); TryOpenWorkspaceInCommandData(commandData); SubscribeViewActivating(commandData); }); #endif // Disable the Dynamo button to prevent a re-run DynamoRevitApp.DynamoButton.Enabled = false; } catch (Exception ex) { // notify instrumentation InstrumentationLogger.LogException(ex); StabilityTracking.GetInstance().NotifyCrash(); MessageBox.Show(ex.ToString()); DynamoRevitApp.DynamoButton.Enabled = true; return(Result.Failed); } return(Result.Succeeded); }
/// <summary> /// A method to deal with unhandle exceptions. Executes right before Revit crashes. /// Dynamo is still valid at this time, but further work may cause corruption. Here, /// we run the ExitCommand, allowing the user to save all of their work. /// </summary> /// <param name="sender"></param> /// <param name="args">Info about the exception</param> private static void Dispatcher_UnhandledException( object sender, DispatcherUnhandledExceptionEventArgs args) { args.Handled = true; // only handle a single crash per Dynamo sesh, this should be reset in the initial command if (handledCrash) { return; } handledCrash = true; string exceptionMessage = args.Exception.Message; try { InstrumentationLogger.LogException(args.Exception); StabilityTracking.GetInstance().NotifyCrash(); revitDynamoModel.Logger.LogError("Dynamo Unhandled Exception"); revitDynamoModel.Logger.LogError(exceptionMessage); } catch { } try { DynamoModel.IsCrashing = true; revitDynamoModel.OnRequestsCrashPrompt( revitDynamoModel, new CrashPromptArgs(args.Exception.Message + "\n\n" + args.Exception.StackTrace)); dynamoViewModel.Exit(false); // don't allow cancellation } catch { } finally { args.Handled = true; // KILLDYNSETTINGS - this is suspect revitDynamoModel.Logger.Dispose(); DynamoRevitApp.DynamoButton.Enabled = true; } }
public CrashPrompt(CrashPromptArgs args, DynamoViewModel dynamoViewModel) { InitializeComponent(); productName = dynamoViewModel.BrandingResourceProvider.ProductName; Title = string.Format(Wpf.Properties.Resources.CrashPromptDialogTitle, productName); txtOverridingText.Text = string.Format(Wpf.Properties.Resources.CrashPromptDialogCrashMessage, productName); InstrumentationLogger.LogAnonymousEvent("CrashPrompt", "Stability"); StabilityTracking.GetInstance().NotifyCrash(); if (args.HasDetails()) { this.details = args.Details; this.CrashDetailsContent.Text = args.Details; this.btnDetails.Visibility = Visibility.Visible; InstrumentationLogger.LogPiiInfo("CrashPrompt", args.Details); } else { InstrumentationLogger.LogPiiInfo("CrashPrompt", args.Details); } if (args.IsFilePath()) { folderPath = Path.GetDirectoryName(args.FilePath); btnOpenFolder.Visibility = Visibility.Visible; } if (args.IsDefaultTextOverridden()) { string overridingText = args.OverridingText; if (args.IsFilePath()) { overridingText = overridingText.Replace("[FILEPATH]", args.FilePath); } ConvertFormattedTextIntoTextblock(this.txtOverridingText, overridingText); } }
/// <summary> /// Performs a search and updates the observable SearchResults property. /// </summary> /// <param name="query"> The search query </param> public void SearchAndUpdateResults(string query) { if (Visible != true) { return; } InstrumentationLogger.LogPiiInfo("Search", query); // if the search query is empty, go back to the default treeview if (string.IsNullOrEmpty(query)) { return; } var foundNodes = Search(query); RaisePropertyChanged("SearchRootCategories"); SearchResults = new ObservableCollection <NodeSearchElementViewModel>(foundNodes); RaisePropertyChanged("SearchResults"); }
public void RunApplication(Application app) { try { DynamoModel.RequestMigrationStatusDialog += MigrationStatusDialogRequested; var model = Dynamo.Applications.StartupUtils.MakeModel(false); viewModel = DynamoViewModel.Start( new DynamoViewModel.StartConfiguration() { CommandFilePath = commandFilePath, DynamoModel = model, Watch3DViewModel = HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(new Watch3DViewModelStartupParams(model), model.Logger), ShowLogin = true }); var view = new DynamoView(viewModel); view.Loaded += (sender, args) => CloseMigrationWindow(); app.Run(view); DynamoModel.RequestMigrationStatusDialog -= MigrationStatusDialogRequested; } catch (Exception e) { try { #if DEBUG // Display the recorded command XML when the crash happens, // so that it maybe saved and re-run later if (viewModel != null) { viewModel.SaveRecordedCommand.Execute(null); } #endif DynamoModel.IsCrashing = true; InstrumentationLogger.LogException(e); StabilityTracking.GetInstance().NotifyCrash(); if (viewModel != null) { // Show the unhandled exception dialog so user can copy the // crash details and report the crash if she chooses to. viewModel.Model.OnRequestsCrashPrompt(null, new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace)); // Give user a chance to save (but does not allow cancellation) viewModel.Exit(allowCancel: false); } } catch { } Debug.WriteLine(e.Message); Debug.WriteLine(e.StackTrace); } }
public static void Main(string[] args) { DynamoViewModel viewModel = null; try { var cmdLineArgs = CommandLineArguments.FromArguments(args); var supportedLocale = new HashSet <string>(new[] { "cs-CZ", "de-DE", "en-US", "es-ES", "fr-FR", "it-IT", "ja-JP", "ko-KR", "pl-PL", "pt-BR", "ru-RU", "zh-CN", "zh-TW" }); string libgLocale; if (!string.IsNullOrEmpty(cmdLineArgs.Locale)) { // Change the application locale, if a locale information is supplied. Thread.CurrentThread.CurrentUICulture = new CultureInfo(cmdLineArgs.Locale); Thread.CurrentThread.CurrentCulture = new CultureInfo(cmdLineArgs.Locale); libgLocale = cmdLineArgs.Locale; } else { // In case no language is specified, libG's locale should be that of the OS. // There is no need to set Dynamo's locale in this case. libgLocale = CultureInfo.InstalledUICulture.ToString(); } // If locale is not supported by Dynamo, default to en-US. if (!supportedLocale.Any(s => s.Equals(libgLocale, StringComparison.InvariantCultureIgnoreCase))) { libgLocale = "en-US"; } // Change the locale that LibG depends on. StringBuilder sb = new StringBuilder("LANGUAGE="); sb.Append(libgLocale.Replace("-", "_")); _putenv(sb.ToString()); MakeStandaloneAndRun(cmdLineArgs.CommandFilePath, out viewModel); } catch (Exception e) { try { #if DEBUG // Display the recorded command XML when the crash happens, // so that it maybe saved and re-run later if (viewModel != null) { viewModel.SaveRecordedCommand.Execute(null); } #endif DynamoModel.IsCrashing = true; InstrumentationLogger.LogException(e); StabilityTracking.GetInstance().NotifyCrash(); if (viewModel != null) { // Show the unhandled exception dialog so user can copy the // crash details and report the crash if she chooses to. viewModel.Model.OnRequestsCrashPrompt(null, new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace)); // Give user a chance to save (but does not allow cancellation) viewModel.Exit(allowCancel: false); } } catch { } Debug.WriteLine(e.Message); Debug.WriteLine(e.StackTrace); } }
private void OnFilterMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { FilterPopup.IsOpen = true; InstrumentationLogger.LogAnonymousEvent("FilterButtonClicked", "Search UX"); }
/// <summary> /// Class constructor /// </summary> public DynamoController(string context, IUpdateManager updateManager, IWatchHandler watchHandler, IPreferences preferences) { DebugSettings = new DebugSettings(); IsCrashing = false; dynSettings.Controller = this; Context = context; //Start heartbeat reporting InstrumentationLogger.Start(); PreferenceSettings = preferences; ((PreferenceSettings)PreferenceSettings).PropertyChanged += PreferenceSettings_PropertyChanged; SIUnit.LengthUnit = PreferenceSettings.LengthUnit; SIUnit.AreaUnit = PreferenceSettings.AreaUnit; SIUnit.VolumeUnit = PreferenceSettings.VolumeUnit; SIUnit.NumberFormat = PreferenceSettings.NumberFormat; UpdateManager = updateManager; UpdateManager.UpdateDownloaded += updateManager_UpdateDownloaded; UpdateManager.ShutdownRequested += updateManager_ShutdownRequested; UpdateManager.CheckForProductUpdate(new UpdateRequest(new Uri(Configurations.UpdateDownloadLocation), dynSettings.DynamoLogger, UpdateManager.UpdateDataAvailable)); WatchHandler = watchHandler; //create the model DynamoModel = new DynamoModel(); DynamoModel.AddHomeWorkspace(); DynamoModel.CurrentWorkspace = DynamoModel.HomeSpace; DynamoModel.CurrentWorkspace.X = 0; DynamoModel.CurrentWorkspace.Y = 0; // custom node loader string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginsPath = Path.Combine(directory, "definitions"); CustomNodeManager = new CustomNodeManager(pluginsPath); SearchViewModel = new SearchViewModel(); dynSettings.PackageLoader = new PackageLoader(); dynSettings.PackageLoader.DoCachedPackageUninstalls(); dynSettings.PackageLoader.LoadPackages(); DisposeLogic.IsShuttingDown = false; EngineController = new EngineController(this); //This is necessary to avoid a race condition by causing a thread join //inside the vm exec //TODO(Luke): Push this into a resync call with the engine controller ResetEngine(); dynSettings.DynamoLogger.Log(String.Format( "Dynamo -- Build {0}", Assembly.GetExecutingAssembly().GetName().Version)); DynamoLoader.ClearCachedAssemblies(); DynamoLoader.LoadNodeModels(); MigrationManager.Instance.MigrationTargets.Add(typeof(WorkspaceMigrations)); Runner = new DynamoRunner(); }
public static void Main(string[] args) { DynamoViewModel viewModel = null; try { // Running Dynamo sandbox with a command file: // DynamoSandbox.exe /c "C:\file path\file.xml" // string commandFilePath = string.Empty; for (int i = 0; i < args.Length; ++i) { // Looking for '/c' string arg = args[i]; if (arg.Length != 2 || (arg[0] != '/')) { continue; } if (arg[1] == 'c' || (arg[1] == 'C')) { // If there's at least one more argument... if (i < args.Length - 1) { commandFilePath = args[i + 1]; } } } MakeStandaloneAndRun(commandFilePath, ref viewModel); } catch (Exception e) { try { #if DEBUG // Display the recorded command XML when the crash happens, // so that it maybe saved and re-run later if (viewModel != null) { viewModel.SaveRecordedCommand.Execute(null); } #endif DynamoModel.IsCrashing = true; InstrumentationLogger.LogException(e); StabilityTracking.GetInstance().NotifyCrash(); if (viewModel != null) { // Show the unhandled exception dialog so user can copy the // crash details and report the crash if she chooses to. viewModel.Model.OnRequestsCrashPrompt(null, new CrashPromptArgs(e.Message + "\n\n" + e.StackTrace)); // Give user a chance to save (but does not allow cancellation) viewModel.Exit(allowCancel: false); } } catch { } Debug.WriteLine(e.Message); Debug.WriteLine(e.StackTrace); } }