Imports System.Text Imports System.Xml Namespace UTSModule.Station Public Class StationPackagePlan Inherits StationPlan Sub New(packet As StationPacket) MyBase.New(packet) CreateStationPlan() End Sub ''' ''' 校验条码未测试后处理方式 ''' ''' Public Property CheckSnTested As CheckStatus ''' ''' 校验条码已参与包装后处理方式 ''' ''' Public Property CheckSnPackaged As CheckStatus ''' ''' 校验条码不属于指定MO后处理方式 ''' ''' Public Property CheckSnMO As CheckStatus ''' ''' 保存图像的数量 ''' ''' Public Property PictureCount As Integer ''' ''' 解锁密码 ''' ''' Public Property UnlockKey As String ''' ''' 条码类型 ''' ''' Public Property BarCodeType As BarcodeTypes ''' ''' 缺失条码数量后的处理方式 ''' ''' Public Property MissingQuantity As MissCountStatus ''' ''' 缺失条码数量后的解锁密码 ''' ''' Public Property MissingQuantityKey As String ''' ''' 是否自动打印 ''' ''' Public Property AutoPrint As Boolean ''' ''' 发生错误后报警文件 ''' ''' Public Property ErrorSound As String ''' ''' 模板文件名 ''' ''' Public Property TemplateFile As String ''' ''' 箱号编辑密码 ''' ''' Public Property BoxMumEditKey As String ''' ''' 公司Logo文件 ''' ''' Public Property CompanyLogo As String ''' ''' 公司名称 ''' ''' Public Property CompanyName As String ''' ''' 箱号规则 ''' ''' Public Property BoxNumText As String ''' ''' 箱号条码 ''' ''' Public Property BoxBarCode As String ''' ''' 前置站位 ''' ''' Public Property ForwardPosition As String ''' ''' 后置站位 ''' ''' Public Property RearPosition As String ''' ''' 软件版本 ''' ''' Public Property Versions As String Public Overrides Sub CreateStationPlan() CheckSnTested = CheckStatus.Fail CheckSnPackaged = CheckStatus.Fail CheckSnMO = CheckStatus.Fail UnlockKey = "" BarCodeType = BarcodeTypes.AsTemplate MissingQuantity = MissCountStatus.Key MissingQuantityKey = "" AutoPrint = False ErrorSound = "" TemplateFile = "" BoxMumEditKey = "" CompanyLogo = "" CompanyName = "" BoxNumText = "" BoxBarCode = "" ForwardPosition = "" RearPosition = "" Versions = "" End Sub Public Overrides Sub SaveFile(path As String) Dim xws As New XmlWriterSettings With xws .Indent = True .NewLineOnAttributes = False .Encoding = New UTF8Encoding(False) End With Using xw As XmlWriter = XmlWriter.Create(path, xws) xw.WriteStartDocument() xw.WriteStartElement($"UtsStationPlan") '创建跟节点 xw.WriteStartElement($"Properties") '创建表属性节点 '测试流程的属性 xw.WriteElementString("CheckSnTested", CheckSnTested.ToString) xw.WriteElementString("CheckSnPackaged", CheckSnPackaged.ToString) xw.WriteElementString("CheckSnMO", CheckSnMO.ToString) xw.WriteElementString("PictureCount", PictureCount.ToString) xw.WriteElementString("UnlockKey", UnlockKey) xw.WriteElementString("BarCodeType", BarCodeType.ToString) xw.WriteElementString("MissingQuantity", MissingQuantity.ToString) xw.WriteElementString("MissingQuantityKey", MissingQuantityKey) xw.WriteElementString("AutoPrint", AutoPrint.ToString) xw.WriteElementString("ErrorSound", ErrorSound) xw.WriteElementString("TemplateFile", TemplateFile) xw.WriteElementString("BoxMumEditKey", BoxMumEditKey) xw.WriteElementString("CompanyLogo", CompanyLogo) xw.WriteElementString("CompanyName", CompanyName) xw.WriteElementString("BoxNumText", BoxNumText) xw.WriteElementString("ForwardPosition", ForwardPosition) xw.WriteElementString("RearPosition", RearPosition) xw.WriteElementString("Versions", Versions) xw.WriteEndElement() xw.WriteEndElement() xw.WriteEndDocument() End Using End Sub ''' ''' 读取测试站属性 ''' ''' Private Sub LoadProperties(nodeList As XmlNodeList) Dim xe As XmlElement For Each node As XmlNode In nodeList xe = CType(node, XmlElement) Select Case xe.LocalName Case "CheckSnTested" If [Enum].TryParse(xe.InnerText, CheckSnTested) = False Then CheckSnTested = CheckStatus.Fail End If Case "CheckSnPackaged" If [Enum].TryParse(xe.InnerText, CheckSnPackaged) = False Then CheckSnPackaged = CheckStatus.Fail End If Case "CheckSnMO" If [Enum].TryParse(xe.InnerText, CheckSnMO) = False Then CheckSnMO = CheckStatus.Fail End If Case "PictureCount" If Integer.TryParse(xe.InnerText, PictureCount) = False Then PictureCount = 1 End If Case "UnlockKey" UnlockKey = xe.InnerText Case "BarCodeType" If [Enum].TryParse(xe.InnerText, BarCodeType) = False Then BarCodeType = BarcodeTypes.AsTemplate End If Case "MissingQuantity" If [Enum].TryParse(xe.InnerText, MissingQuantity) = False Then MissingQuantity = MissCountStatus.Key End If Case "MissingQuantityKey" MissingQuantityKey = xe.InnerText Case "AutoPrint" If Boolean.TryParse(xe.InnerText, AutoPrint) = False Then AutoPrint = False End If Case "ErrorSound" ErrorSound = xe.InnerText Case "TemplateFile" TemplateFile = xe.InnerText Case "BoxMumEditKey" BoxMumEditKey = xe.InnerText Case "CompanyLogo" CompanyLogo = xe.InnerText Case "CompanyName" CompanyName = xe.InnerText Case "BoxNumText" BoxNumText = xe.InnerText Case "BoxBarCode" BoxBarCode = xe.InnerText Case "RearPosition" RearPosition = xe.InnerText Case "ForwardPosition" ForwardPosition = xe.InnerText Case "Versions" Versions = xe.InnerText Case Else 'Throw New Exception($"StationPackagePlan LoadProperties Unknown LocalName:{xe.LocalName}") End Select Next End Sub Public Overrides Sub LoadFile(path As String) Dim xd As New XmlDocument() xd.Load(path) Dim xe As XmlElement Dim nodeList As XmlNodeList = xd.SelectSingleNode($"UtsStationPlan").ChildNodes For Each node As XmlNode In nodeList xe = CType(node, XmlElement) Select Case xe.LocalName Case "Properties" LoadProperties(xe.ChildNodes) Case Else Throw New Exception($"StationPackagePlan LoadXml Unknown LocalName:{xe.LocalName}") End Select Next End Sub ''' ''' 校验条码失败后处理方式 ''' Enum CheckStatus ''' ''' 不处理 ''' None ''' ''' 校验失败 ''' Fail ''' ''' 程序锁定,需要管理员密码解锁,并写入注册表 ''' Lock ''' ''' 忽略错误继续录入 ''' Ignore End Enum ''' ''' 条码总数缺少的处理方式 ''' Enum MissCountStatus ''' ''' 允许录入 ''' Yes ''' ''' 不允许录入 ''' No ''' ''' 需要输入密码解锁 ''' Key End Enum ''' ''' 条码单元格的类型 ''' Enum BarcodeTypes ''' ''' 以模板内容为准 ''' AsTemplate ''' ''' CODE39支持的字符:空格, 数字, 大写字母, $, %, *, +, -, ., / ''' CODE39 ''' ''' CODE128A支持的字符:空格, 数字, 大写字母, 标点符号, @, #, $, %, ^, +, -, *, / ''' CODE128A ''' ''' CODE128B支持的字符:空格, 数字, 小写字母, 大写字母, 标点符号, @, #, $, %, ^, +, -, *, /, ~ ''' CODE128B ''' ''' CODE128C只能包含数字 ''' CODE128C ''' ''' EAN128只能包含数字 ''' EAN128 ''' ''' EAN13是商品编码,必须是13位数字,第13位是根据前面12位运算后得到的 ''' EAN13 ''' ''' Interleaved2of5只能包含数字,数字的长度必须为偶数 ''' Interleaved2of5 End Enum End Class End Namespace