Ejemplo n.º 1
0
        public void NewDineInform(TcpClientInfo clientInfo, NewDineInformProtocol protocol)
        {
            lock (this) {
                NewDineInformClientGuid sender = GetSender(clientInfo);
                if (sender == null)
                {
                    log($"{clientInfo.OriginalRemotePoint} Received NewDineInform From Invalid NewDineInformClient", Log.LogLevel.Error);
                    clientInfo.Close();
                    return;
                }

                log($"{clientInfo.OriginalRemotePoint} (NewDineInform): From: {sender.Description}, HotelId: {protocol.HotelId}, DineId: {protocol.DineId}, IsPaid: {protocol.IsPaid}", Log.LogLevel.Success);

                foreach (var p in Clients)
                {
                    // 不向未连接的客户端与发送方客户端 发送新订单通知信息
                    if (p.Value == null || p.Value.Client == clientInfo.Client)
                    {
                        continue;
                    }

                    send(p.Value.Client, protocol);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> AddGuid(NewDineInformClientGuid clientGuid)
        {
            ctx.NewDineInformClientGuids.Add(clientGuid);
            int result = await ctx.SaveChangesAsync();

            return(result == 1);
        }
Ejemplo n.º 3
0
        public async Task <bool> DeleteGuid(Guid guid)
        {
            NewDineInformClientGuid clientGuid = await ctx.NewDineInformClientGuids.FirstOrDefaultAsync(p => p.Guid == guid);

            if (clientGuid == null)
            {
                return(false);
            }
            ctx.NewDineInformClientGuids.Remove(clientGuid);
            await ctx.SaveChangesAsync();

            return(true);
        }
Ejemplo n.º 4
0
        public async Task <bool> IsInNewDineInformClientGuids(Guid guid)
        {
            NewDineInformClientGuid clientGuid = await ctx.NewDineInformClientGuids.FirstOrDefaultAsync(p => p.Guid == guid);

            return(clientGuid != null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 请求打印交接班
        /// </summary>
        public void RequestPrintShifts(TcpClientInfo clientInfo, RequestPrintShiftsProtocol protocol, NewDineInformClientGuid sender)
        {
            lock (this) {
                if (sender == null)
                {
                    log($"{clientInfo.OriginalRemotePoint} Received RequestPrintShifts From Invalid NewDineInformClient", Log.LogLevel.Error);
                    clientInfo.Close();
                    return;
                }

                protocol.Ids = protocol.Ids ?? new List <int>();

                StringBuilder idStr = new StringBuilder();
                foreach (int id in protocol.Ids)
                {
                    idStr.Append($"{id} ");
                }

                log($"{clientInfo.OriginalRemotePoint} (RequestPrintShifts): From: {sender.Description}, HotelId: {protocol.HotelId}, Ids: {idStr}, DateTime: {protocol.DateTime.ToString("yyyy-MM-dd")}",
                    Log.LogLevel.Success);

                PrintShiftsProtocol p = new PrintShiftsProtocol(protocol.Ids, protocol.DateTime);
                if (Clients[protocol.HotelId] == null)
                {
                    WaitedQueue[protocol.HotelId].Enqueue(p);
                    log($"Printer of Hotel {protocol.HotelId} is not connected", Log.LogLevel.Error);
                    return;
                }
                sendPrintShiftsProtocol(protocol.HotelId, p);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 请求打印订单
        /// </summary>
        public void RequestPrintDine(TcpClientInfo clientInfo, RequestPrintDineProtocol protocol, NewDineInformClientGuid sender)
        {
            lock (this) {
                if (sender == null)
                {
                    log($"{clientInfo.OriginalRemotePoint} Received RequestPrintDine From Invalid NewDineInformClient", Log.LogLevel.Error);
                    clientInfo.Close();
                    return;
                }

                protocol.DineMenuIds = protocol.DineMenuIds ?? new List <int>();
                protocol.PrintTypes  = protocol.PrintTypes ?? new List <PrintType>();

                StringBuilder dineMenuStr = new StringBuilder();
                for (int i = 0; i < protocol.DineMenuIds.Count; i++)
                {
                    dineMenuStr.Append(protocol.DineMenuIds[i]);
                    if (i != protocol.DineMenuIds.Count - 1)
                    {
                        dineMenuStr.Append(' ');
                    }
                }

                StringBuilder typeStr = new StringBuilder();
                foreach (var type in protocol.PrintTypes)
                {
                    typeStr.Append($"{type.ToString()} ");
                }

                log($"{clientInfo.OriginalRemotePoint} (RequestPrintDine): From: {sender.Description}, HotelId: {protocol.HotelId}, DineId: {protocol.DineId}, DineMenuIds: {dineMenuStr}, PrintTypes: {typeStr}",
                    Log.LogLevel.Success);

                PrintDineProtocol p = new PrintDineProtocol(protocol.DineId, protocol.DineMenuIds, protocol.PrintTypes);
                if (Clients[protocol.HotelId] == null)
                {
                    WaitedQueue[protocol.HotelId].Enqueue(p);
                    log($"Printer of Hotel {protocol.HotelId} is not connected", Log.LogLevel.Error);
                    return;
                }
                sendPrintDineProtocol(protocol.HotelId, p);
            }
        }