-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmEvernote.vb
255 lines (211 loc) · 10 KB
/
frmEvernote.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
Imports System.IO
Imports Microsoft.VisualBasic.FileIO
Imports System.Xml
Imports System.Collections
Imports System.Collections.Generic
Imports System.Text
Imports System.Security.Cryptography
'Imports Thrift
'Imports Thrift.Protocol
'Imports Thrift.Transport
'Imports Evernote.EDAM.Type
'Imports Evernote.EDAM.UserStore
'Imports Evernote.EDAM.NoteStore
'Imports Evernote.EDAM.Error
Public Class frmEvernote
'Public Class NoteListItem
' Private mText As String
' Private mValue As String
' Public Sub New(ByVal pText As String, ByVal pValue As String)
' mText = pText
' mValue = pValue
' End Sub
' Public ReadOnly Property Text() As String
' Get
' Return mText
' End Get
' End Property
' Public ReadOnly Property Value() As String
' Get
' Return mValue
' End Get
' End Property
' Public Overrides Function ToString() As String
' Return mText
' End Function
'End Class
'Dim authResult As AuthenticationResult = Nothing
'Dim user As User = Nothing
'Dim authToken As String
'Dim noteStore As NoteStore.Client
'Private dtRecs As DataTable = New DataTable
'Public ReadOnly Property Recs() As DataTable
' Get
' Return dtRecs
' End Get
'End Property
'Public Function Authenticate(ByVal strUser As String, ByVal strPassword As String) As String
' Dim strErr As String = ""
' user = Nothing
' authToken = Nothing
' authResult = Nothing
' ' NOTE: You must change the consumer key and consumer secret to the
' ' key and secret that you received from Evernote.
' ' To get an API key, visit http://dev.evernote.com/documentation/cloud/
' Dim consumerKey As String = "burkmarr"
' Dim consumerSecret As String = "2972741bf1d64045"
' 'Dim evernoteHost As String = "sandbox.evernote.com"
' Dim evernoteHost As String = "www.evernote.com"
' Dim edamBaseUrl As String = "https://" & evernoteHost
' Dim userStoreUrl As New Uri(edamBaseUrl & "/edam/user")
' Dim userStoreTransport As TTransport = New THttpClient(userStoreUrl)
' Dim userStoreProtocol As TProtocol = New TBinaryProtocol(userStoreTransport)
' Dim userStore As New UserStore.Client(userStoreProtocol)
' Dim versionOK As Boolean
' Try
' versionOK = userStore.checkVersion("C# EDAMTest", Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MAJOR, Evernote.EDAM.UserStore.Constants.EDAM_VERSION_MINOR)
' Catch
' versionOK = False
' End Try
' If Not versionOK Then
' strErr = "Problem connecting to Evernote. Check internet connection."
' 'EDAM protocol version is not up to date.
' Return strErr
' End If
' Try
' authResult = userStore.authenticate(strUser, strPassword, consumerKey, consumerSecret)
' Catch ex As EDAMUserException
' Dim parameter As [String] = ex.Parameter
' Dim errorCode As EDAMErrorCode = ex.ErrorCode
' strErr = "Authentication failed (parameter: " & parameter & " errorCode: " & errorCode & ")."
' If errorCode = EDAMErrorCode.INVALID_AUTH Then
' If parameter = "consumerKey" Then
' strErr = strErr & " The application consumer key was not accepted by " & evernoteHost & "."
' ElseIf parameter = "username" Then
' strErr = strErr & " You must authenticate using a username and password from " & evernoteHost & "."
' ElseIf parameter = "password" Then
' strErr = strErr & " The password that you entered is incorrect."
' End If
' End If
' Return strErr
' End Try
' user = authResult.User
' authToken = authResult.AuthenticationToken
' Return ""
'End Function
'Private Sub cbNotebooks_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbNotebooks.SelectedIndexChanged
' lbNotes.Items.Clear()
' Dim filter As NoteFilter = New NoteFilter()
' Dim nli As NoteListItem = cbNotebooks.SelectedItem
' filter.NotebookGuid = nli.Value
' Dim spec As NotesMetadataResultSpec = New NotesMetadataResultSpec()
' spec.IncludeTitle = True
' Dim nml As NotesMetadataList = noteStore.findNotesMetadata(authToken, filter, 0, 100, spec)
' Dim nm As NoteMetadata
' For Each nm In nml.Notes
' lbNotes.Items.Add(New NoteListItem(nm.Title, nm.Guid))
' Next
'End Sub
'Private Sub frmEvernote_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
' cbNotebooks.Items.Clear()
' dtRecs.Rows.Clear()
' Dim noteStoreTransport As TTransport = New THttpClient(New Uri(authResult.NoteStoreUrl))
' Dim noteStoreProtocol As TProtocol = New TBinaryProtocol(noteStoreTransport)
' noteStore = New NoteStore.Client(noteStoreProtocol)
' Dim notebooks As List(Of Notebook) = noteStore.listNotebooks(authToken)
' 'Dim defaultNotebook As Notebook = notebooks(0)
' 'notebook.DefaultNotebook
' cbNotebooks.Items.Clear()
' For Each notebook As Notebook In notebooks
' cbNotebooks.Items.Add(New NoteListItem(notebook.Name, notebook.Guid))
' Next
' cbNotebooks.SelectedIndex = 0
'End Sub
'Private Sub butOkay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butOkay.Click
' Cursor = Cursors.WaitCursor
' dtRecs.Columns.Clear()
' dtRecs.Columns.Add("Title")
' dtRecs.Columns.Add("Lat")
' dtRecs.Columns.Add("Lon")
' dtRecs.Columns.Add("Date")
' dtRecs.Columns.Add("Time")
' dtRecs.Columns.Add("DateTimeKey")
' dtRecs.Columns.Add("Comment")
' dtRecs.Columns.Add("VoiceFile")
' dtRecs.Columns.Add("MediaFile")
' Dim fullNote As Note
' Dim nli As NoteListItem
' Dim base As New DateTime(1970, 1, 1)
' Dim dt As DateTime
' Dim millisecs As Double
' Dim doc As XmlDocument = New XmlDocument
' doc.XmlResolver = Nothing
' Dim strResourceFile As String
' Dim strExt As String = ""
' Dim r As Resource
' Dim row As DataRow
' Dim byteData() As Byte
' Dim oFileStream As System.IO.FileStream
' Dim strComment As String
' Dim strDate As String
' Dim strTime As String
' For Each nli In lbNotes.SelectedItems
' fullNote = noteStore.getNote(authToken, nli.Value, True, False, False, False)
' millisecs = fullNote.Created
' dt = base.AddMilliseconds(millisecs)
' row = dtRecs.NewRow()
' row("Title") = fullNote.Title
' row("Lat") = fullNote.Attributes.Latitude
' row("Lon") = fullNote.Attributes.Longitude
' row("DateTimeKey") = Format(dt, "yyMMddHmmss")
' 'We assume the dates and times in are UTC
' strDate = Format(dt, "dd/MM/yyyy")
' strTime = Format(dt, "H:mm")
' strDate = cfun.UTC2LocalTime(DateTime.Parse(strDate & " " & strTime & ":00"), cfun.RecDateTimeType.RecDate)
' strTime = cfun.UTC2LocalTime(DateTime.Parse(strDate & " " & strTime & ":00"), cfun.RecDateTimeType.RecTime)
' row("Date") = strDate
' row("Time") = strTime
' 'We extract comment with regular expression because trying to parse XML was problematic
' 'due to things like . Resolving the DTD might have helped this, but if this isn't
' 'disabled with doc.XmlResolver = Nothing, the document wont load at all.
' strComment = RegularExpressions.Regex.Replace(fullNote.Content, "<.*?>", "")
' strComment = RegularExpressions.Regex.Replace(strComment, " ", " ")
' strComment = RegularExpressions.Regex.Replace(strComment, vbCr, "")
' strComment = RegularExpressions.Regex.Replace(strComment, vbLf, "")
' strComment = RegularExpressions.Regex.Replace(strComment, vbCrLf, "")
' row("Comment") = strComment
' 'Resources
' If Not fullNote.Resources Is Nothing Then
' For Each r In fullNote.Resources
' If r.Mime.StartsWith("audio") Or r.Mime.StartsWith("image") Then
' 'Its an audio (voice) file
' If r.Mime.EndsWith("wav") Then strExt = ".wav"
' If r.Mime.EndsWith("mpeg") Then strExt = ".mpg"
' If r.Mime.EndsWith("amr") Then strExt = ".amr"
' If r.Mime.EndsWith("gif") Then strExt = ".gif"
' If r.Mime.EndsWith("jpeg") Then strExt = ".jpg"
' If r.Mime.EndsWith("png") Then strExt = ".png"
' If Directory.Exists(frmOptions.txtEvernoteFolder.Text) Then
' strResourceFile = Path.Combine(frmOptions.txtEvernoteFolder.Text, row("DateTimeKey") & strExt)
' byteData = noteStore.getResourceData(authToken, r.Guid)
' oFileStream = New System.IO.FileStream(strResourceFile, System.IO.FileMode.Create)
' oFileStream.Write(byteData, 0, byteData.Length)
' oFileStream.Close()
' If r.Mime.StartsWith("audio") Then
' row("VoiceFile") = strResourceFile
' Else
' row("MediaFile") = strResourceFile
' End If
' End If
' End If
' Next
' End If
' dtRecs.Rows.Add(row)
' Next
' Cursor = Cursors.Arrow
' Me.Close()
'End Sub
'Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
' Me.Close()
'End Sub
End Class