第一次提交至Git
This commit is contained in:
660
AUTS_Studio/ProjectInfo.vb
Normal file
660
AUTS_Studio/ProjectInfo.vb
Normal file
@@ -0,0 +1,660 @@
|
||||
Imports System.IO
|
||||
Imports System.Text
|
||||
Imports System.Xml
|
||||
Imports MySql.Data.MySqlClient
|
||||
|
||||
Imports UTS_Studio.UtsPath
|
||||
|
||||
Imports UTS_Core.Database.Mysql
|
||||
|
||||
Imports UTS_Core.UTSModule.DatabaseTable
|
||||
Public Class ProjectInfo
|
||||
|
||||
''' <summary>
|
||||
''' 初始化项目模式
|
||||
''' </summary>
|
||||
Enum InitializeModeEnum
|
||||
''' <summary>
|
||||
''' 云端加载项目信息
|
||||
''' </summary>
|
||||
RemoteLoad
|
||||
''' <summary>
|
||||
''' 本地加载项目信息
|
||||
''' </summary>
|
||||
LocalLoad
|
||||
''' <summary>
|
||||
''' 新建项目信息
|
||||
''' </summary>
|
||||
Create
|
||||
End Enum
|
||||
|
||||
|
||||
Sub New(userName As String, projectName As String)
|
||||
Creator = userName
|
||||
Name = projectName
|
||||
Description = String.Empty
|
||||
InitializeMode = InitializeModeEnum.Create
|
||||
Station = New List(Of ProjectStationInfo)()
|
||||
End Sub
|
||||
|
||||
Sub New(userName As String, projectName As String, mode As InitializeModeEnum)
|
||||
Creator = userName
|
||||
Name = projectName
|
||||
Description = String.Empty
|
||||
InitializeMode = mode
|
||||
Station = New List(Of ProjectStationInfo)()
|
||||
|
||||
InitializeProject(projectName, InitializeMode)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 当前项目初始化方式
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property InitializeMode() As InitializeModeEnum
|
||||
|
||||
''' <summary>
|
||||
''' 项目代号,创建项目时生成,作为项目索引存在
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property Code() As String
|
||||
|
||||
''' <summary>
|
||||
''' 项目名称
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property Name() As String
|
||||
|
||||
''' <summary>
|
||||
''' 项目描述
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property Description() As String
|
||||
|
||||
''' <summary>
|
||||
''' 项目站集合
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property Station() As List(Of ProjectStationInfo)
|
||||
|
||||
''' <summary>
|
||||
''' 名称是否被修改
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property NameChanged() As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 项目描述是否被修改
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property DescriptionChanged() As Boolean
|
||||
|
||||
''' <summary>
|
||||
''' 项目创建者
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Property Creator() As String
|
||||
|
||||
''' <summary>
|
||||
''' 初始化项目
|
||||
''' </summary>
|
||||
''' <param name="projectName"></param>
|
||||
''' <param name="mode"></param>
|
||||
Public Sub InitializeProject(projectName As String, mode As InitializeModeEnum)
|
||||
If mode = InitializeModeEnum.RemoteLoad Then
|
||||
LoadRemoteProject(projectName)
|
||||
ElseIf mode = InitializeModeEnum.LocalLoad Then
|
||||
LoadLocalProject(projectName)
|
||||
ElseIf mode = InitializeModeEnum.Create Then
|
||||
Code = Name '新建的项目代号与产品名称相同
|
||||
Else
|
||||
Console.WriteLine($"InitializeProject Untreated Mode:{mode}")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 加载本地项目
|
||||
''' </summary>
|
||||
''' <param name="projectName"></param>
|
||||
Private Sub LoadLocalProject(projectName As String)
|
||||
Dim filename As String = $"{SystemDirPath}\{SystemFolderEnum.Temp}\{SystemTempFolderEnum.ProjectDesign}\{projectName}\{projectName}.xml"
|
||||
Dim xd As New XmlDocument() : xd.Load(filename)
|
||||
Dim nodeList As XmlNodeList = xd.SelectSingleNode("Project").ChildNodes
|
||||
For Each node As XmlNode In nodeList
|
||||
Dim xe As XmlElement = CType(node, XmlElement)
|
||||
Select Case xe.LocalName
|
||||
Case $"Code"
|
||||
Code = xe.InnerText
|
||||
Case $"Name"
|
||||
Name = xe.InnerText
|
||||
Case $"Description"
|
||||
Description = xe.InnerText
|
||||
Case "Stations"
|
||||
LoadAllStation(node.ChildNodes)
|
||||
Case Else
|
||||
Console.WriteLine($"LoadLocalProject Unknow XmlNodeName:{xe.LocalName}")
|
||||
End Select
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 加载项目所有站
|
||||
''' </summary>
|
||||
''' <param name="nodeList"></param>
|
||||
Private Sub LoadAllStation(nodeList As XmlNodeList)
|
||||
Station.Clear()
|
||||
Dim xe As XmlElement
|
||||
For Each node As XmlNode In nodeList
|
||||
xe = CType(node, XmlElement)
|
||||
Select Case xe.LocalName
|
||||
Case "Station"
|
||||
LoadStation(xe.ChildNodes)
|
||||
End Select
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 加载测试站信息
|
||||
''' </summary>
|
||||
''' <param name="nodeList">Xml节点</param>
|
||||
Private Sub LoadStation(nodeList As XmlNodeList)
|
||||
Dim stationInfo As New ProjectStationInfo
|
||||
Dim xe As XmlElement
|
||||
For Each node As XmlNode In nodeList
|
||||
xe = CType(node, XmlElement)
|
||||
Select Case xe.LocalName
|
||||
Case $"Code"
|
||||
stationInfo.Code = xe.InnerText
|
||||
Case $"Name"
|
||||
stationInfo.Name = xe.InnerText
|
||||
Case $"Description"
|
||||
stationInfo.Description = xe.InnerText
|
||||
Case $"PacketName"
|
||||
stationInfo.PacketName = xe.InnerText
|
||||
Case Else
|
||||
Console.WriteLine($"LoadStationInfo Unknow XmlNodeName:{xe.LocalName}")
|
||||
End Select
|
||||
Next
|
||||
Station.Add(stationInfo)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 加载远程项目站
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn"></param>
|
||||
''' <param name="projectName"></param>
|
||||
Private Sub LoadRemoteProjectStation(mysqlConn As MySqlConnection, projectName As String)
|
||||
Dim tableName As String = StationTable.TableName(projectName)
|
||||
Dim colNames As String = $"{StationTable.ColNamesEnum.工作站编号},{StationTable.ColNamesEnum.操作站名},
|
||||
{StationTable.ColNamesEnum.作业内容描述},{StationTable.ColNamesEnum.测试版本包名}"
|
||||
Dim dtStation As DataTable = Executor.Search(mysqlConn, tableName, colNames)
|
||||
|
||||
Station.Clear()
|
||||
For Each row As DataRow In dtStation.Rows
|
||||
Station.Add(New ProjectStationInfo() With {
|
||||
.Code = row(0).ToString(),
|
||||
.Name = row(1).ToString(),
|
||||
.Description = row(2).ToString(),
|
||||
.PacketName = row(3).ToString()})
|
||||
Next
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 加载远程项目信息
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn"></param>
|
||||
''' <param name="projectName"></param>
|
||||
Private Sub LoadRemoteProjectInfo(mysqlConn As MySqlConnection, projectName As String)
|
||||
Dim tableName As String = ProjectTable.Name
|
||||
Dim colNames As String = $"{ProjectTable.ColNamesEnum.功能描述},{ProjectTable.ColNamesEnum.项目代号}"
|
||||
Dim condition As String = $"{ProjectTable.ColNamesEnum.产品名称} = '{projectName}' Limit 1"
|
||||
Dim dtProject As DataTable = Executor.Search(mysqlConn, tableName, colNames, condition)
|
||||
If dtProject.Rows.Count <= 0 Then Throw New Exception($"LoadRemoteProjectInfo Error,Not Find ProjectName - {projectName}")
|
||||
|
||||
Description = dtProject.Rows(0)(0).ToString()
|
||||
Code = dtProject.Rows(0)(1).ToString()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 加载远程项目
|
||||
''' </summary>
|
||||
''' <param name="projectName"></param>
|
||||
Private Sub LoadRemoteProject(projectName As String)
|
||||
Dim connectionString As String = CommandHelpers.ConnectionString(ConnectionParams.Server, ConnectionParams.Port,
|
||||
ConnectionParams.UserID, ConnectionParams.Password,
|
||||
ConnectionParams.Database, ConnectionParams.Pooling)
|
||||
Using mysqlConn As New MySqlConnection(connectionString)
|
||||
LoadRemoteProjectInfo(mysqlConn, projectName)
|
||||
LoadRemoteProjectStation(mysqlConn, projectName)
|
||||
End Using
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 加载本地项目列表
|
||||
''' </summary>
|
||||
''' <param name="parentPath"></param>
|
||||
''' <returns></returns>
|
||||
Private Shared Function LoadLocalProjectList(parentPath As String) As String()
|
||||
If Directory.Exists(parentPath) = False Then Return New String() {}
|
||||
Dim prjName, prjDirName As String
|
||||
Dim lstProjects As New List(Of String)
|
||||
Dim prjDirPaths As String() = Directory.GetDirectories(parentPath)
|
||||
For Each prjDirPath As String In prjDirPaths
|
||||
For Each fileName As String In Directory.GetFiles(prjDirPath)
|
||||
prjName = Path.GetFileNameWithoutExtension(fileName)
|
||||
prjDirName = Path.GetDirectoryName(fileName)
|
||||
If prjDirName.EndsWith(prjName) Then
|
||||
lstProjects.Add(prjName)
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
Return lstProjects.ToArray()
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 加载远程所有项目
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn"></param>
|
||||
''' <returns></returns>
|
||||
Private Shared Function LoadRemoteAllProjects(mysqlConn As MySqlConnection) As String()
|
||||
Dim tableName As String = ProjectTable.Name
|
||||
Dim colNames As String = $"{ProjectTable.ColNamesEnum.产品名称}"
|
||||
Dim dtProjects As DataTable = Executor.Search(mysqlConn, tableName, colNames)
|
||||
|
||||
Dim lstProjects As New List(Of String)
|
||||
For Each row As DataRow In dtProjects.Rows
|
||||
lstProjects.Add(row(0).ToString())
|
||||
|
||||
Next
|
||||
Return lstProjects.ToArray()
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 加载远程项目列表
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Private Shared Function LoadRemoteProjectList() As String()
|
||||
Dim connectionString As String = CommandHelpers.ConnectionString(ConnectionParams.Server, ConnectionParams.Port,
|
||||
ConnectionParams.UserID, ConnectionParams.Password,
|
||||
ConnectionParams.Database, ConnectionParams.Pooling)
|
||||
Using mysqlConn As New MySqlConnection(connectionString)
|
||||
Return LoadRemoteAllProjects(mysqlConn)
|
||||
End Using
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 加载项目列表
|
||||
''' </summary>
|
||||
''' <param name="mode"></param>
|
||||
''' <returns></returns>
|
||||
Public Shared Function LoadProjectList(mode As InitializeModeEnum) As String()
|
||||
Select Case mode
|
||||
Case InitializeModeEnum.RemoteLoad
|
||||
Return LoadRemoteProjectList()
|
||||
Case InitializeModeEnum.LocalLoad
|
||||
Dim parentPath As String = $"{SystemDirPath}\{SystemFolderEnum.Temp}\{SystemTempFolderEnum.ProjectDesign}"
|
||||
Return LoadLocalProjectList(parentPath)
|
||||
Case InitializeModeEnum.Create
|
||||
Console.WriteLine($"LoadProjectList Untreated Mode:{mode}")
|
||||
Return New String() {}
|
||||
Case Else
|
||||
Console.WriteLine($"LoadProjectList Untreated Mode:{mode}")
|
||||
Return New String() {}
|
||||
End Select
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 保存项目所有站信息
|
||||
''' </summary>
|
||||
''' <param name="xw"></param>
|
||||
Private Sub SaveProjectAllStation(xw As XmlWriter)
|
||||
xw.WriteStartElement($"Stations") '保存测试站信息节点
|
||||
For Each stationInfo As ProjectStationInfo In Station
|
||||
xw.WriteStartElement($"Station")
|
||||
xw.WriteElementString("Code", stationInfo.Code)
|
||||
xw.WriteElementString("Name", stationInfo.Name)
|
||||
xw.WriteElementString("Description", stationInfo.Description)
|
||||
xw.WriteElementString("PacketName", stationInfo.PacketName)
|
||||
xw.WriteEndElement()
|
||||
Next
|
||||
xw.WriteEndElement()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 保存项目至本地文件
|
||||
''' </summary>
|
||||
''' <param name="filePath"></param>
|
||||
Private Sub SaveProjectToLocalFile(filePath As String)
|
||||
Dim xws As New XmlWriterSettings
|
||||
With xws
|
||||
.Indent = True
|
||||
.NewLineOnAttributes = False
|
||||
.Encoding = New UTF8Encoding(False)
|
||||
End With
|
||||
|
||||
Dim xw As XmlWriter = XmlWriter.Create(filePath, xws)
|
||||
xw.WriteStartDocument()
|
||||
xw.WriteStartElement($"Project") '创建跟节点
|
||||
|
||||
xw.WriteElementString("Code", Code)
|
||||
xw.WriteElementString("Name", Name)
|
||||
xw.WriteElementString("Description", Description)
|
||||
|
||||
SaveProjectAllStation(xw)
|
||||
|
||||
xw.WriteEndElement()
|
||||
xw.WriteEndDocument()
|
||||
xw.Flush()
|
||||
xw.Close()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 将项目信息保存至本Xml文件
|
||||
''' </summary>
|
||||
Public Sub ExportToXml()
|
||||
Dim fileDirPath As String = $"{SystemDirPath}\{SystemFolderEnum.Temp}\{SystemTempFolderEnum.ProjectDesign}\{Name}"
|
||||
Dim filePath As String = $"{fileDirPath}\{Name}.xml"
|
||||
|
||||
If Directory.Exists(fileDirPath) = False Then Directory.CreateDirectory(fileDirPath)
|
||||
If File.Exists(filePath) Then File.Delete(filePath)
|
||||
SaveProjectToLocalFile(filePath)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Function ProjectExists(mysqlConn As MySqlConnection, project As ProjectInfo) As Boolean
|
||||
Dim tableName As String = ProjectTable.Name
|
||||
Dim colNames As String = $"{ProjectTable.ColNamesEnum.产品名称}"
|
||||
Dim condition As String = $"{ProjectTable.ColNamesEnum.产品名称} = '{project.Name}'"
|
||||
Dim dtProjects As DataTable = Executor.Search(mysqlConn, tableName, colNames, condition)
|
||||
Return dtProjects.Rows.Count > 0
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' 项目表修改原有项目信息
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn"></param>
|
||||
''' <param name="project"></param>
|
||||
Private Sub UpdateProjectTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
If NameChanged Or DescriptionChanged Then
|
||||
Dim tableName As String = ProjectTable.Name
|
||||
Dim updateColValue As New Dictionary(Of String, String)
|
||||
|
||||
If NameChanged Then
|
||||
updateColValue.Add(ProjectTable.ColNamesEnum.产品名称.ToString(), project.Name)
|
||||
End If
|
||||
|
||||
If DescriptionChanged Then
|
||||
updateColValue.Add(ProjectTable.ColNamesEnum.功能描述.ToString(), project.Description)
|
||||
End If
|
||||
|
||||
Dim condition As String = $"{ProjectTable.ColNamesEnum.项目代号} = '{project.Code}'"
|
||||
|
||||
Using mysqlComm As MySqlCommand = mysqlConn.CreateCommand()
|
||||
Executor.Update(mysqlComm, tableName, updateColValue, condition)
|
||||
End Using
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 项目表添加新项目
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn"></param>
|
||||
''' <param name="project"></param>
|
||||
Private Sub InsertProjectTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
Dim tableName As String = ProjectTable.Name
|
||||
Dim insetColValue As New Dictionary(Of String, String)
|
||||
insetColValue.Add(ProjectTable.ColNamesEnum.项目代号.ToString(), project.Code)
|
||||
insetColValue.Add(ProjectTable.ColNamesEnum.产品名称.ToString(), project.Name)
|
||||
insetColValue.Add(ProjectTable.ColNamesEnum.功能描述.ToString(), project.Description)
|
||||
insetColValue.Add(ProjectTable.ColNamesEnum.Creator.ToString(), project.Creator)
|
||||
insetColValue.Add(ProjectTable.ColNamesEnum.记录日期.ToString(), $"{Now:yyyy-MM-dd HH:mm:ss}")
|
||||
|
||||
Using mysqlComm As MySqlCommand = mysqlConn.CreateCommand()
|
||||
Executor.Insert(mysqlComm, tableName, insetColValue)
|
||||
End Using
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub AlterUserAuthTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
Dim num As Integer = Executor.AlterColumnCheckExists(mysqlConn, UserAuthTable.TableName, project.Name, UserAuthTable.ProjectColType, UserAuthTable.ProjectColIsNull)
|
||||
Console.WriteLine($"AlterUserAuthTable num:{num}")
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub UploadUserAuthTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
AlterUserAuthTable(mysqlConn, project)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CreateErrorCodeTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
Executor.ExecuteNonQuery(mysqlConn, ErrorCodeTable.CreateTableString(project.Name))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 将表名添加到表版本记录表中,供数据同步软件下载
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn"></param>
|
||||
''' <param name="tableName"></param>
|
||||
Private Sub InsertRowVersionTable(mysqlConn As MySqlConnection, tableName As String, syncType As TableVersionTable.SyncTypeEnum)
|
||||
Dim keyValues As New Dictionary(Of String, String)
|
||||
keyValues.Add(TableVersionTable.ColNamesEnum.TableName.ToString(), tableName)
|
||||
keyValues.Add(TableVersionTable.ColNamesEnum.SyncType.ToString(), syncType.ToString())
|
||||
keyValues.Add(TableVersionTable.ColNamesEnum.UpdateTime.ToString(), Now.ToString("yyyy-MM-dd HH:mm:ss"))
|
||||
|
||||
Executor.InsertRowCheckExists(mysqlConn, TableVersionTable.TableName,
|
||||
TableVersionTable.ColNamesEnum.TableName.ToString(),
|
||||
tableName,
|
||||
keyValues)
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 创建触发器,当源表变动时,同步更新版本记录表更新时间列
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn">mysql连接句柄</param>
|
||||
''' <param name="tableName">添加触发器的数据表名</param>
|
||||
Private Sub AddressOfVersionTable(mysqlConn As MySqlConnection, tableName As String)
|
||||
Executor.ExecuteNonQuery(mysqlConn, TableVersionTable.AfterInsertUpdateTimeTrigger(tableName))
|
||||
Executor.ExecuteNonQuery(mysqlConn, TableVersionTable.AfterUpdateUpdateTimeTrigger(tableName))
|
||||
Executor.ExecuteNonQuery(mysqlConn, TableVersionTable.AfterDeleteUpdateTimeTrigger(tableName))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 发布项目时,更新上传ErrorCode表格
|
||||
''' </summary>
|
||||
Private Sub UploadErrorCodeTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
'创建错误代码表
|
||||
CreateErrorCodeTable(mysqlConn, project)
|
||||
|
||||
'添加记录至VersionTable
|
||||
InsertRowVersionTable(mysqlConn, ErrorCodeTable.TableName(project.Name), TableVersionTable.SyncTypeEnum.new)
|
||||
|
||||
'添加触发器触发器,当表变更时,更新VersionTable的数据
|
||||
AddressOfVersionTable(mysqlConn, ErrorCodeTable.TableName(project.Name))
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CreateStationTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
Executor.ExecuteNonQuery(mysqlConn, StationTable.CreateTableString(project.Name))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 发布项目时,更新项目站表信息
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn">Mysql连接句柄</param>
|
||||
''' <param name="project">项目信息</param>
|
||||
Private Sub UploadStationTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
'因为项目站表名称根据项目不同会有所变化,所有需要提前记录
|
||||
Dim tableName As String = StationTable.TableName(project.Name)
|
||||
|
||||
'创建项目站表
|
||||
CreateStationTable(mysqlConn, project)
|
||||
|
||||
'添加记录至VersionTable
|
||||
InsertRowVersionTable(mysqlConn, tableName, TableVersionTable.SyncTypeEnum.all)
|
||||
|
||||
'添加触发器触发器,当表变更时,更新VersionTable的数据
|
||||
AddressOfVersionTable(mysqlConn, tableName)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CreateFlowChartTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
Executor.ExecuteNonQuery(mysqlConn, FlowChartTable.CreateTableString(project.Name))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 发布项目时,更新产品经过流程表信息
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn">Mysql连接句柄</param>
|
||||
''' <param name="project">项目信息</param>
|
||||
Private Sub UploadFlowChartTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
CreateFlowChartTable(mysqlConn, project)
|
||||
End Sub
|
||||
|
||||
Private Sub CreateReleaseLogTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
Executor.ExecuteNonQuery(mysqlConn, ReleaseLogTable.CreateTableString(project.Name))
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 发布项目时,更新项目站发布记录表信息
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn">Mysql连接句柄</param>
|
||||
''' <param name="project">项目信息</param>
|
||||
Private Sub UploadReleaseLogTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
CreateReleaseLogTable(mysqlConn, project)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub UploadProjectTable(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
If ProjectExists(mysqlConn, project) Then
|
||||
UpdateProjectTable(mysqlConn, project)
|
||||
Else
|
||||
InsertProjectTable(mysqlConn, project) '项目表添加一行
|
||||
End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' 更新上传项目信息
|
||||
''' </summary>
|
||||
''' <param name="mysqlConn"></param>
|
||||
''' <param name="project"></param>
|
||||
Private Sub UploadProjectInfo(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
UploadProjectTable(mysqlConn, project) '将项目信息更新到项目表
|
||||
|
||||
UploadUserAuthTable(mysqlConn, project) '用户权限表添加一个项目列
|
||||
|
||||
UploadErrorCodeTable(mysqlConn, project) '创建错误代码ErrorCode表,并在Version表添加记录,添加触发器
|
||||
|
||||
UploadStationTable(mysqlConn, project) '创建项目站Process表,并在Version表添加记录'添加触发器
|
||||
|
||||
UploadFlowChartTable(mysqlConn, project) '创建流程签名FlowChart表
|
||||
|
||||
UploadReleaseLogTable(mysqlConn, project) '创建发布记录ReleaseLog表
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub InsertRowStationTable(mysqlConn As MySqlConnection, project As ProjectInfo, stationInfo As ProjectStationInfo)
|
||||
Dim keyValues As New Dictionary(Of String, String)
|
||||
keyValues.Add(StationTable.ColNamesEnum.工作站编号.ToString(), stationInfo.Code)
|
||||
keyValues.Add(StationTable.ColNamesEnum.Creator.ToString(), stationInfo.Author)
|
||||
keyValues.Add(StationTable.ColNamesEnum.操作站名.ToString(), stationInfo.Name)
|
||||
keyValues.Add(StationTable.ColNamesEnum.作业内容描述.ToString(), stationInfo.Description)
|
||||
keyValues.Add(StationTable.ColNamesEnum.测试版本包名.ToString(), stationInfo.PacketName)
|
||||
|
||||
|
||||
Executor.InsertRowCheckExists(mysqlConn, StationTable.TableName(project.Name),
|
||||
StationTable.ColNamesEnum.工作站编号.ToString(),
|
||||
stationInfo.Code,
|
||||
keyValues)
|
||||
End Sub
|
||||
|
||||
Private Sub UploadStationTable(mysqlConn As MySqlConnection, project As ProjectInfo, stationInfo As ProjectStationInfo)
|
||||
InsertRowStationTable(mysqlConn, project, stationInfo)
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CreateErrorLogTable(mysqlConn As MySqlConnection, project As ProjectInfo, stationInfo As ProjectStationInfo)
|
||||
Executor.ExecuteNonQuery(mysqlConn, ErrorLogTable.CreateTableString(project.Name, stationInfo.Code))
|
||||
End Sub
|
||||
|
||||
Private Sub UploadErrorLogTable(mysqlConn As MySqlConnection, project As ProjectInfo, stationInfo As ProjectStationInfo)
|
||||
'创建站错误代码记录表
|
||||
CreateErrorLogTable(mysqlConn, project, stationInfo)
|
||||
|
||||
'添加记录至VersionTable
|
||||
InsertRowVersionTable(mysqlConn, ErrorLogTable.TableName(project.Name, stationInfo.Code), TableVersionTable.SyncTypeEnum.new)
|
||||
|
||||
'添加触发器触发器,当表变更时,更新VersionTable的数据
|
||||
AddressOfVersionTable(mysqlConn, ErrorLogTable.TableName(project.Name, stationInfo.Code))
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub CreateTestLogTable(mysqlConn As MySqlConnection, project As ProjectInfo, stationInfo As ProjectStationInfo)
|
||||
Executor.ExecuteNonQuery(mysqlConn, TestLogTable.CreateTableString(project.Name, stationInfo.Code))
|
||||
End Sub
|
||||
|
||||
Private Sub UploadTestLogTable(mysqlConn As MySqlConnection, project As ProjectInfo, stationInfo As ProjectStationInfo)
|
||||
CreateTestLogTable(mysqlConn, project, stationInfo) '创建站测试记录表
|
||||
|
||||
|
||||
'添加触发器,测试失败时,将失败记录添加到错误代码记录表中(考虑删除,手动增加)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub AlterFlowChartTable(mysqlConn As MySqlConnection, project As ProjectInfo, stationInfo As ProjectStationInfo)
|
||||
Dim num As Integer = Executor.AlterColumnCheckExists(mysqlConn, FlowChartTable.TableName(project.Name), stationInfo.Code, FlowChartTable.StationColType, FlowChartTable.StationColIsNull)
|
||||
Console.WriteLine($"AlterFlowChartTable num:{num}")
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub UploadStationFlowChartTable(mysqlConn As MySqlConnection, project As ProjectInfo, stationInfo As ProjectStationInfo)
|
||||
AlterFlowChartTable(mysqlConn, project, stationInfo)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub UploadStationInfo(mysqlConn As MySqlConnection, project As ProjectInfo)
|
||||
For Each stationInfo As ProjectStationInfo In project.Station
|
||||
UploadStationTable(mysqlConn, project, stationInfo) '项目站Process表,更新一行数据
|
||||
UploadErrorLogTable(mysqlConn, project, stationInfo) '创建错误记录ErrorLog表,并在Version表添加记录,添加触发器
|
||||
UploadTestLogTable(mysqlConn, project, stationInfo) '创建测试站记录表,添加触发器?
|
||||
|
||||
UploadStationFlowChartTable(mysqlConn, project, stationInfo) '流程签名FlowChart表,新增项目站列
|
||||
|
||||
'成功发布站包则更新项目站发布Release记录(当前工具仅供设计项目及其包含测试站,不支持发布站包功能,所以不处理当前功能)
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub ReleaseDataToDatabase()
|
||||
'项目创建者要当前用户关联
|
||||
'项目站要与当前用户关联
|
||||
|
||||
Dim connectionString As String = CommandHelpers.ConnectionString(ConnectionParams.Server, ConnectionParams.Port,
|
||||
ConnectionParams.UserID, ConnectionParams.Password,
|
||||
ConnectionParams.Database, ConnectionParams.Pooling)
|
||||
Using mysqlConn As New MySqlConnection(connectionString)
|
||||
mysqlConn.Open()
|
||||
|
||||
UploadProjectInfo(mysqlConn, Me) '更新数据库项目相关信息
|
||||
|
||||
UploadStationInfo(mysqlConn, Me) '更新数据库项目站相关信息
|
||||
|
||||
mysqlConn.Close()
|
||||
End Using
|
||||
End Sub
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' 发布项目
|
||||
''' </summary>
|
||||
Public Sub Release()
|
||||
ExportToXml()
|
||||
|
||||
ReleaseDataToDatabase()
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user