Пример #1
0
        public object run(LogicProcess process)
        {
            bool            success  = false;
            IMarketResponse response = process.comm.SendQueryUserRequest();

            if (response.getType() == ResponseType.qUser)
            {
                MQUser resp = (MQUser)response;
                Dictionary <string, int> commodityList = resp.getCommodities();
                int currAmount = commodityList[process.commodity.ToString()];
                success = (currAmount > 0);
            }
            next(process, success);
            return(response);
        }
Пример #2
0
        public int gatherInfo()
        {
            int numOfReqeusts = 0;

            //backup
            MQUser oldUserData = userData;
            List <MQCommodityWrapper> oldCommoditiesInfo = commoditiesInfo;
            List <MQReqWrapper>       oldRequestsInfo    = requestsInfo;


            //Gather data from the server
            try
            {
                userData = (MQUser)comm.SendQueryUserRequest(); numOfReqeusts++;
            }
            catch (Exception e)
            {
                userData = oldUserData;
                myLogger.Error("AMA failed to acquire userData: " + e.Message);
            }

            try
            {
                commoditiesInfo = comm.SendQueryAllMarketRequest(); numOfReqeusts++;
            }
            catch (Exception e)
            {
                commoditiesInfo = oldCommoditiesInfo;
                myLogger.Error("AMA failed to acquire commoditiesInfo: " + e.Message);
            }

            try
            {
                requestsInfo = comm.SendQueryAllUserRequest(); numOfReqeusts++;
            }
            catch (Exception e)
            {
                requestsInfo = oldRequestsInfo;
                myLogger.Error("AMA failed to acquire requestsInfo: " + e.Message);
            }
            //return number of requests in this method
            return(numOfReqeusts);
        }
Пример #3
0
        public IMarketResponse SendQueryUserRequest()
        {
            QueryUserRequest userReq        = new QueryUserRequest(); //create query user requset
            MQUser           marketResponse = new MQUser();

            try
            {
                marketResponse = client.SendPostRequest <QueryUserRequest, MQUser>(url, user, privateKey, userReq);
                myLogger.Info("Sent Query Buy/Sell Request{user:"******", url:" + url);
            }
            catch (Exception e)
            {
                return(catchMethod(e));
            }

            myHistory.Info("Sent Query Buy/Sell Request-\r\nuser:"******"\n Response: " + marketResponse.ToString());

            return(marketResponse);
        }