コード例 #1
0
        public static async Task Run([TimerTrigger("0 0 11 * * SUN")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation("DeleteTableData function executed");

            Task <(CloudTableClient, CloudTable)> connectionVariables = GeneralHelpers.CreateConnectionVariables(log);

            if (connectionVariables.Result.Item1 != null && connectionVariables.Result.Item2 != null)
            {
                List <DataTableEntity> queriedData = await QueryWeatherDataAsync(connectionVariables.Result.Item2, log);

                if (queriedData.Count > 0)
                {
                    double days = ConfigReader.BeforeDays;

                    List <DataTableEntity> deletableRows = queriedData.Where(r => r.Timestamp
                                                                             < DateTime.UtcNow.AddDays(days)).ToList();

                    if (deletableRows.Count > 0)
                    {
                        await DeleteEntityAsync(deletableRows, connectionVariables.Result.Item2, log);
                    }
                }
            }

            log.LogInformation("DeleteTableData function execution is ready");
        }
コード例 #2
0
        public static async Task <List <DataTableEntity> > GetLatestEntityAsync(ILogger log)
        {
            log.LogInformation($"GetLatestEntity");

            List <DataTableEntity> entity = new List <DataTableEntity>();

            Task <(CloudTableClient, CloudTable)> connectionVariables = GeneralHelpers.CreateConnectionVariables(log);

            if (connectionVariables.Result.Item1 != null && connectionVariables.Result.Item2 != null)
            {
                CloudTable             t    = connectionVariables.Result.Item2;
                List <DataTableEntity> data = await GeneralHelpers.QueryTableDataAsync(t);

                entity = data.OrderByDescending(e => e.Timestamp).Take(5).ToList();
            }

            return(entity);
        }