public static async Task <string> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage Request, TraceWriter log, ExecutionContext context) { try { // Get request body dynamic requestData = await Request.Content.ReadAsAsync <object>(); //var objectIdentifier = data.userContext.Principal.FindFirst(ObjectIdentifierType).Value; Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context); TimezoneHelper timezoneHelper = new TimezoneHelper(helperMethods.getTimeTrackerOptions()); var editedHours = requestData.data; string userIdentifier = Request.Headers.Authorization.Parameter.ToString(); WorkHours workHours = editedHours.ToObject <WorkHours>(); WorkHoursRepository workHoursRepository = helperMethods.GetWorkHoursRepository(userIdentifier); await workHoursRepository.SaveItemAsync(workHours); return("Procesed"); } catch (Exception ex) { string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; log.Info(message + " occurred in SaveHoursByDate : " + DateTime.Now); return(message); } }
public static async Task Run([TimerTrigger("0 30 5 * * *")] TimerInfo myTimer, TraceWriter log, ExecutionContext context) { try { Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context); AutoSubmitWorkHoursTask autoSubmit = new AutoSubmitWorkHoursTask(helperMethods.getTimeTrackerOptions(), helperMethods.getGraphAppUserService(), helperMethods.getGraphAppSharePointService()); await autoSubmit.ExecuteAsync(); log.Info($"C# Timer trigger function executed every 24 hours that would contain the logic for autosubmit."); } catch (Exception ex) { string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; log.Info(message + " occurred in AutoSubmitWorkHours : " + DateTime.Now); } }