Example #1
0
        public static async Task <HttpResponseMessage> GetAllQueriesIdentifierGroupRun(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequestMessage req,
            ILogger log)
        {
            #region Logging
            if (null != log)
            {
                log.LogDebug("Function triggered HTTP in GetAllQueriesIdentifierGroup");
            }
            #endregion

            string   queryName      = req.RequestUri.ParseQueryString()["QueryName"];
            string   asOfDateString = req.RequestUri.ParseQueryString()["AsOfDate"];
            DateTime?asOfDate       = null;
            if (!string.IsNullOrWhiteSpace(asOfDateString))
            {
                DateTime dtOut;
                if (DateTime.TryParse(asOfDateString, out dtOut))
                {
                    asOfDate = dtOut;
                }
            }

            if (string.IsNullOrWhiteSpace(queryName))
            {
                // Get request body
                AllQueriesIdentifierGroup_Request data = await req.Content.ReadAsAsync <AllQueriesIdentifierGroup_Request>();

                queryName = data.QueryName;
                asOfDate  = data.AsOfDate;
            }

            AllQueriesIdentifierGroup_Request request = new AllQueriesIdentifierGroup_Request()
            {
                QueryName = queryName,
                AsOfDate  = asOfDate
            };

            if (string.IsNullOrWhiteSpace(queryName))
            {
                return(req.CreateResponse(HttpStatusCode.BadRequest,
                                          "Please pass a query name on the query string or in the request body"));
            }
            else
            {
                IEnumerable <string> ret = await AllQueriesIdentifierGroupProcess(request, log);

                return(req.CreateResponse(HttpStatusCode.OK, ret,
                                          new System.Net.Http.Formatting.JsonMediaTypeFormatter()));
            }
        }
Example #2
0
        public static async Task <IEnumerable <string> > GetAllQueriesIdentifierGroupActivity(
            [ActivityTrigger] DurableActivityContext context,
            ILogger log)
        {
            AllQueriesIdentifierGroup_Request request = context.GetInput <AllQueriesIdentifierGroup_Request>();

            #region Logging
            if (null != log)
            {
                log.LogInformation($"GetAllQueriesIdentifierGroupActivity called for query: {request.QueryName} as of {request.AsOfDate} status matching {request.MatchStatus} ");
            }
            #endregion

            return(await AllQueriesIdentifierGroupProcess(request, log));
        }
Example #3
0
        /// <summary>
        /// Get all the unique identifiers of the queries that match the input request settings
        /// </summary>
        /// <param name="request">
        /// </param>
        private static async Task <IEnumerable <string> > AllQueriesIdentifierGroupProcess(
            AllQueriesIdentifierGroup_Request request,
            ILogger log)
        {
            #region Logging
            if (null != log)
            {
                log.LogInformation($"Creating identifier group processor for {request.QueryName }");
            }
            #endregion

            #region Input validations
            // If no match status, default to ALL
            if (string.IsNullOrWhiteSpace(request.MatchStatus))
            {
                request.MatchStatus = @"All";
            }
            // If as of date is stupid, clear it
            if (request.AsOfDate.HasValue)
            {
                if (request.AsOfDate.Value.Year < 2000)
                {
                    request.AsOfDate = null;
                }
            }
            #endregion

            IdentifierGroup allQueries = new IdentifierGroup(Constants.Domain_Query,
                                                             request.QueryName,
                                                             request.MatchStatus);

            if (null != allQueries)
            {
                return(await allQueries.GetAll(request.AsOfDate));
            }
            else
            {
                return(Enumerable.Empty <string>());
            }
        }