[Tween-svn] [1318] Twitter検索yatsのアドレス変更対応

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 1月 5日 (水) 21:24:57 JST


Revision: 1318
          http://sourceforge.jp/projects/tween/svn/view?view=rev&revision=1318
Author:   kiri_feather
Date:     2011-01-05 21:24:57 +0900 (Wed, 05 Jan 2011)

Log Message:
-----------
Twitter検索yatsのアドレス変更対応
userStream_StatusArrivedでエラーハンドリング(想定外のデータが来た場合の対応。デバッグ用。)
USのDeleteイベントはイベントログから除外。
USのDeleteイベントで当該発言のFav/Unfavイベントをイベントログから削除

Modified Paths:
--------------
    trunk/Tween/My Project/Resources.Designer.vb
    trunk/Tween/My Project/Resources.en.resx
    trunk/Tween/My Project/Resources.resx
    trunk/Tween/My Project/Resources.zh-CHS.resx
    trunk/Tween/Twitter.vb


-------------- next part --------------
Modified: trunk/Tween/My Project/Resources.Designer.vb
===================================================================
--- trunk/Tween/My Project/Resources.Designer.vb	2011-01-05 11:54:41 UTC (rev 1317)
+++ trunk/Tween/My Project/Resources.Designer.vb	2011-01-05 12:24:57 UTC (rev 1318)
@@ -1948,7 +1948,7 @@
         End Property
         
         '''<summary>
-        '''  http://pcod.no-ip.org/yats/search?query={0} に類似しているローカライズされた文字列を検索します。
+        '''  http://yats-data.com/yats/search?query={0} に類似しているローカライズされた文字列を検索します。
         '''</summary>
         Friend ReadOnly Property SearchItem3Url() As String
             Get

Modified: trunk/Tween/My Project/Resources.en.resx
===================================================================
--- trunk/Tween/My Project/Resources.en.resx	2011-01-05 11:54:41 UTC (rev 1317)
+++ trunk/Tween/My Project/Resources.en.resx	2011-01-05 12:24:57 UTC (rev 1318)
@@ -418,7 +418,7 @@
     <value>http://www.google.com/search?q={0}</value>
   </data>
   <data name="SearchItem3Url" xml:space="preserve">
-    <value>http://pcod.no-ip.org/yats/search?query={0}</value>
+    <value>http://yats-data.com/yats/search?query={0}</value>
   </data>
   <data name="SearchItem4Url" xml:space="preserve">
     <value>http://search.twitter.com/search?q={0}</value>

Modified: trunk/Tween/My Project/Resources.resx
===================================================================
--- trunk/Tween/My Project/Resources.resx	2011-01-05 11:54:41 UTC (rev 1317)
+++ trunk/Tween/My Project/Resources.resx	2011-01-05 12:24:57 UTC (rev 1318)
@@ -443,7 +443,7 @@
     <value>http://www.google.com/search?hl=ja&amp;q={0}</value>
   </data>
   <data name="SearchItem3Url" xml:space="preserve">
-    <value>http://pcod.no-ip.org/yats/search?query={0}</value>
+    <value>http://yats-data.com/yats/search?query={0}</value>
   </data>
   <data name="SearchItem4Url" xml:space="preserve">
     <value>http://search.twitter.com/search?q={0}</value>

Modified: trunk/Tween/My Project/Resources.zh-CHS.resx
===================================================================
--- trunk/Tween/My Project/Resources.zh-CHS.resx	2011-01-05 11:54:41 UTC (rev 1317)
+++ trunk/Tween/My Project/Resources.zh-CHS.resx	2011-01-05 12:24:57 UTC (rev 1318)
@@ -412,7 +412,7 @@
     <value>http://www.google.com.hk/search?q={0}</value>
   </data>
   <data name="SearchItem3Url" xml:space="preserve">
-    <value>http://pcod.no-ip.org/yats/search?query={0}</value>
+    <value>http://yats-data.com/yats/search?query={0}</value>
   </data>
   <data name="SearchItem4Url" xml:space="preserve">
     <value>http://search.twitter.com/search?q={0}</value>

Modified: trunk/Tween/Twitter.vb
===================================================================
--- trunk/Tween/Twitter.vb	2011-01-05 11:54:41 UTC (rev 1317)
+++ trunk/Tween/Twitter.vb	2011-01-05 12:24:57 UTC (rev 1318)
@@ -2760,56 +2760,56 @@
 
         Dim isDm As Boolean = False
 
-        Using jsonReader As XmlDictionaryReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(line), XmlDictionaryReaderQuotas.Max)
-            Dim xElm As XElement = XElement.Load(jsonReader)
-            If xElm.Element("friends") IsNot Nothing Then
-                Debug.Print("friends")
-                Exit Sub
-            ElseIf xElm.Element("delete") IsNot Nothing Then
-                Debug.Print("delete")
-                Dim post As PostClass = Nothing
-                Dim id As Int64
-                If xElm.Element("delete").Element("direct_message") IsNot Nothing AndAlso
-                    xElm.Element("delete").Element("direct_message").Element("id") IsNot Nothing Then
-                    id = CLng(xElm.Element("delete").Element("direct_message").Element("id").Value)
-                    RaiseEvent PostDeleted(id, post)
-                ElseIf xElm.Element("delete").Element("status") IsNot Nothing AndAlso
-                    xElm.Element("delete").Element("status").Element("id") IsNot Nothing Then
-                    id = CLng(xElm.Element("delete").Element("status").Element("id").Value)
-                    RaiseEvent PostDeleted(id, post)
-                Else
-                    TraceOut("delete:" + line)
+        Try
+            Using jsonReader As XmlDictionaryReader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(line), XmlDictionaryReaderQuotas.Max)
+                Dim xElm As XElement = XElement.Load(jsonReader)
+                If xElm.Element("friends") IsNot Nothing Then
+                    Debug.Print("friends")
                     Exit Sub
