Esempio n. 1
0
 public Task<long> AddCommentAsync(Bug bug, string comment, bool isPrivate = false, double workTime = 0.0)
 {
     return DoServiceCallAsync (BugComment, new Dictionary<string, object> {
         {"id", bug.Id},
         {"comment", comment},
         {"is_private", isPrivate},
         {"work_time", workTime},
     }).ContinueWith (t => {
         var result = (JsonObject) t.Result["result"];
         return (long) result["id"];
     }, TaskScheduler.Default);
 }
Esempio n. 2
0
        public static Bug FromJsonObject(IDictionary <string, object> jsonObject)
        {
            jsonObject = jsonObject.WrapInMissingKeySafeDictionary();
            var bug = new Bug();

            try {
                bug.AssignedTo     = (string)jsonObject["assigned_to"];
                bug.BlocksOn       = ((JsonArray)jsonObject["blocks"]).Cast <long> ().ToArray();
                bug.Classification = (string)jsonObject["classification"];
                bug.Component      = (string)jsonObject["component"];
                bug.Creator        = (string)jsonObject["creator"];
                bug.DependsOn      = ((JsonArray)jsonObject["depends_on"]).Cast <long> ().ToArray();
                bug.DuplicateOf    = (long?)jsonObject["duplicate_of"];
                bug.Groups         = ((JsonArray)jsonObject["groups"]).Cast <string> ().ToArray();
                bug.Id             = (long)jsonObject["id"];
                bug.Keywords       = ((JsonArray)jsonObject["keywords"]).Cast <string> ().ToArray();
                bug.LastChanged    = DateTime.SpecifyKind(DateTime.Parse((string)jsonObject["last_change_time"]), DateTimeKind.Utc);
                bug.Milestone      = (string)jsonObject["target_milestone"];
                bug.Priority       = (string)jsonObject["priority"];
                bug.Product        = (string)jsonObject["product"];
                bug.Resolution     = (string)jsonObject["resolution"];
                bug.SeeAlso        = ((JsonArray)jsonObject["see_also"]).Cast <string> ().ToArray();
                bug.Severity       = (string)jsonObject["severity"];
                bug.Status         = (string)jsonObject["status"];
                bug.Subscribers    = ((JsonArray)jsonObject["cc"]).Cast <string> ().ToArray();
                bug.Summary        = (string)jsonObject["summary"];
                bug.Version        = (string)jsonObject["version"];
                bug.Attributes     = jsonObject.AsReadOnly();
            } catch (Exception e) {
                                #if DEBUG
                Console.Error.WriteLine(jsonObject.ToString());
                                #endif
                Console.WriteLine("Failed to parse bug from JSON: {0}", e.Message);
            }
            return(bug);
        }
Esempio n. 3
0
        public static Bug FromJsonObject(IDictionary<string, object> jsonObject)
        {
            jsonObject = jsonObject.WrapInMissingKeySafeDictionary ();
            var bug = new Bug ();

            try {
                bug.AssignedTo = (string) jsonObject["assigned_to"];
                bug.BlocksOn = ((JsonArray) jsonObject["blocks"]).Cast<long> ().ToArray ();
                bug.Classification = (string) jsonObject["classification"];
                bug.Component = (string) jsonObject["component"];
                bug.Creator = (string) jsonObject["creator"];
                bug.DependsOn = ((JsonArray) jsonObject["depends_on"]).Cast<long> ().ToArray ();
                bug.DuplicateOf = (long?) jsonObject["duplicate_of"];
                bug.Groups = ((JsonArray) jsonObject["groups"]).Cast<string> ().ToArray ();
                bug.Id = (long) jsonObject["id"];
                bug.Keywords = ((JsonArray) jsonObject["keywords"]).Cast<string> ().ToArray ();
                bug.LastChanged = DateTime.SpecifyKind (DateTime.Parse ((string) jsonObject["last_change_time"]), DateTimeKind.Utc);
                bug.Milestone = (string) jsonObject["target_milestone"];
                bug.Priority = (string) jsonObject["priority"];
                bug.Product = (string) jsonObject["product"];
                bug.Resolution = (string) jsonObject["resolution"];
                bug.SeeAlso = ((JsonArray) jsonObject["see_also"]).Cast<string> ().ToArray ();
                bug.Severity = (string) jsonObject["severity"];
                bug.Status = (string) jsonObject["status"];
                bug.Subscribers = ((JsonArray) jsonObject["cc"]).Cast<string> ().ToArray ();
                bug.Summary = (string) jsonObject["summary"];
                bug.Version = (string) jsonObject["version"];
                bug.Attributes = jsonObject.AsReadOnly ();
                bug.Url = (string) jsonObject["url"];
            } catch (Exception e) {
                #if DEBUG
                Console.Error.WriteLine(jsonObject.ToString());
                #endif
                Console.WriteLine("Failed to parse bug from JSON: {0}", e.Message);
            }
            return bug;
        }
Esempio n. 4
0
 public Task<bool> UpdateBugAsync(Bug bug, object fields)
 {
     return DoServiceCallAsync (BugUpdate, new Dictionary<string, object> {
         {"ids", new [] { bug.Id }}
     }.Concat (fields.ToDictionary ()).ToDictionary (t => t.Key, t => t.Value)).ContinueWith (t => {
         return true;
     }, TaskScheduler.Default);
 }