菜单

VB.NET 多线程

2020年1月29日 - 金沙国际棋牌下载官网

Class IniFile
#Region “声明读写INI文件的API函数”
    ‘读文件
    ”’ <summary>
    ”’ 读INI文件
    ”’ </summary>
    ”’ <param
name=”lpApplicationName”>欲查找的条目的小节名称</param>
    ”’ <param name=”lpKeyName”>关键字</param>
    ”’ <param
name=”lpDefault”>指定的条目没有找到时的返回值</param>
    ”’ <param
name=”lpReturnedString”>字符串缓冲区大小不能小于nSize</param>
    ”’ <param
name=”nSize”>指定装载到lpReturnedString缓冲区的最大字符数量</param>
    ”’ <param name=”lpFileName”>文件路径</param>
    ”’
<returns>返回lpReturnedString中的字符数量</returns>
    ”’ <remarks></remarks>
    Private Declare Function GetPrivateProfileString Lib “kernel32”
Alias “GetPrivateProfileStringA” (ByVal lpApplicationName As String,
ByVal lpKeyName As String, ByVal lpDefault As String, ByVal
lpReturnedString As System.Text.StringBuilder, ByVal nSize As Int32,
ByVal lpFileName As String) As Long
    ‘写文件
    ”’ <summary>
    ”’ 写INI文件
    ”’ </summary>
    ”’ <param
name=”lpApplicationName”>欲写入的条目的小节名称</param>
    ”’ <param name=”lpKeyName”>关键字</param>
    ”’ <param name=”lpString”>欲写入的字符串</param>
    ”’ <param name=”lpFileName”>文件路径</param>
    ”’ <returns>返回0表示失败,非0表示成功</returns>
    ”’ <remarks></remarks>
    Private Declare Function WritePrivateProfileString Lib “kernel32”
Alias “WritePrivateProfileStringA” (ByVal lpApplicationName As String,
ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As
String) As Long
    ‘Public Declare Function GetPrivateProfileSectionNames Lib
“kernel32.dll” Alias “GetPrivateProfileSectionNamesA” (ByVal
lpszReturnBuffer As String, ByVal nSize As Long, ByVal lpFileName As
String) As Long

图片 1图片 2代码

图片 3图片 4代码

#End Region
    ”’ <summary>
    ”’ 读INI
    ”’ </summary>
    ”’ <param name=”ApplicationName”>INI中的节点</param>
    ”’ <param name=”KeyName”>节点中的键</param>
    ”’ <param
name=”DefaultValue”>找不到时返回的值</param>
    ”’ <param
name=”FilePath”>INI文件路径,一定要写完整</param>
    ”’ <returns>读到的值</returns>
    ”’ <remarks></remarks>
    Public Function ReadIniFile(ByVal ApplicationName As String, ByVal
KeyName As String, ByVal DefaultValue As String, ByVal FilePath As
String) As String
        If File.Exists(FilePath) Then
            Dim resultstring As New System.Text.StringBuilder(1024)
            GetPrivateProfileString(ApplicationName, KeyName,
DefaultValue, resultstring, 1024, FilePath)
            Return resultstring.ToString
        Else
            Return Nothing
        End If
    End Function
    ”’ <summary>
    ”’ 写INI
    ”’ </summary>
    ”’ <param name=”ApplicationName”>INI中的节点</param>
    ”’ <param name=”KeyName”>节点的键</param>
    ”’ <param name=”KeyValue”>要写的键值</param>
    ”’ <param
name=”FilePath”>INI文件路径,一定要写完整</param>
    ”’ <returns></returns>
    ”’
