代码
Imports Dsdt.CasinoManager.BusinessRule
Imports Wireless.Entities
Namespace Common
Public Class GlobalDataProvider
Private Shared Instance As GlobalDataProvider = New GlobalDataProvider()
'保存登录用户信息的文件
Private Shared loginUserStatusFile As String = String.Concat(Application.StartupPath, "/Config/LoginStatus.txt")
Public Shared userList As New List(Of LoginUserStatus)
'所有菜品列表
Private _lstMenu As List(Of Dsdt.CasinoManager.BusinessRule.Menu)
Private _menus As MenusClass
Private _threadFlag As Boolean = False
''' <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
''' <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
''' <summary>
''' 当前正在处理的点单对象
''' </summary>
''' <remarks></remarks>
Private Shared _orderList As New List(Of OrderRunningNumber)
'''' <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
''' <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
''' <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
''' <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
Private Shared Sub DownloadThread()
'获取所有菜品
If Instance._menus Is Nothing Then
Instance._menus = New MenusClass()
End If
End Sub
Private Sub New()
'singleton
End Sub
''' <summary>
'''
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Shared ReadOnly Property Menus() As MenusClass
Get
Return Instance._menus
End Get
End Property
Public Shared Property threadFlag() As Boolean
Get
Return Instance._threadFlag
End Get
Set(ByVal value As Boolean)
Instance._threadFlag = value
End Set
End Property
''' <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
''' <summary>
''' 当前用户是否已经登录
''' </summary>
''' <param name="user"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function IsLogin(ByVal user As LoginUser) As Boolean
End Function
''' <summary>
''' 保存手持登录状态
''' </summary>
''' <param name="user"></param>
''' <remarks></remarks>
Public Shared Sub ProcessLoginUser(ByVal user As LoginUser)
If user Is Nothing Then
Return
End If
End Sub
''' <summary>
''' 写文件
''' </summary>
Public Shared Function SaveData(ByVal strData As String, ByVal strFileName As String) As Integer
On Error GoTo SysErr
Dim i As Short
SaveData = 1
FileOpen(1, strFileName, OpenMode.Output)
PrintLine(1, strData)
FileClose(1)
Exit Function
SysErr:
FileClose(1)
MsgBox(Err.Description)
Err.Clear()
End Function
End Class
End NameSpace
Imports Wireless.Entities
Namespace Common
Public Class GlobalDataProvider
Private Shared Instance As GlobalDataProvider = New GlobalDataProvider()
'保存登录用户信息的文件
Private Shared loginUserStatusFile As String = String.Concat(Application.StartupPath, "/Config/LoginStatus.txt")
Public Shared userList As New List(Of LoginUserStatus)
'所有菜品列表
Private _lstMenu As List(Of Dsdt.CasinoManager.BusinessRule.Menu)
Private _menus As MenusClass
Private _threadFlag As Boolean = False
''' <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
''' <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
''' <summary>
''' 当前正在处理的点单对象
''' </summary>
''' <remarks></remarks>
Private Shared _orderList As New List(Of OrderRunningNumber)
'''' <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
''' <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
''' <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
''' <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
Private Shared Sub DownloadThread()
'获取所有菜品
If Instance._menus Is Nothing Then
Instance._menus = New MenusClass()
End If
End Sub
Private Sub New()
'singleton
End Sub
''' <summary>
'''
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Shared ReadOnly Property Menus() As MenusClass
Get
Return Instance._menus
End Get
End Property
Public Shared Property threadFlag() As Boolean
Get
Return Instance._threadFlag
End Get
Set(ByVal value As Boolean)
Instance._threadFlag = value
End Set
End Property
''' <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
''' <summary>
''' 当前用户是否已经登录
''' </summary>
''' <param name="user"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function IsLogin(ByVal user As LoginUser) As Boolean
End Function
''' <summary>
''' 保存手持登录状态
''' </summary>
''' <param name="user"></param>
''' <remarks></remarks>
Public Shared Sub ProcessLoginUser(ByVal user As LoginUser)
If user Is Nothing Then
Return
End If
End Sub
''' <summary>
''' 写文件
''' </summary>
Public Shared Function SaveData(ByVal strData As String, ByVal strFileName As String) As Integer
On Error GoTo SysErr
Dim i As Short
SaveData = 1
FileOpen(1, strFileName, OpenMode.Output)
PrintLine(1, strData)
FileClose(1)
Exit Function
SysErr:
FileClose(1)
MsgBox(Err.Description)
Err.Clear()
End Function
End Class
End NameSpace