コード例 #1
0
        public dynamic TakeSnapshot(ContentItem contentItem)
        {
            var part = contentItem.As <ProjectPart>();

            if (part == null)
            {
                return(null);
            }

            ProjectPartRecord oldData = new ProjectPartRecord();

            oldData.Title       = part.Record.Title;
            oldData.Description = part.Record.Description;

            return(oldData);
        }
コード例 #2
0
        public IEnumerable <ActivityStreamChangeItem> GetChangesDescriptions(ActiviyStreamWriterContext context)
        {
            if (!this.CanApply(context))
            {
                return(null);
            }

            List <string> changes = new List <string>();

            ProjectPartRecord old      = context.Snapshot != null ? (context.Snapshot as ProjectPartRecord) : null;
            ProjectPartRecord newValue = (context.ContentItem.As <ProjectPart>()).Record;

            if (old == null)
            {
                string change = T("Project is created").Text;
                return(new[] { new ActivityStreamChangeItem(change) });
            }

            // 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)));
        }
コード例 #3
0
        public IEnumerable <ActivityStreamChangeItem> GetChangesDescriptions(ActiviyStreamWriterContext context)
        {
            if (!this.CanApply(context))
            {
                yield break;
            }

            var attachToProjectPart = context.ContentItem.As <AttachToProjectPart>();

            ProjectPartRecord newProject = attachToProjectPart.Record.Project;
            ProjectPartRecord oldProject = context.Snapshot != null ? context.Snapshot.Project : null;

            if (oldProject == null && newProject == null)
            {
                yield break;
            }
            else if (oldProject == null && newProject != null)
            {
                newProject = this.projectService.GetProject(newProject.Id).As <ProjectPart>().Record;
                string change = T("{0} is attached to project '{1}'", contentItemDescriptorManager.GetDescription(context.ContentItem), newProject.Title).Text;
                yield return(new ActivityStreamChangeItem(change));
            }
            else if (oldProject != null && newProject == null)
            {
                oldProject = this.projectService.GetProject(oldProject.Id).As <ProjectPart>().Record;
                string change = T("{0} is detached from the project '{1}'", contentItemDescriptorManager.GetDescription(context.ContentItem), oldProject.Title).Text;
                yield return(new ActivityStreamChangeItem(change));
            }
            else if (oldProject != null && newProject != null && oldProject.Id != newProject.Id)
            {
                var oldProjectContentItem = this.projectService.GetProject(oldProject.Id);
                var newProjectContentItem = this.projectService.GetProject(newProject.Id);

                string change = T("{0} is detached from the project '{1}'", contentItemDescriptorManager.GetDescription(context.ContentItem), oldProjectContentItem.Record.Title).Text;
                yield return(new ActivityStreamChangeItem(change, true, oldProjectContentItem.ContentItem.Id, oldProjectContentItem.ContentItem.VersionRecord.Id));

                change = T("{0} is attached to project '{1}'", contentItemDescriptorManager.GetDescription(context.ContentItem), newProjectContentItem.Record.Title).Text;
                yield return(new ActivityStreamChangeItem(change, true, newProjectContentItem.ContentItem.Id, newProjectContentItem.ContentItem.VersionRecord.Id));
            }
        }