コード例 #1
0
 public ContextInformationFilter(IIdentityService identityService, IContextInformation contextInformation, ISystemDateTimeService systemDateTimeService, IDistributedCache distributedCache)
 {
     _identityService       = identityService ?? throw new ArgumentNullException(nameof(identityService));
     _contextInformation    = contextInformation ?? throw new ArgumentNullException(nameof(contextInformation));
     _systemDateTimeService = systemDateTimeService ?? throw new ArgumentNullException(nameof(systemDateTimeService));
     _distributedCache      = distributedCache ?? throw new ArgumentNullException(nameof(distributedCache));
 }
コード例 #2
0
ファイル: BaseRepository.cs プロジェクト: mrsunil/bp2
        private static void AddDataVersionIdParameter(IContextInformation contextInformation, DynamicParameters parameters)
        {
            var dataVersionIdParameter = parameters.ParameterNames.AsList().Find(p => p.Equals(DataVersionIdParameterName, StringComparison.InvariantCultureIgnoreCase));

            if (dataVersionIdParameter != null && parameters.Get <object>(dataVersionIdParameter) == null && (contextInformation != null && contextInformation.DataVersionId.HasValue))
            {
                parameters.Add(DataVersionIdParameter, contextInformation.DataVersionId);
            }
        }
コード例 #3
0
ファイル: BaseRepository.cs プロジェクト: mrsunil/bp2
        private static void AddContextInformationParameter(IContextInformation contextInformation, DynamicParameters parameter)
        {
            if (!parameter.ParameterNames.AsList().Contains(ContextInformationParameterName))
            {
                var json = JsonConvert.SerializeObject(contextInformation, Formatting.Indented, new JsonSerializerSettings
                {
                    ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
                });

                parameter.Add(ContextInformationParameter, json);
            }
        }
コード例 #4
0
        public async Task Invoke(HttpContext context, IIdentityService identityService, IContextInformation contextInformation)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (identityService == null)
            {
                throw new ArgumentNullException(nameof(identityService));
            }

            var programId = context.Request.Headers.FirstOrDefault(x => x.Key == AtlasHeaderNames.AtlasProgramId).Value.ToString();

            if (string.IsNullOrWhiteSpace(programId))
            {
                var error = new ProblemDetails
                {
                    Title    = Resources.ExceptionProblemInvalidOperationTitle,
                    Type     = "https://atlas.ldc.com/business-error",
                    Status   = StatusCodes.Status400BadRequest,
                    Detail   = $"The HTTP header {AtlasHeaderNames.AtlasProgramId} is missing.",
                    Instance = context.Request.Path
                };

                context.Response.ContentType = "application/problem+json";
                context.Response.StatusCode  = StatusCodes.Status400BadRequest;

                await context.Response.WriteAsync(JsonConvert.SerializeObject(error, Formatting.Indented, new JsonSerializerSettings
                {
                    ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
                }));
            }
            else
            {
                contextInformation.ApiActionName = programId;

                contextInformation.UserId = identityService.GetUserName();

                await _next(context);
            }
        }
コード例 #5
0
ファイル: DapperContext.cs プロジェクト: mrsunil/bp2
 public DapperContext(IOptions <DatabaseConfiguration> option, IContextInformation contextInformation)
 {
     _databaseConfiguration = option.Value;
     ContextInformation     = contextInformation;
 }