Skip to content

Commit

Permalink
Updated to GA version of Azure Functions 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
robdmoore committed Oct 11, 2018
1 parent 62ec63b commit 74e25ba
Show file tree
Hide file tree
Showing 31 changed files with 182 additions and 117 deletions.
37 changes: 37 additions & 0 deletions DDD.Core/AppInsights/AppInsightsUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using Microsoft.WindowsAzure.Storage.Table;

namespace DDD.Core.AppInsights
{
public class AppInsightsVotingUser : TableEntity
{
public AppInsightsVotingUser() { }

public AppInsightsVotingUser(string conferenceInstance, string userId, string voteId, string startTime)
{
PartitionKey = conferenceInstance;
RowKey = Guid.NewGuid().ToString();
UserId = userId;
VoteId = voteId;
StartTime = startTime;
}

public string UserId { get; set; }
public string VoteId { get; set; }
public string StartTime { get; set; }
}

public class AppInsightsVotingUserComparer : IEqualityComparer<AppInsightsVotingUser>
{
public bool Equals(AppInsightsVotingUser x, AppInsightsVotingUser y)
{
return x.UserId == y.UserId && x.VoteId == y.VoteId;
}

public int GetHashCode(AppInsightsVotingUser obj)
{
return (obj.UserId + "|" + obj.VoteId).GetHashCode();
}
}
}
19 changes: 19 additions & 0 deletions DDD.Core/Eventbrite/EventbriteOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.WindowsAzure.Storage.Table;

namespace DDD.Core.Eventbrite
{
public class EventbriteOrder : TableEntity
{
public EventbriteOrder()
{
}

public EventbriteOrder(string conferenceInstance, string orderNumber)
{
PartitionKey = conferenceInstance;
RowKey = orderNumber;
}

public string OrderId => RowKey;
}
}
45 changes: 45 additions & 0 deletions DDD.Core/Voting/Vote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using Microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;

