| @@ -12,11 +12,14 @@ | |||
| <PackageReference Include="Azure.Storage.Queues" Version="12.10.0" /> | |||
| <PackageReference Include="GemBox.Spreadsheet" Version="37.3.30.1110" /> | |||
| <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" /> | |||
| <PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" /> | |||
| <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" /> | |||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="4.0.4" /> | |||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" /> | |||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" /> | |||
| <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" /> | |||
| <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SendGrid" Version="3.0.2" /> | |||
| <PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.2.0" /> | |||
| <PackageReference Include="System.Core" Version="3.5.21022.801" /> | |||
| <PackageReference Include="System.Drawing.Common" Version="6.0.0" /> | |||
| <PackageReference Include="System.IO.Packaging" Version="6.0.0" /> | |||
| @@ -7,17 +7,24 @@ using System.Threading.Tasks; | |||
| using System.Net; | |||
| using System.Net.Http; | |||
| using System.Net.Http.Headers; | |||
| using GemBox.Spreadsheet; | |||
| using Microsoft.AspNetCore.Mvc; | |||
| using Microsoft.AspNetCore.Http; | |||
| using Microsoft.Build.Tasks.Deployment.Bootstrapper; | |||
| namespace BlackRockReportFunction.Bussines | |||
| { | |||
| public class ClockifyReports | |||
| { | |||
| public static string? clockifyApiKey = Environment.GetEnvironmentVariable("ClockifyApiKey"); | |||
| static HttpClient client = new HttpClient(); | |||
| static void InitializeClockifyIntegration() | |||
| public static async Task InitializeClockifyIntegration() | |||
| { | |||
| client.DefaultRequestHeaders.Add("X-API-Key", clockifyApiKey); | |||
| client.BaseAddress = new Uri("https://reports.api.clockify.me/v1"); | |||
| client.DefaultRequestHeaders.Accept.Clear(); | |||
| @@ -26,7 +33,7 @@ namespace BlackRockReportFunction.Bussines | |||
| .Add(new MediaTypeWithQualityHeaderValue("application/json")); | |||
| } | |||
| static async Task<Uri> CreateClockifyReport(ClockifyReport clockifyReport) | |||
| public static async Task<Uri> CreateClockifyReport(ClockifyReport clockifyReport) | |||
| { | |||
| HttpResponseMessage httpResponseMessage = await client | |||
| .PostAsJsonAsync("api/clockifyreport", clockifyReport); | |||
| @@ -36,7 +43,7 @@ namespace BlackRockReportFunction.Bussines | |||
| return httpResponseMessage.Headers.Location; | |||
| } | |||
| static async Task<ClockifyReport> GetClockifyReportAsync(string path) | |||
| public static async Task<ClockifyReport> GetClockifyReportAsync(string path) | |||
| { | |||
| ClockifyReport clockifyReport = null; | |||
| HttpResponseMessage httpResponseMessage= await client.GetAsync(path); | |||
| @@ -1,12 +1,6 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using GemBox.Spreadsheet; | |||
| using GemBox.Spreadsheet; | |||
| using BlackRockReportFunction.Models; | |||
| using BlackRockReportFunction.Helpers; | |||
| using System.Windows.Forms; | |||
| namespace BlackRockReportFunction.Bussines | |||
| { | |||
| @@ -1,6 +1,7 @@ | |||
| using System; | |||
| using System.Net; | |||
| using System.Net.Http.Headers; | |||
| using BlackRockReportFunction.Bussines; | |||
| using Microsoft.Azure.Functions.Worker; | |||
| using Microsoft.Extensions.Logging; | |||
| @@ -16,8 +17,10 @@ namespace BlackRockReportFunction | |||
| } | |||
| [Function("ClockifyApiIntegrationFunction")] | |||
| public void Run([TimerTrigger("* * * */5 * *")] MyInfo myTimer) | |||
| public void Run([TimerTrigger("*/5 * * * * *")] MyInfo myTimer) | |||
| { | |||
| ClockifyReports.InitializeClockifyIntegration(); | |||
| _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}"); | |||
| } | |||
| } | |||