-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmShopsteCategory.vb
458 lines (335 loc) · 17.8 KB
/
frmShopsteCategory.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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
Imports System.Net
Imports System.IO
Imports System.Security.Cryptography.X509Certificates
Imports System.Net.Security
Public Class frmShopsteCategory
Public strKategorieJTLShop As String = ""
Private Sub frmShopsteCategory_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim dtSubShopCat As DataTable = FillTestTableSubShopCat()
CreateTree(0, dtSubShopCat)
TreeView1.CollapseAll()
Dim dtshopsteCat As DataTable = FillTestTableShopsteCat()
CreateTreeShopste(0, dtshopsteCat)
TreeView2.CollapseAll()
'Call getHTTPResponseMessage("http://shopste.com/api.php?modus=get_shopste_category&domain_id=" & My.Settings.domain_id, mgetUpdaterMessage.getShopsteShopCategory, True)
'TreeView1.Nodes.Clear()
'' TreeView1 = tvShopste
'Dim treenode As TreeNode
'Dim strContent As String = My.Computer.FileSystem.ReadAllText("shopste-subshop.dat")
'Dim i As Integer = 0
'If strContent.Length > 0 Then
' 'Dim strLine() As String = strContent.Split("<br>")
' ''Creating the root node
' ''Dim root = New TreeNode("Shopste Kategorien")
' '' frmShopsteKategorieMapping.tvShopste()
' '' TreeView1.Nodes.Add(root)
' 'Dim itmp As Integer = 0
' 'For i = 0 To strLine.Length - 2
' ' Dim strData() As String = strLine(i).Split("|")
' ' ' If i = 93 Then
' ' ' Stop
' ' 'End If
' ' treenode = New TreeNode(strData(3))
' ' treenode.Tag = strData(0).Replace("br>", "")
' ' Select Case strData(2)
' ' Case "0"
' ' 'Creating the root node
' ' 'Dim root = treenode
' ' ' frmShopsteKategorieMapping.tvShopste()
' ' TreeView1.Nodes.Add(treenode)
' ' Case "1"
' ' TreeView1.Nodes(TreeView1.Nodes.Count - 1).Nodes.Add(treenode)
' ' Case "2"
' ' TreeView1.Nodes(TreeView1.Nodes.Count - 1).Nodes(TreeView1.Nodes(TreeView1.Nodes.Count - 1).Nodes.Count - 1).Nodes.Add(treenode)
' ' End Select
' ' 'Creating child nodes under the first child
' ' 'For loopindex As Integer = 1 To 4
' ' 'TreeView1.Nodes(0).Nodes(0).Nodes.Add(New _
' ' ' TreeNode("Sub Project" & Str(loopindex)))
' ' 'Next loopindex
' ' ' creating child nodes under the root
' ' 'TreeView1.Nodes(0).Nodes.Add(New TreeNode("Project 6"))
' ' 'creating child nodes under the created child node
' ' 'For loopindex As Integer = 1 To 3
' ' 'TreeView1.Nodes(0).Nodes(1).Nodes.Add(New _
' ' ' TreeNode("Project File" & Str(loopindex)))
' ' 'Next loopindex
' 'Next
'End If
'Call getHTTPResponseMessage("http://shopste.com/api.php?modus=get_shopste_category&domain_id=1", mgetUpdaterMessage.getShopsteCategory, True)
''Dim treenode As TreeNode
'strContent = My.Computer.FileSystem.ReadAllText("shopste-category.dat")
'i = 0
'If strContent.Length > 0 Then
' Dim strLine() As String = strContent.Split("<br>")
' 'Creating the root node
' 'Dim root = New TreeNode("Shopste Kategorien")
' ' frmShopsteKategorieMapping.tvShopste()
' ' TreeView1.Nodes.Add(root)
' Dim itmp As Integer = 0
' For i = 0 To strLine.Length - 2
' Dim strData() As String = strLine(i).Split("|")
' ' If i = 93 Then
' ' Stop
' 'End If
' TreeNode = New TreeNode(strData(3))
' TreeNode.Tag = strData(0).Replace("br>", "")
' Select Case strData(2)
' Case "0"
' 'Creating the root node
' 'Dim root = treenode
' ' frmShopsteKategorieMapping.tvShopste()
' TreeView2.Nodes.Add(TreeNode)
' Case "1"
' TreeView2.Nodes(TreeView2.Nodes.Count - 1).Nodes.Add(TreeNode)
' Case "2"
' TreeView2.Nodes(TreeView2.Nodes.Count - 1).Nodes(TreeView2.Nodes(TreeView1.Nodes.Count - 1).Nodes.Count - 1).Nodes.Add(TreeNode)
' End Select
' 'Creating child nodes under the first child
' 'For loopindex As Integer = 1 To 4
' 'TreeView1.Nodes(0).Nodes(0).Nodes.Add(New _
' ' TreeNode("Sub Project" & Str(loopindex)))
' 'Next loopindex
' ' creating child nodes under the root
' 'TreeView1.Nodes(0).Nodes.Add(New TreeNode("Project 6"))
' 'creating child nodes under the created child node
' 'For loopindex As Integer = 1 To 3
' 'TreeView1.Nodes(0).Nodes(1).Nodes.Add(New _
' ' TreeNode("Project File" & Str(loopindex)))
' 'Next loopindex
' Next
'End If
End Sub
Private Sub CreateTree(parent As Integer, dt As DataTable)
' Dim MaxLevel1 As Integer = CInt(DataTable1.Compute("MAX(LEVEL)", ""))
Dim j As Integer
Try
Dim Rows1() As DataRow = dt.Select("PARENT2 = '" & parent & "'")
Dim treen As New TreeNode
For j = 0 To Rows1.Length - 1
Dim ID1 As String = Rows1(j).Item("ID").ToString
Dim Name1 As String = Rows1(j).Item("NAME").ToString
Dim Parent1 As String = Rows1(j).Item("PARENT2").ToString
Dim level As Integer = Rows1(j).Item("Level").ToString
If level = 1 Then
'TreeView1.Nodes.Add(ID1, Name1)
'treen.Tag = ID1
'treen.Text = Name1
TreeView1.Nodes.Add(ID1, Name1)
CreateTree(Rows1(j).Item("ID").ToString, dt)
Else
Dim TreeNodes1() As TreeNode = TreeView1.Nodes.Find(Parent1, True)
If TreeNodes1.Length > 0 Then
TreeNodes1(0).Nodes.Add(ID1, Name1)
' Node1.ChildNodes.Add(New TreeNode(Name1, ID1))
End If
CreateTree(Rows1(j).Item("ID").ToString, dt)
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'
End Sub
Private Sub CreateTreeShopste(parent As Integer, dt As DataTable)
' Dim MaxLevel1 As Integer = CInt(DataTable1.Compute("MAX(LEVEL)", ""))
Dim j As Integer
Try
Dim Rows1() As DataRow = dt.Select("PARENT2 = '" & parent & "'")
Dim treen As New TreeNode
For j = 0 To Rows1.Length - 1
Dim ID1 As String = Rows1(j).Item("ID").ToString
Dim Name1 As String = Rows1(j).Item("NAME").ToString
Dim Parent1 As String = Rows1(j).Item("PARENT2").ToString
Dim level As Integer = Rows1(j).Item("Level").ToString
If level = 1 Then
'TreeView1.Nodes.Add(ID1, Name1)
'treen.Tag = ID1
'treen.Text = Name1
TreeView2.Nodes.Add(ID1, Name1)
CreateTreeShopste(Rows1(j).Item("ID").ToString, dt)
Else
Dim TreeNodes1() As TreeNode = TreeView2.Nodes.Find(Parent1, True)
If TreeNodes1.Length > 0 Then
TreeNodes1(0).Nodes.Add(ID1, Name1)
' Node1.ChildNodes.Add(New TreeNode(Name1, ID1))
End If
CreateTreeShopste(Rows1(j).Item("ID").ToString, dt)
End If
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
'
End Sub
Private Function FillTestTableShopsteCat() As DataTable
Dim DataTable1 As New DataTable
DataTable1.Columns.Add("ID", GetType(Integer))
DataTable1.Columns.Add("NAME", GetType(String))
DataTable1.Columns.Add("PARENT2", GetType(Integer))
DataTable1.Columns.Add("LEVEL", GetType(Integer))
Call getHTTPResponseMessage(My.Settings.SHOPSTE_API_URL & "?modus=get_shopste_category&domain_id=1" & "&txtUsername=" & My.Settings.SHOPSTE_USERNAME & "&txtPasswort=" & My.Settings.SHOPSTE_PASSWORD, mgetUpdaterMessage.getShopsteCategory, True)
TreeView2.Nodes.Clear()
' TreeView1 = tvShopste
Dim treenode As New TreeNode
Dim strContent As String = My.Computer.FileSystem.ReadAllText("shopste-category.dat")
Dim i As Integer = 0
Try
If strContent.Length > 0 Then
Dim strLine() As String = strContent.Split("<br>")
For i = 0 To strLine.Length - 2
Dim strData() As String = strLine(i).Split("|")
' If strData(4) = 0 Then
' strData(4) = ""
' End If
DataTable1.Rows.Add(strData(0).Replace("br>", ""), strData(3), strData(4), strData(2))
Next i
End If
'DataTable1.Rows.Add(1, "Patrick")
'Dim i As Integer
'For i = 0 To DataTable1.Rows.Count - 1
' Dim ID1 As String = DataTable1.Rows(i).Item("ID").ToString
' DataTable1.Rows(i).Item("LEVEL") = FindLevel(ID1, 0)
'Next
Return DataTable1
Catch ex As Exception
MessageBox.Show("Fehler:" + ex.Message)
End Try
End Function
Private Function FillTestTableSubShopCat() As DataTable
Dim DataTable1 As New DataTable
DataTable1.Columns.Add("ID", GetType(Integer))
DataTable1.Columns.Add("NAME", GetType(String))
DataTable1.Columns.Add("PARENT2", GetType(Integer))
DataTable1.Columns.Add("LEVEL", GetType(Integer))
Call getHTTPResponseMessage(My.Settings.SHOPSTE_API_URL & "?modus=get_shopste_category&domain_id=" & My.Settings.SHOPSTE_domain_id & "&txtUsername=" & My.Settings.SHOPSTE_USERNAME & "&txtPasswort=" & My.Settings.SHOPSTE_PASSWORD, mgetUpdaterMessage.getShopsteCategory, True)
TreeView1.Nodes.Clear()
' TreeView1 = tvShopste
Dim treenode As New TreeNode
Dim strContent As String = My.Computer.FileSystem.ReadAllText("shopste-category.dat")
Dim i As Integer = 0
Try
If strContent.Length > 0 Then
Dim strLine() As String = strContent.Split("<br>")
For i = 0 To strLine.Length - 2
Dim strData() As String = strLine(i).Split("|")
' If strData(4) = 0 Then
' strData(4) = ""
' End If
DataTable1.Rows.Add(strData(0).Replace("br>", ""), strData(3), strData(4), strData(2))
Next i
End If
'DataTable1.Rows.Add(1, "Patrick")
'Dim i As Integer
'For i = 0 To DataTable1.Rows.Count - 1
' Dim ID1 As String = DataTable1.Rows(i).Item("ID").ToString
' DataTable1.Rows(i).Item("LEVEL") = FindLevel(ID1, 0)
'Next
Return DataTable1
Catch ex As Exception
MessageBox.Show("Fehler:" + ex.Message)
End Try
End Function
Private Sub TreeView1_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterSelect
End Sub
Private Sub TreeView1_NodeMouseClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
Label1.Text = e.Node.Name
' strShopSubCat = e.Node.Name
End Sub
Private Sub TreeView2_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TreeView2.AfterSelect
End Sub
Private Sub TreeView2_NodeMouseClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles TreeView2.NodeMouseClick
Label2.Text = e.Node.Name
' frmShopsteImporter.strShopsteCat = e.Node.Name
End Sub
Private Sub btnKategorieZuordnen_Click(sender As Object, e As EventArgs) Handles btnKategorieZuordnen.Click
'frmShopsteImporter.bZuordnen = True
'strKategorieJTLShop
If frmMain.clsDB.chkJTLShopCat2Shopste(strKategorieJTLShop) = 0 Then
frmMain.clsDB.setINSERT_KategorieJTL2Shopste(strKategorieJTLShop, Label2.Text)
Else
frmMain.clsDB.setUPDATE_KategorieJTL2Shopste(strKategorieJTLShop, Label2.Text)
End If
Me.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' frmShopsteImporter.bZuordnen = False
Me.Close()
End Sub
Public Shared Function customCertValidation(ByVal sender As Object,
ByVal cert As X509Certificate,
ByVal chain As X509Chain,
ByVal errors As SslPolicyErrors) As Boolean
Return True
End Function
Private Sub NeueKategorieAnlegenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NeueKategorieAnlegenToolStripMenuItem.Click
Dim strInput As String = InputBox("Bitte Unterkategorie-Namen eingeben", "Sub-Shop Unterkategorie anlegen.")
If strInput.Length > 0 Then
'MessageBox.Show(strInput & " " & Label1.Text)
ServicePointManager.ServerCertificateValidationCallback =
New System.Net.Security.RemoteCertificateValidationCallback(AddressOf customCertValidation)
Dim Request As HttpWebRequest = CType(WebRequest.Create(My.Settings.SHOPSTE_API_URL & "api.php"), HttpWebRequest)
Request.Method = "POST"
Request.ContentType = "application/x-www-form-urlencoded"
'msgMessage.Text = icount & " | " & ListView1.Items.Count - 1 & " - Bereite einfügen vor..."
Application.DoEvents()
Dim Post As String = "modus=system_category_add&domain_id=" & My.Settings.SHOPSTE_domain_id & "&shop_cat_title=" & strInput & "&shop_cat_position=0&shop_cat_id=" & Label1.Text & "&page_layout=col2-left-layout&subtyp=new" & "&txtUsername=" & My.Settings.SHOPSTE_USERNAME & "&txtPasswort=" & My.Settings.SHOPSTE_PASSWORD
' Clipboard.SetText(WebUtility.HtmlEncode(ListView1.SelectedItems(0).SubItems(5).Text))
'Dim postQuery As Byte() = System.Text.Encoding.ASCII.GetBytes("Post
Dim byteArray() As Byte = System.Text.Encoding.UTF8.GetBytes(Post)
Request.ContentLength = byteArray.Length
Dim DataStream As Stream = Request.GetRequestStream()
DataStream.Write(byteArray, 0, byteArray.Length)
DataStream.Close()
Dim Response As HttpWebResponse = Request.GetResponse()
DataStream = Response.GetResponseStream()
Dim reader As New StreamReader(DataStream)
Dim ServerResponse As String = reader.ReadToEnd()
reader.Close()
DataStream.Close()
Response.Close()
' msgMessage.Text = ServerResponse
If InStr(ServerResponse, "shopid") Then
End If
Dim dtSubShopCat As DataTable = FillTestTableSubShopCat()
CreateTree(0, dtSubShopCat)
TreeView1.ExpandAll()
End If
End Sub
Private Sub KategorieUmbennenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles KategorieUmbennenToolStripMenuItem.Click
Dim strInput As String = InputBox("Bitte Unterkategorie-Namen eingeben", "Sub-Shop Unterkategorie anlegen.")
If strInput.Length > 0 Then
'MessageBox.Show(strInput & " " & Label1.Text)
ServicePointManager.ServerCertificateValidationCallback =
New System.Net.Security.RemoteCertificateValidationCallback(AddressOf customCertValidation)
Dim Request As HttpWebRequest = CType(WebRequest.Create(My.Settings.SHOPSTE_API_URL & "api.php"), HttpWebRequest)
Request.Method = "POST"
Request.ContentType = "application/x-www-form-urlencoded"
'msgMessage.Text = icount & " | " & ListView1.Items.Count - 1 & " - Bereite einfügen vor..."
Application.DoEvents()
Dim Post As String = "modus=system_category_add&domain_id=" & My.Settings.SHOPSTE_domain_id & "&shop_cat_title=" & strInput & "&shop_cat_position=0&shop_cat_id=" & Label1.Text & "&page_layout=col2-left-layout&subtyp=rename" & "&txtUsername=" & My.Settings.SHOPSTE_USERNAME & "&txtPasswort=" & My.Settings.SHOPSTE_PASSWORD
' Clipboard.SetText(WebUtility.HtmlEncode(ListView1.SelectedItems(0).SubItems(5).Text))
'Dim postQuery As Byte() = System.Text.Encoding.ASCII.GetBytes("Post
Dim byteArray() As Byte = System.Text.Encoding.UTF8.GetBytes(Post)
Request.ContentLength = byteArray.Length
Dim DataStream As Stream = Request.GetRequestStream()
DataStream.Write(byteArray, 0, byteArray.Length)
DataStream.Close()
Dim Response As HttpWebResponse = Request.GetResponse()
DataStream = Response.GetResponseStream()
Dim reader As New StreamReader(DataStream)
Dim ServerResponse As String = reader.ReadToEnd()
reader.Close()
DataStream.Close()
Response.Close()
' msgMessage.Text = ServerResponse
If InStr(ServerResponse, "shopid") Then
End If
Dim dtSubShopCat As DataTable = FillTestTableSubShopCat()
CreateTree(0, dtSubShopCat)
TreeView1.ExpandAll()
End If
End Sub
Private Sub TreeView2_Click(sender As Object, e As EventArgs) Handles TreeView2.Click
End Sub
End Class