public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log, ExecutionContext context) { try { // Get request body dynamic data = await req.Content.ReadAsAsync <object>(); string userIdentifier = req.Headers.Authorization.Parameter.ToString(); // Set name to query string or body data var date = data?.selDate; string notificationMsgBody = data?.notificationMsgBody; DateTime selDate = DateTime.Parse(date.ToString()); Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context); bool isSave = await helperMethods.GetTimeTrackerDataService(userIdentifier).MyTeamsSubmitHours(selDate, notificationMsgBody); return(isSave == false?req.CreateResponse(HttpStatusCode.BadRequest, "Please pass selected date in the request body") : req.CreateResponse(HttpStatusCode.OK, isSave)); } catch (Exception ex) { string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; log.Info(message + " occurred in Submit Team Hours : " + DateTime.Now); return(req.CreateResponse(HttpStatusCode.BadRequest, "Error Occured.Please check log Details")); } }
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 <string> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log, ExecutionContext context) { try { // Get request body dynamic requestData = await req.Content.ReadAsAsync <object>(); Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context); var data = requestData.siteList; SiteList siteList = data.ToObject <SiteList>(); DateTime date = requestData.date; string userIdentifier = req.Headers.Authorization.Parameter.ToString(); var workHoursList = await helperMethods.computeHours(userIdentifier, date, siteList); return("sucses"); } catch (Exception ex) { string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; log.Info(message + " occurred in FirstTimeLogin : " + DateTime.Now); return(ex.Message); } }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log, ExecutionContext context) { try { dynamic data = await req.Content.ReadAsAsync <object>(); DateTime selDt = data.selDate; string identifier = data.objIdentifier; string reason = data.reason; string ID = data.id; string date = data.date; string notificationMsgBody = data.notificationMsgBody; // Get request body string userIdentifier = req.Headers.Authorization.Parameter.ToString(); Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context); bool isSuccess = await helperMethods.GetTimeTrackerDataService(userIdentifier).MyTeamWorkHoursRevisionRequest(selDt, identifier, reason, ID, date, notificationMsgBody); // Set name to query string or body data return(isSuccess == null ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body") : req.CreateResponse(HttpStatusCode.OK, isSuccess)); } catch (Exception ex) { string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; log.Info(message + " occurred in HoursRevisionRequest : " + DateTime.Now); return(req.CreateResponse(HttpStatusCode.BadRequest, "Error Occurred.Please check log details")); } }
public static async Task Run([TimerTrigger("0 30 5 * * *")] TimerInfo myTimer, TraceWriter log, ExecutionContext context) { try { log.Info($"C# Timer trigger function executed at: {DateTime.Now}"); Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context); AnalyticsService analyticService = helperMethods.GetAnalyticsService(); bool status = await analyticService.UpdateAnalytics(); } catch (Exception ex) { string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; log.Info(message + " occurred in UpdateAnalyticsFunction : " + DateTime.Now); } }
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); } }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage Request, TraceWriter log, ExecutionContext context) { try { string userIdentifier = Request.Headers.Authorization.Parameter.ToString(); // Get request body dynamic requestData = await Request.Content.ReadAsAsync <object>(); string notificationMsgBody = requestData.notificationMsgBody; Helpers.HelperMethods helperMethods = new Helpers.HelperMethods(context); var isSave = await helperMethods.GetTimeTrackerDataService(userIdentifier).SubmitHoursForMonthAsync(notificationMsgBody); return(isSave == null ? Request.CreateResponse(System.Net.HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body") : Request.CreateResponse(HttpStatusCode.OK, isSave)); } catch (Exception ex) { string message = ex.InnerException != null?ex.InnerException.ToString() : ex.Message; log.Info(message + " occurred in SubmitHours : " + DateTime.Now); return(Request.CreateResponse(HttpStatusCode.BadRequest, "Error Occured.Please check log Details")); } }