Exemple #1
0
        private static void Main(string[] args)
        {
            Log.Debug($"{nameof(Main)} (enter)");

            SignatureService.LoadPublicKey("Team1/StockServer");

            ConversationManager.Start(ConversationBuilder);
            ComService.AddUdpClient(Config.DEFAULT_UDP_CLIENT, Config.GetInt(Config.BROKER_PORT));

            RequestStockStream();
            PrintMenu();
            PortfolioManager.LoadPortfolios();

            var input = Console.ReadLine();

            while (!input.Equals("exit"))
            {
                RequestStockStream();
                PrintMenu();
                input = Console.ReadLine();
            }

            ConversationManager.Stop();

            Log.Debug($"{nameof(Main)} (exit)");
        }
Exemple #2
0
        private static Conversation HandleGetPortfolio(Envelope e)
        {
            Conversation conv = null;

            GetPortfolioRequest m = e.Contents as GetPortfolioRequest;

            var user = m.Account.Username;
            var pass = m.Account.Password;

            if (PortfolioManager.TryToGet(user, pass, out Portfolio portfolio))
            {
                conv = new GetPortfoliolResponseConversation(m.ConversationID);
                conv.SetInitialState(new GetPortfolioReceiveState(e, conv));
            }
            else
            {
                conv = new SendErrorMessageConversation(m.ConversationID);
                conv.SetInitialState(new SendErrorMessageState("Invalid login credentials.", e, conv, null, Config.GetInt(Config.BROKER_PROCESS_NUM)));
            }

            return(conv);
        }