namespace DDD.Core.Voting
{
public class Vote : TableEntity
{
public Vote() { }

public Vote(string conferenceInstance, Guid voteId, string[] sessionIds, int[] indices, string ticketNumber, string ipAddress, string voterSessionId, DateTimeOffset votingStartTime, DateTimeOffset votingSubmittedTime)
{
PartitionKey = conferenceInstance;
RowKey = voteId.ToString();
SessionIds = JsonConvert.SerializeObject(sessionIds);
Indices = JsonConvert.SerializeObject(indices);
TicketNumber = ticketNumber;
IpAddress = ipAddress;
VoterSessionId = voterSessionId;
VotingStartTime = votingStartTime;
VotingSubmittedTime = votingSubmittedTime;
}

public string SessionIds { get; set; }

public string[] GetSessionIds()
{
return JsonConvert.DeserializeObject<string[]>(SessionIds);
}

public string Indices { get; set; }

public string[] GetIndices()
{
return JsonConvert.DeserializeObject<string[]>(Indices);
}

public string TicketNumber { get; set; }
public string IpAddress { get; set; }
public string VoterSessionId { get; set; }
public DateTimeOffset VotingStartTime { get; set; }
public DateTimeOffset VotingSubmittedTime { get; set; }
public string VoteId => RowKey;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class AppInsightsSyncConfig : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class ConferenceConfig : Attribute
{
Expand Down
15 changes: 15 additions & 0 deletions DDD.Functions.Extensions/DDD.Functions.Extensions.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="microsoft.net.sdk.functions" Version="1.0.22" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DDD.Core\DDD.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class EventbriteSyncConfig : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class FeedbackConfig : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class KeyDatesConfig : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class NewSessionNotificationConfig : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Threading.Tasks;
using DDD.Core.AppInsights;
using DDD.Core.AzureStorage;
using DDD.Core.Eventbrite;
using DDD.Core.Voting;
using Microsoft.WindowsAzure.Storage;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public static class SessionData
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class SessionizeSyncConfig : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class SessionsConfig : Attribute
{
Expand Down
22 changes: 22 additions & 0 deletions DDD.Functions.Extensions/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Linq;
using DDD.Functions.Extensions;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host.Config;
using Microsoft.Azure.WebJobs.Hosting;

[assembly: WebJobsStartup(typeof(Startup))]

namespace DDD.Functions.Extensions
{
public class Startup : IWebJobsStartup
{
public void Configure(IWebJobsBuilder builder)
{
typeof(ConferenceConfig).Assembly.GetTypes()
.Where(t => typeof(IExtensionConfigProvider).IsAssignableFrom(t))
.ToList()
.ForEach(t => builder.AddExtension(t));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class SubmissionsConfig : Attribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.Azure.WebJobs.Description;
using Microsoft.Azure.WebJobs.Host.Config;

namespace DDD.Functions.Config
namespace DDD.Functions.Extensions
{
public class VotingConfig : Attribute
{
Expand Down
36 changes: 2 additions & 34 deletions DDD.Functions/AppInsightsSync.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using DDD.Functions.Config;
using DDD.Core.AppInsights;
using DDD.Functions.Extensions;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Table;

namespace DDD.Functions
{
Expand Down Expand Up @@ -92,35 +91,4 @@ public VotingUserQuery Hydrate(AppInsightsTableResponseColumn[] columns, string[
public string StartTime { get; set; }
public string VoteId { get; set; }
}

public class AppInsightsVotingUser : TableEntity
{
public AppInsightsVotingUser() {}

public AppInsightsVotingUser(string conferenceInstance, string userId, string voteId, string startTime)
{
PartitionKey = conferenceInstance;
RowKey = Guid.NewGuid().ToString();
UserId = userId;
VoteId = voteId;
StartTime = startTime;
}

public string UserId { get; set; }
public string VoteId { get; set; }
public string StartTime { get; set; }
}

public class AppInsightsVotingUserComparer : IEqualityComparer<AppInsightsVotingUser>
{
public bool Equals(AppInsightsVotingUser x, AppInsightsVotingUser y)
{
return x.UserId == y.UserId && x.VoteId == y.VoteId;
}

public int GetHashCode(AppInsightsVotingUser obj)
{
return (obj.UserId + "|" + obj.VoteId).GetHashCode();
}
}
}
4 changes: 2 additions & 2 deletions DDD.Functions/DDD.Functions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.0-beta7" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.13" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.22" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DDD.Functions.Extensions\DDD.Functions.Extensions.csproj" />
<ProjectReference Include="..\DDD.Sessionize\DDD.Sessionize.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
19 changes: 2 additions & 17 deletions DDD.Functions/EventbriteSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using DDD.Functions.Config;
using DDD.Core.Eventbrite;
using DDD.Functions.Extensions;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;

namespace DDD.Functions
Expand Down Expand Up @@ -81,19 +81,4 @@ public class Pagination
public string Continuation { get; set; }
[JsonProperty("has_more_items")] public bool HasMoreItems { get; set; }
}

public class EventbriteOrder : TableEntity
{
public EventbriteOrder()
{
}

public EventbriteOrder(string conferenceInstance, string orderNumber)
{
PartitionKey = conferenceInstance;
RowKey = orderNumber;
}

public string OrderId => RowKey;
}
}
2 changes: 1 addition & 1 deletion DDD.Functions/GetAgenda.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using DDD.Functions.Config;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using System.Linq;
using DDD.Functions.Extensions;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;

Expand Down
2 changes: 1 addition & 1 deletion DDD.Functions/GetFeedback.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using DDD.Functions.Config;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using System.Linq;
using DDD.Functions.Extensions;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;

Expand Down
2 changes: 1 addition & 1 deletion DDD.Functions/GetPrizeDraw.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using DDD.Functions.Config;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
using System.Linq;
using DDD.Functions.Extensions;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;

Expand Down
2 changes: 1 addition & 1 deletion DDD.Functions/GetSubmissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using DDD.Functions.Config;
using System.Threading.Tasks;
using System.Linq;
using System;
using DDD.Functions.Extensions;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;

Expand Down
Loading

0 comments on commit 74e25ba

Please sign in to comment.