public ActivityStreamContentDescription GetContentDescription(ActiviyStreamWriterContext context) { return(null); }
public bool CanApply(ActiviyStreamWriterContext context) { return(true); }
public IEnumerable <ActivityStreamChangeItem> GetChangesDescriptions(ActiviyStreamWriterContext context) { if (!this.CanApply(context)) { return(null); } List <string> changes = new List <string>(); Func <byte, string> getAccessType = c => { switch (c) { case ContentItemPermissionAccessTypes.Assignee: return(T("Assignee").Text); case ContentItemPermissionAccessTypes.SharedForEdit: return(T("Edit Access").Text); case ContentItemPermissionAccessTypes.SharedForView: return(T("Watcher Access").Text); } return(T("[NULL]").Text); }; List <ContentItemPermissionDetailRecord> oldPermissions = context.Snapshot != null && context.Snapshot.Items != null ? context.Snapshot.Items as List <ContentItemPermissionDetailRecord> : new List <ContentItemPermissionDetailRecord>(); ContentItemPermissionPart newValue = context.ContentItem.As <ContentItemPermissionPart>(); var newPermissions = newValue.Record.Items ?? new List <ContentItemPermissionDetailRecord>(); foreach (var oldPermission in oldPermissions) { var newPermission = newPermissions.FirstOrDefault(c => c.Id == oldPermission.Id); if (newPermission == null) { changes.Add(this.GetContentItemPermissionChangeDescription(oldPermission, "Delete '{0}' of '{1}' to the {2}", getAccessType(oldPermission.AccessType), context.ContentItem)); continue; } if (newPermission.AccessType != oldPermission.AccessType) { changes.Add(this.GetContentItemPermissionChangeDescription(oldPermission, "Change Access of '{1}' to the '{2}' to '{0}'", getAccessType(newPermission.AccessType), context.ContentItem)); continue; } } foreach (var newPermission in newPermissions) { var oldPermission = oldPermissions.FirstOrDefault(c => c.Id == newPermission.Id); if (oldPermission == null) { string message = newPermission.AccessType == ContentItemPermissionAccessTypes.Assignee ? "Assign the '{2}' to: '{1}'" : "Grant '{1}' the '{0}' to the '{2}'"; changes.Add(this.GetContentItemPermissionChangeDescription(newPermission, message, getAccessType(newPermission.AccessType), context.ContentItem)); continue; } } return(changes.Select(c => new ActivityStreamChangeItem(c))); }
public bool CanApply(ActiviyStreamWriterContext context) { return(context.ContentItem.As <ContentItemPermissionPart>() != null && (context.Snapshot != null)); }
public IEnumerable <ActivityStreamChangeItem> GetChangesDescriptions(ActiviyStreamWriterContext context) { if (!this.CanApply(context)) { return(null); } List <string> changes = new List <string>(); TicketPartRecord old = context.Snapshot != null ? (context.Snapshot as TicketPartRecord) : null; TicketPartRecord newValue = (context.ContentItem.As <TicketPart>()).Record; if (old == null) { string change = T("Ticket is created").Text; return(new[] { new ActivityStreamChangeItem(change) }); } // change status this.AddBasicDataRecordChange( changes, old.StatusRecord, newValue.StatusRecord, (id) => this.basicDataService.GetStatusRecords().FirstOrDefault(c => c.Id == id), "changed the status to: '{0}'"); // change ticketType this.AddBasicDataRecordChange( changes, old.TicketType, newValue.TicketType, (id) => this.basicDataService.GetTicketTypes().FirstOrDefault(c => c.Id == id), "changed the Ticket Type to: '{0}'"); // change service this.AddBasicDataRecordChange( changes, old.Service, newValue.Service, (id) => this.basicDataService.GetServices().FirstOrDefault(c => c.Id == id), "changed the Service to: '{0}'"); // change priority this.AddBasicDataRecordChange( changes, old.PriorityRecord, newValue.PriorityRecord, (id) => this.basicDataService.GetPriorities().FirstOrDefault(c => c.Id == id), "changed the Priority to: '{0}'"); // change DueDate if (old.DueDate != newValue.DueDate) { string newDueDateString = newValue.DueDate != null?T(newValue.DueDate.Value.ToLongDateString() + " " + newValue.DueDate.Value.ToLongTimeString()).Text : this.T("null").Text; newDueDateString = string.Format( CultureInfo.CurrentUICulture, T("changed the DueDate to: '{0}'").Text, newDueDateString); changes.Add(newDueDateString); } // change Title if (old.Title != newValue.Title) { string newTitleString = !string.IsNullOrEmpty(newValue.Title) ? newValue.Title : this.T("Empty").Text; newTitleString = string.Format( CultureInfo.CurrentUICulture, T("changed the Title to: '{0}'").Text, newTitleString); changes.Add(newTitleString); } // change Description if (old.Description != newValue.Description) { string newDescriptionString = !string.IsNullOrEmpty(newValue.Description) ? newValue.Description : this.T("Empty").Text; newDescriptionString = T("changed the Description").Text; changes.Add(newDescriptionString); } return(changes.Select(c => new ActivityStreamChangeItem(c))); }
public bool CanApply(ActiviyStreamWriterContext context) { return(context.ContentItem.As <TicketPart>() != null); }