瀏覽代碼

//

master
Dunja Stevanovic 3 年之前
父節點
當前提交
bb4d118a45

+ 2
- 2
BlackRockReportFunction/Bussines/ReportGenerator.cs 查看文件

@@ -36,7 +36,7 @@ namespace BlackRockReportFunction.Bussines
{
Name = DefaultFontName,
Weight = ExcelFont.BoldWeight,
Size = DefaultFontSize * 11,
Size = DefaultFontSize * 10,
},
VerticalAlignment = VerticalAlignmentStyle.Center,
};
@@ -47,7 +47,7 @@ namespace BlackRockReportFunction.Bussines
{
Name = DefaultFontName,
Weight = ExcelFont.NormalWeight,
Size = DefaultFontSize * 11,
Size = DefaultFontSize * 10,
},
VerticalAlignment = VerticalAlignmentStyle.Center,
};

+ 7
- 4
BlackRockReportFunction/ClockifyApiIntegrationFunction.cs 查看文件

@@ -21,7 +21,7 @@ namespace BlackRockReportFunction

public static async Task InitializeClockifyIntegration()
{
//client.DefaultRequestHeaders.Add("X-API-Key", clockifyApiKey); ///
//client.DefaultRequestHeaders.Add("X-API-Key", clockifyApiKey);

client.DefaultRequestHeaders.Add("X-API-Key", "MmU2ZTA2MGItMTM1ZS00ZTg1LTkwMjAtMDkzYThiZmNmYmIy");

@@ -39,11 +39,14 @@ namespace BlackRockReportFunction

[Function("ClockifyApiIntegrationFunction")]
[QueueOutput("queue1")]
public string Run([TimerTrigger("*/15 * * * * *" )] MyInfo myTimer) //TODO: Set on Friday at 20 o'clock
public string Run([TimerTrigger("*/15 * * * * *" )] MyInfo myTimer) //TODO: Set on Friday at 20 o'clock "0 0 20 * * 5"
{
InitializeClockifyIntegration(); // Clockify API Integration

var json = "{\"dateRangeStart\":\"2022-05-30T00:00:00.000\",\"dateRangeEnd\":\"2022-06-05T23:59:59.000\",\"summaryFilter\":{\"groups\":[\"USER\",\"TIMEENTRY\"]},\"clients\":{\"ids\":[\"61488f8d9eb0753d0e40d761\"]},\"projects\":{\"ids\":[\"6242f015f6fe850b94cd0c64\"]},\"amountShown\":\"HIDE_AMOUNT\"}";
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 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\"}";

HttpContent httpContent = new StringContent(json, Encoding.UTF8, "application/json");

@@ -56,7 +59,7 @@ namespace BlackRockReportFunction
_logger.LogInformation($"Data collection successfull!");

return JsonConvert.SerializeObject(JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result), Formatting.Indented);
//var responseContent = JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result); // TO DO: Convert JSON to csv
//var responseContent = JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result);
}
else
{

+ 4
- 1
BlackRockReportFunction/MailSenderFunction.cs 查看文件

@@ -41,6 +41,7 @@ namespace BlackRockReportFunction
var email = new MimeMessage();
email.From.Add(MailboxAddress.Parse("[email protected]"));
email.To.Add(MailboxAddress.Parse("[email protected]"));
//email.To.Add(MailboxAddress.Parse("[email protected]"));
email.Subject = "BlackRock Report";
var body = new TextPart(TextFormat.Html) { Text = string.Format("Here is yours report for last week. {0}", fileName) };

@@ -60,8 +61,10 @@ namespace BlackRockReportFunction
multipart.Add(attachment);
email.Body = multipart;

using var smtp = new SmtpClient();
//using var smtp = new SmtpClient();
SmtpClient smtp = new SmtpClient();
smtp.Connect("smtp.ethereal.email", 587, SecureSocketOptions.StartTls);
//smtp.UseDefaultCredentials = true;
smtp.Authenticate("[email protected]", "ecsdGZxWHk4yfjZpD5"); //"[email protected]", "8pPsjCbwCFMrEeKNef"
smtp.Send(email);
smtp.Disconnect(true);

Loading…
取消
儲存