コード例 #1
0
        private string GetTicketIdAndTitle(TicketPartRecord ticektPart)
        {
            string identityString = ticektPart.Identity != null?
                                    ticektPart.Identity.Id.ToString(CultureInfo.InvariantCulture) :
                                        string.Empty;

            string title = ticektPart.Title;

            return(string.Format("{0} - {1}", identityString, title));
        }
コード例 #2
0
        private TicketViewModel Convert(TicketPartRecord record, List <ServiceRecord> serviceRecords, List <PriorityRecord> priorities, List <BasicDataRecordViewModel> statusRecords, List <TicketTypeRecord> ticketTypes)
        {
            TicketViewModel model = new TicketViewModel
            {
                TicketId             = record.Id,
                StatusId             = record.StatusRecord != null ? (int?)record.StatusRecord.Id : null,
                PriorityId           = record.PriorityRecord != null ? (int?)record.PriorityRecord.Id : null,
                ServiceId            = record.Service != null ? (int?)record.Service.Id : null,
                TypeId               = record.TicketType != null ? (int?)record.TicketType.Id : null,
                ParentTicketId       = record.Parent != null ? (int?)record.Parent.Id : null,
                ParentTicketTitle    = record.Parent != null ? record.Parent.Title : string.Empty,
                RelatedContentItemId = record.RelatedContentItem != null ? (int?)record.RelatedContentItem.Id : null,
                Text         = record.Description,
                TicketNumber = record.Identity != null ? (int)record.Identity.Id : default(int),
                Title        = record.Title,
                DueDate      = record.DueDate,
                SourceId     = record.SourceId,
                SourceData   = record.SourceData
            };

            if (record.ContentItemRecord != null)
            {
                model.ContentItemId = record.ContentItemRecord.Id;
            }

            if (record.Parent != null && record.Parent.Identity != null)
            {
                model.ParentTicketNumber = record.Parent.Identity.Id;
            }

            // set status name
            model.StatusName = this.GetBasicDataRecordName(model.StatusId, statusRecords);

            // Priority name
            model.PriorityName = this.GetBasicDataRecordName(model.PriorityId, priorities);

            // Service Name
            model.ServiceName = this.GetBasicDataRecordName(model.ServiceId, serviceRecords);

            // Ticket Type name
            model.TypeName = this.GetBasicDataRecordName(model.TypeId, ticketTypes);

            return(model);
        }
コード例 #3
0
        public dynamic TakeSnapshot(ContentItem contentItem)
        {
            var part = contentItem.As <TicketPart>();

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

            TicketPartRecord oldData = new TicketPartRecord();

            oldData.StatusRecord   = part.Record.StatusRecord;
            oldData.TicketType     = part.Record.TicketType;
            oldData.Title          = part.Record.Title;
            oldData.Description    = part.Record.Description;
            oldData.DueDate        = part.Record.DueDate;
            oldData.PriorityRecord = part.Record.PriorityRecord;
            oldData.Service        = part.Record.Service;

            return(oldData);
        }
コード例 #4
0
        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)));
        }