Ejemplo n.º 1
0
        public Task Update(string keyOrId, JiraIssueFields fields)
        {
            var source = new TaskCompletionSource <bool>();

            try
            {
                lock (lockObject)
                {
                    var stored = issues.SingleOrDefault(x =>
                                                        string.Equals(x.Key, keyOrId, StringComparison.InvariantCultureIgnoreCase) ||
                                                        string.Equals(x.Id, keyOrId, StringComparison.InvariantCultureIgnoreCase));
                    if (stored == null)
                    {
                        throw new JiraException($"issue '{keyOrId}' is not found");
                    }
                    fields.CopyTo(stored.IssueFields);
                    source.SetResult(true);
                }
            }
            catch (Exception e)
            {
                source.SetException(e);
            }

            return(source.Task);
        }
Ejemplo n.º 2
0
        public static JiraIssueDto FromBytes(byte[] bytes)
        {
            using var ms = new MemoryStream(bytes);
            var model = (JiraIssueDtoBinary)formatter.Deserialize(ms);

            return(new JiraIssueDto
            {
                Key = model.key,
                Id = model.id,
                Self = model.self,
                IssueFields = JiraIssueFields.FromJson(model.json)
            });
        }
        public JiraIssueFields GetChangedFields()
        {
            var result = changedFields;

            if (scopeFields.Count > 0)
            {
                result = new JiraIssueFields();
                changedFields.CopyTo(result, scopeFields);
            }

            result.CopyTo(issueFields);
            changedFields = new JiraIssueFields();
            return(result);
        }
Ejemplo n.º 4
0
 private static JiraIssueFields Restrict(JiraIssueFields issueFields, IEnumerable <string> requestFields)
 {
     return(requestFields == null
         ? issueFields
         : requestFields.Aggregate(new JiraIssueFields(), (res, cur) =>
     {
         var property = issueFields.GetProperty(cur, typeof(object));
         if (property != null)
         {
             res.SetProperty(cur, property);
         }
         return res;
     }));
 }
Ejemplo n.º 5
0
 public Task Update(string keyOrId, JiraIssueFields fields)
 {
     return(InvokeByLock(() =>
     {
         var key = GetIssueStorageKey(keyOrId);
         if (!issueStorage.TryRead(key, out var issueBytes))
         {
             throw new JiraException($"issue [{keyOrId}] is not found");
         }
         var replacedIssue = JiraIssueDto.FromBytes(issueBytes);
         fields.CopyTo(replacedIssue.IssueFields);
         issueStorage.Write(key, replacedIssue.ToBytes());
         return true;
     }));
 }
 public JiraIssueFields GetFields()
 {
     changedFields.CopyTo(issueFields);
     changedFields = new JiraIssueFields();
     return(issueFields);
 }
 public JiraIssueFieldsController(JiraIssueFields issueFields)
 {
     this.issueFields = issueFields;
 }