+                ElseIf xElm.Element("delete") IsNot Nothing Then
+                    Debug.Print("delete")
+                    Dim post As PostClass = Nothing
+                    Dim id As Int64
+                    If xElm.Element("delete").Element("direct_message") IsNot Nothing AndAlso
+                        xElm.Element("delete").Element("direct_message").Element("id") IsNot Nothing Then
+                        id = CLng(xElm.Element("delete").Element("direct_message").Element("id").Value)
+                        RaiseEvent PostDeleted(id, post)
+                    ElseIf xElm.Element("delete").Element("status") IsNot Nothing AndAlso
+                        xElm.Element("delete").Element("status").Element("id") IsNot Nothing Then
+                        id = CLng(xElm.Element("delete").Element("status").Element("id").Value)
+                        RaiseEvent PostDeleted(id, post)
+                    Else
+                        TraceOut("delete:" + line)
+                        Exit Sub
+                    End If
+                    CreateDeleteEvent(DateTime.Now, id, post)
+                    Exit Sub
+                ElseIf xElm.Element("limit") IsNot Nothing Then
+                    Debug.Print(line)
+                    Exit Sub
+                ElseIf xElm.Element("event") IsNot Nothing Then
+                    Debug.Print("event: " + xElm.Element("event").Value)
+                    CreateEventFromJson(line)
+                    Exit Sub
+                ElseIf xElm.Element("direct_message") IsNot Nothing Then
+                    Debug.Print("direct_message")
+                    isDm = True
+                ElseIf xElm.Element("scrub_geo") IsNot Nothing Then
+                    Try
+                        Debug.Print("scrub_geo: user_id=" + xElm.Element("user_id").Value.ToString + " up_to_status_id=" + xElm.Element("up_to_status_id").Value.ToString)
+                    Catch ex As Exception
+                        TraceOut("scrub_geo:" + line)
+                    End Try
+                    Exit Sub
                 End If
-                CreateDeleteEvent(DateTime.Now, id, post)
-                Exit Sub
-            ElseIf xElm.Element("limit") IsNot Nothing Then
-                Debug.Print(line)
-                Exit Sub
-            ElseIf xElm.Element("event") IsNot Nothing Then
-                Debug.Print("event: " + xElm.Element("event").Value)
-                CreateEventFromJson(line)
-                Exit Sub
-            ElseIf xElm.Element("direct_message") IsNot Nothing Then
-                Debug.Print("direct_message")
-                isDm = True
-            ElseIf xElm.Element("scrub_geo") IsNot Nothing Then
-                Try
-                    Debug.Print("scrub_geo: user_id=" + xElm.Element("user_id").Value.ToString + " up_to_status_id=" + xElm.Element("up_to_status_id").Value.ToString)
-                Catch ex As Exception
-                    TraceOut("scrub_geo:" + line)
-                End Try
-                Exit Sub
-            End If
-        End Using
+            End Using
 
-        Dim res As New StringBuilder
-        res.Length = 0
-        res.Append("[")
-        res.Append(line)
-        res.Append("]")
+            Dim res As New StringBuilder
+            res.Length = 0
+            res.Append("[")
+            res.Append(line)
+            res.Append("]")
 
-        Try
             If isDm Then
                 CreateDirectMessagesFromJson(res.ToString, WORKERTYPE.UserStream, False)
             Else
@@ -2825,6 +2825,7 @@
     Private Sub CreateDeleteEvent(ByVal createdat As DateTime, ByVal id As Int64, ByVal post As PostClass)
         Dim evt As New FormattedEvent
         evt.CreatedAt = createdat
+        evt.Id = id
         If post Is Nothing Then
             Dim tmp As PostClass = (From p In _deletemessages Where p.Id = id).FirstOrDefault
             If tmp IsNot Nothing Then
@@ -2849,7 +2850,13 @@
             evt.Username = post.Name
             evt.Target = If(post.Data.Length > 5, post.Data.Substring(0, 5) + "...", post.Data) + " [" + post.PDate.ToString + "]"
         End If
-        Me.StoredEvent.Insert(0, evt)
+        For i As Integer = Me.StoredEvent.Count - 1 To 0 Step -1
+            Dim sEvt As FormattedEvent = Me.StoredEvent(i)
+            If sEvt.Id = id AndAlso (sEvt.Event = "favorite" OrElse sEvt.Event = "unfavorite") Then
+                Me.StoredEvent.RemoveAt(i)
+            End If
+        Next
+        'Me.StoredEvent.Insert(0, evt)
         RaiseEvent UserStreamEventReceived(evt)
     End Sub
 



Tween-svn メーリングリストの案内
Back to archive index