新增snlist三条命令
This commit is contained in:
@@ -734,7 +734,7 @@ Namespace UTSModule.DbConnect
|
||||
Dim sqlText As String = $"Call `{dbName}`.`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("InternalNo") And result.TestResult = TestResult.TestResultEnum.Pass Then
|
||||
MoId = result.CustomRecord("OrderID")
|
||||
sqlText = $"Call `{dbName}`.`UpdateSnListBarcode_MO`('{result.DUT_SN}',{station.SnListOrder},'{timeString}',{logResult},'{a1String}',{MoId});"
|
||||
@@ -764,7 +764,7 @@ Namespace UTSModule.DbConnect
|
||||
Dim MoId As String = "-1"
|
||||
'A类型站额外更新组装字段
|
||||
If station.StationType = ProcessStation.StationTypeEnum.Assem Then
|
||||
‘a1String = result.CustomRecord("AssemblySn")
|
||||
'a1String = result.CustomRecord("AssemblySn")
|
||||
updateString &= $",`{SnListTable.ColNames.AssemblySn}` = '{a1String}',`{SnListTable.ColNames.AssemblyTime}` = '{timeString}'"
|
||||
End If
|
||||
|
||||
@@ -774,7 +774,7 @@ Namespace UTSModule.DbConnect
|
||||
|
||||
If saveCache Then
|
||||
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
|
||||
MoId = result.CustomRecord("OrderID")
|
||||
cmdText = $"Call `{dbName}`.`UpdateSnListBarcode_MO`('{result.DUT_SN}',{station.SnListOrder},'{timeString}',{logResult},'{a1String}',{MoId});"
|
||||
@@ -796,6 +796,46 @@ Namespace UTSModule.DbConnect
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 更新SNList表指定字段名称的值
|
||||
''' </summary>
|
||||
''' <param name="db"></param>
|
||||
''' <param name="dbName"></param>
|
||||
''' <param name="filedNames"></param>
|
||||
''' <param name="filedValues"></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)
|
||||
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 a1String As String = ""
|
||||
|
||||
Dim localDbName As String = UtsFilterDbName(db.DatabaseType, dbName) '过滤库名
|
||||
Dim updateString As String = $"`S{Station.SnListOrder}` = '{timeString}',`Result{Station.SnListOrder}` = {logResult}"
|
||||
Dim MoId As String = "-1"
|
||||
'A类型站额外更新组装字段
|
||||
If Station.StationType = ProcessStation.StationTypeEnum.Assem Then
|
||||
'a1String = result.CustomRecord("AssemblySn")
|
||||
updateString &= $",`{SnListTable.ColNames.AssemblySn}` = '{a1String}',`{SnListTable.ColNames.AssemblyTime}` = '{timeString}'"
|
||||
End If
|
||||
|
||||
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)
|
||||
db.ExecuteNonQuery(cmdText)
|
||||
|
||||
If saveCache Then
|
||||
cmdText = $"Call `{UtsDb.RemotePrivateDb}`.`UpdateSnListBarcode`('{result.DUT_SN}',{Station.SnListOrder},'{timeString}',{logResult},'{a1String}');"
|
||||
'CZH 2023 06 07 增加SN_list MoId
|
||||
If result.CustomRecord.ContainsKey("OrderID") Then
|
||||
MoId = result.CustomRecord("OrderID")
|
||||
cmdText = $"Call `{dbName}`.`UpdateSnListBarcode_MO`('{result.DUT_SN}',{Station.SnListOrder},'{timeString}',{logResult},'{a1String}',{MoId});"
|
||||
End If
|
||||
''''''''''''''''''
|
||||
|
||||
SaveCmdStringToCacheTable(db, cmdText)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 更新本地SN总表的测试记录(用于处理组播写入Sn总表操作)
|
||||
''' </summary>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
Imports System.Diagnostics.Eventing.Reader
|
||||
Imports System.Drawing
|
||||
Imports System.Web.UI.WebControls
|
||||
Imports System.Drawing
|
||||
Imports System.Windows.Forms
|
||||
Imports FlexCell
|
||||
Imports FluentFTP
|
||||
Imports UTS_Core.UTSModule.Production
|
||||
Imports UTS_Core.UTSModule.Test.Command
|
||||
Imports UTS_Core.UTSModule.Test.StatusMonitor
|
||||
@@ -2050,7 +2047,6 @@ Namespace UTSModule.Station
|
||||
Public Sub Grid_RowNodeTextChanged(sender As Object, e As RowNodeChangedEventArgs)
|
||||
Dim row As Integer = e.Node.RowListIndex
|
||||
Dim node As RowNode = e.Node
|
||||
Dim cmd As ICommand
|
||||
|
||||
_uploading = True
|
||||
With _grd
|
||||
@@ -2103,15 +2099,6 @@ Namespace UTSModule.Station
|
||||
End With
|
||||
OnUserAction(e.BeforeNode)
|
||||
OnUserActionEnd(e.Node)
|
||||
'If CommandManager.IsRuning = False Then
|
||||
|
||||
|
||||
' Dim dic As New Dictionary(Of Integer, TextChangedRowNode) From {
|
||||
' {row, New TextChangedRowNode With {.BeforeRowNode = e.BeforeNode.Clone, .AfterRowNode = e.Node.Clone}}
|
||||
' }
|
||||
' CommandManager.AddUndoCommand(New GridNodeTextChangedCommand(Me, dic))
|
||||
' RaiseEvent PlanGridCommandChanged(Nothing, Nothing)
|
||||
'End If
|
||||
|
||||
StationEditStatusMonitor.StationEditStatus = StationEditStatusMonitor.StationEditStatusEnum.Changed
|
||||
|
||||
|
||||
@@ -1,279 +0,0 @@
|
||||
Namespace UTSModule.Test.Command
|
||||
''' <summary>
|
||||
''' UTS串口通讯返回值比较函数静态类
|
||||
''' </summary>
|
||||
Public Class CompareFunction
|
||||
|
||||
#Region "String"
|
||||
''' <summary>
|
||||
''' 仅一个参数字符串比较,忽略大小写
|
||||
''' </summary>
|
||||
''' <param name="testReturn">测试命令返回集合</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function StringCompare(testReturn As TestCommandReturn) As Boolean
|
||||
Return StringCompare(testReturn.RecordValue, testReturn.LowerLimit, testReturn.UpperLimit)
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 仅一个参数字符串是否包含关系,忽略大小写,下限则为目标字符串包含下限,上限则为上限字符串包含目标字符串
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Shared Function StringContain(value As String, lowerLimit As String, upperLimit As String) As Boolean
|
||||
Dim result As Boolean = True
|
||||
|
||||
If String.IsNullOrWhiteSpace(lowerLimit) = False Then '需要比较下限
|
||||
If value.Contains(lowerLimit) = False Then '不符合条件
|
||||
result = False
|
||||
Return result '失败则不用比较上限
|
||||
End If
|
||||
End If
|
||||
|
||||
If String.IsNullOrWhiteSpace(upperLimit) = False Then '需要比较上限
|
||||
If upperLimit.Contains(value) = False Then '不符合条件
|
||||
result = False
|
||||
End If
|
||||
End If
|
||||
|
||||
Return result
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 仅一个参数字符串比较,忽略大小写
|
||||
''' </summary>
|
||||
''' <param name="value">当前值</param>
|
||||
''' <param name="lowerLimit">下限</param>
|
||||
''' <param name="upperLimit">上限</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function StringCompare(value As String, lowerLimit As String, upperLimit As String) As Boolean
|
||||
Dim result As Boolean = True
|
||||
|
||||
If String.IsNullOrWhiteSpace(lowerLimit) = False Then '需要比较下限
|
||||
If String.Compare(value, lowerLimit, True) < 0 Then '不符合条件
|
||||
result = False
|
||||
Return result '失败则不用比较上限
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If String.IsNullOrWhiteSpace(upperLimit) = False Then '需要比较上限
|
||||
If String.Compare(value, upperLimit, True) > 0 Then '不符合条件
|
||||
result = False
|
||||
End If
|
||||
End If
|
||||
|
||||
Return result
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 多参数字符串列表比较上下限
|
||||
''' </summary>
|
||||
''' <param name="param">参数列表</param>
|
||||
''' <param name="lowerLimit">下限字符串,切割时按冒号切割,位数不足则默认不比较</param>
|
||||
''' <param name="upperLimit">上限字符串,切割时按冒号切割,位数不足则默认不比较</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function ParamStringListCompare(param As List(Of String), lowerLimit As String, upperLimit As String) As Boolean
|
||||
Dim lowerList As String() = lowerLimit.Split(":"c)
|
||||
Dim upperList As String() = upperLimit.Split(":"c)
|
||||
Dim lower As String
|
||||
Dim upper As String
|
||||
|
||||
If param.Count() = 0 Then
|
||||
If StringCompare("", lowerList(0), upperList(0)) = False Then Return False
|
||||
End If
|
||||
|
||||
For i As Integer = 0 To param.Count - 1
|
||||
If i = lowerList.Count() Then
|
||||
lower = String.Empty
|
||||
Else
|
||||
lower = lowerList(i)
|
||||
End If
|
||||
|
||||
If i = upperList.Count() Then
|
||||
upper = String.Empty
|
||||
Else
|
||||
upper = upperList(i)
|
||||
End If
|
||||
|
||||
|
||||
If StringCompare(param(i), lower, upper) = False Then Return False
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Double"
|
||||
''' <summary>
|
||||
''' 浮点型比较方式
|
||||
''' </summary>
|
||||
''' <param name="testReturn"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function DoubleCompare(testReturn As TestCommandReturn) As Boolean
|
||||
|
||||
Return DoubleCompare(testReturn.RecordValue, testReturn.LowerLimit, testReturn.UpperLimit)
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 仅一个参数浮点型比较
|
||||
''' </summary>
|
||||
''' <param name="value">当前值</param>
|
||||
''' <param name="lowerLimit">下限</param>
|
||||
''' <param name="upperLimit">上限</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function DoubleCompare(value As String, lowerLimit As String, upperLimit As String) As Boolean
|
||||
Dim result As Boolean = True
|
||||
|
||||
Dim compareLower As Boolean = IsNumeric(lowerLimit)
|
||||
Dim compareUpper As Boolean = IsNumeric(upperLimit)
|
||||
|
||||
If IsNumeric(value) = False Then
|
||||
If compareLower OrElse compareUpper Then result = False
|
||||
Else
|
||||
Dim val As Double = CDbl(value)
|
||||
|
||||
If compareLower Then
|
||||
If val < CDbl(lowerLimit) Then
|
||||
result = False
|
||||
Return result '失败则不用比较上限
|
||||
End If
|
||||
End If
|
||||
|
||||
If compareUpper Then
|
||||
If val > CDbl(upperLimit) Then result = False
|
||||
End If
|
||||
End If
|
||||
|
||||
Return result
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 多参数浮点型列表比较上下限
|
||||
''' </summary>
|
||||
''' <param name="param">参数列表</param>
|
||||
''' <param name="lowerLimit">下限字符串,切割时按冒号切割,位数不足则默认不比较</param>
|
||||
''' <param name="upperLimit">上限字符串,切割时按冒号切割,位数不足则默认不比较</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function ParamDoubleListCompare(param As List(Of String), lowerLimit As String, upperLimit As String) As Boolean
|
||||
Dim lowerList As String() = lowerLimit.Split(":"c)
|
||||
Dim upperList As String() = upperLimit.Split(":"c)
|
||||
Dim lower As String
|
||||
Dim upper As String
|
||||
|
||||
If param.Count = 0 Then
|
||||
If DoubleCompare("", lowerList(0), upperList(0)) = False Then Return False
|
||||
End If
|
||||
|
||||
For i As Integer = 0 To param.Count - 1
|
||||
If i = lowerList.Count() Then
|
||||
lower = String.Empty
|
||||
Else
|
||||
lower = lowerList(i)
|
||||
End If
|
||||
|
||||
If i = upperList.Count() Then
|
||||
upper = String.Empty
|
||||
Else
|
||||
upper = upperList(i)
|
||||
End If
|
||||
|
||||
|
||||
If DoubleCompare(param(i), lower, upper) = False Then Return False
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Integer"
|
||||
''' <summary>
|
||||
''' 整数型比较方式
|
||||
''' </summary>
|
||||
''' <param name="testReturn"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function IntegerCompare(testReturn As TestCommandReturn) As Boolean
|
||||
|
||||
Return IntegerCompare(testReturn.RecordValue, testReturn.LowerLimit, testReturn.UpperLimit)
|
||||
End Function
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 仅一个参数整数比较,忽略大小写
|
||||
''' </summary>
|
||||
''' <param name="value">当前值</param>
|
||||
''' <param name="lowerLimit">下限</param>
|
||||
''' <param name="upperLimit">上限</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function IntegerCompare(value As String, lowerLimit As String, upperLimit As String) As Boolean
|
||||
Dim result As Boolean = True
|
||||
|
||||
Dim compareLower As Boolean = IsNumeric(lowerLimit)
|
||||
Dim compareUpper As Boolean = IsNumeric(upperLimit)
|
||||
|
||||
If IsNumeric(value) = False Then
|
||||
If compareLower OrElse compareUpper Then result = False
|
||||
Else
|
||||
Dim val As Double = CInt(value)
|
||||
|
||||
If compareLower Then
|
||||
If val < CInt(lowerLimit) Then
|
||||
result = False
|
||||
Return result '失败则不用比较上限
|
||||
End If
|
||||
End If
|
||||
|
||||
If compareUpper Then
|
||||
If val > CInt(upperLimit) Then result = False
|
||||
End If
|
||||
End If
|
||||
|
||||
Return result
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 多参数整数型列表比较上下限
|
||||
''' </summary>
|
||||
''' <param name="param">参数列表</param>
|
||||
''' <param name="lowerLimit">下限字符串,切割时按冒号切割,位数不足则默认不比较</param>
|
||||
''' <param name="upperLimit">上限字符串,切割时按冒号切割,位数不足则默认不比较</param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function ParamIntegerListCompare(param As List(Of String), lowerLimit As String, upperLimit As String) As Boolean
|
||||
Dim lowerList As String() = lowerLimit.Split(":"c)
|
||||
Dim upperList As String() = upperLimit.Split(":"c)
|
||||
Dim lower As String
|
||||
Dim upper As String
|
||||
|
||||
If param.Count = 0 Then
|
||||
If IntegerCompare("", lowerList(0), upperList(0)) = False Then Return False
|
||||
End If
|
||||
|
||||
For i As Integer = 0 To param.Count - 1
|
||||
If i = lowerList.Count() Then
|
||||
lower = String.Empty
|
||||
Else
|
||||
lower = lowerList(i)
|
||||
End If
|
||||
|
||||
If i = upperList.Count() Then
|
||||
upper = String.Empty
|
||||
Else
|
||||
upper = upperList(i)
|
||||
End If
|
||||
|
||||
|
||||
If IntegerCompare(param(i), lower, upper) = False Then Return False
|
||||
Next
|
||||
|
||||
Return True
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
End Namespace
|
||||
@@ -0,0 +1,20 @@
|
||||
Imports UTS_Core.UTSModule.Test.Command
|
||||
|
||||
Public Class CombindRecordCommand
|
||||
Inherits TestCommandExecutor
|
||||
|
||||
Sub New(command As TestCommand)
|
||||
MyBase.New(command)
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Function Execute() As TestCommandReturn
|
||||
'链接本地库
|
||||
'获取本地库数据
|
||||
|
||||
'链接云端库
|
||||
'获取云端库数据
|
||||
'失败则写入同步表格
|
||||
End Function
|
||||
End Class
|
||||
@@ -0,0 +1,18 @@
|
||||
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
|
||||
@@ -0,0 +1,25 @@
|
||||
Imports UTS_Core.UTSModule.Test.Command
|
||||
|
||||
Public Class GetRecordCommand
|
||||
Inherits TestCommandExecutor
|
||||
|
||||
|
||||
Private _sn As String
|
||||
Private dbFiledName As String
|
||||
|
||||
Sub New(command As TestCommand)
|
||||
MyBase.New(command)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Function Execute() As TestCommandReturn
|
||||
'链接云端库
|
||||
'获取云端库数据
|
||||
|
||||
|
||||
'链接本地库
|
||||
'获取本地库数据
|
||||
|
||||
|
||||
End Function
|
||||
End Class
|
||||
@@ -0,0 +1,19 @@
|
||||
Imports UTS_Core.UTSModule.Test.Command
|
||||
|
||||
Public Class SetRecordCommand
|
||||
Inherits TestCommandExecutor
|
||||
|
||||
Sub New(command As TestCommand)
|
||||
MyBase.New(command)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Function Execute() As TestCommandReturn
|
||||
'链接本地库
|
||||
'获取本地库数据
|
||||
|
||||
'链接云端库
|
||||
'获取云端库数据
|
||||
'失败则写入同步表格
|
||||
End Function
|
||||
End Class
|
||||
@@ -0,0 +1,84 @@
|
||||
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
|
||||
@@ -3,10 +3,14 @@
|
||||
Public Shared Function CreateExecutor(command As TestCommand) As TestCommandExecutor
|
||||
Dim executor As TestCommandExecutor
|
||||
Select Case command.Name
|
||||
Case "Get_DB_Data"
|
||||
executor = New CheckUtsPlatformExecutor(command)
|
||||
Case "GetRecord"
|
||||
Return New GetRecordCommand(command)
|
||||
Case "SetRecord"
|
||||
Return New SetRecordCommand(command)
|
||||
Case "CombindRecord"
|
||||
Return New CombindRecordCommand(command)
|
||||
Case Else
|
||||
Throw New Exception($"System集,未知命令 :{command.Name}")
|
||||
Throw New Exception($"Database集,未知命令 :{command.Name}")
|
||||
End Select
|
||||
Return executor
|
||||
End Function
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
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,86 @@
|
||||
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 SetRecordCommand
|
||||
Inherits TestCommandExecutor
|
||||
|
||||
Private _filedName As String
|
||||
Private _filedValue As String
|
||||
Private _dutSn As String
|
||||
|
||||
|
||||
Sub New(command As TestCommand)
|
||||
MyBase.New(command)
|
||||
|
||||
_dutSn = command.Parameter(0)
|
||||
_filedName = command.Parameter(1)
|
||||
_filedValue = command.Parameter(2)
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Public Overrides Function Execute() As TestCommandReturn
|
||||
CommandReturn.ExecuteResult = True
|
||||
CommandReturn.RecordValue = "True"
|
||||
|
||||
'优先储存云端
|
||||
Dim saveDbCmdText As String = String.Empty
|
||||
Using db As New DbExecutor(UtsDb.RemoteDbType, UtsDb.RemoteConnString)
|
||||
Dim updateString As String = $"`{_filedName}` = {_filedValue}"
|
||||
Dim condition As String = $"`{SnListTable.ColNames.BarCode}` = '{_dutSn}'"
|
||||
Dim cmdText As String = db.CmdHelper.DbUpdate(UtsDb.RemotePrivateDb, SnListTable.TableName, updateString, condition)
|
||||
|
||||
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 updateString As String = $"`{_filedName}` = {_filedValue}"
|
||||
' 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.Update(SnListTable.TableName, updateString, condition)
|
||||
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
|
||||
|
||||
Return CommandReturn
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user