以下代码,执行的时候,在循环体内,第一次没问题,循环到第二次的时候就会提示出错:意外被中断
详细错误信息:
Error reading JObject from JsonReader. Path '', line 0, position 0.
请问是什么原因?
------------------------------
Dim tb5 As Table = e.form.controls("table5").Table
Dim tb2 As Table = e.form.controls("table2").Table
If tb2.rows.count < 1 Then
msgbox("请先加载商品数据")
Return
End If
If tb5.Cols.contains("商品id") = False Then
msgbox("请先加载已有数据")
Return
End If
SystemReady = False
try
Forms("正在更新提示").open
tb5.StopRedraw
Dim stToken As String = Functions.Execute("SYS_API获取有赞token")
If stToken IsNot Nothing AndAlso stToken.length > 0 Then
Dim hc As New HttpClient("https://open.youzanyun.com/api/youzan.item.sku.list/1.0.0?access_token=" & stToken)
hc.C
Dim k As Integer = 0 '循环第几轮
Dim m As Integer = tb2.rows.count
m = m -1
Dim n As Integer = 0 '当前记录
Dim jo As New JObject
Do While n < m
Dim joC As New JObject
joC("param") = New JObject
joC("param")("use_cache") = False
Dim ja As New Jarray '定义数组
Do While True
If n < m AndAlso (n - k * 20) < 20 Then
If tb2.rows(n)("售卖状态") = "1" OrElse tb2.rows(n)("售卖状态") = "2" Then
ja.Add(tb2.rows(n)("商品ID"))
n = n + 1
Else
n = n + 1
End If
Else
Exit Do
End If
Loop
k = k + 1
joC("param")("item_ids") = ja '将Roles设置为前面定义的数组
hc.Content =CompressJson(joC)
jo = JObject.Parse(hc.GetData)
If jo("success") IsNot Nothing AndAlso jo("success").tostring = "true" Then
Dim st As New Date(1970,1,1,8,0,0)
Dim drc As DataRow
For Each jp As object In jo("data")
For Each jt As JToken In jo("data")(jp.Name)
If jt("combinSku").tostring = "false" Then
drc = tb5.DataTable.addnew
drc("商品ID") = jt("itemId").tostring
drc("规格ID") = jt("skuId").tostring
drc("规格编码") = jt("code").tostring
If jt("sku") IsNot Nothing Then
Dim stN As String = ""
For Each jt2 As JToken In JArray.Parse(jt("sku").tostring)
stN = stN & "_" & jt2("v").tostring
Next
drc("规格名称") = stN.Trim("_")
End if
drc("规格售价") = Val(jt("price").tostring) / 100
drc("规格库存") = Val(jt("stockNum").tostring)
Dim timestamp As Integer = Val(jt("updateTime").tostring)
drc("更新时间") = st.AddSeconds(timestamp)
drc("同步状态") = "已同步"
End If
Next
Next
End If
Loop
Else
msgbox("错误:无法获取有赞token")
End If
Catch ex As Exception
MessageBox.Show("操作失败")
Forms("正在更新提示").close
SystemReady = True
End Try
Forms("正在更新提示").close
tb5.ResumeRedraw
SystemReady = True