public async Task <ShopsData> GetShopsData() { var shopsDataQuery = @"{ shops { id } productTypes { name }}"; _logger.LogInformation("Fetching shops data..."); try { var qraphQLShopsData = await RetryUtils.RetryIfThrown <Exception, GraphQLResponse <GraphQLShopsData> >(async() => await SendQueryAsync <GraphQLShopsData>(_clientUrl, shopsDataQuery), 10, 250, 1000); var shopsData = new ShopsData() { ProductsIDs = qraphQLShopsData.Data.ProductTypes.Select(x => x.Name).ToList(), ShopsIDs = qraphQLShopsData.Data.Shops.Select(x => x.Id).ToList() }; if (qraphQLShopsData.Errors != null) { _logger.LogWarning($"Fetched shops data with warnings: {qraphQLShopsData.Errors}"); return(shopsData); } _logger.LogInformation("Fetched shops data successfully"); return(shopsData); } catch (Exception e) { _logger.LogError(ExceptionEvents.GenerateEventId(LoggerEventType.GraphQLClient), e, "Error while getting shop data"); return(null); } }
public void OnShop(ServerMsgObj msg) { ShopsData shopRes = JsonUtility.FromJson <ShopsData>(msg.Msg); ShopItem[] shop = null; int type = 0; if (shopRes.shop_1.Length > 0) { type = 1; shop = shopRes.shop_1; } else if (shopRes.shop_2.Length > 0) { type = 2; shop = shopRes.shop_2; } else if (shopRes.shop_3.Length > 0) { type = 3; shop = shopRes.shop_3; } else if (shopRes.shop_4.Length > 0) { type = 4; shop = shopRes.shop_4; } else if (shopRes.shop_5.Length > 0) { type = 5; shop = shopRes.shop_5; } Debug.Log(shop.Length); if (shop.Length > 0) { ShopMgr.Instance.ServerGoods(type, shop); ZEventSystem.Dispatch(EventConst.ShowUnitShop, type); } }