protected void BindSettings()
 {
     TwitterSettingsInfo twtData = new TwitterSettingsInfo();
     TwitterSqlhandler twtSql = new TwitterSqlhandler();
     int userModuuleID;
     bool status = int.TryParse(SageUserModuleID, out userModuuleID);
     twtData = twtSql.GetTwitterSettingValues(userModuuleID, GetPortalID);      
     txtScreenName.Text = twtData.ScreenName.ToString();
     txtTwittsCount.Text = twtData.Count.ToString();
 }
Ejemplo n.º 2
0
    protected void BindSettings()
    {
        TwitterSettingsInfo twtData = new TwitterSettingsInfo();
        TwitterSqlhandler   twtSql  = new TwitterSqlhandler();
        int  userModuuleID;
        bool status = int.TryParse(SageUserModuleID, out userModuuleID);

        twtData             = twtSql.GetTwitterSettingValues(userModuuleID, GetPortalID);
        txtScreenName.Text  = twtData.ScreenName.ToString();
        txtTwittsCount.Text = twtData.Count.ToString();
    }
    protected void FetchTwitts()
    {
        try
        {
            string dt = DateTime.Now.ToString();
            TwitterSettingsInfo twtData = new TwitterSettingsInfo();
            TwitterSqlhandler twtSql = new TwitterSqlhandler();
            int userModuleID;
            bool status = int.TryParse(SageUserModuleID, out userModuleID);
            twtData = twtSql.GetTwitterSettingValues(userModuleID, GetPortalID);
            string title = string.Empty;
            title = twtData.Title;
            string screenName = twtData.ScreenName.ToString();
            int count = twtData.Count;
            string twtUrl = string.Format(twitterUrl, screenName, count);
            WebRequest reqTwitts = WebRequest.Create(twtUrl);
            WebResponse twtResp = reqTwitts.GetResponse();
            if (twtResp != null)
            {
                XmlDocument twtXdoc = new XmlDocument();
                twtXdoc.Load(twtResp.GetResponseStream());
                twtResp.Close();
                reqTwitts.Abort();
                XmlElement root = twtXdoc.DocumentElement;
                XmlNodeList nodes = root.SelectNodes("/statuses/status");
                StringBuilder strTwittsViewer = new StringBuilder();
                strTwittsViewer.Append("<h2>" + title + "</h2>");
                foreach (XmlNode node in nodes)
                {
                    DateTime diffDate = DateTime.ParseExact(node["created_at"].InnerText, "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture);
                    strTwittsViewer.Append("<p>");
                    strTwittsViewer.Append(ConvertUrlsToLinks(node["text"].InnerText));
                    strTwittsViewer.Append("<span> about ");
                    TimeSpan ts = DateTime.Now - diffDate;
                    if (ts.Days > 0)
                    {
                        strTwittsViewer.Append(ts.Days);
                        strTwittsViewer.Append(" days ago");
                    }
                    else if (ts.Hours > 0)
                    {
                        strTwittsViewer.Append(ts.Hours);
                        strTwittsViewer.Append(" hours ago");
                    }
                    else if (ts.Minutes > 0)
                    {
                        strTwittsViewer.Append(ts.Minutes);
                        strTwittsViewer.Append(" minutes ago");
                    }
                    else
                    {
                        strTwittsViewer.Append(ts.Seconds);
                        strTwittsViewer.Append(" seconds ago");
                    }
                    strTwittsViewer.Append(" via </span>");
                    strTwittsViewer.Append(node["source"].InnerText);
                    strTwittsViewer.Append("</p>");
                }
                ltrlTwitts.Text = strTwittsViewer.ToString();
            }
        }
        catch
        {

        }
    }
Ejemplo n.º 4
0
 protected void FetchTwitts()
 {
     try
     {
         string dt = DateTime.Now.ToString();
         TwitterSettingsInfo twtData = new TwitterSettingsInfo();
         TwitterSqlhandler   twtSql  = new TwitterSqlhandler();
         int  userModuleID;
         bool status = int.TryParse(SageUserModuleID, out userModuleID);
         twtData = twtSql.GetTwitterSettingValues(userModuleID, GetPortalID);
         string title = string.Empty;
         title = twtData.Title;
         string      screenName = twtData.ScreenName.ToString();
         int         count      = twtData.Count;
         string      twtUrl     = string.Format(twitterUrl, screenName, count);
         WebRequest  reqTwitts  = WebRequest.Create(twtUrl);
         WebResponse twtResp    = reqTwitts.GetResponse();
         if (twtResp != null)
         {
             XmlDocument twtXdoc = new XmlDocument();
             twtXdoc.Load(twtResp.GetResponseStream());
             twtResp.Close();
             reqTwitts.Abort();
             XmlElement    root            = twtXdoc.DocumentElement;
             XmlNodeList   nodes           = root.SelectNodes("/statuses/status");
             StringBuilder strTwittsViewer = new StringBuilder();
             strTwittsViewer.Append("<h2>" + title + "</h2>");
             foreach (XmlNode node in nodes)
             {
                 DateTime diffDate = DateTime.ParseExact(node["created_at"].InnerText, "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture);
                 strTwittsViewer.Append("<p>");
                 strTwittsViewer.Append(ConvertUrlsToLinks(node["text"].InnerText));
                 strTwittsViewer.Append("<span> about ");
                 TimeSpan ts = DateTime.Now - diffDate;
                 if (ts.Days > 0)
                 {
                     strTwittsViewer.Append(ts.Days);
                     strTwittsViewer.Append(" days ago");
                 }
                 else if (ts.Hours > 0)
                 {
                     strTwittsViewer.Append(ts.Hours);
                     strTwittsViewer.Append(" hours ago");
                 }
                 else if (ts.Minutes > 0)
                 {
                     strTwittsViewer.Append(ts.Minutes);
                     strTwittsViewer.Append(" minutes ago");
                 }
                 else
                 {
                     strTwittsViewer.Append(ts.Seconds);
                     strTwittsViewer.Append(" seconds ago");
                 }
                 strTwittsViewer.Append(" via </span>");
                 strTwittsViewer.Append(node["source"].InnerText);
                 strTwittsViewer.Append("</p>");
             }
             ltrlTwitts.Text = strTwittsViewer.ToString();
         }
     }
     catch
     {
     }
 }