public PresentlyWebPart(String user, String password, String subdomain)
 {
     this.Username = user;
     this.Password = password;
     this.Url = subdomain;
     _twitterService = new TwitterService(this);
     this.AllowEdit = true;
 }
 public PresentlyWebPart()
 {
     _twitterService = new TwitterService(this);
     this.AllowEdit=true;
 }
        protected override void OnPreRender(EventArgs e)
        {
            if (_twitterService == null)
                _twitterService = new TwitterService(this);
            else if (property_modified)
            {
                _twitterService.updateLogins(this.Username, this.Password, this.Url);
                lit.Text = GetTweets();
                timer.Interval = refreshInterval * 1000;

                property_modified = false;
            }
            base.OnPreRender(e);
        }
        protected override void CreateChildControls()
        {
            if (timer == null)
                timer = new Timer();
            timer.ID = this.ID + "timer";
            timer.Interval = refreshInterval * 1000;
            timer.Tick += new EventHandler<EventArgs>(this.TimerHandler);
            //this.Controls.Add(timer);

            if (update == null)
                update = new Button();
            update.Text = "Update";
            update.ID = "big_box_submit";
            update.CssClass = "presently_update_submit";
            update.Click += new EventHandler(this.submit_Click);
            if (refreshBox == null)
                refreshBox = new UpdatePanel();
            refreshBox.ContentTemplateContainer.Controls.Add(timer);

            //EnsurePostBack();

            if (_twitterService == null)
                _twitterService = new TwitterService(this);
            else {
                _twitterService.updateLogins(this.Username, this.Password, this.Url);
                property_modified = false;
            }
            //HtmlGenericControl stylesheet = new HtmlGenericControl("style");
            //stylesheet.InnerHtml = Constants.Styles;
            //this.Controls.Add(stylesheet);

            if (lit == null)
            {
                lit = new Literal();
                lit.Text = "";
            }
            if (!_twitterService.isConfigured())
                lit.Text = "<br/>Please provide presently URL and User/Password in the settings.<br/>" + lit.Text;
            /*else if (!Page.IsPostBack)
                lit.Text = GetTweets();
            */
            if (refreshBox.Triggers != null)
            {
                refreshBox.Triggers.Clear();
                AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
                trigger.ControlID = timer.ID;
                trigger.EventName = "Tick";
                refreshBox.Triggers.Add(trigger);
                trigger = new AsyncPostBackTrigger();
                trigger.ControlID = update.ID;
                trigger.EventName = "Click";
                refreshBox.Triggers.Add(trigger);
            }
        }
 public void TestSendTweets()
 {
     ServicePointManager.ServerCertificateValidationCallback +=
         delegate(
         object sender,
         X509Certificate certificate,
         X509Chain chain,
         SslPolicyErrors sslPolicyErrors)
         {
             return true;
         };
     com.intridea.presently.PresentlyWebPart part = new com.intridea.presently.PresentlyWebPart("pyu", "test1234", "test.cs.intridea.com");
     TwitterService ts = new TwitterService(part);
     ts.LastId = "935793";
     TwitterLib.TweetCollection tweets = ts.GetTweets();
     ts.SendTweet("d @ping test");
     TwitterLib.TweetCollection tweets2 = ts.GetTweets();
     Assert.IsTrue(tweets2.Count > 0);
 }
        protected override void CreateChildControls()
        {
            if (timer == null)
            {
                timer = new Timer();
            }
            timer.ID       = this.ID + "timer";
            timer.Interval = refreshInterval * 1000;
            timer.Tick    += new EventHandler <EventArgs>(this.TimerHandler);
            //this.Controls.Add(timer);

            if (update == null)
            {
                update = new Button();
            }
            update.Text     = "Update";
            update.ID       = "big_box_submit";
            update.CssClass = "presently_update_submit";
            update.Click   += new EventHandler(this.submit_Click);
            if (refreshBox == null)
            {
                refreshBox = new UpdatePanel();
            }
            refreshBox.ContentTemplateContainer.Controls.Add(timer);

            //EnsurePostBack();

            if (_twitterService == null)
            {
                _twitterService = new TwitterService(this);
            }
            else
            {
                _twitterService.updateLogins(this.Username, this.Password, this.Url);
                property_modified = false;
            }
            //HtmlGenericControl stylesheet = new HtmlGenericControl("style");
            //stylesheet.InnerHtml = Constants.Styles;
            //this.Controls.Add(stylesheet);

            if (lit == null)
            {
                lit      = new Literal();
                lit.Text = "";
            }
            if (!_twitterService.isConfigured())
            {
                lit.Text = "<br/>Please provide presently URL and User/Password in the settings.<br/>" + lit.Text;
            }

            /*else if (!Page.IsPostBack)
             *  lit.Text = GetTweets();
             */
            if (refreshBox.Triggers != null)
            {
                refreshBox.Triggers.Clear();
                AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
                trigger.ControlID = timer.ID;
                trigger.EventName = "Tick";
                refreshBox.Triggers.Add(trigger);
                trigger           = new AsyncPostBackTrigger();
                trigger.ControlID = update.ID;
                trigger.EventName = "Click";
                refreshBox.Triggers.Add(trigger);
            }
        }
 public PresentlyWebPart()
 {
     _twitterService = new TwitterService(this);
     this.AllowEdit  = true;
 }