示例#1
0
        public void GetStartupsMarketsQuery_Success()
        {
            string startupIdsString = "13779,153114,54476,202927,228506,52745,168275,6702";

            string[] startupIdsStrings = startupIdsString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            int[]    startupIds        = Array.ConvertAll <string, int>(startupIdsStrings, new Converter <string, int>(Convert.ToInt32));

            // Get markets for this batch of users.
            var startupsMarketsCallback = new AsyncCallback(ProcessStartupsMarketsQuery);

            GetStartupsMarketsQuery startupsMarketsQuery = new GetStartupsMarketsQuery(startupIds.ToList(), startupsMarketsCallback, AngelListClient, defaultLogWriter);

            IAsyncResult result = startupsMarketsQuery.BeginExecute();

            if (!result.AsyncWaitHandle.WaitOne(20 * 1000))
            {
                throw new TimeoutException("GetStartupsMarketsQuery");
            }
        }
        public void LoadUsersMarkets(List <int> userIds)
        {
            // Get startup ids for the users.
            GetUsersStartupIdsQuery startupIdsQuery = new GetUsersStartupIdsQuery(userIds, AngelListClient);
            var userIdStartupIdsDict = startupIdsQuery.Execute();

            HashSet <int> uniqueStartupIds = new HashSet <int>();

            foreach (int userId in userIdStartupIdsDict.Keys)
            {
                foreach (int startupId in userIdStartupIdsDict[userId])
                {
                    uniqueStartupIds.Add(startupId);
                }
            }

            GetStartupsMarketsQuery          startupsMarketsQuery = new GetStartupsMarketsQuery(uniqueStartupIds.ToList(), userIdStartupIdsDict, AngelListClient, defaultLogWriter);
            Dictionary <int, List <Market> > result = (Dictionary <int, List <Market> >)startupsMarketsQuery.Execute();

            ProcessStartupsMarketsQuery(result, userIdStartupIdsDict);
        }