Dim fl1 As String = "e:\wwwroot\mobo\"
Dim wb As New weui
Dim e As RequestEventArgs = args(0)
Dim cmd As new SQLCommand
cmd.C
cmd.CommandTimeOut = 600
Dim space As TimeSpan = Date.now - #1/1/1970 00:00:00# '从1970年开始算毫秒值
Dim wjm As Long= space.TotalMilliseconds '需要的时间毫秒值
Dim wjlj As String = fl1 & "盘点\" & e.PostValues("username") & e.PostValues("dy") & wjm & ".txt"
FileSys.CopyFile(fl1 & "wj\pd.txt", wjlj ,True)
FileSys.WriteAllText(wjlj , e.PostValues("txm"), True)
'以上是将APP抛上来的数据存入一个txt文件
'将txt的数据写入表格
Dim strs As String = FileSys.ReadAllText(wjlj,Encoding.Default)
Dim h As String
Dim m As String
Dim kw As String
Dim djbh As String
strs = strs.Trim()
Dim rs() As String = strs.Split("#")
For i As Integer = 0 To rs.Length - 1
Dim cs() As String = rs(i).Split(",")
If cs.Length = 6 Then
Dim dr2 As DataRow = DataTables("盘点明细表导入").Addnew()
dr2("首列") = cs(0)
dr2("门店名称") = e.PostValues("username")
dr2("姓名") = e.PostValues("dy")
dr2("库位") = cs(1)
dr2("条码") = cs(3)
dr2("数量") = cs(4)
dr2("扫码时间") = cs(5)
dr2("盘点日期") = Date.Today
dr2("上传时间") = Date.now
End If
Next
'以上是将txt的数据写入表格
'将table的数据保存到数据库
If Date.now.Hour < 10 Then
h = "0" & Date.now.Hour
Else
h = Date.now.Hour
End If
If Date.now.Minute < 10 Then
m = "0" & Date.now.Minute
Else
m = Date.now.Minute
End If
'这一步我知道可以改成 SqlBulkCopy 的模式快速导入
For Each dr3 As DataRow In DataTables("盘点明细表导入").DataRows
dr3("单据编号") = dr3("库位") & h & m
cmd.CommandText =" insert into 盘点明细表(首列,门店名称,姓名,条码,扫码时间,数量,盘点日期,库位,上传时间,单据编号,扫码时间条码) values ('" & dr3("首列") & "' , '" & dr3("门店名称") & "' , '" & dr3("姓名") & "' , '" & dr3("条码") & "', '" & dr3("扫码时间") & "' , '" & dr3("数量") & "','" & dr3("盘点日期") & "','" & dr3("库位") & "','" & dr3("上传时间") & "' ,'" & dr3("单据编号") & "' ,'" & dr3("扫码时间条码") & "' )"
cmd.ExecuteNonQuery()
dr3.Delete
Next
'以上是将table的数据保存到数据库
e.WriteString("服务器接收数据成功")