Exemple #1
0
        private void updateWorkItemState(Ticket source, WorkItem workItem)
        {
            var statesTosave = new List <string>();

            if (source.TicketState != Ticket.State.Done)
            {
                if (source.TicketState == Ticket.State.InProgress)
                {
                    statesTosave.Add(tfsStateMap.GetSelectedInProgressStateFor(workItem.Type.Name));
                }
                else if (source.TicketState == Ticket.State.Todo || source.TicketState == Ticket.State.Unknown)
                {
                    statesTosave.Add(tfsStateMap.GetSelectedApprovedStateFor(workItem.Type.Name));
                }

                if (importSummary.OpenTickets.ContainsKey(source.TicketType) == false)
                {
                    importSummary.OpenTickets.Add(source.TicketType, 1);
                }
                else
                {
                    importSummary.OpenTickets[source.TicketType]++;
                }
            }
            else
            {
                statesTosave = tfsStateMap.GetStateTransistionsToDoneFor(workItem.Type.Name);
            }

            foreach (var stateToSave in statesTosave)
            {
                workItem.State = stateToSave;

                var validationErrors = workItem.Validate();
                if (validationErrors.Count == 0)
                {
                    workItem.Save(SaveFlags.MergeLinks);
                }
                else
                {
                    var waring = string.Format("Failed to set state for Work-item {0} - \"{1}\"", workItem.Id,
                                               workItem.Title);
                    importSummary.Warnings.Add(waring);
                    var failure = new TfsFailedValidation(source, validationErrors);
                    importSummary.Warnings.Add(" " + failure.Summary);
                    foreach (var issue in failure.Issues)
                    {
                        var fieldInTrouble = string.Format("  * {0} - {1} (Value: {2})", issue.Name, issue.Problem,
                                                           issue.Value);
                        importSummary.Warnings.Add(fieldInTrouble);
                        foreach (var info in issue.Info)
                        {
                            importSummary.Warnings.Add("  * " + info);
                        }
                    }
                    break;
                }
            }
        }
Exemple #2
0
        public bool CheckTicket(Ticket toAdd, out IFailedTicket failure)
        {
            failure = null;
            var okToAdd = true;

            if (previouslyImported.ContainsKey(toAdd.ID) == false)
            {
                var validationErrors = toWorkItem(toAdd).Validate();
                okToAdd = (validationErrors.Count == 0);
                if (okToAdd == false)
                {
                    failure = new TfsFailedValidation(toAdd, validationErrors);
                }
            }
            return(okToAdd);
        }
Exemple #3
0
        private void updateWorkItemState(Ticket source, WorkItem workItem)
        {
            var statesTosave = new List<string>();

            if (source.TicketState != Ticket.State.Done)
            {
                if (source.TicketState == Ticket.State.InProgress)
                {
                    statesTosave.Add(tfsStateMap.GetSelectedInProgressStateFor(workItem.Type.Name));
                }
                else if (source.TicketState == Ticket.State.Todo || source.TicketState == Ticket.State.Unknown)
                {
                    statesTosave.Add(tfsStateMap.GetSelectedApprovedStateFor(workItem.Type.Name));
                }

                if (importSummary.OpenTickets.ContainsKey(source.TicketType) == false)
                {
                    importSummary.OpenTickets.Add(source.TicketType, 1);
                }
                else
                {
                    importSummary.OpenTickets[source.TicketType]++;
                }
            }
            else
            {
                statesTosave = tfsStateMap.GetStateTransistionsToDoneFor(workItem.Type.Name);
            }

            foreach (var stateToSave in statesTosave)
            {
                workItem.State = stateToSave;

                var validationErrors = workItem.Validate();
                if (validationErrors.Count == 0)
                {
                    workItem.Save(SaveFlags.MergeLinks);
                }
                else
                {
                    var waring = string.Format("Failed to set state for Work-item {0} - \"{1}\"", workItem.Id,
                        workItem.Title);
                    importSummary.Warnings.Add(waring);
                    var failure = new TfsFailedValidation(source, validationErrors);
                    importSummary.Warnings.Add(" " + failure.Summary);
                    foreach (var issue in failure.Issues)
                    {
                        var fieldInTrouble = string.Format("  * {0} - {1} (Value: {2})", issue.Name, issue.Problem,
                            issue.Value);
                        importSummary.Warnings.Add(fieldInTrouble);
                        foreach (var info in issue.Info)
                        {
                            importSummary.Warnings.Add("  * " + info);
                        }
                    }
                    break;
                }
            }
        }
Exemple #4
0
 public bool CheckTicket(Ticket toAdd, out IFailedTicket failure)
 {
     failure = null;
     var okToAdd = true;
     if (previouslyImported.ContainsKey(toAdd.ID) == false)
     {
         var validationErrors = toWorkItem(toAdd).Validate();
         okToAdd = (validationErrors.Count == 0);
         if (okToAdd == false)
         {
             failure = new TfsFailedValidation(toAdd, validationErrors);
         }
     }
     return okToAdd;
 }