/// <summary>
        /// Logs a message to the workflow run.
        /// </summary>
        /// <param name="context">The workflow run context.</param>
        /// <param name="message">The message to log.</param>
        private void LogToRun(IRunState context, string message)
        {
            var activityName = string.Empty;

            var wf = context != null?context.GetSafeWorkflowDescription() : "";

            EventLog.Application.WriteTrace(wf + message);

            if (context == null || context.WorkflowRun == null)
            {
                return;
            }

            if (context.CurrentActivity != null)
            {
                activityName = context.CurrentActivity.Name;
            }

            var logEntry = new LogActivityLogEntry
            {
                Name        = activityName,
                Description = message
            };

            ActivityLogWriter.WriteLogEntry(logEntry.As <TenantLogEntry>());
        }
Пример #2
0
        public void WriteLogEntry_PurgerCalled()
        {
            ActivityLogWriter         activityLogWriter;
            Mock <IActivityLogPurger> activityLogPurgerMock;
            LogActivityLogEntry       logActivityLogEntry;
            Expression <Action <IActivityLogPurger> > purgeCall;

            activityLogPurgerMock = new Mock <IActivityLogPurger>(MockBehavior.Strict);
            purgeCall             = alp => alp.Purge();
            activityLogPurgerMock.Setup(purgeCall);

            logActivityLogEntry = new LogActivityLogEntry();

            activityLogWriter = new ActivityLogWriter(activityLogPurgerMock.Object);
            activityLogWriter.WriteLogEntry(logActivityLogEntry.As <TenantLogEntry>());

            activityLogPurgerMock.Verify(purgeCall, Times.Once());
        }