private void OnSendBlogsListCompleted(object sender, XMLRPCCompletedEventArgs <BooleanResponseObject> args)
        {
            PushNotificationsSendBlogsList rpc = sender as PushNotificationsSendBlogsList;

            rpc.Completed -= OnSendBlogsListCompleted;
            if (args.Cancelled)
            {
            }
            else if (null == args.Error)
            {
                return;
            }
            else
            {
                Exception e = args.Error;
                Utils.Tools.LogException(String.Format("PushNotificationsSendBlogsList  error occurred. {0}", e.Message), e);
            }
        }
        public void sendBlogsList()
        {
            string device_uuid = this.getDeviceUUID();

            if (device_uuid == null)
            {
                return;                      //emulators
            }
            Dictionary <string, string>       credentials = new Dictionary <string, string>();
            Dictionary <string, Queue <int> > blogIDsDict = new Dictionary <string, Queue <int> >();

            //loop over blogs and retrieves the list of .com accounts added to the app
            List <Blog> blogs = DataService.Current.Blogs.ToList();

            foreach (Blog currentBlog in blogs)
            {
                if (currentBlog.isWPcom() || currentBlog.hasJetpack())
                {
                    if (currentBlog.isWPcom())
                    {
                        if (!credentials.ContainsKey(currentBlog.Username))
                        {
                            credentials.Add(currentBlog.Username, currentBlog.Password);
                        }

                        Queue <int> currentAccountBlogIDs;
                        blogIDsDict.TryGetValue(currentBlog.Username, out currentAccountBlogIDs);
                        if (currentAccountBlogIDs == null)
                        {
                            currentAccountBlogIDs = new Queue <int>();
                            currentAccountBlogIDs.Enqueue(currentBlog.BlogId);
                            blogIDsDict.Add(currentBlog.Username, currentAccountBlogIDs);
                        }
                        else
                        {
                            currentAccountBlogIDs.Enqueue(currentBlog.BlogId);
                        }
                    }
                    else
                    {
                        if (currentBlog.DotcomUsername != null && currentBlog.DotcomPassword != null)
                        {
                            if (!credentials.ContainsKey(currentBlog.DotcomUsername))
                            {
                                credentials.Add(currentBlog.DotcomUsername, currentBlog.DotcomPassword);
                            }

                            Queue <int> currentAccountBlogIDs;
                            blogIDsDict.TryGetValue(currentBlog.DotcomUsername, out currentAccountBlogIDs);
                            if (currentAccountBlogIDs == null)
                            {
                                currentAccountBlogIDs = new Queue <int>();
                                string currentJetpackBlogID = currentBlog.getJetpackClientID();
                                if (currentJetpackBlogID == null)
                                {
                                    continue;
                                }
                                currentAccountBlogIDs.Enqueue(Convert.ToInt32(currentJetpackBlogID));
                                blogIDsDict.Add(currentBlog.DotcomUsername, currentAccountBlogIDs);
                            }
                            else
                            {
                                currentAccountBlogIDs.Enqueue(currentBlog.BlogId);
                            }
                        }
                    }//end else
                }
            }

            string app_version = System.Reflection.Assembly.GetExecutingAssembly().FullName.Split('=')[1].Split(',')[0];

            foreach (KeyValuePair <String, String> entry in credentials)
            {
                // do something with entry.Value or entry.Key
                Queue <int> currentAccountBlogIDs;
                blogIDsDict.TryGetValue(entry.Key, out currentAccountBlogIDs);
                if (currentAccountBlogIDs == null)
                {
                    continue;
                }
                PushNotificationsSendBlogsList rpc = new PushNotificationsSendBlogsList(pushNotificationURL, entry.Key, entry.Value, device_uuid, currentAccountBlogIDs, app_version);
                // rpc.Completed += OnSendBlogsListCompleted;
                rpc.ExecuteAsync();
            }
        }
        public void sendBlogsList()
        {
            string device_uuid = this.getDeviceUUID();
            if (device_uuid == null) return; //emulators

            Dictionary<string, string> credentials = new Dictionary<string, string>();
            Dictionary<string, Queue<int>> blogIDsDict = new Dictionary<string, Queue<int>>();

            //loop over blogs and retrieves the list of .com accounts added to the app
            List<Blog> blogs = DataService.Current.Blogs.ToList();
            foreach (Blog currentBlog in blogs)
            {
                if (currentBlog.isWPcom() || currentBlog.hasJetpack())
                {
                    if (currentBlog.isWPcom())
                    {
                        if (!credentials.ContainsKey(currentBlog.Username))
                            credentials.Add(currentBlog.Username, currentBlog.Password);

                        Queue<int> currentAccountBlogIDs;
                        blogIDsDict.TryGetValue(currentBlog.Username, out currentAccountBlogIDs);
                        if( currentAccountBlogIDs == null ) {
                            currentAccountBlogIDs = new Queue<int>();
                            currentAccountBlogIDs.Enqueue(currentBlog.BlogId);
                            blogIDsDict.Add(currentBlog.Username, currentAccountBlogIDs);
                        } else {
                            currentAccountBlogIDs.Enqueue(currentBlog.BlogId);
                        }
                    }
                    else
                    {
                        if (currentBlog.DotcomUsername != null && currentBlog.DotcomPassword != null)
                        {
                            if (!credentials.ContainsKey(currentBlog.DotcomUsername))
                                credentials.Add(currentBlog.DotcomUsername, currentBlog.DotcomPassword);

                            Queue<int> currentAccountBlogIDs;
                            blogIDsDict.TryGetValue(currentBlog.DotcomUsername, out currentAccountBlogIDs);
                            if (currentAccountBlogIDs == null)
                            {
                                currentAccountBlogIDs = new Queue<int>();
                                string currentJetpackBlogID = currentBlog.getJetpackClientID();
                                if (currentJetpackBlogID == null)
                                    continue;
                                currentAccountBlogIDs.Enqueue(Convert.ToInt32(currentJetpackBlogID));
                                blogIDsDict.Add(currentBlog.DotcomUsername, currentAccountBlogIDs);
                            }
                            else
                            {
                                currentAccountBlogIDs.Enqueue(currentBlog.BlogId);
                            }
                        }
                    }//end else
                }
            }

            string app_version = System.Reflection.Assembly.GetExecutingAssembly().FullName.Split('=')[1].Split(',')[0];
            foreach (KeyValuePair<String, String> entry in credentials)
            {
                // do something with entry.Value or entry.Key
                Queue<int> currentAccountBlogIDs;
                blogIDsDict.TryGetValue(entry.Key, out currentAccountBlogIDs);
                if (currentAccountBlogIDs == null)
                    continue;
                PushNotificationsSendBlogsList rpc = new PushNotificationsSendBlogsList(pushNotificationURL, entry.Key, entry.Value, device_uuid, currentAccountBlogIDs, app_version);
               // rpc.Completed += OnSendBlogsListCompleted;
                rpc.ExecuteAsync();
            }
        }