<remarks>可以给已经存在的键赋值,也可以同时创建键</remarks>
    Public Function WriteFile(ByVal ApplicationName As String, ByVal
KeyName As String, ByVal KeyValue As String, ByVal FilePath As String)
As Boolean
        If File.Exists(FilePath) Then
            Dim i As Long = WritePrivateProfileString(ApplicationName,
KeyName, KeyValue, FilePath)
            If i = 0 Then
                Return False
            Else
                Return True
            End If
        Else
            Return False
        End If
    End Function
    ”’ <summary>
    ”’ 删除指定的键
    ”’ </summary>
    ”’ <param name=”ApplicationName”>键所在的节点</param>
    ”’ <param name=”KeyName”>键名</param>
    ”’ <param name=”FilePath”>INI文件路径</param>
    ”’ <returns></returns>
    ”’ <remarks></remarks>
    Public Function DelKey(ByVal ApplicationName As String, ByVal
KeyName As String, ByVal FilePath As String) As Boolean
        If File.Exists(FilePath) Then
            Dim i As Long = WritePrivateProfileString(ApplicationName,
KeyName, Nothing, FilePath)
            If i = 0 Then
                Return False
            Else
                Return True
            End If
        Else
            Return False
        End If
    End Function
    ”’ <summary>
    ”’ 删除节点
    ”’ </summary>
    ”’ <param name=”ApplicationName”>节点名</param>
    ”’ <param name=”FilePath”>INI文件路径</param>
    ”’ <returns></returns>
    ”’ <remarks></remarks>
    Public Function DelApplication(ByVal ApplicationName As String,
ByVal FilePath As String) As Boolean
        If File.Exists(FilePath) Then
            Dim i As Long = WritePrivateProfileString(ApplicationName,
Nothing, Nothing, FilePath)
            If i = 0 Then
                Return False
            Else
                Return True
            End If
        Else
            Return False
        End If
    End Function
End Class

Imports Dsdt.CasinoManager.BusinessRule
Imports Wireless.Entities

Imports Wireless.Entities
Imports Wireless.Printer.RemotingConnection
Imports Wireless.Common
Imports Dsdt.CasinoManager.BusinessRule
Imports HNA.PubClass.DishModel

Namespace Common
    Public Class GlobalDataProvider

