Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8506b42fc4 | ||
|
|
00a9562f33 | ||
|
|
d98ad06813 |
14
GetGames.cs
14
GetGames.cs
@@ -14,8 +14,9 @@ namespace azfx_calendars_functions_dotnet
|
|||||||
{
|
{
|
||||||
public static readonly HttpClient client = new HttpClient();
|
public static readonly HttpClient client = new HttpClient();
|
||||||
|
|
||||||
|
[Disable("IS_DISABLED")]
|
||||||
[FunctionName("GetGames")]
|
[FunctionName("GetGames")]
|
||||||
public static async Task Run([TimerTrigger("0 30 19 * * *")]TimerInfo myTimer, ILogger log)
|
public static async Task Run([TimerTrigger("0 0 12 * * *")]TimerInfo myTimer, ILogger log)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -40,15 +41,15 @@ namespace azfx_calendars_functions_dotnet
|
|||||||
string responseBody = await response.Content.ReadAsStringAsync();
|
string responseBody = await response.Content.ReadAsStringAsync();
|
||||||
Schedule.Root schedule = JsonConvert.DeserializeObject<Schedule.Root>(responseBody);
|
Schedule.Root schedule = JsonConvert.DeserializeObject<Schedule.Root>(responseBody);
|
||||||
|
|
||||||
string siteName = team.name.Replace(" ", String.Empty);
|
string siteName = teamName.Replace(".", "").Replace(" ", String.Empty);
|
||||||
string serverRelativeUrl = string.Format("/sites/{0}", siteName);
|
string serverRelativeUrl = string.Format("/sites/{0}", siteName);
|
||||||
|
|
||||||
foreach (Schedule.Date date in schedule.dates)
|
foreach (Schedule.Date date in schedule.dates)
|
||||||
{
|
{
|
||||||
foreach (Schedule.Game game in date.games)
|
foreach (Schedule.Game game in date.games)
|
||||||
{
|
{
|
||||||
string opponent = game.teams.home.team.id == team.id ? game.teams.away.team.name : game.teams.home.team.name;
|
|
||||||
Boolean isHomeTeam = game.teams.home.team.id == team.id ? true : false;
|
Boolean isHomeTeam = game.teams.home.team.id == team.id ? true : false;
|
||||||
|
string opponent = game.teams.home.team.id == team.id ? game.teams.away.team.name : game.teams.home.team.name;
|
||||||
Dictionary<string, object> additionalData = new Dictionary<string, object>();
|
Dictionary<string, object> additionalData = new Dictionary<string, object>();
|
||||||
List<string> gameType = new List<string>();
|
List<string> gameType = new List<string>();
|
||||||
string gamePk = game.gamePk.ToString();
|
string gamePk = game.gamePk.ToString();
|
||||||
@@ -84,8 +85,9 @@ namespace azfx_calendars_functions_dotnet
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
additionalData.Add("Title", opponent);
|
additionalData.Add("Title", teamName);
|
||||||
additionalData.Add("IsHomeTeam", isHomeTeam);
|
additionalData.Add("IsHomeTeam", isHomeTeam);
|
||||||
|
additionalData.Add("Opponent", opponent);
|
||||||
additionalData.Add("Location", game.venue.name);
|
additionalData.Add("Location", game.venue.name);
|
||||||
additionalData.Add("GameType", gameType[0].ToString());
|
additionalData.Add("GameType", gameType[0].ToString());
|
||||||
additionalData.Add("GameStatus", game.status.detailedState);
|
additionalData.Add("GameStatus", game.status.detailedState);
|
||||||
@@ -121,8 +123,8 @@ namespace azfx_calendars_functions_dotnet
|
|||||||
|
|
||||||
foreach (KeyValuePair<string, object> entry in listItemFields) {
|
foreach (KeyValuePair<string, object> entry in listItemFields) {
|
||||||
if (entry.Key != "@odata.etag") {
|
if (entry.Key != "@odata.etag") {
|
||||||
var listItemFieldValue = entry.Value.ToString();
|
string listItemFieldValue = entry.Value.ToString();
|
||||||
var additionalDataKeyValue = additionalData[entry.Key].ToString();
|
string additionalDataKeyValue = additionalData[entry.Key].ToString();
|
||||||
|
|
||||||
if (listItemFieldValue != additionalDataKeyValue) {
|
if (listItemFieldValue != additionalDataKeyValue) {
|
||||||
fieldValuesToUpdate.Add(entry.Key, additionalDataKeyValue);
|
fieldValuesToUpdate.Add(entry.Key, additionalDataKeyValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user