Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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);
        }