Ejemplo n.º 1
0
        // TODO(Ben): Documentation to come before pull request.
        protected virtual void SerializeSessionData(XmlDocument document)
        {
            if (document.DocumentElement == null)
            {
                var message = "Workspace should have been saved before this";
                throw new InvalidOperationException(message);
            }

            try
            {
                ProtoCore.Core core = null;
                if (dynSettings.Controller != null)
                {
                    var engine = dynSettings.Controller.EngineController;
                    if (engine != null && (engine.LiveRunnerCore != null))
                    {
                        core = engine.LiveRunnerCore;
                    }
                }

                if (core == null) // No execution yet as of this point.
                {
                    return;
                }

                // Selecting all nodes that are either a DSFunction,
                // a DSVarArgFunction or a CodeBlockNodeModel into a list.
                var nodeGuids = this.Nodes.Where((n) =>
                {
                    return(n is DSFunction ||
                           (n is DSVarArgFunction) ||
                           (n is CodeBlockNodeModel));
                }).Select((n) => n.GUID);

                var nodeTraceDataList = core.GetTraceDataForNodes(nodeGuids);

                if (nodeTraceDataList.Count() > 0)
                {
                    Utils.SaveTraceDataToXmlDocument(document, nodeTraceDataList);
                }
            }
            catch (Exception exception)
            {
                // We'd prefer file saving process to not crash Dynamo,
                // otherwise user will lose the last hope in retaining data.
                dynSettings.DynamoLogger.Log(exception.Message);
                dynSettings.DynamoLogger.Log(exception.StackTrace);
            }
        }
Ejemplo n.º 2
0
        // TODO(Ben): Documentation to come before pull request.
        // TODO(Steve): This probably only belongs on HomeWorkspaceModel. -- MAGN-5715
        protected virtual void SerializeSessionData(XmlDocument document, ProtoCore.Core core)
        {
            if (document.DocumentElement == null)
            {
                const string message = "Workspace should have been saved before this";
                throw new InvalidOperationException(message);
            }

            try
            {
                if (core == null) // No execution yet as of this point.
                {
                    return;
                }

                // Selecting all nodes that are either a DSFunction,
                // a DSVarArgFunction or a CodeBlockNodeModel into a list.
                var nodeGuids =
                    Nodes.Where(
                        n => n is DSFunction || n is DSVarArgFunction || n is CodeBlockNodeModel)
                    .Select(n => n.GUID);

                var nodeTraceDataList = core.GetTraceDataForNodes(nodeGuids);

                if (nodeTraceDataList.Any())
                {
                    Utils.SaveTraceDataToXmlDocument(document, nodeTraceDataList);
                }
            }
            catch (Exception exception)
            {
                // We'd prefer file saving process to not crash Dynamo,
                // otherwise user will lose the last hope in retaining data.
                Log(exception.Message);
                Log(exception.StackTrace);
            }
        }