Пример #1
0
 public static void SetLastSelected(string ListName, status selectedStatus, SpecialTimeLine specialTime)
 {
     if (ListName == "Conversation" || ListName == "Search_TimeLine" || ListName=="@User_TimeLine") { return; }
     if (!LastSelectedItemsDictionary.ContainsKey(ListName))
     {
         LastSelectedItemsDictionary.Add(ListName, "");
     }
     LastSelectedItemsDictionary[ListName] = selectedStatus.id;
     
     if (!NewestSelectedItemsDictionary.ContainsKey(ListName))
     {
         lock(NewestSelectedItemsDictionary)
         {
             NewestSelectedItemsDictionary.Add(ListName, selectedStatus);
             StoreStatusInRegistry(ListName, selectedStatus);
         }
         SetUnreadCount(ListName, selectedStatus.id, specialTime);
     }
     else
     {
         if (NewestSelectedItemsDictionary[ListName].createdAt <= selectedStatus.createdAt)
         {
             NewestSelectedItemsDictionary[ListName] = selectedStatus;
             StoreStatusInRegistry(ListName, selectedStatus);
             SetUnreadCount(ListName, selectedStatus.id, specialTime);
         }
     }
     
     StoreSelectedItem(ListName, selectedStatus.id);
 }
Пример #2
0
 public static void SetLastSelected(string ListName, status selectedStatus)
 {
     ISpecialTimeLine t = null;
     if (ListName.StartsWith("Grouped_TimeLine_"))
     {
         t = SpecialTimeLinesRepository.GetFromListName(ListName);
     }
     SetLastSelected(ListName,selectedStatus,t);
 }
Пример #3
0
        public static void SetLastSelected(string ListName, status selectedStatus, ISpecialTimeLine specialTime)
        {
            if (ListName == "Conversation" || ListName == "Search_TimeLine" || ListName == "@User_TimeLine" || ListName == "Favorites_TimeLine" ) { return; }
            if (!LastSelectedItemsDictionary.ContainsKey(ListName))
            {
                LastSelectedItemsDictionary.Add(ListName, "");
            }
            LastSelectedItemsDictionary[ListName] = selectedStatus.id;

            var newInfo = new NewestSelectedInformation
            {
                CreatedAtTicks = (Int64) selectedStatus.createdAt.Ticks,
                id = selectedStatus.id
            };


            if (!NewestSelectedItemsDictionary.ContainsKey(ListName))
            {
                lock(NewestSelectedItemsDictionary)
                {
                    NewestSelectedItemsDictionary.Add(ListName, newInfo);
                    StoreNewestInfoInRegistry(ListName, newInfo);
                }
                SetUnreadCount(ListName, selectedStatus.id, specialTime);
            }
            else
            {
                if (NewestSelectedItemsDictionary[ListName].CreatedAtTicks <= newInfo.CreatedAtTicks)
                {
                    NewestSelectedItemsDictionary[ListName] = newInfo;
                    StoreNewestInfoInRegistry(ListName, newInfo);
                    SetUnreadCount(ListName, newInfo.id, specialTime);
                }
            }
            
            StoreSelectedItem(ListName, selectedStatus.id);
        }
Пример #4
0
 public static string Serialize(status[] List)
 {
     if (List.Length == 0) { return null; }
     StringBuilder sb = new StringBuilder();
     using (System.IO.StringWriter w = new System.IO.StringWriter(sb))
     {
         statusSerializer.Serialize(w, List);
     }
     return sb.ToString();
 }
Пример #5
0
        public static status[] FromBrightKite(string response)
        {
            List<status> resultList = new List<status>();

            XmlDocument results = new XmlDocument();

            results.LoadXml(response);
            XmlNodeList entries = results.SelectNodes("//note");
            foreach (XmlNode entry in entries)
            {
                status newStat = new status();
                newStat.text = entry.SelectSingleNode("body").InnerText;
                newStat.id = entry.SelectSingleNode("id").InnerText;
                newStat.created_at = entry.SelectSingleNode("created_at").InnerText;
                newStat.location = entry.SelectSingleNode("place/display_location").InnerText;
                string userName = entry.SelectSingleNode("creator/login").InnerText;
                string avURL = entry.SelectSingleNode("creator/small_avatar_url").InnerText;
                newStat.user = new User();
                newStat.user.screen_name = userName;
                newStat.user.profile_image_url = "http://brightkite.com/" + avURL;
                resultList.Add(newStat);

            }
            return resultList.ToArray();
        }
