Esempio n. 1
0
        private IEnumerable <Changes> SetData(JiraObjs.Issue jira)
        {
            this.Original = jira;

            var changes = new List <Changes>();

            if (this.Status != jira.fields.status.name)
            {
                changes.Add(new Changes("Status", this.Priority, jira.fields.priority.id));
            }

            if (this.Priority != jira.fields.priority.id)
            {
                changes.Add(new Changes("Priority", this.Priority, jira.fields.priority.id));
            }

            if (this.Summary != jira.fields.summary)
            {
                changes.Add(new Changes("Summary", this.Summary, jira.fields.summary));
            }


            // comments
            var delsc = this.Comments.Where(p => !jira.fields.comment.comments.Select(a => a.id).Contains(p.Id)).Select(p => p.Id);
            var addsc = jira.fields.comment.comments.Where(p => !this.Comments.Select(a => a.Id).Contains(p.id)).Select(a => a.id);

            var updsc = (from c in this.Comments
                         from j in jira.fields.comment.comments
                         where c.Id == j.id && c.ModiFecha != j.updated
                         select new { o = c.Id, n = j.id });

            changes.AddRange(delsc.Select(p => new Changes("Comments", p, null)));
            changes.AddRange(addsc.Select(p => new Changes("Comments", null, p)));
            changes.AddRange(updsc.Select(p => new Changes("Comments", p.o, p.n)));

            // adjuntos
            var dels = this.Adjuntos.Where(p => !jira.fields.attachment.Select(a => a.filename).Contains(p.Filename)).Select(p => p.Filename);
            var adds = jira.fields.attachment.Where(p => !this.Adjuntos.Select(a => a.Filename).Contains(p.filename)).Select(a => a.filename);

            changes.AddRange(dels.Select(p => new Changes("Adjuntos", p, null)));
            changes.AddRange(adds.Select(p => new Changes("Adjuntos", null, p)));


            // Seteo los nuevos valores
            this.Key      = jira.key;
            this.Status   = jira.fields.status.name;
            this.Priority = jira.fields.priority.id;
            this.Summary  = jira.fields.summary;
            this.Comments = jira.fields.comment.comments.Select(p => new Comment(p)).ToList();
            this.Adjuntos = jira.fields.attachment.Select(p => new Attachment(p)).ToList();

            return(changes);
        }
Esempio n. 2
0
 public Issue(JiraObjs.Issue obj)
 {
     SetData(obj);
 }