Beispiel #1
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log, ExecutionContext context)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            var config = new ConfigurationBuilder()
                         .SetBasePath(context.FunctionAppDirectory)
                         .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                         .AddEnvironmentVariables()
                         .Build();

            log.LogInformation("Starting Test");
            log.LogInformation("Creating Key Vault");
            ADPKeyVault secretVault = new ADPKeyVault(
                new Uri(config["KeyVaultURI"]),
                config["CertificateName"],
                config["ClientIDName"],
                config["ClientSecretName"]
                );

            log.LogInformation("Creating ADP Service");
            WorkforceNowService adpService = new WorkforceNowService(
                secretVault,
                new Uri(config["TokenURI"])
                );

            log.LogInformation("Creating ADP Event Service");
            EventNotificationService eventService = new EventNotificationService(
                adpService,
                new Uri(config["EventNotificationURI"])
                );

            log.LogInformation("Calling Events");
            ADPEventMessage eventMessage = eventService.getEvents();

            foreach (ADPEvent curEvent in eventMessage.Events)
            {
                log.LogInformation(curEvent.EventID + " - " + curEvent.EvenNameCode.CodeValue);
            }
            log.LogInformation("Nothing Crashed");

            return(new OkObjectResult(JsonConvert.SerializeObject(eventMessage)));
        }
Beispiel #2
0
        public ADPEventMessage getEvents()
        {
            HttpResponseMessage eventResponse = this._ADPService.sendGetMessage(_EventURI, "practioner");
            Task <string>       eventJSONTask = eventResponse.Content.ReadAsStringAsync();

            eventJSONTask.Wait();
            string eventJSON = eventJSONTask.Result;

            ADPEventMessage toReturn = JsonConvert.DeserializeObject <ADPEventMessage>(eventJSON);

            IEnumerable <string> messageIds;

            if (eventResponse.Headers.TryGetValues("adp-msg-msgid", out messageIds))
            {
                string currentID = messageIds.First();
                foreach (ADPEvent curEvent in toReturn.Events)
                {
                    curEvent.MessageID = currentID;
                }
            }

            return(toReturn);
        }