Пример #6
0
        public static status[] FromDirectReplies(string response, Yedda.Twitter.Account Account)
        {
            List<status> resultList = new List<status>();

            XmlDocument results = new XmlDocument();

            results.LoadXml(response);
            XmlNodeList entries = results.SelectNodes("//direct_message");
            foreach (XmlNode entry in entries)
            {
                status newStat = new status();
                newStat.text = entry.SelectSingleNode("text").InnerText;
                newStat.id = entry.SelectSingleNode("id").InnerText;
                newStat.created_at = entry.SelectSingleNode("created_at").InnerText;
                string userName = entry.SelectSingleNode("sender/screen_name").InnerText;
                
                newStat.user = new User();
                newStat.user.screen_name = userName;
                newStat.user.profile_image_url = entry.SelectSingleNode("sender/profile_image_url").InnerText;
                newStat.user.location = entry.SelectSingleNode("sender/location").InnerText;
                newStat.user.description = entry.SelectSingleNode("sender/description").InnerText;

                resultList.Add(newStat);

            }
            foreach (status stat in resultList)
            {
                stat.TypeofMessage = StatusTypes.Direct;
                stat.Account = Account;
            }
            return resultList.ToArray();
        }
Пример #7
0
 public static status[] DeserializeFromAtom(string response, Yedda.Twitter.Account Account)
 {
     List<status> resultList = new List<status>();
     
     XmlDocument results = new XmlDocument();
     
     results.LoadXml(response);
     XmlNamespaceManager nm = new XmlNamespaceManager(results.NameTable);
     nm.AddNamespace("google", "http://base.google.com/ns/1.0");
     nm.AddNamespace("openSearch", "http://a9.com/-/spec/opensearch/1.1/");
     nm.AddNamespace("s", "http://www.w3.org/2005/Atom");
     XmlNodeList entries = results.SelectNodes("//s:entry", nm);
     System.Diagnostics.Debug.WriteLine(entries.Count);
     try
     {
         foreach (XmlNode entry in entries)
         {
             status newStat = new status();
             newStat.text = entry.SelectSingleNode("s:title", nm).InnerText;
             newStat.id = entry.SelectSingleNode("s:id", nm).InnerText;
             newStat.created_at = entry.SelectSingleNode("s:published", nm).InnerText;
             string userName = entry.SelectSingleNode("s:author/s:name", nm).InnerText;
             newStat.created_at = entry.SelectSingleNode("s:published", nm).InnerText;
             string userscreenName = userName.Split(new char[] { ' ' })[0];
             newStat.user = new User();
             newStat.user.screen_name = userscreenName;
             newStat.user.profile_image_url = entry.SelectSingleNode("s:link[@type=\"image/png\"]", nm).Attributes["href"].Value;
             newStat.user.needsFetching = true;
             resultList.Add(newStat);
         }
     }
     catch { }
     foreach (status stat in resultList)
     {
         stat.TypeofMessage = StatusTypes.SearchResult;
         stat.Account = Account;
     }
     return resultList.ToArray();
 }
Пример #8
0
 public static status[] Deserialize(string response, Yedda.Twitter.Account Account, StatusTypes TypeOfMessage)
 {
     Library.status[] statuses = null;
     
     
     
     if (string.IsNullOrEmpty(response))
     {
         statuses = new status[0];
     }
     else
     {
         if (Account == null || Account.ServerURL.ServerType != Yedda.Twitter.TwitterServer.brightkite)
         {
             using (System.IO.StringReader r = new System.IO.StringReader(response))
             {
                 statuses = (Library.status[])statusSerializer.Deserialize(r);
             }
         }
         else if (Account.ServerURL.ServerType == Yedda.Twitter.TwitterServer.brightkite)
         {
             statuses = FromBrightKite(response);
         }
     }
     if (Account != null)
     {
         foreach (Library.status stat in statuses)
         {
             stat.Account = Account;
             stat.TypeofMessage = TypeOfMessage;
         }
     }
     return statuses;
 }
