Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Action text on custom activity in Activity logging

Vote:
 

I have made a new Activity type to use for logging changes to Users. So that changes will show up in the Change Log in episerver

This is my new activity:

public class UserActivity : Activity
{
  public UserActivity(string activityType, int action) : base(activityType, action)
  {
  }

  public UserActivity(string activityType, int action, IDictionary<string, string> extendedData) : base(activityType, action, extendedData)
  {
  }
}

public enum UserActivityType
{
  Create,
  Update,
  Delete
}

and here is the code i use when adding an activity

var activityRepository = ServiceLocator.Current.GetInstance<IActivityRepository>();

var data = new Dictionary<string, string>();
data.Add("Username", username);
var activity = new UserActivity("User", (int)UserActivityType.Delete, data);

now an entry will appear in the Change Log, with Category = "User" but the Action is 2.

How do i change the shown action to a string i define instead of the int value?

#202726
Mar 29, 2019 12:32
Vote:
 

I looked in the DLLs and found out :)

public void Initialize(InitializationEngine context)
{
  var activityTypeRegistry = ServiceLocator.Current.GetInstance<IActivityTypeRegistry>();

  var actionTypeList = new List<ActionType>();
  actionTypeList.Add(new ActionType(0, "User created"));
  actionTypeList.Add(new ActionType(1, "User updated"));
  actionTypeList.Add(new ActionType(2, "User deleted"));

  var activityType = new ActivityType("User", actionTypeList);
  activityTypeRegistry.Register(activityType);
}

#202728
Mar 29, 2019 12:59
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.