public ReturnValue SendImage(string url, int width, int hight, int agentID, string title, string toParty, string toTag, string toUser)
        {
            ReturnValue val = new ReturnValue
            {
                Success = false
            };

            try
            {
                string path = "C:/Images/";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string str2 = title + ".html";
                if (!File.Exists(path + str2))
                {
                    File.Create(path + str2);
                }
                Bitmap bitmap = WebSiteBrowser.GetWebSiteThumbnail(url, width, hight);
                string str3   = title + ".Png";
                bitmap.Save(path + str3, ImageFormat.Png);
                val = this.enterprise.UploadMedia("image", path + str3);
                if (!val.Success)
                {
                    return(val);
                }
                return(this.SendImage(agentID, val.Result.ToString(), toParty, toTag, toUser));
            }
            catch (Exception exception)
            {
                val.Message = exception.Message + exception.StackTrace;
            }
            return(val);
        }
Example #2
0
        void PoliticianPivot_LoadedPivotItem(object sender, PivotItemEventArgs e)
        {
            //HACK: remove any progress bar that inadvertently wasn't destroyed
            RemoveProgressBar();

            if (e.Item.Name == "BillsPivotItem")
            {
                try
                {
                    AddProgressBar();

                    string memberCode;
                    if (App.ViewModel.SelectedPolitician.IsSenator)
                    {
                        memberCode = "SMEMB";
                    }
                    else
                    {
                        memberCode = "HMEMB";
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append("Dbd111=d111");
                    sb.Append("&srch=/bss/d111query.html");
                    sb.Append("&TYPE1=bimp");
                    sb.AppendFormat("&{0}={1}", memberCode, App.ViewModel.SelectedPolitician.LastName);
                    sb.Append("&Sponfld=SPON");
                    string data        = sb.ToString();
                    string dataEncoded = data.Replace("/", "%2F");

                    Byte[] bytes = Encoding.UTF8.GetBytes(dataEncoded);
                    ThomasBillsBrowser.Navigate(new Uri("http://thomas.loc.gov/cgi-bin/bdquery"), bytes, "Content-Type: application/x-www-form-urlencoded");
                }
                catch
                {
                    RemoveProgressBar();
                }
            }
            else if (e.Item.Name == "VotesPivotItem")
            {
                try
                {
                    AddProgressBar();

                    RssFeed recentVoteFeed = new RssFeed();
                    recentVoteFeed.FeedCompleted += new EventHandler <FeedCompletedEventArgs>(recentVoteFeed_FeedCompleted);
                    recentVoteFeed.FeedError     += new EventHandler(recentVoteFeed_FeedError);
                    recentVoteFeed.GetFeedAsync(String.Format("http://www.govtrack.us/users/events-rss2.xpd?monitors=pv:{0}&days=30", App.ViewModel.SelectedPolitician.GovTrackId));
                }
                catch
                {
                    RemoveProgressBar();
                }
            }
            else if (e.Item.Name == "TwitterPivotItem")
            {
                try
                {
                    AddProgressBar();

                    RssFeed twitterTimelineFeed = new RssFeed();
                    twitterTimelineFeed.FeedCompleted += new EventHandler <FeedCompletedEventArgs>(twitterTimelineFeed_FeedCompleted);
                    twitterTimelineFeed.FeedError     += new EventHandler(twitterTimelineFeed_FeedError);
                    twitterTimelineFeed.GetFeedAsync(String.Format("http://twitter.com/statuses/user_timeline/{0}.rss", App.ViewModel.SelectedPolitician.TwitterId));
                }
                catch
                {
                    RemoveProgressBar();
                }
            }
            else if (e.Item.Name == "WebPivotItem")
            {
                AddProgressBar();

                try
                {
                    WebSiteBrowser.Navigate(new Uri(App.ViewModel.SelectedPolitician.WebSite));
                }
                catch
                {
                    RemoveProgressBar();
                }
            }
            else if (e.Item.Name == "ContactPivotItem")
            {
                ContactPivotItem.DataContext = App.ViewModel.SelectedPolitician;
            }
        }