Dunja Stevanovic 3 anos atrás
pai
commit
bb4d118a45

+ 2
- 2
BlackRockReportFunction/Bussines/ReportGenerator.cs Ver arquivo

{ {
Name = DefaultFontName, Name = DefaultFontName,
Weight = ExcelFont.BoldWeight, Weight = ExcelFont.BoldWeight,
Size = DefaultFontSize * 11,
Size = DefaultFontSize * 10,
}, },
VerticalAlignment = VerticalAlignmentStyle.Center, VerticalAlignment = VerticalAlignmentStyle.Center,
}; };
{ {
Name = DefaultFontName, Name = DefaultFontName,
Weight = ExcelFont.NormalWeight, Weight = ExcelFont.NormalWeight,
Size = DefaultFontSize * 11,
Size = DefaultFontSize * 10,
}, },
VerticalAlignment = VerticalAlignmentStyle.Center, VerticalAlignment = VerticalAlignmentStyle.Center,
}; };

+ 7
- 4
BlackRockReportFunction/ClockifyApiIntegrationFunction.cs Ver arquivo



public static async Task InitializeClockifyIntegration() 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"); client.DefaultRequestHeaders.Add("X-API-Key", "MmU2ZTA2MGItMTM1ZS00ZTg1LTkwMjAtMDkzYThiZmNmYmIy");




[Function("ClockifyApiIntegrationFunction")] [Function("ClockifyApiIntegrationFunction")]
[QueueOutput("queue1")] [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 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"); HttpContent httpContent = new StringContent(json, Encoding.UTF8, "application/json");


_logger.LogInformation($"Data collection successfull!"); _logger.LogInformation($"Data collection successfull!");


return JsonConvert.SerializeObject(JsonConvert.DeserializeObject<object>(response.Content.ReadAsStringAsync().Result), Formatting.Indented); 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 else
{ {

+ 4
- 1
BlackRockReportFunction/MailSenderFunction.cs Ver arquivo

var email = new MimeMessage(); var email = new MimeMessage();
email.From.Add(MailboxAddress.Parse("nikola.jovanovic@dilig.net")); email.From.Add(MailboxAddress.Parse("nikola.jovanovic@dilig.net"));
email.To.Add(MailboxAddress.Parse("greta.bartoletti@ethereal.email")); email.To.Add(MailboxAddress.Parse("greta.bartoletti@ethereal.email"));
//email.To.Add(MailboxAddress.Parse("greta.bartoletti@ethereal.email"));
email.Subject = "BlackRock Report"; email.Subject = "BlackRock Report";
var body = new TextPart(TextFormat.Html) { Text = string.Format("Here is yours report for last week. {0}", fileName) }; var body = new TextPart(TextFormat.Html) { Text = string.Format("Here is yours report for last week. {0}", fileName) };


multipart.Add(attachment); multipart.Add(attachment);
email.Body = multipart; 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.Connect("smtp.ethereal.email", 587, SecureSocketOptions.StartTls);
//smtp.UseDefaultCredentials = true;
smtp.Authenticate("greta.bartoletti@ethereal.email", "ecsdGZxWHk4yfjZpD5"); //"shaniya.blick76@ethereal.email", "8pPsjCbwCFMrEeKNef" smtp.Authenticate("greta.bartoletti@ethereal.email", "ecsdGZxWHk4yfjZpD5"); //"shaniya.blick76@ethereal.email", "8pPsjCbwCFMrEeKNef"
smtp.Send(email); smtp.Send(email);
smtp.Disconnect(true); smtp.Disconnect(true);

Carregando…
Cancelar
Salvar