初始化项目
This commit is contained in:
312
BLV_Studio/FrmReleaseFirmware.vb
Normal file
312
BLV_Studio/FrmReleaseFirmware.vb
Normal file
@@ -0,0 +1,312 @@
|
||||
Imports System.IO
|
||||
Imports System.Security.Cryptography
|
||||
|
||||
Public Class HotelConfigurationLogic
|
||||
Public InsertFirmware As New Dictionary(Of String, String)
|
||||
Public InsertFirmwareV4 As New Dictionary(Of String, String)
|
||||
Private _dicPojer As Dictionary(Of String, String)
|
||||
Private _dicRoonType As Dictionary(Of String, String)
|
||||
|
||||
Public FileName As String
|
||||
Public SafeFileName As String
|
||||
Public FileNameV4 As String
|
||||
Public SafeFileNameV4 As String
|
||||
|
||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
SetAPP_FOR_Codev(False)
|
||||
'SetLauncher_cbointem(Launcher_cbo, "tbl_luncher_list", "Luncher_Name")
|
||||
DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect
|
||||
DataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect
|
||||
End Sub
|
||||
Public Function SetLauncher_cbointem(cbo As ComboBox, tabname As String, clunm As String, Optional col As String = "", Optional hotel As Integer = 0) As Dictionary(Of String, String)
|
||||
cbo.Items.Clear()
|
||||
Dim udt As DataTable
|
||||
Dim dickey As String = ""
|
||||
Dim dicval As String = ""
|
||||
Dim dic As New Dictionary(Of String, String)
|
||||
Using db As New DbExecutor(DbExecutor.DbTypeEnum.Mysql, FrmMain.DbConnString)
|
||||
db.Open()
|
||||
If hotel <> 0 Then
|
||||
udt = db.ExecuteDataTable(db.CmdHelper.SearchAll(tabname, $"`HOTEL_OLD_ID`='{hotel}'"))
|
||||
Else
|
||||
udt = db.ExecuteDataTable(db.CmdHelper.SearchAll(tabname))
|
||||
End If
|
||||
|
||||
db.Close()
|
||||
End Using
|
||||
|
||||
If IsNothing(udt) Then
|
||||
Return Nothing
|
||||
Else
|
||||
For Each dtrow As DataRow In udt.Rows
|
||||
|
||||
For i As Integer = 0 To udt.Columns.Count - 1
|
||||
|
||||
If udt.Columns(i).ColumnName.Equals(clunm) Then
|
||||
|
||||
dickey = dtrow.Item(i).ToString
|
||||
ElseIf udt.Columns(i).ColumnName.Equals(col) Then
|
||||
dicval = dtrow.Item(i).ToString
|
||||
Else
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Next
|
||||
If String.IsNullOrWhiteSpace(dicval) Then
|
||||
dickey = dickey
|
||||
Else
|
||||
dickey = dicval & "_" & dickey
|
||||
End If
|
||||
|
||||
If dic.ContainsKey(dickey) Then
|
||||
Continue For
|
||||
End If
|
||||
dic.Add(dickey, dicval)
|
||||
|
||||
Next
|
||||
cbo.Items.AddRange(dic.Keys.ToArray)
|
||||
End If
|
||||
Return dic
|
||||
End Function
|
||||
|
||||
|
||||
Private Sub ComboBox1_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles Firmware_cbo.SelectionChangeCommitted
|
||||
If Firmware_cbo.SelectedItem.Equals("APP_FOR_Code") Then
|
||||
SetAPP_FOR_Codev(True)
|
||||
SetLauncher_cbointem(ApplicableModels_cbo, "tbl_rcu_model_list", "RCU_Model_Name")
|
||||
_dicPojer = SetLauncher_cbointem(FirmwarePojer_cbo, "tbl_hotel_basic_info", "HOTEL_NAME_CN", "IDOLD")
|
||||
|
||||
DataGridView1.Rows.Clear()
|
||||
For Each hot In _dicPojer
|
||||
DataGridView1.Rows.Add(hot.Key)
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub SetAPP_FOR_Codev(flag As Boolean)
|
||||
ApplicableModels_cbo.Enabled = flag
|
||||
FirmwarePojer_cbo.Enabled = flag
|
||||
FirmwareHouseType_cbo.Enabled = flag
|
||||
Search_txt.Enabled = flag
|
||||
Search_btn.Enabled = flag
|
||||
DataGridView1.Enabled = flag
|
||||
DataGridView2.Enabled = flag
|
||||
End Sub
|
||||
|
||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Ok_btn.Click
|
||||
InsertFirmware.Clear()
|
||||
InsertFirmwareV4.Clear()
|
||||
If Not Firmware_cbo.Text.Length > 0 Then
|
||||
MsgBox("未选择上传固件类型")
|
||||
InsertFirmware.Clear()
|
||||
Return
|
||||
|
||||
End If
|
||||
If Not FirmwarePath_txt.Text.Length > 0 Then
|
||||
MsgBox("未选择上传固件")
|
||||
Return
|
||||
|
||||
End If
|
||||
If Not FirmwarePathV4_txt.Text.Length > 0 Then
|
||||
MsgBox("未选择上传固件")
|
||||
Return
|
||||
End If
|
||||
If Not FirmwareVer_txt.Text.Length > 0 Then
|
||||
MsgBox("未输入上传固件版本")
|
||||
Return
|
||||
|
||||
End If
|
||||
' If Not FirmwareV4_txt.Text.Length > 0 Then
|
||||
' MsgBox("未输入上传固件版本")
|
||||
' Return
|
||||
|
||||
'End If
|
||||
'If Not Launcher_cbo.Text.Length > 0 Then
|
||||
' MsgBox("未选择上传固件Launcher")
|
||||
' Return
|
||||
|
||||
'End If
|
||||
If Firmware_cbo.SelectedItem.Equals("APP_FOR_Code") Then
|
||||
If Not ApplicableModels_cbo.Text.Length > 0 Then
|
||||
MsgBox("未选择固件适用机型")
|
||||
Return
|
||||
Else
|
||||
InsertFirmware.Add("AppForModel", ApplicableModels_cbo.Text)
|
||||
End If
|
||||
|
||||
If Not DataGridView2.SelectedRows.Item(0).Cells(0).Value.Length > 0 Then
|
||||
MsgBox("未选择固件适用项目")
|
||||
Return
|
||||
Else
|
||||
'If _dicPojer.ContainsKey(FirmwarePojer_cbo.SelectedItem.ToString) Then
|
||||
' Dim clunm As String = _dicPojer.Item(FirmwarePojer_cbo.SelectedItem.ToString)
|
||||
' InsertFirmware.Add("HOTEL_ID", clunm)
|
||||
'End If
|
||||
If _dicPojer.ContainsKey(DataGridView1.SelectedRows.Item(0).Cells(0).Value) Then
|
||||
Dim clunm As String = _dicPojer.Item(DataGridView1.SelectedRows.Item(0).Cells(0).Value)
|
||||
InsertFirmware.Add("HOTEL_ID", clunm)
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If Not DataGridView2.SelectedRows.Item(0).Cells(0).Value.Length > 0 Then
|
||||
MsgBox("未选择固件适用户型")
|
||||
Return
|
||||
Else
|
||||
If _dicPojer.ContainsKey(DataGridView2.SelectedRows.Item(0).Cells(0).Value) Then
|
||||
Dim clunm As String = _dicPojer.Item(DataGridView2.SelectedRows.Item(0).Cells(0).Value)
|
||||
InsertFirmware.Add("ROOM_TYPE_ID", clunm)
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not Remark_txt.Text.Length > 0 Then
|
||||
MsgBox("未填写上传固件说明:")
|
||||
Return
|
||||
|
||||
End If
|
||||
|
||||
Dim filepath As String = FirmwarePath_txt.Text
|
||||
Dim filepathV4 As String = FirmwarePathV4_txt.Text
|
||||
Dim md5 As String = GetStringMd5(filepath)
|
||||
Dim v4md5 As String = GetStringMd5(filepathV4)
|
||||
Dim filename As String = filepath.Substring(filepath.LastIndexOf("\") + 1)
|
||||
Dim filenameV4 As String = filepathV4.Substring(filepathV4.LastIndexOf("\") + 1)
|
||||
InsertFirmware.Add("AppType", Firmware_cbo.Text)
|
||||
InsertFirmware.Add("FileName", filename)
|
||||
InsertFirmware.Add("MD5Val", md5)
|
||||
InsertFirmware.Add("Ver", FirmwareVer_txt.Text)
|
||||
'InsertFirmware.Add("Luncher_Ver", Launcher_cbo.Text)
|
||||
InsertFirmware.Add("Remark", Remark_txt.Text)
|
||||
InsertFirmware.Add("DateTime", Now.ToString("yyyy-MM-dd HH:mm:ss.fff"))
|
||||
InsertFirmware.Add("FilePath", "\Data\Firmware\".Replace("\", "\\"))
|
||||
InsertFirmware.Add("IsValid", "1")
|
||||
|
||||
For Each index In InsertFirmware
|
||||
InsertFirmwareV4.Add (index.Key,index .Value )
|
||||
Next
|
||||
|
||||
InsertFirmwareV4.Item("FileName") = filenameV4
|
||||
InsertFirmwareV4.Item("MD5Val") = v4md5
|
||||
'InsertFirmwarev4.Item("Ver")= FirmwareV4_txt.Text
|
||||
|
||||
Me.DialogResult = System.Windows.Forms.DialogResult.OK
|
||||
Me.Close()
|
||||
Return
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function GetStringMd5(filePath As String) As String
|
||||
Dim dataFile() As Byte = File.ReadAllBytes(filePath)
|
||||
Dim databuff As Byte() = MD5.Create().ComputeHash(dataFile)
|
||||
Dim MD5str As String = BitConverter.ToString(databuff)
|
||||
' Console.WriteLine($"md5-1:{MD5str}")
|
||||
Return MD5str.Replace("-", "")
|
||||
End Function
|
||||
|
||||
Private Sub No_btn_Click(sender As Object, e As EventArgs) Handles No_btn.Click
|
||||
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
|
||||
Return
|
||||
End Sub
|
||||
|
||||
Private Sub SelectFile_btn_Click(sender As Object, e As EventArgs) Handles SelectFile_btn.Click
|
||||
Dim openFileDialog As New OpenFileDialog
|
||||
openFileDialog.InitialDirectory = Application.StartupPath
|
||||
openFileDialog.RestoreDirectory = True
|
||||
openFileDialog.Title = "选择上传固件"
|
||||
openFileDialog.Filter = $"配置文件(*.hex)|*.hex"
|
||||
If openFileDialog.ShowDialog() = DialogResult.OK Then
|
||||
FirmwarePath_txt.Text = openFileDialog.FileName
|
||||
FileName = openFileDialog.FileName
|
||||
SafeFileName = openFileDialog.SafeFileName
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub FirmwarePojer_cbo_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles FirmwarePojer_cbo.SelectionChangeCommitted
|
||||
|
||||
If _dicPojer.ContainsKey(FirmwarePojer_cbo.SelectedItem.ToString) Then
|
||||
Dim clunm As String = _dicPojer.Item(FirmwarePojer_cbo.SelectedItem.ToString)
|
||||
_dicRoonType = SetLauncher_cbointem(FirmwareHouseType_cbo, "tbl_room_type_list", "ROOM_TYPE_NAME", "ROOM_TYPE_ID", clunm)
|
||||
|
||||
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Search_btn_Click(sender As Object, e As EventArgs) Handles Search_btn.Click
|
||||
|
||||
Dim txt As String = Search_txt.Text
|
||||
|
||||
'Dim query = From name As String In FirmwarePojer_cbo.Items
|
||||
' Order By name.Contains(txt) Descending
|
||||
' Select name
|
||||
Dim query = From name As String In FirmwarePojer_cbo.Items
|
||||
Where name.Contains(txt) = True
|
||||
Select name
|
||||
'FirmwarePojer_cbo.Items.Clear
|
||||
' for Each s In query
|
||||
' Console.WriteLine($"排序:{s}")
|
||||
' Next
|
||||
Dim li As New List(Of String)
|
||||
li.AddRange(query.ToArray)
|
||||
DataGridView2.Rows.Clear()
|
||||
DataGridView1.Rows.Clear()
|
||||
For Each hot In query
|
||||
DataGridView1.Rows.Add(hot)
|
||||
Next
|
||||
|
||||
'FirmwarePojer_cbo.Items.Clear()
|
||||
'FirmwarePojer_cbo.Items.AddRange(li.ToArray)
|
||||
|
||||
|
||||
'dim source As ParallelQuery=query
|
||||
'FirmwarePojer_cbo.Items . .AsOrdered (source)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Shared Sub Demo()
|
||||
|
||||
Dim names As New List(Of String) From {"Zhao", "Qian", "Sun", "Li"}
|
||||
Dim result = From name In names Where name.Contains("a"c) Select name
|
||||
|
||||
Console.WriteLine($"result:{String.Join(",", result.ToArray) }")
|
||||
|
||||
names.AddRange({"Zhou", "Wu", "Zhen", "Wang"})
|
||||
Console.WriteLine($"result:{String.Join(",", result.ToArray) }")
|
||||
End Sub
|
||||
|
||||
Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
|
||||
|
||||
If _dicPojer.ContainsKey(DataGridView1.SelectedRows.Item(0).Cells(0).Value) Then
|
||||
Dim clunm As String = _dicPojer.Item(DataGridView1.SelectedRows.Item(0).Cells(0).Value)
|
||||
_dicRoonType = SetLauncher_cbointem(FirmwareHouseType_cbo, "tbl_room_type_list", "ROOM_TYPE_NAME", "ROOM_TYPE_ID", clunm)
|
||||
DataGridView2.Rows.Clear()
|
||||
For Each hot In _dicRoonType
|
||||
DataGridView2.Rows.Add(hot.Key)
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub DataGridView2_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView2.CellClick
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub SelectFileV4_btn_Click(sender As Object, e As EventArgs) Handles SelectFileV4_btn.Click
|
||||
Dim openFileDialog As New OpenFileDialog
|
||||
openFileDialog.InitialDirectory = Application.StartupPath
|
||||
openFileDialog.RestoreDirectory = True
|
||||
openFileDialog.Title = "选择上传固件"
|
||||
openFileDialog.Filter = $"配置文件(*.hex)|*.hex"
|
||||
If openFileDialog.ShowDialog() = DialogResult.OK Then
|
||||
FirmwarePathV4_txt.Text = openFileDialog.FileName
|
||||
FileNameV4 = openFileDialog.FileName
|
||||
SafeFileNameV4 = openFileDialog.SafeFileName
|
||||
End If
|
||||
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user