Foxtable(狐表)用户栏目专家坐堂 → Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"} 如何定义表中无对应字段 值的组合呢?


  共有3193人关注过本帖树形打印复制链接

主题:Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"} 如何定义表中无对应字段 值的组合呢?

帅哥哟,离线,有人找我吗?
cnsjroom
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1571 积分:11238 威望:0 精华:0 注册:2021/1/17 17:06:00
Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"} 如何定义表中无对应字段 值的组合呢?  发帖心情 Post By:2021/7/9 20:34:00 [只看该作者]

Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"}  如何定义表中无对应字段 值的组合呢?

Dim 标志 As String
Dim 编码 As String ="10010"
Dim 状态 As String
Dim Products As List(Of String)
Products = DataTables("m_Localizer").SQLGetValues("ID")
For Each Product As String In Products
    'Output.Show(Product)
    Dim dr As DataRow
    dr = DataTables("Alarm_Current").Find("AlarmTypeID='1001' And EquipmentID='" & Product & "'")
    If dr IsNot Nothing '如果找到, 则设置各列内容
        标志="100"
        状态="正常"
    Else
        标志="200"
        状态="异常"
    End If
Next



Dim  c As Integer =DataTables("m_Localizer").Compute("count(vc_Name)")
output.show(c)
Dim Cols1() As String = {"编码","EquipmentID","标志","dt_BeginDate","状态"}
Dim s As String
s=Date.now() & "," & c

s = s.TrimStart(",")
FileSys.WriteAllText("D:\persionLoaction\Data\DeviceStatus.txt",s & vbcrlf,False)

For Each dr As DataRow In DataTables("m_Localizer").DataRows
    s = ""
    For i As Integer = 0 To Cols1.Length -1
        If s > "" Then s = s  & ","
        If dr.IsNull(Cols1(i)) = False Then
            s =  s  & dr(Cols1(i))
        End If
    Next
    s = s.TrimStart(",")
    FileSys.WriteAllText("D:\persionLoaction\Data\DeviceStatus.txt", s & vbcrlf , True, Encoding.Default)
Next

想实现如下内容输出,上述代码怎么修改呢?
2021-07-08 11:05:29,13
"编码","EquipmentID","标志","dt_BeginDate","状态"
10010,11,100,2021-07-08 11:05:29,正常
10010,21,100,2021-07-08 11:05:29,正常
10010,31,100,2021-07-08 11:05:29,正常
10010,52,100,2021-07-08 11:05:29,正常
10010,53,100,2021-07-08 11:05:29,正常
10010,61,100,2021-07-08 11:05:29,正常
10010,63,100,2021-07-08 11:05:29,正常
10010,71,100,2021-07-08 11:05:29,正常
10010,72,100,2021-07-08 11:05:29,正常
10010,101,100,2021-07-08 11:05:29,正常
10010,102,100,2021-07-08 11:05:29,正常
10010,103,100,2021-07-08 11:05:29,正常
10010,106,100,2021-07-08 11:05:29,正常



 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110669 积分:563259 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2021/7/10 9:18:00 [只看该作者]

Dim Cols1() As String = {编码,"EquipmentID",标志,"dt_BeginDate",状态}

……
    For i As Integer = 0 To Cols1.Length -1
        If s > "" Then s = s  & ","
        If DataTables("m_Localizer").DataCols.Contains(Cols1(i)
if  dr.IsNull(Cols1(i)) = False Then
            s =  s  & dr(Cols1(i))
end if
else
s =  s  & Cols1(i)
        End If
    Next
[此贴子已经被作者于2021/7/10 9:21:20编辑过]

 回到顶部