In SDL Tridion 9.1, we suppose to write Anguilla (JS) Event Handling for Tracking all the Event Logs (like Component checkin, checkout, delete, save, Page publish, unpublish...etc).
We upgraded to Tridion 9.6, New UI is not supporting for Custom JS Event handling. if we use Classic view, we can able to trigger the Event logs. So, few logs are missing, if anyone used NewUI.
We changed approach to Handling events Using TOM.NET approach using This link.
if 10+ Users are Accessing the CMS, CPU went high and impacting the Performance and observed delay on functionality like publishing page, Publishing Component..etc.
Here is my Code Sample, Can you please help me How to capture the logs complete Asynchronously with out impact on performance.?
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Tridion.ContentManager;
using Tridion.ContentManager.ContentManagement;
using Tridion.ContentManager.Extensibility;
using Tridion.ContentManager.Extensibility.Events;
using Tridion.Logging;
namespace Automation.EventSystem
{
[TcmExtension("AutomationExtension")]
public class EventsHandler : TcmExtension, IDisposable
{
private readonly List<EventSubscription> eventSubscriptions = new List<EventSubscription>();
public EventsHandler()
{
if (Utility.EventConfig.EnableEventLogging)
{
this.eventSubscriptions.Add(EventSystem.Subscribe<IdentifiableObject, TcmEventArgs>(LogStart, EventPhases.Initiated));
this.eventSubscriptions.Add(EventSystem.SubscribeAsync<IdentifiableObject, TcmEventArgs>(LogEvent, EventPhases.TransactionCommitted | EventPhases.TransactionAborted | EventPhases.TransactionInDoubt | EventPhases.Initiated));
}
}
private static void LogStart(IdentifiableObject subject, TcmEventArgs tcmEventArgs, EventPhases phase)
{
try
{
if (tcmEventArgs.ContextVariables.ContainsKey("InitiatedTicks")) return;
tcmEventArgs.ContextVariables.Add("InitiatedTicks", DateTime.Now.Ticks);
}
catch (Exception e) { }
}
private void LogEvent(IdentifiableObject subject, TcmEventArgs tcmEventArgs, EventPhases phase)
{
try
{
var logtxt = string.Format(Constants.Common.EventLogText
, DateTime.UtcNow
, System.Threading.Thread.CurrentThread.ManagedThreadId
, eventname
, eventfamily
, subject.Id.ToString()
, subject.Title
, subject.GetType().Name
, subject.Session.User.Id.ToString()
, subject.Session.User.Title
, Environment.MachineName
, phase.ToString()
, Environment.NewLine);
File.AppendAllText(string.Format(Utility.EventConfig.EventLogFilePath, filename), logtxt);
}
catch (Exception e) { }
}
}
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
foreach (EventSubscription subscription in this.eventSubscriptions)
{
subscription.Unsubscribe();
}
}
}
}