Пример #9
0
        private static status DeserializeSingleJSONStatus(System.Collections.Hashtable jsonTable, StatusTypes TypeOfMessage)
        {
            
            var u = new User
                        {
                            id = jsonTable["from_user_id"].ToString(),
                            needsFetching = true,
                            screen_name = (string) jsonTable["from_user"],
                            profile_image_url = (string) jsonTable["profile_image_url"],
                            //Search results don't contain this info!
                            name = "",
                            description = ""
                        };

            var ret = new status
                          {
                              user = u,
                              text = (string) jsonTable["text"],
                              id = jsonTable["id"].ToString(),
                              created_at = (string) jsonTable["created_at"],
                              source = (string) jsonTable["source"],
                              TypeofMessage = TypeOfMessage,
                              //Search results don't contain this info!
                              in_reply_to_status_id = "",
                              favorited = ""
                          };
            
            return ret;
        }
Пример #10
0
        public static status[] Deserialize(string response, Twitter.Account Account, StatusTypes TypeOfMessage)
        {
            status[] statuses = null;

            try
            {
                if (string.IsNullOrEmpty(response))
                {
                    statuses = new status[0];
                }
                else
                {
                    if (Account == null || Account.ServerURL.ServerType != Twitter.TwitterServer.brightkite)
                    {
                        using (var r = new StringReader(response))
                        {
                            statuses = (status[]) statusSerializer.Deserialize(r);
                        }
                    }
                    else if (Account.ServerURL.ServerType == Twitter.TwitterServer.brightkite)
                    {
                        statuses = FromBrightKite(response);
                    }
                }
                if (Account != null)
                {
                    foreach (status stat in statuses)
                    {
                        stat.Account = Account;
                        stat.TypeofMessage = TypeOfMessage;
                    }
                }
            }
            catch{}
            return statuses;
        }
Пример #11
0
        public static List<status> GetList(TimelineManagement.TimeLineType typeToGet, int Count, string Constraints)
        {
            var cache = new List<status>();
            using (SQLiteConnection conn = GetConnection())
            {
                string FetchQuery = SQLFetchFromCache;
                FetchQuery = FetchQuery + " WHERE " + AddTypeWhereClause(typeToGet) + Constraints + SQLOrder + SQLLimit;

                using (var comm = new SQLiteCommand(FetchQuery, conn))
                {
                    comm.Parameters.Add(new SQLiteParameter("@count", Count));
                    conn.Open();
                    using (SQLiteDataReader r = comm.ExecuteReader())
                    {
                        while (r.Read())
                        {
                            var newStat = new status
                                              {
                                                  id = r.GetString(0),
                                                  text = r.GetString(1),
                                                  TypeofMessage = ((StatusTypes) r.GetInt32(14)),
                                                  createdAt = r.GetDateTime(3),
                                                  in_reply_to_status_id = r.GetString(4),
                                                  favorited = r.GetString(5),
                                                  source = r.GetString(6),
                                                  AccountSummary = r.GetString(7),
                                                  SearchTerm = r.GetString(10)
                                              };    

                            var u = new User
                                        {
                                            id = r.GetString(2),
                                            screen_name = r.GetString(10),
                                            name = r.GetString(11),
                                            description = r.GetString(12),
                                            profile_image_url = r.GetString(13)
                                        };
                            newStat.user = u;
                            cache.Add(newStat);
                        }
                    }
                    conn.Close();
                }
            }
            return cache;
        }
Пример #12
0
 private static void StoreStatusInRegistry(string ListName, status Item)
 {
     NewestSavedItemsRoot.SetValue(ListName, Item.Serialized);
 }