Beispiel #1
0
        protected bool AddClientStation(string userName, string senderIP, int senderPort)
        {
            try
            {
                if (_clientList.Count(c => c.UserName == userName) > 0)
                {
                    // duplicate logging in of one user
                }
                else
                {
                    ClientStation client = _clientList.SingleOrDefault(c => c.UserName == userName);

                    if (client != null && (client.IPAddress != senderIP || client.Port != senderPort))
                    {
                        client.IPAddress = senderIP;
                        client.Port      = senderPort;
                    }
                    else
                    {
                        _clientList.Add(new ClientStation(userName, senderIP, senderPort));
                    }
                }
                return(true);
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[AddClientStation]", exc);
                return(false);
            }
        }
        public string Logout(string userName, string senderIP, string senderPort)
        {
            try
            {
                ServerLogger.logInfo("Login", string.Format("User Logout [userName: {0}] - [Port: {1}]", userName, senderPort), serverView);

                ClientStation client = _clientList.FirstOrDefault(c => c.UserName == userName && c.IPAddress == senderIP && c.Port == int.Parse(senderPort));
                if (client != null)
                {
                    _clientList.Remove(client);
                    return("");
                }
                return("Người dùng này chưa được Đăng Nhập");
            }
            catch (Exception exc)
            {
                ServerLogger.logError("[Logout]", exc);
                return(exc.Message);
            }
        }
Beispiel #3
0
        protected string SendNotifyToClient(ClientStation client, ClientAction action, params object[] args)
        {
            string result = "";

            switch (action)
            {
            case ClientAction.CancelTicket:
                result = client.TargetClient.CancelTicket(args[0] as TTicket);
                break;

            case ClientAction.CheckConnection:
                result = client.TargetClient.CheckConnection(args[0] as string) ? "SUCCESS" : "FAIL";
                break;

            case ClientAction.CompleteOrder:
                result = client.TargetClient.CompleteOrder(args[0] as TOrder);
                break;

            case ClientAction.CreateOrder:
                result = client.TargetClient.CreateTransportOrder(args[0] as TOrder, args[1] as List <TOrderItem>);
                break;

            case ClientAction.ReloadCustomerLoading:
                result = client.TargetClient.ReloadCustomerLoading(args[0] as List <TCustomer>);
                break;

            case ClientAction.ReloadOrderLoading:
                result = client.TargetClient.ReloadOrderLoading(args[0] as List <TOrder>, args[1] as List <TOrderItem>);
                break;

            case ClientAction.ReloadSaleTicketDate:
                result = client.TargetClient.ReloadSaleTicketDate(args[0] as List <TSaleTicketDate>);
                break;

            case ClientAction.ReloadSystemSetting:
                result = client.TargetClient.ReloadSystemSetting(args[0] as List <TConfiguration>);
                break;

            case ClientAction.ReloadTicketLoading:
                result = client.TargetClient.ReloadTicketLoading(args[0] as List <TTicket>);
                break;

            case ClientAction.ReloadTicketPrice:
                result = client.TargetClient.ReloadTicketPrice(args[0] as List <TTicketPrice>);
                break;

            case ClientAction.ReloadTransportPrice:
                result = client.TargetClient.ReloadTransportPrice(args[0] as List <TTransportPrice>);
                break;

            case ClientAction.SellTicket:
                result = client.TargetClient.CreateNewTicket(args[0] as TTicket);
                break;

            case ClientAction.UpdateOrder:
                result = client.TargetClient.UpdateOrderInfo(args[0] as TOrder, args[1] as List <TOrderItem>);
                break;

            case ClientAction.UpdateTicket:
                result = client.TargetClient.UpdateTicket(args[0] as TTicket);
                break;
            }

            return(result);
        }