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 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 imbSave_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         int    PortalID = GetPortalID;
         string url      = txtScreenName.Text;
         int    userModuleID;
         bool   status = int.TryParse(SageUserModuleID, out userModuleID);
         bool   statuses;
         int    count;
         statuses = int.TryParse(txtTwittsCount.Text, out count);
         TwitterSqlhandler twtSql = new TwitterSqlhandler();
         twtSql.SaveTwitterSettings(userModuleID.ToString(), GetPortalID.ToString(), "Tweets", url, count.ToString());
         ShowMessage(SageMessageTitle.Information.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/TwitterDeck/ModuleLocalText", "TwitterSettingSavedSuccessfully"), "", SageMessageType.Success);
     }
     catch (Exception Ex)
     {
         ProcessException(Ex);
     }
 }
 protected void imbSave_Click(object sender, ImageClickEventArgs e)
 {
     try
     {            
         int PortalID = GetPortalID;         
         string url = txtScreenName.Text;
         int userModuleID;
         bool status = int.TryParse(SageUserModuleID, out userModuleID);
         bool statuses;
         int count;
         statuses = int.TryParse(txtTwittsCount.Text, out count);
         TwitterSqlhandler twtSql = new TwitterSqlhandler();
         twtSql.SaveTwitterSettings(userModuleID.ToString(), GetPortalID.ToString(), "Tweets", url, count.ToString());
         ShowMessage(SageMessageTitle.Information.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/TwitterDeck/ModuleLocalText", "TwitterSettingSavedSuccessfully"), "", SageMessageType.Success);
     }
     catch (Exception Ex)
     {
         ProcessException(Ex);
     }
 }
    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
        {

        }
    }
Example #6
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
     {
     }
 }