コード例 #1
0
ファイル: BugService.cs プロジェクト: skyronic/splatter
        // Todo: remove
        public void DoSomething()
        {
            GetBugsParams reqParams;
            reqParams.permissive = false;
            reqParams.ids = new Int32[]{7861, 112, 6187};
            GetCommentsParams comParams = new GetCommentsParams();
            comParams.ids = reqParams.ids;
            //AttemptStructDeserialization(null, typeof(Comment));

            GetBugsResponse response = bugProxy.GetBugs(reqParams);
            XmlRpcStruct comResponse = bugProxy.GetComments(comParams);

            foreach(BugReport bug in response.bugs)
            {
                Console.WriteLine (bug.ToString());
            }

            XmlRpcStruct bug_comments = (XmlRpcStruct)comResponse["bugs"];
            foreach(XmlRpcStruct bug1_comments in bug_comments.Values)
            {
                object[] comment_list = (object[])bug1_comments["comments"];
                foreach(XmlRpcStruct comment in comment_list)
                {
                    //Console.WriteLine(comment["text"].ToString());
                    object obj1 = AttemptStructDeserialization(comment, typeof(Comment));
                    if(obj1 !=null)
                    {
                        Console.WriteLine (obj1.ToString());
                    }
                }
            }
        }
コード例 #2
0
ファイル: QueryService.cs プロジェクト: skyronic/splatter
        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);
                        }

                    }
                }
            }
        }