Exemplo n.º 1
0
        private void GetData(bool TwitterData)
        {
            try {
                friendsorfollowers = Master.Friendorfollower.ToString();
                //try to serialize
                if (TwitterData)
                {
                    if (lblError.Visible & ListTimeLine.Count == 0)
                    {
                        ListTimeLine = Serializer.ReadTimelineBindingListXML(friendsorfollowers);
                    }
                    else if (!lblError.Visible)
                    {
                        Serializer.WriteTimelineXML(ListTimeLine.ToList(), friendsorfollowers);
                    }
                }
                else
                {
                    ListTimeLine = Serializer.ReadTimelineBindingListXML(friendsorfollowers);
                }
            } catch (Exception ex) {
                string exerror = ex.Message;
            }

            int totalTimeLine = 0;

            if (ListTimeLine != null)
            {
                totalTimeLine = ListTimeLine.Count;
            }

            string screen_name = string.Empty;

            if (twdata != null && twdata.ConsumerCredentials != null)
            {
                screen_name = twdata.ConsumerCredentials.screen_name;
            }
            else
            {
                Twitter.MyConsumerCredentials mycreds = new Twitter.MyConsumerCredentials();
                screen_name = mycreds.screen_name;
            }
            lblTotal.Text = string.Concat(screen_name, Constants.SPACE, Resources.Resource.Has, Constants.SPACE, ListTimeLine.Count, Constants.SPACE, friendsorfollowers);
            BindData();
        }
        private void GetData(bool TwitterData)
        {
            try {
                friendsorfollowers = Master.Friendorfollower.ToString();
                //try to serialize
                if (TwitterData)
                {
                    if (lblError.Visible & listUsers.Count == 0)
                    {
                        listUsers = Serializer.ReadListXML(friendsorfollowers);
                    }
                    else if (!lblError.Visible)
                    {
                        Serializer.WriteFollowersXML(listUsers, friendsorfollowers);
                    }
                }
                else
                {
                    listUsers = Serializer.ReadListXML(friendsorfollowers);
                }
            } catch (Exception ex) {
                string exerror = ex.Message;
            }

            int totalFollowers = 0;

            if (listUsers != null)
            {
                totalFollowers = listUsers.Count;
            }

            string screen_name = string.Empty;

            if (twdata != null && twdata.ConsumerCredentials != null)
            {
                screen_name = twdata.ConsumerCredentials.screen_name;
            }
            else
            {
                Twitter.MyConsumerCredentials mycreds = new Twitter.MyConsumerCredentials();
                screen_name = mycreds.screen_name;
            }
            lblTotalFollowers.Text = string.Concat(screen_name, Constants.SPACE, Resources.Resource.Has, Constants.SPACE, listUsers.Count, Constants.SPACE, friendsorfollowers);

            Random objRnd = new Random();
            List <Twitter.User> randomFollowers = listUsers.OrderBy(item => objRnd.Next()).ToList <Twitter.User>();

            HtmlGenericControl ul = (HtmlGenericControl)ulTwitterFollowers;

            foreach (Twitter.User tw in randomFollowers)
            {
                HtmlGenericControl li = new HtmlGenericControl(Constants.LI);

                HtmlGenericControl ianchor = new HtmlGenericControl(Constants.A);
                ianchor.Attributes.Add(Constants.TARGET, Constants.BLANK);
                ianchor.Attributes.Add(Constants.TITLE, tw.ScreenName);
                ianchor.Attributes.Add(Constants.HREF, string.Concat(Constants.HTTPTWITTER, tw.ScreenName));

                HtmlImage img = new HtmlImage();
                img.Src = tw.ProfileImage;
                ianchor.Controls.Add(img);

                HtmlGenericControl span = new HtmlGenericControl(Constants.SPAN);
                span.InnerHtml = tw.ScreenName;
                ianchor.Controls.Add(span);

                li.Controls.Add(ianchor);
                ul.Controls.Add(li);
            }
        }