Namespace DishInterface

        Private Shared Instance As GlobalDataProvider = New GlobalDataProvider()

    Public Delegate Sub PrintBillDeletate(ByVal IsLaress As Boolean, ByVal machineNumber As String, ByVal data As List(Of BillList), ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
    Public Class OrderDishesImpl

        ‘保存登录用户信息的文件
        Private Shared loginUserStatusFile As String = String.Concat(Application.StartupPath, “/Config/LoginStatus.txt”)

        Private Shared _currentTable As Table

        Public Shared userList As New List(Of LoginUserStatus)

        Private Shared uStatus As Wireless.Entities.LoginUserStatus

        ‘所有菜品列表
        Private _lstMenu As List(Of Dsdt.CasinoManager.BusinessRule.Menu)

        ‘种数(本次点菜)
        Private Shared _orderKindCount As Decimal
        ‘份数(本次点菜)
        Private Shared _copiesCount As Decimal

        Private _menus As MenusClass

        ”’ <summary>
        ”’ 点菜 (入单)
        ”’ </summary>
        ”’ <param name=”argOrderDishes”></param>
        ”’ <returns></returns>
        ”’ <remarks></remarks>
        Public Shared Function OrderDishes(ByVal argOrderDishes As Entities.OrderDishes()) As String

        Private _threadFlag As Boolean = False

            If argOrderDishes Is Nothing OrElse argOrderDishes.Length < 1 Then
                Throw New Exception(“获取菜单数据异常!”)
            End If

        ”’ <summary>
        ”’ 
        ”’ </summary>
        ”’ <param name=”vMachineNo”></param>
        ”’ <returns></returns>
        ”’ <remarks></remarks>
        Public Shared Function IsLogin(ByVal vMachineNo As String) As Boolean
            For Each uStatus As LoginUserStatus In userList
                If (vMachineNo.Equals(uStatus.MachineNo) = True) Then
                    Return True
                End If
            Next
            Return False
        End Function

            Dim message As String = String.Empty
            Dim result As String = String.Format(“{0} {1}{2}”, MobilFormatUtil.FormatString(argOrderDishes(0).TypeCode, 4), _
                                                          MobilFormatUtil.FormatString(argOrderDishes(0).MachineNumber, 3), _
                                                         vbCrLf)

        ”’ <summary>
        ”’ 获取机器号的登录用户信息
        ”’ </summary>
        ”’ <param name=”vMachineNo”></param>
        ”’ <returns></returns>
        ”’ <remarks></remarks>
        Public Shared Function GetLoginUserStatusByMachineNo(ByVal vMachineNo As String) As LoginUserStatus
            For Each uStatus As LoginUserStatus In userList
                If vMachineNo = uStatus.MachineNo Then
                    Return uStatus
                End If
            Next
            Return Nothing
        End Function

            uStatus = GlobalDataProvider.GetLoginUserStatusByMachineNo(argOrderDishes(0).MachineNumber)
            If uStatus Is Nothing Then
                Return String.Concat(result, “请先登录!”)
            End If

        ”’ <summary>
        ”’ 当前正在处理的点单对象
        ”’ </summary>
        ”’ <remarks></remarks>
        Private Shared _orderList As New List(Of OrderRunningNumber)

            ‘将手持设备的台号(nWireTableId)映射为原有的桌号(cCode)
            For i As Integer = 0 To argOrderDishes.Length – 1
                argOrderDishes(i).TabelNoBillNo = TableCollection.All.GetCodeByWirlessId(argOrderDishes(i).TabelNoBillNo)
            Next

        ”” <summary>
        ”” 判断当前的入单是否应该处理,若在列表中则不处理,否则,将当前的点单追加到列表中()
        ”” </summary>
        ”” <remarks></remarks>
        ‘Public Shared Function IsOrderProcess(ByVal machineNo As String, ByVal runningNo As String) As Boolean
        ‘    For Each item As OrderRunningNumber In _orderList
        ‘        If item.MachineNo = machineNo AndAlso item.RunningNo = runningNo AndAlso item.IsSuccess = True Then
        ‘            Return True
        ‘        End If
        ‘    Next
        ‘    Dim newOrder As New OrderRunningNumber
        ‘    newOrder.MachineNo = machineNo
        ‘    newOrder.RunningNo = runningNo
        ‘    _orderList.Add(newOrder)
        ‘    Return False
        ‘End Function

            If argOrderDishes(0).TabelNoBillNo Is Nothing Then
                Return String.Concat(result, “台不存在!”)
            End If

        ”’ <summary>
        ”’ 返回已经上次的点单流水记录
        ”’ </summary>
        ”’ <returns></returns>
        ”’ <remarks></remarks>
        Public Shared Function GetLastOrderLine(ByVal machineNo As String, ByVal runningNo As String) As OrderRunningNumber
            For Each item As OrderRunningNumber In OrderList
                If item.MachineNo = machineNo AndAlso item.RunningNo = runningNo Then
                    Return item
                End If
            Next
            Return Nothing
        End Function

            ‘取得台对象
            _currentTable = TableCollection.All.GetTableByCode(argOrderDishes(0).TabelNoBillNo.Trim)
            _currentTable = TableCollection.All.GetOneTables(_currentTable.ID)

        ”’ <summary>
        ”’ 如果当前的入单操作完成,则从列表中删除(释放内存空间)
        ”’ </summary>
        ”’ <param name=”machineNo”></param>
        ”’ <param name=”runningNo”></param>
        ”’ <remarks></remarks>
        Public Shared Sub RemoveProceedOrder(ByVal machineNo As String, ByVal runningNo As String)
            For i As Integer = OrderList.Count – 1 To 0
                If OrderList(i).MachineNo = machineNo AndAlso OrderList(i).RunningNo = runningNo Then
                    OrderList.RemoveAt(i)
                End If
            Next
        End Sub

            If _currentTable Is Nothing Then
                Return String.Concat(result, “台不存在!”)
            End If
            ‘取得当前台所有开台 
            Dim _currentOpentTables As OpenTableCollection = _currentTable.GetOpenTables()

        ”’ <summary>
        ”’ 初始化数据
        ”’ </summary>
        ”’ <returns></returns>
        ”’ <remarks></remarks>
        Public Shared Function InitializeData() As Boolean
            Dim dThread As Threading.Thread
            dThread = New Threading.Thread(AddressOf DownloadThread)
            dThread.Start()
        End Function

            If _currentOpentTables Is Nothing OrElse _currentOpentTables.Count < 1 Then
                Return String.Concat(result, “当前台未开!”)
            End If

        Private Shared Sub DownloadThread()
            ‘获取所有菜品
            If Instance._menus Is Nothing Then
                Instance._menus = New MenusClass()
            End If
        End Sub

            ‘NOTE :取得当前开台对象 
            Dim _openTable As Dsdt.CasinoManager.BusinessRule.OpenTable = _currentOpentTables(0)

        Private Sub New()
            ‘singleton
        End Sub

            ‘判断当前台的账单状态
            If _openTable.CurrentBillState = BillState.Printed Then
                Return String.Concat(result, “本单已预结,请先解冻!”)
            Else
                Try
                    ‘执行入单操作
                    ‘本次点菜种数和份数
                    _orderKindCount = 0
                    _copiesCount = 0

        ”’ <summary>
        ”’ 
        ”’ </summary>
        ”’ <value></value>
        ”’ <returns></returns>
        ”’ <remarks></remarks>
        Public Shared ReadOnly Property Menus() As MenusClass
            Get
                Return Instance._menus
            End Get
        End Property

                    If ExecInsertBillList(argOrderDishes, False, -1) Then
                        ‘取得累计点菜种类和份数
                        Dim billLists As BillListCollection = _openTable.GetBillLists
                        Dim _totalOrderKindCount As Decimal = billLists.Count
                        Dim _totalCopiesCount As Decimal

        Public Shared Property threadFlag() As Boolean
            Get
                Return Instance._threadFlag
            End Get
            Set(ByVal value As Boolean)
                Instance._threadFlag = value
            End Set
        End Property

                        For Each item As BillList In billLists
                            _totalCopiesCount += item.Count
                        Next
                        message = String.Format(“点菜成功”)
                        ‘message = String.Format(“点菜成功!” + vbCrLf, _
                        ‘                        “{0} 本次点菜:{1}种/{2}份 累计点菜:{3}种/{4}份”, _
                        ‘                        argOrderDishes(0).TabelNoBillNo, _
                        ‘                         _orderKindCount, _copiesCount, _
                        ‘                        _totalOrderKindCount, _totalCopiesCount _
                        ‘                        )
                    Else
                        message = “点菜失败!”
                    End If
                Catch ex As Exception
                    message = “点菜失败!”
                End Try
            End If

        ”’ <summary>
        ”’ 当前正在处理的点单对象
        ”’ </summary>
        ”’ <remarks></remarks>
        Public Shared Property OrderList() As List(Of OrderRunningNumber)
            Get
                Return _orderList
            End Get
            Set(ByVal value As List(Of OrderRunningNumber))
                _orderList = value
            End Set
        End Property

            Return String.Concat(result, message)

        ”’ <summary>
        ”’  当前用户是否已经登录
        ”’ </summary>
        ”’ <param name=”user”></param>
        ”’ <returns></returns>
        ”’ <remarks></remarks>
        Public Shared Function IsLogin(ByVal user As LoginUser) As Boolean

        End Function

        End Function

        ”’ <summary>
        ”’ 执行入单操作
        ”’ </summary>
        ”’ <param name=”argOrderDishes”></param>
        ”’ <param name=”IsLaress”></param>
        ”’ <param name=”nLargessManId”></param>
        ”’ <returns></returns>
        ”’ <remarks></remarks>
        Private Shared Function ExecInsertBillList(ByVal argOrderDishes As Entities.OrderDishes(), ByVal IsLaress As Boolean, ByVal nLargessManId As Integer) As Boolean

        ”’ <summary>
        ”’ 保存手持登录状态
        ”’ </summary>
        ”’ <param name=”user”></param>
        ”’ <remarks></remarks>
        Public Shared Sub ProcessLoginUser(ByVal user As LoginUser)
            If user Is Nothing Then
                Return
            End If

            Dim result As Boolean
            If argOrderDishes.Length > 0 Then
                ‘菜单List
                Dim data As New List(Of BillList)

        End Sub

                ‘将数据封装到BillList列表中
                For Each item As Entities.OrderDishes In argOrderDishes
                    data.Add(InsertDataToBillList(item, IsLaress, nLargessManId))
                    _orderKindCount += 1
                Next

        ”’ <summary>
        ”’ 写文件
        ”’ </summary>
        Public Shared Function SaveData(ByVal strData As String, ByVal strFileName As String) As Integer

                If data.Count > 0 Then
                    ‘
                    ‘If _currentTable.GetOpenTables()(0).InsertBillList(data, argOrderDishes(0).MachineNumber, argOrderDishes(0).MachineNumber) Then
                    If _currentTable.GetOpenTables()(0).InsertBillList(data, uStatus.UserId, argOrderDishes(0).MachineNumber) Then
                        ‘Print
                        Dim printDelegate As PrintBillDeletate = New PrintBillDeletate(AddressOf PrintBill)
                        printDelegate.BeginInvoke(IsLaress, argOrderDishes(0).MachineNumber, data, _currentTable, uStatus, Nothing, Nothing)
                        result = True
                    Else
                        result = False
                    End If
                End If

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图