public DebuggingStatusResult GetDebuggingState(String debuggerSessionId, String lastLogMessageId) { int logId = -1; if (!int.TryParse(lastLogMessageId, out logId)) { logId = -1; } if (logId != -1) { logId++; } String logMessages = mDebugSession.GetLogMessagesXml(-1, logId, -1); WriteLog(logMessages); return(new DebuggingStatusResult() { SessionId = mSessionId, IsRunning = mDebugSession.IsRunning(), ExecutionStatus = StripXmlDeclaration(mDebugSession.GetExecutionStatusXml()), Log = StripXmlDeclaration(logMessages), Error = mDebugSession.GetLastException() }); }
/// <summary> /// Execute the template transformation with the given parameters /// </summary> /// <param name="itemUri">Tridion item URI.</param> /// <param name="templateUri">Tridion template URI.</param> /// <param name="publicationTargetUri">Tridion publication target URI.</param> /// <param name="logLevel">Log level.</param> /// <returns>Package "Output" item as <see cref="T:System.String" /></returns> public override String Execute(String itemUri, String templateUri, String publicationTargetUri = null) { String sessionId = Guid.NewGuid().ToString(); DebugSession debugSession = null; try { String templateXml = mCompoundService.GetCompoundTemplateXml(templateUri); debugSession = new DebugSession(sessionId, templateUri, templateXml, itemUri, null, true, publicationTargetUri, DebuggerConfig.Instance.Templating.EnableImpersonation && !String.IsNullOrEmpty(DebuggerConfig.Instance.Templating.ImpersonationIdentity) ? DebuggerConfig.Instance.Templating.ImpersonationIdentity : WindowsIdentity.GetCurrent().Name, DebuggerConfig.Instance.Logging.IncludeTridionClasses, DebuggerConfig.Instance.Logging.Level); debugSession.SetPreviewLocations( DebuggerConfig.Instance.CMS.PreviewDirectory, PreviewServer.PreviewUrl); // Signal for any debuggers DebuggerHook(); debugSession.Start(); int lastMessageId = -1; while (debugSession.IsRunning()) { Thread.Sleep(1000); lastMessageId = debugSession.WriteLogEntries(lastMessageId); } String postPackage = debugSession.GetPostPackageName(); String outputItemDataId = debugSession.GetPackageItemDataId(postPackage, "Output"); return(debugSession.GetPackageItemString(outputItemDataId)); } catch (Exception ex) { Logger.Log(System.Diagnostics.TraceEventType.Error, "Exception while executing DebugEngine for item {0}, template {1}: {2}", itemUri, templateUri, LoggerExtensions.TraceException(ex)); } finally { if (debugSession != null) { debugSession.Stop(); } } return(String.Empty); }
public DebuggingStatusResult StartDebuggingWithItemUri(String compoundTemplateId, String compoundTemplateXml, String itemId, bool includeSystemLog, System.Diagnostics.TraceEventType logLevel) { try { mDebugSession = new DebugSession(mSessionId, compoundTemplateId, compoundTemplateXml, itemId, null, true, "tcm:0-0-0", DebuggerConfig.Instance.Templating.EnableImpersonation && !String.IsNullOrEmpty(DebuggerConfig.Instance.Templating.ImpersonationIdentity) ? DebuggerConfig.Instance.Templating.ImpersonationIdentity : WindowsIdentity.GetCurrent().Name, includeSystemLog, logLevel); // Signal for any debuggers DebuggerHook(); mDebugSession.SetPreviewLocations( DebuggerConfig.Instance.CMS.PreviewDirectory, PreviewServer.PreviewUrl); mDebugSession.Start(); } catch (Exception ex) { Logger.Log(System.Diagnostics.TraceEventType.Error, LoggerExtensions.TraceException(ex)); } String logMessages = mDebugSession.GetLogMessagesXml(-1, -1, -1); WriteLog(logMessages); return(new DebuggingStatusResult() { SessionId = mSessionId, IsRunning = mDebugSession.IsRunning(), ExecutionStatus = StripXmlDeclaration(mDebugSession.GetExecutionStatusXml()), Log = StripXmlDeclaration(logMessages), Error = mDebugSession.GetLastException() }); }
public DebuggingStatusResult StartDebuggingWithPackage(String compoundTemplateId, String compoundTemplateXml, String packageXml, bool includeSystemLog, System.Diagnostics.TraceEventType logLevel) { try { mDebugSession = new DebugSession(mSessionId, compoundTemplateId, compoundTemplateXml, null, packageXml, true, "tcm:0-0-0", DebuggerConfig.Instance.Templating.EnableImpersonation && !String.IsNullOrEmpty(DebuggerConfig.Instance.Templating.ImpersonationIdentity) ? DebuggerConfig.Instance.Templating.ImpersonationIdentity : WindowsIdentity.GetCurrent().Name, DebuggerConfig.Instance.Logging.IncludeTridionClasses, logLevel); // Signal for any debuggers DebuggerHook(); mDebugSession.SetPreviewLocations( DebuggerConfig.Instance.CMS.PreviewDirectory, PreviewServer.PreviewUrl); mDebugSession.Start(); } catch (Exception ex) { Logger.Log(System.Diagnostics.TraceEventType.Error, LoggerExtensions.TraceException(ex)); } String logMessages = mDebugSession.GetLogMessagesXml(-1, -1, -1); WriteLog(logMessages); return new DebuggingStatusResult() { SessionId = mSessionId, IsRunning = mDebugSession.IsRunning(), ExecutionStatus = StripXmlDeclaration(mDebugSession.GetExecutionStatusXml()), Log = StripXmlDeclaration(logMessages), Error = mDebugSession.GetLastException() }; }
/// <summary> /// Execute the template transformation with the given parameters /// </summary> /// <param name="itemUri">Tridion item URI.</param> /// <param name="templateUri">Tridion template URI.</param> /// <param name="publicationTargetUri">Tridion publication target URI.</param> /// <param name="logLevel">Log level.</param> /// <returns>Package "Output" item as <see cref="T:System.String" /></returns> public override String Execute(String itemUri, String templateUri, String publicationTargetUri = null) { String sessionId = Guid.NewGuid().ToString(); DebugSession debugSession = null; try { String templateXml = mCompoundService.GetCompoundTemplateXml(templateUri); debugSession = new DebugSession(sessionId, templateUri, templateXml, itemUri, null, true, publicationTargetUri, DebuggerConfig.Instance.Templating.EnableImpersonation && !String.IsNullOrEmpty(DebuggerConfig.Instance.Templating.ImpersonationIdentity) ? DebuggerConfig.Instance.Templating.ImpersonationIdentity : WindowsIdentity.GetCurrent().Name, DebuggerConfig.Instance.Logging.IncludeTridionClasses, DebuggerConfig.Instance.Logging.Level); debugSession.SetPreviewLocations( DebuggerConfig.Instance.CMS.PreviewDirectory, PreviewServer.PreviewUrl); // Signal for any debuggers DebuggerHook(); debugSession.Start(); int lastMessageId = -1; while (debugSession.IsRunning()) { Thread.Sleep(1000); lastMessageId = debugSession.WriteLogEntries(lastMessageId); } String postPackage = debugSession.GetPostPackageName(); String outputItemDataId = debugSession.GetPackageItemDataId(postPackage, "Output"); return debugSession.GetPackageItemString(outputItemDataId); } catch (Exception ex) { Logger.Log(System.Diagnostics.TraceEventType.Error, "Exception while executing DebugEngine for item {0}, template {1}: {2}", itemUri, templateUri, LoggerExtensions.TraceException(ex)); } finally { if (debugSession != null) debugSession.Stop(); } return String.Empty; }