Example #1
0
    public void LoadData()
    {
        dataLoaded = ReadGoogleSheet.FillDataHasList <TowerData, AttitudeField, LevelAttitude>("1fm4Mitj8s55MOAykzEjo6c6IHV3X9FX_T7HzBV1z22E", "0");
        GameData g = GameObject.FindObjectOfType <GameData>();

        g.Towers.ReplayData(dataLoaded);
    }
Example #2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            ReadGoogleSheet.Init();
            while (!stoppingToken.IsCancellationRequested)
            {
                _logger.LogInformation("Hosted 2 service executing - {0}", DateTime.Now);

                using (var scope = _scopeFactory.CreateScope())
                {
                    var _unitOfWork            = scope.ServiceProvider.GetRequiredService <IUnitOfWork>();
                    var _serviceService        = scope.ServiceProvider.GetRequiredService <IServiceService>();
                    var _serviceRequestService = scope.ServiceProvider.GetRequiredService <IServiceRequestService>();
                    var serviceList            = await _unitOfWork.ServiceRepository.GetServices();

                    foreach (var service in serviceList)
                    {
                        if (!string.IsNullOrEmpty(service.SheetLink) && service.SheetLink.Contains("spreadsheets/d/"))
                        {
                            //string url = "https://docs.google.com/spreadsheets/d/1skxD2Zt1mdggWnOrb32xeWCNNo5zmy7xCiwIJSDWhpw/edit#gid=221254995";
                            string   url   = service.SheetLink;
                            string[] parts = url.Split("spreadsheets/d/");
                            string   result;
                            if (parts[1].Contains("/"))
                            {
                                string[] parts2 = parts[1].Split("/");
                                result = parts2[0];
                            }
                            else
                            {
                                result = parts[1];
                            }
                            dynamic jsonList = ReadGoogleSheet.ReadSheet(result);
                            foreach (var json in jsonList)
                            {
                                await _serviceRequestService.UpdateServiceRequest(json.TicketId, new ServiceRequestModel { JsonInformation = json.JsonInformation });
                            }
                        }
                    }
                }
                await Task.Delay(TimeSpan.FromSeconds(13));
            }
        }