新增如下命令:
SetRecord GetReocrd CombindRecord
This commit is contained in:
@@ -1439,8 +1439,6 @@ Public Class Service1
|
|||||||
_license = New License(licensePath)
|
_license = New License(licensePath)
|
||||||
_license.CheckLicense()
|
_license.CheckLicense()
|
||||||
|
|
||||||
UTS_Core.DebugLog.ApplicationLog.WriteInfoLog($"License Info:{JsonConvert.SerializeObject(_license, Formatting.Indented)}.")
|
|
||||||
|
|
||||||
UTS_Core.DebugLog.ApplicationLog.WriteInfoLog($"CheckLicense Success.")
|
UTS_Core.DebugLog.ApplicationLog.WriteInfoLog($"CheckLicense Success.")
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
UTS_Core.DebugLog.ApplicationLog.WriteErrorLog($"CheckLicense Error:{ex.Message}.")
|
UTS_Core.DebugLog.ApplicationLog.WriteErrorLog($"CheckLicense Error:{ex.Message}.")
|
||||||
@@ -1460,8 +1458,6 @@ Public Class Service1
|
|||||||
|
|
||||||
Dim packet() As Byte = _webPacker.FillPacket(CByte(UtsWebPacket.Commands.UploadTaskStatus), param.ToArray)
|
Dim packet() As Byte = _webPacker.FillPacket(CByte(UtsWebPacket.Commands.UploadTaskStatus), param.ToArray)
|
||||||
SendDataToWeb(_webUdpClient.Client, _webRemoteIP, packet)
|
SendDataToWeb(_webUdpClient.Client, _webRemoteIP, packet)
|
||||||
|
|
||||||
ServiceLog.WriteDebugLog($"UploadAddTask :{JsonConvert.SerializeObject(task)}")
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ Public Class DbSynchronizer
|
|||||||
''' 同步数据库,开始同步
|
''' 同步数据库,开始同步
|
||||||
''' </summary>
|
''' </summary>
|
||||||
Public Sub SyncDatabase()
|
Public Sub SyncDatabase()
|
||||||
ServiceLog.WriteDebugLog($"RemoteConnString:{Parameters.RemoteConnString} LocalConnString:{Parameters.LocalConnString}")
|
|
||||||
|
|
||||||
Using remoteDb As New DbExecutor(Parameters.RemoteType, Parameters.RemoteConnString)
|
Using remoteDb As New DbExecutor(Parameters.RemoteType, Parameters.RemoteConnString)
|
||||||
remoteDb.Open()
|
remoteDb.Open()
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
c3886199ae22c3f880bce6f672a51ae51def76056da39af819cd26fad1c0b813
|
f016d1be56f6fedc61741e9fdbb1f0d49638d13457a53b051aea0362c5491bcc
|
||||||
|
|||||||
@@ -249,3 +249,4 @@ C:\Project\AUTS_Win\bin\Debug\System.Threading.Tasks.Extensions.xml
|
|||||||
C:\Project\AUTS_Win\bin\Debug\K4os.Compression.LZ4.xml
|
C:\Project\AUTS_Win\bin\Debug\K4os.Compression.LZ4.xml
|
||||||
C:\Project\AUTS_Win\bin\Debug\K4os.Hash.xxHash.xml
|
C:\Project\AUTS_Win\bin\Debug\K4os.Hash.xxHash.xml
|
||||||
C:\Project\AUTS_Win\obj\Debug\AUTS_Win.exe.config
|
C:\Project\AUTS_Win\obj\Debug\AUTS_Win.exe.config
|
||||||
|
G:\Git\AUTS\AUTS_Win\obj\Debug\AUTS_Win.exe.config
|
||||||
|
|||||||
Binary file not shown.
@@ -805,34 +805,34 @@ Namespace UTSModule.DbConnect
|
|||||||
''' <param name="filedValues"></param>
|
''' <param name="filedValues"></param>
|
||||||
''' <param name="saveCache"></param>
|
''' <param name="saveCache"></param>
|
||||||
Public Shared Sub UpdateSnListTableToLocal(db As DbExecutor, dbName As String, filedNames As List(Of String), filedValues As List(Of String), Optional saveCache As Boolean = True)
|
Public Shared Sub UpdateSnListTableToLocal(db As DbExecutor, dbName As String, filedNames As List(Of String), filedValues As List(Of String), Optional saveCache As Boolean = True)
|
||||||
Dim timeString As String = $"{result.StartTime:yyyy-MM-dd HH:mm:ss}"
|
'Dim timeString As String = $"{result.StartTime:yyyy-MM-dd HH:mm:ss}"
|
||||||
Dim logResult As Integer = CInt(IIf(result.TestResult = TestResult.TestResultEnum.Pass, 1, 0))
|
'Dim logResult As Integer = CInt(IIf(result.TestResult = TestResult.TestResultEnum.Pass, 1, 0))
|
||||||
Dim a1String As String = ""
|
'Dim a1String As String = ""
|
||||||
|
|
||||||
Dim localDbName As String = UtsFilterDbName(db.DatabaseType, dbName) '过滤库名
|
'Dim localDbName As String = UtsFilterDbName(db.DatabaseType, dbName) '过滤库名
|
||||||
Dim updateString As String = $"`S{Station.SnListOrder}` = '{timeString}',`Result{Station.SnListOrder}` = {logResult}"
|
'Dim updateString As String = $"`S{Station.SnListOrder}` = '{timeString}',`Result{Station.SnListOrder}` = {logResult}"
|
||||||
Dim MoId As String = "-1"
|
'Dim MoId As String = "-1"
|
||||||
'A类型站额外更新组装字段
|
''A类型站额外更新组装字段
|
||||||
If Station.StationType = ProcessStation.StationTypeEnum.Assem Then
|
'If Station.StationType = ProcessStation.StationTypeEnum.Assem Then
|
||||||
'a1String = result.CustomRecord("AssemblySn")
|
' 'a1String = result.CustomRecord("AssemblySn")
|
||||||
updateString &= $",`{SnListTable.ColNames.AssemblySn}` = '{a1String}',`{SnListTable.ColNames.AssemblyTime}` = '{timeString}'"
|
' updateString &= $",`{SnListTable.ColNames.AssemblySn}` = '{a1String}',`{SnListTable.ColNames.AssemblyTime}` = '{timeString}'"
|
||||||
End If
|
'End If
|
||||||
|
|
||||||
Dim condition As String = $"`{SnListTable.ColNames.ProductID}` = '{Station.ParentProject.Index}' and `{SnListTable.ColNames.BarCode}` = '{result.DUT_SN}'"
|
'Dim condition As String = $"`{SnListTable.ColNames.ProductID}` = '{Station.ParentProject.Index}' and `{SnListTable.ColNames.BarCode}` = '{result.DUT_SN}'"
|
||||||
Dim cmdText As String = db.CmdHelper.DbUpdate(localDbName, SnListTable.TableName, updateString, condition)
|
'Dim cmdText As String = db.CmdHelper.DbUpdate(localDbName, SnListTable.TableName, updateString, condition)
|
||||||
db.ExecuteNonQuery(cmdText)
|
'db.ExecuteNonQuery(cmdText)
|
||||||
|
|
||||||
If saveCache Then
|
'If saveCache Then
|
||||||
cmdText = $"Call `{UtsDb.RemotePrivateDb}`.`UpdateSnListBarcode`('{result.DUT_SN}',{Station.SnListOrder},'{timeString}',{logResult},'{a1String}');"
|
' cmdText = $"Call `{UtsDb.RemotePrivateDb}`.`UpdateSnListBarcode`('{result.DUT_SN}',{Station.SnListOrder},'{timeString}',{logResult},'{a1String}');"
|
||||||
'CZH 2023 06 07 增加SN_list MoId
|
' 'CZH 2023 06 07 增加SN_list MoId
|
||||||
If result.CustomRecord.ContainsKey("OrderID") Then
|
' If result.CustomRecord.ContainsKey("OrderID") Then
|
||||||
MoId = result.CustomRecord("OrderID")
|
' MoId = result.CustomRecord("OrderID")
|
||||||
cmdText = $"Call `{dbName}`.`UpdateSnListBarcode_MO`('{result.DUT_SN}',{Station.SnListOrder},'{timeString}',{logResult},'{a1String}',{MoId});"
|
' cmdText = $"Call `{dbName}`.`UpdateSnListBarcode_MO`('{result.DUT_SN}',{Station.SnListOrder},'{timeString}',{logResult},'{a1String}',{MoId});"
|
||||||
End If
|
' End If
|
||||||
''''''''''''''''''
|
' ''''''''''''''''''
|
||||||
|
|
||||||
SaveCmdStringToCacheTable(db, cmdText)
|
' SaveCmdStringToCacheTable(db, cmdText)
|
||||||
End If
|
'End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
Imports UTS_Core.Database
|
|
||||||
Imports UTS_Core.UTSModule
|
|
||||||
Imports UTS_Core.UTSModule.DbConnect
|
|
||||||
Imports UTS_Core.UTSModule.DbTableModel.Customer
|
|
||||||
Imports UTS_Core.UTSModule.Test.Command
|
|
||||||
|
|
||||||
Public Class CombindRecordCommand
|
|
||||||
Inherits TestCommandExecutor
|
|
||||||
|
|
||||||
Private _filedNames As New List(Of String)
|
|
||||||
Private _dutSn As String
|
|
||||||
Private _dutSn2 As String
|
|
||||||
|
|
||||||
Sub New(command As TestCommand)
|
|
||||||
MyBase.New(command)
|
|
||||||
|
|
||||||
_dutSn = command.Parameter(0)
|
|
||||||
_dutSn2 = command.Parameter(1)
|
|
||||||
|
|
||||||
_filedNames.Add(command.Parameter(0))
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Public Overrides Function Execute() As TestCommandReturn
|
|
||||||
CommandReturn.ExecuteResult = True
|
|
||||||
CommandReturn.RecordValue = "True"
|
|
||||||
|
|
||||||
Dim filedName As String = _filedNames(0)
|
|
||||||
Dim updateString As String = $"t1.`{filedName}` = t2.`{filedName}`"
|
|
||||||
For i As Integer = 1 To _filedNames.Count - 1
|
|
||||||
updateString += $",t1.`{filedName}` = t2.`{filedName}` "
|
|
||||||
Next
|
|
||||||
|
|
||||||
|
|
||||||
Dim saveDbCmdText As String = String.Empty
|
|
||||||
Using db As New DbExecutor(UtsDb.RemoteDbType, UtsDb.RemoteConnString)
|
|
||||||
Dim cmdText As String = $"UPDATE `{UtsDb.RemotePrivateDb}`.`{SnListTable.TableName}` t1 JOIN `{UtsDb.RemotePrivateDb}`.`{SnListTable.TableName}` t2 ON t2.`{SnListTable.ColNames.BarCode}` = '{_dutSn2}' SET {updateString} WHERE t1.`{SnListTable.ColNames.BarCode}` = '{_dutSn}';"
|
|
||||||
|
|
||||||
Try
|
|
||||||
db.Open()
|
|
||||||
db.ExecuteNonQuery(cmdText)
|
|
||||||
db.Close()
|
|
||||||
Catch ex As Exception
|
|
||||||
saveDbCmdText = cmdText '云端执行,使用本地执行
|
|
||||||
End Try
|
|
||||||
End Using
|
|
||||||
|
|
||||||
'本地存储
|
|
||||||
Using db As New DbExecutor(UtsDb.LocalDbType, UtsDb.LocalConnString)
|
|
||||||
Try
|
|
||||||
db.Open()
|
|
||||||
Catch ex As Exception
|
|
||||||
CommandReturn.ExecuteResult = False
|
|
||||||
CommandReturn.RecordValue = "False"
|
|
||||||
CommandReturn.ExecuteResultTipString = $"本地数据库连接失败,{ex.Message}"
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Try
|
|
||||||
Dim cmdText As String = $"UPDATE `{SnListTable.TableName}` t1 JOIN `{UtsDb.RemotePrivateDb}`.`{SnListTable.TableName}` t2 ON t2.`{SnListTable.ColNames.BarCode}` = '{_dutSn2}' SET {updateString} WHERE t1.`{SnListTable.ColNames.BarCode}` = '{_dutSn}';"
|
|
||||||
db.ExecuteNonQuery(cmdText)
|
|
||||||
Catch ex As Exception
|
|
||||||
CommandReturn.ExecuteResult = False
|
|
||||||
CommandReturn.RecordValue = "False"
|
|
||||||
CommandReturn.ExecuteResultTipString = $"本地数据库保存失败,{ex.Message}"
|
|
||||||
End Try
|
|
||||||
|
|
||||||
|
|
||||||
'本地缓存
|
|
||||||
Try
|
|
||||||
If String.IsNullOrEmpty(saveDbCmdText) Then
|
|
||||||
DbConnector.SaveCmdStringToCacheTable(db, saveDbCmdText)
|
|
||||||
CommandReturn.ExecuteResultTipString = "本地缓存成功"
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
CommandReturn.ExecuteResult = False
|
|
||||||
CommandReturn.RecordValue = "False"
|
|
||||||
CommandReturn.ExecuteResultTipString = $"本地数据库缓存失败,{ex.Message}"
|
|
||||||
End Try
|
|
||||||
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
End Using
|
|
||||||
|
|
||||||
End Function
|
|
||||||
End Class
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
Namespace UTSModule.Test.Command.DatabaseCommand
|
|
||||||
Public Class DatabaseCommandManager
|
|
||||||
Public Shared Function CreateExecutor(command As TestCommand) As TestCommandExecutor
|
|
||||||
Dim executor As TestCommandExecutor
|
|
||||||
Select Case command.Name
|
|
||||||
Case "GetRecord"
|
|
||||||
Return New GetRecordCommand(command)
|
|
||||||
Case "SetRecord"
|
|
||||||
Return New SetRecordCommand(command)
|
|
||||||
Case "CombindRecord"
|
|
||||||
Return New CombindRecordCommand(command)
|
|
||||||
Case Else
|
|
||||||
Throw New Exception($"Database集,未知命令 :{command.Name}")
|
|
||||||
End Select
|
|
||||||
Return executor
|
|
||||||
End Function
|
|
||||||
End Class
|
|
||||||
End Namespace
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
Imports UTS_Core.Database
|
|
||||||
Imports UTS_Core.UTSModule
|
|
||||||
Imports UTS_Core.UTSModule.DbConnect
|
|
||||||
Imports UTS_Core.UTSModule.DbTableModel.Customer
|
|
||||||
Imports UTS_Core.UTSModule.Test.Command
|
|
||||||
|
|
||||||
Public Class GetRecordCommand
|
|
||||||
Inherits TestCommandExecutor
|
|
||||||
|
|
||||||
Private _filedName As String
|
|
||||||
Private _dutSn As String
|
|
||||||
|
|
||||||
Sub New(command As TestCommand)
|
|
||||||
MyBase.New(command)
|
|
||||||
|
|
||||||
_dutSn = command.Parameter(0)
|
|
||||||
_filedName = command.Parameter(1)
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Public Overrides Function Execute() As TestCommandReturn
|
|
||||||
'优先查询云端
|
|
||||||
Dim useLocalSearch As Boolean = False
|
|
||||||
Using db As New DbExecutor(UtsDb.RemoteDbType, UtsDb.RemoteConnString)
|
|
||||||
Dim condition As String = $"`{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
|
||||||
Dim cmdText As String = db.CmdHelper.DbSearch(UtsDb.RemotePrivateDb, _filedName, SnListTable.TableName, condition)
|
|
||||||
|
|
||||||
Try
|
|
||||||
db.Open()
|
|
||||||
CommandReturn.RecordValue = db.ExecuteScalar(cmdText).ToString()
|
|
||||||
CommandReturn.ExecuteResult = True
|
|
||||||
db.Close()
|
|
||||||
Catch ex As Exception
|
|
||||||
useLocalSearch = True '云端查询失败,使用本地查询
|
|
||||||
End Try
|
|
||||||
End Using
|
|
||||||
|
|
||||||
|
|
||||||
'本地存储
|
|
||||||
If useLocalSearch Then
|
|
||||||
Using db As New DbExecutor(UtsDb.LocalDbType, UtsDb.LocalConnString)
|
|
||||||
Try
|
|
||||||
db.Open()
|
|
||||||
Catch ex As Exception
|
|
||||||
CommandReturn.ExecuteResult = False
|
|
||||||
CommandReturn.RecordValue = ""
|
|
||||||
CommandReturn.ExecuteResultTipString = $"本地数据库连接失败,{ex.Message}"
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Try
|
|
||||||
' Dim condition As String = $"`{SnListTable.ColNames.ProductID}` = '{Station.ParentProject.Index}' and `{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
|
||||||
Dim condition As String = $"`{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
|
||||||
Dim cmdText As String = db.CmdHelper.Search(_filedName, SnListTable.TableName, condition)
|
|
||||||
CommandReturn.RecordValue = db.ExecuteScalar(cmdText).ToString()
|
|
||||||
CommandReturn.ExecuteResult = True
|
|
||||||
CommandReturn.ExecuteResultTipString = $"本地数据库查询成功"
|
|
||||||
Catch ex As Exception
|
|
||||||
CommandReturn.ExecuteResult = False
|
|
||||||
CommandReturn.RecordValue = ""
|
|
||||||
CommandReturn.ExecuteResultTipString = $"本地数据库查询失败,{ex.Message}"
|
|
||||||
End Try
|
|
||||||
|
|
||||||
db.Close()
|
|
||||||
End Using
|
|
||||||
End If
|
|
||||||
|
|
||||||
Return CommandReturn
|
|
||||||
|
|
||||||
|
|
||||||
End Function
|
|
||||||
End Class
|
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
Imports UTS_Core.Database
|
||||||
|
Imports UTS_Core.UTSModule
|
||||||
|
Imports UTS_Core.UTSModule.DbConnect
|
||||||
|
Imports UTS_Core.UTSModule.DbTableModel.Customer
|
||||||
|
Imports UTS_Core.UTSModule.Test.Command
|
||||||
|
Imports System.Linq
|
||||||
|
|
||||||
|
Public Class CombindRecordCommand
|
||||||
|
Inherits TestCommandExecutor
|
||||||
|
|
||||||
|
Private _filedNames As New List(Of String)
|
||||||
|
Private _dutSn As String
|
||||||
|
Private _dutSn2 As String
|
||||||
|
|
||||||
|
Sub New(command As TestCommand)
|
||||||
|
MyBase.New(command)
|
||||||
|
'合并逻辑:将源SN指定字段的值复制到目标SN,如果目标SN已经有值,则进行覆盖操作
|
||||||
|
'如果合并字段名为 S1~S12,则对应的Result1~Result12 也进行合并,即Sx与Resultx配对进行操作
|
||||||
|
'覆盖方向:源SN -》 目标SN’
|
||||||
|
_dutSn = command.Parameter(0) '目标SN’
|
||||||
|
_dutSn2 = command.Parameter(1) '源SN’
|
||||||
|
|
||||||
|
'_filedNames.Add(command.Parameter(2)) '字段名,多个字段名之间用“:”分割,大小写不敏感,去掉前后空格
|
||||||
|
|
||||||
|
'Dim upperArr = arr.Select(Function(x) x.ToUpper()).ToArray()
|
||||||
|
' upperArr = {"A", "B", "C"}
|
||||||
|
|
||||||
|
_filedNames.AddRange(command.Parameter(2).Split(":"c).Select(Function(x) x.Trim()))
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Overrides Function Execute() As TestCommandReturn
|
||||||
|
CommandReturn.ExecuteResult = True
|
||||||
|
CommandReturn.RecordValue = "True"
|
||||||
|
|
||||||
|
Dim filedName As String = _filedNames(0)
|
||||||
|
Dim updateString As String = $"t1.`{filedName}` = t2.`{filedName}`"
|
||||||
|
For i As Integer = 1 To _filedNames.Count - 1
|
||||||
|
filedName = _filedNames(i)
|
||||||
|
updateString += $",t1.`{filedName}` = t2.`{filedName}` "
|
||||||
|
Next
|
||||||
|
|
||||||
|
|
||||||
|
Dim saveDbCmdText As String = String.Empty
|
||||||
|
Using db As New DbExecutor(UtsDb.RemoteDbType, UtsDb.RemoteConnString)
|
||||||
|
Dim cmdText As String = $"UPDATE `{UtsDb.RemotePrivateDb}`.`{SnListTable.TableName}` t1 JOIN `{UtsDb.RemotePrivateDb}`.`{SnListTable.TableName}` t2 On t2.`{SnListTable.ColNames.BarCode}` = '{_dutSn2}' SET {updateString} WHERE t1.`{SnListTable.ColNames.BarCode}` = '{_dutSn}';"
|
||||||
|
|
||||||
|
Try
|
||||||
|
db.Open()
|
||||||
|
db.ExecuteNonQuery(cmdText)
|
||||||
|
db.Close()
|
||||||
|
Catch ex As Exception
|
||||||
|
|
||||||
|
CommandReturn.ExecuteResult = False
|
||||||
|
CommandReturn.RecordValue = "False"
|
||||||
|
CommandReturn.ExecuteResultTipString = $"数据库更新失败,{ex.Message}"
|
||||||
|
End Try
|
||||||
|
End Using
|
||||||
|
|
||||||
|
''本地存储
|
||||||
|
'Using db As New DbExecutor(UtsDb.LocalDbType, UtsDb.LocalConnString)
|
||||||
|
' Try
|
||||||
|
' db.Open()
|
||||||
|
' Catch ex As Exception
|
||||||
|
' CommandReturn.ExecuteResult = False
|
||||||
|
' CommandReturn.RecordValue = "False"
|
||||||
|
' CommandReturn.ExecuteResultTipString = $"本地数据库连接失败,{ex.Message}"
|
||||||
|
' End Try
|
||||||
|
|
||||||
|
' Try
|
||||||
|
' Dim cmdText As String = $"UPDATE `{SnListTable.TableName}` t1 JOIN `{UtsDb.RemotePrivateDb}`.`{SnListTable.TableName}` t2 ON t2.`{SnListTable.ColNames.BarCode}` = '{_dutSn2}' SET {updateString} WHERE t1.`{SnListTable.ColNames.BarCode}` = '{_dutSn}';"
|
||||||
|
' db.ExecuteNonQuery(cmdText)
|
||||||
|
' Catch ex As Exception
|
||||||
|
' CommandReturn.ExecuteResult = False
|
||||||
|
' CommandReturn.RecordValue = "False"
|
||||||
|
' CommandReturn.ExecuteResultTipString = $"本地数据库保存失败,{ex.Message}"
|
||||||
|
' End Try
|
||||||
|
|
||||||
|
|
||||||
|
' '本地缓存
|
||||||
|
' Try
|
||||||
|
' If Not String.IsNullOrEmpty(saveDbCmdText) Then
|
||||||
|
' DbConnector.SaveCmdStringToCacheTable(db, saveDbCmdText)
|
||||||
|
' CommandReturn.ExecuteResultTipString = "本地缓存成功"
|
||||||
|
' End If
|
||||||
|
' Catch ex As Exception
|
||||||
|
' CommandReturn.ExecuteResult = False
|
||||||
|
' CommandReturn.RecordValue = "False"
|
||||||
|
' CommandReturn.ExecuteResultTipString = $"本地数据库缓存失败,{ex.Message}"
|
||||||
|
' End Try
|
||||||
|
|
||||||
|
|
||||||
|
' db.Close()
|
||||||
|
'End Using
|
||||||
|
|
||||||
|
Return CommandReturn
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
Imports UTS_Core.Database
|
||||||
|
Imports UTS_Core.UTSModule
|
||||||
|
Imports UTS_Core.UTSModule.DbTableModel.Customer
|
||||||
|
Imports UTS_Core.UTSModule.Test.Command
|
||||||
|
|
||||||
|
Public Class GetRecordCommand
|
||||||
|
Inherits TestCommandExecutor
|
||||||
|
|
||||||
|
Private _filedName As String
|
||||||
|
Private _dutSn As String
|
||||||
|
Private _mode As String
|
||||||
|
|
||||||
|
Private _LowerLimit As String = ""
|
||||||
|
Private _UpperLimit As String = ""
|
||||||
|
Private _stringLen_LowwerLimit As String = ""
|
||||||
|
Private _stringLen_UpperLimit As String = ""
|
||||||
|
Private _Char_VerfiyMode As String = ""
|
||||||
|
|
||||||
|
Sub New(command As TestCommand)
|
||||||
|
MyBase.New(command)
|
||||||
|
|
||||||
|
_dutSn = command.Parameter(0)
|
||||||
|
_filedName = command.Parameter(1)
|
||||||
|
_mode = command.Parameter(2) 'Local:只查询本地 Remote:只查询云端 Both:查询本地和云端(云端优先)
|
||||||
|
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub GetByLocal()
|
||||||
|
Using db As New DbExecutor(UtsDb.LocalDbType, UtsDb.LocalConnString)
|
||||||
|
Try
|
||||||
|
db.Open()
|
||||||
|
Catch ex As Exception
|
||||||
|
CommandReturn.ExecuteResult = False
|
||||||
|
CommandReturn.RecordValue = ""
|
||||||
|
CommandReturn.ExecuteResultTipString = $"本地数据库连接失败,{ex.Message}"
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Try
|
||||||
|
' Dim condition As String = $"`{SnListTable.ColNames.ProductID}` = '{Station.ParentProject.Index}' and `{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
||||||
|
Dim condition As String = $"`{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
||||||
|
Dim cmdText As String = db.CmdHelper.Search(_filedName, SnListTable.TableName, condition)
|
||||||
|
CommandReturn.RecordValue = db.ExecuteScalar(cmdText).ToString()
|
||||||
|
CommandReturn.ExecuteResult = True
|
||||||
|
CommandReturn.ExecuteResultTipString = $"本地数据库查询成功"
|
||||||
|
Catch ex As Exception
|
||||||
|
CommandReturn.ExecuteResult = False
|
||||||
|
CommandReturn.RecordValue = ""
|
||||||
|
CommandReturn.ExecuteResultTipString = $"本地数据库查询失败,{ex.Message}"
|
||||||
|
End Try
|
||||||
|
|
||||||
|
db.Close()
|
||||||
|
End Using
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Private Function GetByRemote() As Boolean
|
||||||
|
Dim useLocalSearch As Boolean = False
|
||||||
|
|
||||||
|
|
||||||
|
Using db As New DbExecutor(UtsDb.RemoteDbType, UtsDb.RemoteConnString)
|
||||||
|
Dim condition As String = $"`{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
||||||
|
Dim cmdText As String = db.CmdHelper.DbSearch(UtsDb.RemotePrivateDb, _filedName, SnListTable.TableName, condition)
|
||||||
|
|
||||||
|
Try
|
||||||
|
db.Open()
|
||||||
|
CommandReturn.RecordValue = db.ExecuteScalar(cmdText).ToString()
|
||||||
|
CommandReturn.ExecuteResult = True
|
||||||
|
db.Close()
|
||||||
|
Catch ex As Exception
|
||||||
|
useLocalSearch = True '云端查询失败,使用本地查询
|
||||||
|
End Try
|
||||||
|
End Using
|
||||||
|
|
||||||
|
Return useLocalSearch
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
Public Overrides Function Execute() As TestCommandReturn
|
||||||
|
Select Case _mode
|
||||||
|
Case "Local", "0"
|
||||||
|
GetByLocal()
|
||||||
|
Case "Both", "2"
|
||||||
|
If GetByRemote() = False Then GetByLocal()
|
||||||
|
|
||||||
|
Case "Remote", "1"
|
||||||
|
GetByRemote()
|
||||||
|
Case Else
|
||||||
|
GetByRemote()
|
||||||
|
End Select
|
||||||
|
|
||||||
|
'todo:数据验证
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
''优先查询云端
|
||||||
|
'Dim useLocalSearch As Boolean = False
|
||||||
|
'Using db As New DbExecutor(UtsDb.RemoteDbType, UtsDb.RemoteConnString)
|
||||||
|
' Dim condition As String = $"`{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
||||||
|
' Dim cmdText As String = db.CmdHelper.DbSearch(UtsDb.RemotePrivateDb, _filedName, SnListTable.TableName, condition)
|
||||||
|
|
||||||
|
' Try
|
||||||
|
' db.Open()
|
||||||
|
' CommandReturn.RecordValue = db.ExecuteScalar(cmdText).ToString()
|
||||||
|
' CommandReturn.ExecuteResult = True
|
||||||
|
' db.Close()
|
||||||
|
' Catch ex As Exception
|
||||||
|
' useLocalSearch = True '云端查询失败,使用本地查询
|
||||||
|
' End Try
|
||||||
|
'End Using
|
||||||
|
|
||||||
|
|
||||||
|
''本地存储
|
||||||
|
'If useLocalSearch Then
|
||||||
|
' Using db As New DbExecutor(UtsDb.LocalDbType, UtsDb.LocalConnString)
|
||||||
|
' Try
|
||||||
|
' db.Open()
|
||||||
|
' Catch ex As Exception
|
||||||
|
' CommandReturn.ExecuteResult = False
|
||||||
|
' CommandReturn.RecordValue = ""
|
||||||
|
' CommandReturn.ExecuteResultTipString = $"本地数据库连接失败,{ex.Message}"
|
||||||
|
' End Try
|
||||||
|
|
||||||
|
' Try
|
||||||
|
' ' Dim condition As String = $"`{SnListTable.ColNames.ProductID}` = '{Station.ParentProject.Index}' and `{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
||||||
|
' Dim condition As String = $"`{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
||||||
|
' Dim cmdText As String = db.CmdHelper.Search(_filedName, SnListTable.TableName, condition)
|
||||||
|
' CommandReturn.RecordValue = db.ExecuteScalar(cmdText).ToString()
|
||||||
|
' CommandReturn.ExecuteResult = True
|
||||||
|
' CommandReturn.ExecuteResultTipString = $"本地数据库查询成功"
|
||||||
|
' Catch ex As Exception
|
||||||
|
' CommandReturn.ExecuteResult = False
|
||||||
|
' CommandReturn.RecordValue = ""
|
||||||
|
' CommandReturn.ExecuteResultTipString = $"本地数据库查询失败,{ex.Message}"
|
||||||
|
' End Try
|
||||||
|
|
||||||
|
' db.Close()
|
||||||
|
' End Using
|
||||||
|
'End If
|
||||||
|
|
||||||
|
Return CommandReturn
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
@@ -19,7 +19,7 @@ Public Class SetRecordCommand
|
|||||||
_filedName = command.Parameter(1)
|
_filedName = command.Parameter(1)
|
||||||
_filedValue = command.Parameter(2)
|
_filedValue = command.Parameter(2)
|
||||||
|
|
||||||
|
'todo:SetRecord 只能对自定义字段进行写入,保护字段不执行’
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Overrides Function Execute() As TestCommandReturn
|
Public Overrides Function Execute() As TestCommandReturn
|
||||||
@@ -67,7 +67,7 @@ Public Class SetRecordCommand
|
|||||||
|
|
||||||
'本地缓存
|
'本地缓存
|
||||||
Try
|
Try
|
||||||
If String.IsNullOrEmpty(saveDbCmdText) Then
|
If Not String.IsNullOrEmpty(saveDbCmdText) Then
|
||||||
DbConnector.SaveCmdStringToCacheTable(db, saveDbCmdText)
|
DbConnector.SaveCmdStringToCacheTable(db, saveDbCmdText)
|
||||||
CommandReturn.ExecuteResultTipString = "本地缓存成功"
|
CommandReturn.ExecuteResultTipString = "本地缓存成功"
|
||||||
End If
|
End If
|
||||||
@@ -21,6 +21,12 @@
|
|||||||
executor = New GetDBDataExecutor(command)
|
executor = New GetDBDataExecutor(command)
|
||||||
Case "Call"
|
Case "Call"
|
||||||
executor = New CallExecutor(command)
|
executor = New CallExecutor(command)
|
||||||
|
Case "GetRecord"
|
||||||
|
Return New GetRecordCommand(command)
|
||||||
|
Case "SetRecord"
|
||||||
|
Return New SetRecordCommand(command)
|
||||||
|
Case "CombindRecord"
|
||||||
|
Return New CombindRecordCommand(command)
|
||||||
Case Else
|
Case Else
|
||||||
Throw New Exception($"System集,未知命令 :{command.Name}")
|
Throw New Exception($"System集,未知命令 :{command.Name}")
|
||||||
End Select
|
End Select
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
Imports UTS_Core.UTSModule.Test.Command.ComPortCommand
|
Imports UTS_Core.UTSModule.Test.Command.ComPortCommand
|
||||||
|
Imports UTS_Core.UTSModule.Test.Command.ConverterCommand
|
||||||
Imports UTS_Core.UTSModule.Test.Command.ProcessCommand
|
Imports UTS_Core.UTSModule.Test.Command.ProcessCommand
|
||||||
Imports UTS_Core.UTSModule.Test.Command.SystemCommand
|
Imports UTS_Core.UTSModule.Test.Command.SystemCommand
|
||||||
Imports UTS_Core.UTSModule.Test.Command.UtsComPortCommand
|
Imports UTS_Core.UTSModule.Test.Command.UtsComPortCommand
|
||||||
Imports UTS_Core.UTSModule.Test.Command.ConverterCommand
|
|
||||||
|
|
||||||
Namespace UTSModule.Test.Command
|
Namespace UTSModule.Test.Command
|
||||||
Public Class TestCommandManger
|
Public Class TestCommandManger
|
||||||
|
|||||||
@@ -342,10 +342,9 @@
|
|||||||
<Compile Include="UTSModule\Test\Command\ConverterCommand\GetValueExecutor.vb" />
|
<Compile Include="UTSModule\Test\Command\ConverterCommand\GetValueExecutor.vb" />
|
||||||
<Compile Include="UTSModule\Test\Command\ConverterCommand\CompareExecutor.vb" />
|
<Compile Include="UTSModule\Test\Command\ConverterCommand\CompareExecutor.vb" />
|
||||||
<Compile Include="UTSModule\Test\Command\ConverterCommand\SubStringExecutor.vb" />
|
<Compile Include="UTSModule\Test\Command\ConverterCommand\SubStringExecutor.vb" />
|
||||||
<Compile Include="UTSModule\Test\Command\DatabaseCommand\CombindRecordCommand.vb" />
|
<Compile Include="UTSModule\Test\Command\SystemCommand\CombindRecordCommand.vb" />
|
||||||
<Compile Include="UTSModule\Test\Command\DatabaseCommand\DatabaseCommandManager.vb" />
|
<Compile Include="UTSModule\Test\Command\SystemCommand\GetRecordCommand.vb" />
|
||||||
<Compile Include="UTSModule\Test\Command\DatabaseCommand\GetRecordCommand.vb" />
|
<Compile Include="UTSModule\Test\Command\SystemCommand\SetRecordCommand.vb" />
|
||||||
<Compile Include="UTSModule\Test\Command\DatabaseCommand\SetRecordCommand.vb" />
|
|
||||||
<Compile Include="UTSModule\Test\Command\ProcessCommand\ProcessCommandManager.vb" />
|
<Compile Include="UTSModule\Test\Command\ProcessCommand\ProcessCommandManager.vb" />
|
||||||
<Compile Include="UTSModule\Test\Command\ProcessCommand\ProcessExecuteExecutor.vb" />
|
<Compile Include="UTSModule\Test\Command\ProcessCommand\ProcessExecuteExecutor.vb" />
|
||||||
<Compile Include="UTSModule\Test\Command\SystemCommand\CallExecutor.vb" />
|
<Compile Include="UTSModule\Test\Command\SystemCommand\CallExecutor.vb" />
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
|||||||
34de90036f057f2c0b29d8bef1e24cf1ba7a80e898f2f80e37d38e472d36018d
|
bc36b2673dd91a86b3284d3625ed2d97a7b0a0f3bbce3b71f7327a4440c08219
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user