Esempio n. 1
0
        public FXServer(string[] args)
        {
            Util.SetConsoleTitle("FXServer");

            DbConn dbConn = new DbConn();

            Console.WriteLine("Reading currencies from db");
            List<CurrencyMsgItem> tmpList = new List<CurrencyMsgItem>();
            SqlDataReader reader = dbConn.ExecuteQuery(new SqlCommand("SELECT ID, ShortName, USDValue FROM Currency ORDER BY ID ASC"));
            while (reader.Read()) {
                int id = reader.GetInt32(0);
                string shortName = reader.GetString(1);
                decimal USDValue = reader.GetDecimal(2);
                Console.WriteLine("{0}: {1}", id, USDValue);
                tmpList.Add(new CurrencyMsgItem(id, USDValue));

                //we don't make the price of USD fluctuate relative to USD...
                if (shortName == "USD")
                    USDID = id;
            }
            reader.Close();
            currencies.items = tmpList.ToArray();

            dbConn.Dispose();

            bankServer = new Server(ServerConfigs["FXServer-Bank"], AppSettings, true);
        }
Esempio n. 2
0
        public ShippingCompany(string[] args)
        {
            myID = SetID("ShippingCompany", args);

            int nTraders;
            try
            {
                nTraders = Int32.Parse(args[1]);
            }
            catch (Exception)
            {
                throw new ApplicationException("Requires 2 command line arguments: first is id, second is number of traders");
            }

            DbConn dbConn = new DbConn();
            portDistances = DBUtil.GetPortDistancesLookup(dbConn);
            dbConn.Dispose();

            bankClient = new Client(ServerConfigs["Bank-Shipping"], AppSettings, myID, false);

            var conf = ServerConfigs["Trader-Shipping"];
            for (int i = 0; i != nTraders; ++i)
            {
                traderClients[conf.port] = new Client(conf, AppSettings, myID, false);
                moveWishes[conf.port] = new List<MoveContractMsg>();
                conf.port += 1;
            }
        }