|
|
|
@@ -9,6 +9,7 @@ using Newtonsoft.Json; |
|
|
|
using System.Net.Http; |
|
|
|
using System.Net.Http.Headers; |
|
|
|
using System.Text; |
|
|
|
using BlackRockReportFunction.Exception; |
|
|
|
|
|
|
|
namespace BlackRockReportFunction |
|
|
|
{ |
|
|
|
@@ -39,12 +40,12 @@ namespace BlackRockReportFunction |
|
|
|
|
|
|
|
[Function("ClockifyApiIntegrationFunction")] |
|
|
|
[QueueOutput("queue1")] |
|
|
|
public string Run([TimerTrigger("*/15 * * * * *" )] MyInfo myTimer) //TODO: Set on Friday at 20 o'clock "0 0 20 * * 5" |
|
|
|
public string Run([TimerTrigger("*/15 * * * * *")] TimerInfo myTimer) //TODO: Set on Friday at 20 o'clock "0 0 20 * * 5" |
|
|
|
{ |
|
|
|
InitializeClockifyIntegration(); // Clockify API Integration |
|
|
|
|
|
|
|
var monday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday).ToString("yyyy-MM-dd"); |
|
|
|
var friday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Friday).ToString("yyyy-MM-dd"); // TO DO: Set end day of week |
|
|
|
var friday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Friday).ToString("yyyy-MM-dd"); |
|
|
|
|
|
|
|
var json = "{\"dateRangeStart\":\""+monday+"T00:00:00.000\",\"dateRangeEnd\":\""+friday+"T23:59:59.000\",\"summaryFilter\":{\"groups\":[\"USER\",\"TIMEENTRY\"]},\"clients\":{\"ids\":[\"61488f8d9eb0753d0e40d761\"]},\"projects\":{\"ids\":[\"6242f015f6fe850b94cd0c64\"]},\"amountShown\":\"HIDE_AMOUNT\"}"; |
|
|
|
|
|
|
|
@@ -52,7 +53,7 @@ namespace BlackRockReportFunction |
|
|
|
|
|
|
|
HttpResponseMessage response = client.PostAsync(client.BaseAddress + "/workspaces/5eb44340ef0f6c66fc88732a/reports/summary", httpContent).Result; |
|
|
|
|
|
|
|
//TO DO: Clear code!!! |
|
|
|
|
|
|
|
|
|
|
|
if (response.IsSuccessStatusCode) |
|
|
|
{ |
|
|
|
@@ -63,26 +64,34 @@ namespace BlackRockReportFunction |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return JsonConvert.SerializeObject(JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result), Formatting.Indented); |
|
|
|
_logger.LogInformation($"Request failed. Error status code: {(int)response.StatusCode}"); |
|
|
|
throw new HttpErrorStatusCodeException(response.StatusCode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class MyInfo |
|
|
|
{ |
|
|
|
public MyScheduleStatus ScheduleStatus { get; set; } |
|
|
|
//public class MyInfo |
|
|
|
//{ |
|
|
|
// public MyScheduleStatus ScheduleStatus { get; set; } |
|
|
|
|
|
|
|
public bool IsPastDue { get; set; } |
|
|
|
} |
|
|
|
// public bool IsPastDue { get; set; } |
|
|
|
//} |
|
|
|
|
|
|
|
public class MyScheduleStatus |
|
|
|
{ |
|
|
|
public DateTime Last { get; set; } |
|
|
|
//public class MyScheduleStatus |
|
|
|
//{ |
|
|
|
// public DateTime Last { get; set; } |
|
|
|
|
|
|
|
public DateTime Next { get; set; } |
|
|
|
// public DateTime Next { get; set; } |
|
|
|
|
|
|
|
// public DateTime LastUpdated { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DateTime LastUpdated { get; set; } |
|
|
|
} |
|
|
|
} |