public void FetchComments()
{
GetCommentsParams commentParameters = new GetCommentsParams ();
commentParameters.ids = BugIds.ToArray ();
for (int i = 0; i < Bugs.Count; i++) {
Bugs[i].ResetComments ();
}
Console.WriteLine ("Fetching comments");
// Set the source if it hasn't been set alreayd
Generator.SetSource (SplatterCore.Instance.Sources[this.SourceID]);
Tracer trace = new Tracer();
//trace.Attach(Generator.bugProxy);
XmlRpcStruct comResponse = Generator.bugProxy.GetComments (commentParameters);
Console.WriteLine ("Done!");
// Okay, this is a ridiculous hack; I have no clue what it does. I wrote it last week;
XmlRpcStruct bug_comments = (XmlRpcStruct)comResponse["bugs"];
foreach (XmlRpcStruct bug1_comments in bug_comments.Values) {
object[] comment_list = (object[])bug1_comments["comments"];
List<Comment> targetCommentList = new List<Comment>();
foreach (XmlRpcStruct comment in comment_list) {
//Console.WriteLine(comment["text"].ToString());
Comment obj1 = (Comment)AttemptStructDeserialization (comment, typeof(Comment));
Comment target = (Comment)obj1;
// find the bug that's in the bug list of queries
if (BugIds.Contains (target.bug_id)) {
// I have absolutely no clue what I'm doing here
if(! Bugs[BugIds.IndexOf (target.bug_id)].Comments.Exists(delegate(Comment c1){
return target.id == c1.id;
}))
{
int targetId = BugIds.IndexOf (target.bug_id);
Bugs[targetId].Comments.Add(target);
Bugs[targetId].MarkUnread();
//Console.WriteLine ("Found a new comment" + target.ToString());
}
else
{
int targetId = BugIds.IndexOf (target.bug_id);
}
}
}
}
}