以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- Dim sem As String =dr1("告知内容") 用什么办法实现这个sem的值以五百个字为标准进行拆分,并进行多条信息的发送? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=144904) |
-- 作者:李孝春 -- 发布时间:2020/1/2 14:22:00 -- Dim sem As String =dr1("告知内容") 用什么办法实现这个sem的值以五百个字为标准进行拆分,并进行多条信息的发送? 这个sem在实际中可能会录入大于五百字的内容,我想实现拆分,假设现在录入1200字,我需要拆分成500 500 200 三个内容,然后在下面的发送HC部分,进行三次组合,将这条信息发送出去 怎么操作呢? 代码如下: Dim lsts As New List(Of String) lsts= DataTables("告知内容").SQLGetValues("姓名" ,"操作单位=\'" & _usergroup & "\' And ( 是否告知 is null or 是否告知<> \'是\')") For Each lst As String In lsts Dim dr21 As DataRow = DataTables("告知内容").sqlfind("姓名 = \'" & lst & "\'and 操作单位=\'" & _usergroup & "\' " ) If dr21 IsNot Nothing Then \'如果不存在同编号的订单 If dr21("手机号码") IsNot Nothing Then Dim ab As DataRow = DataTables("参数表").sqlFind("使用单位 = \'" & _usergroup & "\'") Dim drs1 = DataTables("告知内容").sqlSelect("姓名 = \'" & lst & "\' and 操作单位=\'" & _usergroup & "\' And ( 是否告知 is null or 是否告知<> \'是\')") For Each dr1 As DataRow In drs1 If dr1("告知内容") <>"" Then Dim t As Date= Date.Now Dim t1 As String =Format(Date.Now, "yyyMMddHHmmss") Dim Val As String = Rand.Next(1000) \' Dim s As String = val.PadLeft(4, "0") Dim password As String= ab("移动平台密码") \'接入密码 Dim t2 As String = password & t1 & s Dim account As String = ab("移动平台账号") \'接入账号 Dim serviceCode As String = ab("移动平台接入号") \'接入号 Dim authCode As String = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(t2, "MD5") Dim reqNo As String = t1 & s Dim sem As String =dr1("告知内容") 这个sem在实际中可能会录入大于五百字的内容,我想实现拆分,假设现在录入1200字,我需要拆分成500 500 200 三个内容,然后在下面的发送HC部分,进行三次组合,将这条信息发送出去 怎么操作呢? \'output.Show(sem) \'MessageBox.Show(sem) Dim content As String =Functions.Execute("utf8",sem) \'MessageBox.Show(content) Dim msisdn As String =dr1("手机号码") \'MessageBox.Show(msisdn) Dim hc As New HttpClient("http://218.201.202.174:8900/smstemp/http/sendSms?account="&account.Trim()&"&reqNo="&reqNo.Trim()&"&authCode="&authCode.Trim()&"&serviceCode="&serviceCode.Trim()&"&msisdn="&msisdn.Trim()&"&c&msgType=0") Dim ret As String = hc.GetData() Dim Tel As String = ret Dim Parts() As String = Tel.Split("=") Dim Tel1 As String = Parts(1) Dim Parts1() As String = Tel1.Split(",") \'MessageBox.Show(parts1(0)) If parts1(0)=0 Then \'MessageBox.Show(parts1(0)) dr1("是否告知")="是" & parts1(0) Else \'MessageBox.Show(parts1(0)) dr1("是否告知")="否" & parts1(0) End If dr1.Save End If Next End If End If Next
|
-- 作者:有点蓝 -- 发布时间:2020/1/2 14:29:00 -- Dim sem As String = dr1("告知内容") Do While sem.Length > 500 Dim s As String = sem.SubString(0,500) sem = sem.SubString(500) Output.Show(s) ‘改为发送的代码’ Loop Output.Show(sem) ‘改为发送的代码’ |
-- 作者:李孝春 -- 发布时间:2020/1/2 16:20:00 -- 回复:(有点蓝)Dim sem As String = dr1("告知... 代码修正为如下: 能够实现信息拆分发送了 但是发送的顺序不能控制 导致信息不会按照原来的排版顺序 依次发送 出现了倒序发送 麻烦老师多多指导一下,让拆分后的内容也能够按照正序发送 第二:如下代码是否还可以简化,感觉太繁琐! Dim lsts As New List(Of String) lsts= DataTables("告知内容").SQLGetValues("姓名" ,"操作单位=\'" & _usergroup & "\' And ( 是否告知 is null or 是否告知<> \'是\')") For Each lst As String In lsts Dim dr21 As DataRow = DataTables("告知内容").sqlfind("姓名 = \'" & lst & "\'and 操作单位=\'" & _usergroup & "\' " ) If dr21 IsNot Nothing Then \'如果不存在同编号的订单 If dr21("手机号码") IsNot Nothing Then Dim ab As DataRow = DataTables("参数表").sqlFind("使用单位 = \'" & _usergroup & "\'") Dim drs1 = DataTables("告知内容").sqlSelect("姓名 = \'" & lst & "\' and 操作单位=\'" & _usergroup & "\' And ( 是否告知 is null or 是否告知<> \'是\')") For Each dr1 As DataRow In drs1 If dr1("告知内容") <>"" Then Dim t As Date= Date.Now Dim t1 As String =Format(Date.Now, "yyyMMddHHmmss") Dim Val As String = Rand.Next(1000) \' Dim s As String = val.PadLeft(4, "0") Dim password As String= ab("移动平台密码") \'接入密码 Dim t2 As String = password & t1 & s Dim account As String = ab("移动平台账号") \'接入账号 Dim serviceCode As String = ab("移动平台接入号") \'接入号 Dim authCode As String = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(t2, "MD5") Dim reqNo As String = t1 & s Dim msisdn As String =dr1("手机号码") Dim sem As String =dr1("告知内容") Do While sem.Length > 500 Dim s1 As String = sem.SubString(0,500) sem = sem.SubString(500) Output.Show(s1) \'改为发送的代码\' Dim content1 As String =Functions.Execute("utf8",s1) Dim hc1 As New HttpClient("http://218.201.202.174:8900/smstemp/http/sendSms?account="&account.Trim()&"&reqNo="&reqNo.Trim()&"&authCode="&authCode.Trim()&"&serviceCode="&serviceCode.Trim()&"&msisdn="&msisdn.Trim()&"&c&msgType=0") Dim ret1 As String = hc1.GetData() Dim Tel1 As String = ret1 Dim Parts1() As String = Tel1.Split("=") Dim Tel11 As String = Parts1(1) Dim Parts11() As String = Tel11.Split(",") \'MessageBox.Show(parts1(0)) If parts11(0)=0 Then \'MessageBox.Show(parts1(0)) dr1("是否告知")="是" dr1("状态码")=parts11(0) Else \'MessageBox.Show(parts1(0)) dr1("是否告知")="否" dr1("状态码")=parts11(0) End If dr1.Save Loop Output.Show(sem) \'改为发送的代码\' Dim content As String =Functions.Execute("utf8",sem) Dim hc As New HttpClient("http://218.201.202.174:8900/smstemp/http/sendSms?account="&account.Trim()&"&reqNo="&reqNo.Trim()&"&authCode="&authCode.Trim()&"&serviceCode="&serviceCode.Trim()&"&msisdn="&msisdn.Trim()&"&c&msgType=0") Dim ret As String = hc.GetData() Dim Tel As String = ret Dim Parts() As String = Tel.Split("=") Dim Tel2 As String = Parts(1) Dim Parts2() As String = Tel2.Split(",") \'MessageBox.Show(parts1(0)) If parts2(0)=0 Then \'MessageBox.Show(parts1(0)) dr1("是否告知")="是" dr1("状态码")=parts2(0) Else \'MessageBox.Show(parts1(0)) dr1("是否告知")="否" dr1("状态码")=parts2(0) End If dr1.Save End If Next End If End If Next
|
-- 作者:有点蓝 -- 发布时间:2020/1/2 16:32:00 -- 这个代码肯定是按顺序处理的,如果有问题肯定是短信接口的原因 |