示例#1
0
        public AuditManager(IAuditConfiguration config)
        {
            defaultAuditor    = config.DefaultAuditor;
            namespaceAuditors = config.NamespaceAuditors.ToImmutableDictionary();

            Validate();
        }
示例#2
0
 public AuditManager(IAuditConfiguration config, ILogger <AuditManager> logger)
 {
     this.logger       = logger;
     defaultAuditor    = config.DefaultAuditor;
     namespaceAuditors = config.NamespaceAuditors.ToImmutableDictionary();
     Validate();
 }
        public SQLiteUnitOfWorkFactory(
            INHibernatePersistenceConfiguration configuration,
            ISessionFactory sessionFactory,
            IInterceptUnitOfWork[] interceptors,
            IAuditConfiguration auditConfiguration,
            IDateTime dateTime,
            IUserContext userContext,
            ILogger logger)
        {
            ThrowIf.ArgumentIsNull(configuration, "configuration");
            ThrowIf.ArgumentIsNull(sessionFactory, "sessionFactory");
            ThrowIf.ArgumentIsNull(logger, "logger");

            this.sessionFactory     = sessionFactory;
            this.interceptors       = interceptors;
            this.auditConfiguration = auditConfiguration;
            this.dateTime           = dateTime;
            this.userContext        = userContext;
            this.logger             = logger;

            // Create an in-memory database connection for the factory. This will be (re)used for each
            // new instance of NHibernateUnitOfWork.
            this.connection = new SQLiteConnection(SQLiteDatabaseConfigurer.InMemoryConnectionString);
            this.connection.Open();

            // Create the schema in the connection based on the NHibernate mappings
            configuration.CreateSchema(this.connection);
        }
        public NHibernateTransaction(
            ISessionFactory sessionFactory,
            IDbConnection connection,
            IInterceptUnitOfWork[] interceptors,
            IAuditConfiguration auditConfiguration,
            IDateTime dateTime,
            IUserContext userContext,
            ILogger logger)
        {
            ThrowIf.ArgumentIsNull(sessionFactory, "sessionFactory");
            ThrowIf.ArgumentIsNull(logger, "logger");

            if ((interceptors != null && interceptors.Length != 0) || (auditConfiguration != null && dateTime != null && userContext != null))
            {
                if (connection != null)
                {
                    this.session = sessionFactory.OpenSession(connection, new SessionInterceptor(interceptors, auditConfiguration, dateTime, userContext));
                }
                else
                {
                    this.session = sessionFactory.OpenSession(new SessionInterceptor(interceptors, auditConfiguration, dateTime, userContext));
                }
            }
            else if (connection != null)
            {
                this.session = sessionFactory.OpenSession(connection);
            }
            else
            {
                this.session = sessionFactory.OpenSession();
            }

            this.session.FlushMode = FlushMode.Commit;
            this.logger            = logger;
        }
示例#5
0
        public static IUnitOfWorkFactory CreateUnitOfWorkFactory(
            IInterceptUnitOfWork interceptor       = null,
            IAuditConfiguration auditConfiguration = null,
            IDateTime dateTime       = null,
            IUserContext userContext = null)
        {
            var configuration = new EntityFrameworkDbContextConfiguration <CompareContext>(connectionStringOrName => new CompareContext(connectionStringOrName));

            configuration.ConnectionStringName("Persistence");

            var interceptors = new List <IInterceptUnitOfWork>();

            if (interceptor != null)
            {
                interceptors.Add(interceptor);
            }

            if (auditConfiguration != null)
            {
                interceptors.Add(new EntityFrameworkAuditInterceptor(auditConfiguration, dateTime, userContext));
            }

            return(new EntityFrameworkUnitOfWork.Factory(configuration, interceptors.ToArray(), new ConsoleLogger {
                DebugLoggingIsEnabled = false
            }));
        }
示例#6
0
        public static IUnitOfWorkFactory CreateUnitOfWorkFactory(
            IInterceptUnitOfWork interceptor       = null,
            IAuditConfiguration auditConfiguration = null,
            IDateTime dateTime       = null,
            IUserContext userContext = null)
        {
            var configuration = new EntityFrameworkConfiguration();

            configuration.ConnectionStringName("Persistence");
            configuration.ProviderName(EntityFrameworkConfiguration.SqlServerProviderName);
            configuration.RegisterEntitiesFromAssemblyOf <FooConfiguration>();

            var interceptors = new List <IInterceptUnitOfWork>();

            if (interceptor != null)
            {
                interceptors.Add(interceptor);
            }

            if (auditConfiguration != null)
            {
                interceptors.Add(new EntityFrameworkAuditInterceptor(auditConfiguration, dateTime, userContext));
            }

            return(new EntityFrameworkUnitOfWork.Factory(configuration, interceptors.ToArray(), new ConsoleLogger {
                DebugLoggingIsEnabled = false
            }));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ContainerManagedObjectContextFactory"/> class.
 /// </summary>
 /// <param name="auditEventPublisher">The audit event publisher.</param>
 /// <param name="auditConfiguration">The audit configuration.</param>
 /// <param name="userContextFactory">The user context factory.</param>
 public ContainerManagedObjectContextFactory(IAuditEventPublisher auditEventPublisher, IAuditConfiguration auditConfiguration, IUserContextFactory userContextFactory)
 {
     _auditEventPublisher = auditEventPublisher;
     _auditConfiguration = auditConfiguration;
     _userContextFactory = userContextFactory;
     _dataModelConnectionString = DataUtils.GetEFConnectionString("MEDSEEK.eHealth.Framework.Dal.Model", ServiceContext.HostSettings.ServiceHostDBConnectionString);
 }
示例#8
0
        public static IUnitOfWorkFactory CreateUnitOfWorkFactory(
            IInterceptUnitOfWork interceptor       = null,
            IAuditConfiguration auditConfiguration = null,
            IDateTime dateTime       = null,
            IUserContext userContext = null)
        {
            var logger = new ConsoleLogger {
                DebugLoggingIsEnabled = false
            };

            var databaseConfigurer = new SqlServerDatabaseConfigurer()
                                     .ConnectionStringName("Persistence");

            var mapperConfigurer = new ByCodeMapperConfigurer()
                                   .RegisterEntitiesFromAssembly(Assembly.GetExecutingAssembly());

            var configuration = new NHibernateConfiguration(logger);

            configuration.RegisterConfigurer(databaseConfigurer);
            configuration.RegisterConfigurer(mapperConfigurer);
            configuration.RegisterConfigurer(new ProxyConfigurer <CastleProxyFactoryFactory>());

            IInterceptUnitOfWork[] interceptors = null;

            if (interceptor != null)
            {
                interceptors = new[] { interceptor };
            }

            return(new NHibernateUnitOfWork.Factory(configuration, interceptors, auditConfiguration, dateTime, userContext, logger));
        }
 public CommunicationProviderFactory(IAuditConfiguration configuration, ILogManager logManager)
 {
     _providers = new Dictionary <CommunicationServiceTypes, ICommunicationProvider>
     {
         { CommunicationServiceTypes.Email, new EmailProvider(configuration, logManager) },
         { CommunicationServiceTypes.Ftp, new FtpProvider(configuration, logManager) }
     };
 }
 public EntityFrameworkAuditInterceptor(
     IAuditConfiguration auditConfiguration,
     IDateTime dateTime,
     IUserContext userContext)
 {
     this.auditConfiguration = auditConfiguration;
     this.dateTime           = dateTime;
     this.userContext        = userContext;
 }
示例#11
0
 /// <summary>
 /// Initializes new instance of <see cref="MilvaDbContext{TUser, TRole, TKey}"/>.
 /// </summary>
 /// <param name="options"></param>
 /// <param name="httpContextAccessor"></param>
 /// <param name="auditConfiguration"></param>
 /// <param name="useUtcForDateTimes"></param>
 public MilvaDbContextBase(DbContextOptions options,
                           IHttpContextAccessor httpContextAccessor,
                           IAuditConfiguration auditConfiguration,
                           bool useUtcForDateTimes = false) : base(options)
 {
     _httpContextAccessor = httpContextAccessor;
     AuditConfiguration   = auditConfiguration;
     _useUtcForDateTimes  = useUtcForDateTimes;
     IgnoreSoftDelete     = false;
 }
        /// <summary>
        /// Configures the Auditing framework to use the <see cref="ClaimsPrincipal"/> flowed via the
        /// <see cref="LandmarkHttpClient"/> as x-landmark-xxx headers.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <returns></returns>
        public static IAuditConfiguration ForFlowedUserData(this IAuditConfiguration config)
        {
            Contract.Requires(config != null);
            Guard.AgainstNullArgument(nameof(config), config);
            Contract.EndContractBlock();

            config.AddBehaviour(AuditBehaviours.SetUserDataToFlowedUser);

            return(config);
        }
示例#13
0
 public SessionInterceptor(
     IInterceptUnitOfWork[] interceptors,
     IAuditConfiguration auditConfiguration,
     IDateTime dateTime,
     IUserContext userContext)
 {
     this.interceptors       = interceptors;
     this.auditConfiguration = auditConfiguration;
     this.dateTime           = dateTime;
     this.userContext        = userContext;
 }
        /// <summary>
        /// Configures the Auditing framework to use the specified <see cref="ClaimsPrincipal"/> factory
        /// as the current Actor source each time auditing occurs.
        /// </summary>
        /// <param name="config">The <see cref="IAuditConfiguration" /> instance to configure.</param>
        /// <param name="factory">The factory.</param>
        /// <returns>The configured <see cref="IAuditConfiguration"/> instance.</returns>
        public static IAuditConfiguration UsingClaimsPrincipalFactory(this IAuditConfiguration config, Func <ClaimsPrincipal> factory)
        {
            Contract.Requires(config != null);
            Contract.Requires(factory != null);
            Guard.AgainstNullArgument(nameof(config), config);
            Guard.AgainstNullArgument(nameof(factory), factory);
            Contract.EndContractBlock();

            config.AddBehaviour(auditEvent => AuditBehaviours.SetUserDataUsingClaimsPrincipalFactory(auditEvent, factory));

            return(config);
        }
示例#15
0
        private byte[] GetLogoData(string filename, IAuditConfiguration configuration)
        {
            var fullfilename = $@"{configuration.LegacyConfiguration.ClientImageFolder}{filename}";

            //if(!File.Exists(fullfilename))
            //    fullfilename = $@"{configuration.LegacyConfiguration.ClientImageFolder}19thumb.png";

            //return File.ReadAllBytes(fullfilename);

            if (File.Exists(fullfilename))
            {
                return(File.ReadAllBytes(fullfilename));
            }

            return(null);
        }
示例#16
0
            public Factory(
                INHibernatePersistenceConfiguration configuration,
                IInterceptUnitOfWork[] interceptors,
                IAuditConfiguration auditConfiguration,
                IDateTime dateTime,
                IUserContext userContext,
                ILogger logger)
            {
                ThrowIf.ArgumentIsNull(configuration, "configuration");
                ThrowIf.ArgumentIsNull(logger, "logger");

                this.sessionFactory     = configuration.CreateSessionFactory();
                this.interceptors       = interceptors;
                this.auditConfiguration = auditConfiguration;
                this.dateTime           = dateTime;
                this.userContext        = userContext;
                this.logger             = logger;
            }
示例#17
0
        private static void ConfigureLogger(IAuditConfiguration configuration)
        {
            var config = new LoggingConfiguration();

            var databaseTarget = new NLog.Targets.DatabaseTarget
            {
                ConnectionString = configuration.AuditDataConnection,
                CommandText      = @"
                    INSERT INTO [v2].[ApplicationLog]([Level], [Type], [Message]) 
                    VALUES(@level, @type, @message);"
            };

            databaseTarget.Parameters.Add(new DatabaseParameterInfo {
                Name = "@level", Layout = "${level}"
            });
            databaseTarget.Parameters.Add(new DatabaseParameterInfo {
                Name = "@type", Layout = "${exception:format=type}"
            });
            databaseTarget.Parameters.Add(new DatabaseParameterInfo {
                Name = "@message", Layout = "${message:exceptionSeparator=->:withException=true}"
            });
            databaseTarget.Parameters.Add(new DatabaseParameterInfo {
                Name = "@stackTrace", Layout = "${exception:format=stackTrace}"
            });

            config.LoggingRules.Add(new LoggingRule("*", LogLevel.Error, databaseTarget));
            config.LoggingRules.Add(new LoggingRule("*", LogLevel.Warn, databaseTarget));
            config.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, databaseTarget));

            var fileTarget = new FileTarget
            {
                FileName = $@"logs\errors_{DateTime.Now:yyyyMMdd}.log",
                Layout   = Layout.FromString("${message:exceptionSeparator=->:withException=true}")
            };

            config.LoggingRules.Add(new LoggingRule("*", LogLevel.Error, fileTarget));

            NLog.LogManager.Configuration = config;
        }
示例#18
0
        public IClientSettings ToModel(IAuditConfiguration configuration)
        {
            var model = new ClientSettings
            {
                Id                         = CarrierSettingsID,
                BillingContact             = BillingContact,
                BillingContactEmail        = BillingContactEmail,
                WpdEmail                   = WPDEmail,
                WpdOptions                 = WPDOptions,
                Format                     = Format,
                Frequency                  = Frequency,
                MonthlyDueDates            = MonthlyDueDates,
                QuarterlyDueDates          = QuarterlyDueDates,
                SemiAnnualFullTerm         = SemiAnnualFullTerm,
                SemiAnnualShortTerm        = SemiAnnualShortTerm,
                SemiAnnualCancellation     = SemiAnnualCancellation,
                AnnualFullTerm             = AnnualFullTerm,
                AnnualShortTerm            = AnnualShortTerm,
                AnnualCancellation         = AnnualCancellation,
                AuditDueDate               = AuditDueDate,
                WelcomeLetterDays          = WLDays,
                LocationWarning            = LocationWarning,
                AuditType                  = AuditType,
                RequestAllSubs             = RequestAllSubs,
                ProcessClaims              = ProcessClaims,
                SubContractorLabel         = SubContractorLabel,
                UseCasualLabor             = UseCasualLabor,
                UseLocationEmployeeCount   = UseLocationEmployeeCount,
                SubContractorHeaderContent = SubContractorHeaderContent,
                AuditTypes                 = AuditTypes,
                ShowClassAllocationSummary = ShowClassAllocationSummary,
                WpdEmailSubjectFormat      = WpdEmailSubjectFormat,
                WpdFilenameFormat          = WpdFilenameFormat,
                UseShareAuditWelcomeLetter = UseShareAuditWelcomeLetter,
                Logo                       = GetLogoData(LogoFilename, configuration)
            };

            return(model);
        }
        public GenerateWelcomeLetterStep(ILogManager logManager,
                                         IAuditApplicationService auditApplicationService,
                                         IDocumentApplicationService documentApplicationService,
                                         IFileUploadApplicationService auditUploadApplicationService,
                                         IAuditConfiguration auditConfiguration,
                                         IWelcomeLetterGl wecomeLetterGl,
                                         IWelcomeLetterWc welcomeLetterWc)
        {
            _logManager = logManager;
            _auditApplicationService       = auditApplicationService;
            _auditUploadApplicationService = auditUploadApplicationService;
            _documentApplicationService    = documentApplicationService;
            _auditConfiguration            = auditConfiguration;
            _welcomeLetterGl = wecomeLetterGl;
            _welcomeLetterWc = welcomeLetterWc;

            _letterGenerators = new Dictionary <AuditTypeEnum, Func <IToken, IToken> >
            {
                { AuditTypeEnum.NotSet, NoOpGenerator },
                { AuditTypeEnum.Combo, GenerateGlWelcomeletter },
                { AuditTypeEnum.GL, GenerateGlWelcomeletter },
                { AuditTypeEnum.WC, GenerateWcWelcomeLetter }
            };
        }
 private void Initialize(UserContext userContext, IAuditEventPublisher auditEventPublisher, IAuditConfiguration auditConfiguration)
 {
     _userContext = userContext;
     _auditEventPublisher = auditEventPublisher;
     _auditConfiguration = auditConfiguration;
     InitializeAuditEvent();
     AttachToEvents();
 }
示例#21
0
        //private readonly IMilvaEncryptionProvider _provider;

        public EducationAppDbContext(DbContextOptions <EducationAppDbContext> options,
                                     IHttpContextAccessor httpContextAccessor,
                                     IAuditConfiguration auditConfiguration) : base(options, httpContextAccessor, auditConfiguration)
        {
        }
示例#22
0
 	public TestAuditableContext(string connectionString, UserContext userContext, IAuditEventPublisher auditEventPublisher, IAuditConfiguration auditConfiguration)
 		: base(connectionString, ContainerName, userContext, auditEventPublisher, auditConfiguration)
 	{
         this.ContextOptions.LazyLoadingEnabled = true;
         this.ContextOptions.ProxyCreationEnabled = false;
 	}
示例#23
0
 public LogManager(IAuditConfiguration configuration)
 {
     ConfigureLogger(configuration);
 }
示例#24
0
 public EmailProvider(IAuditConfiguration configuration, ILogManager logManager)
 {
     _configuration = configuration.EmailConfiguration;
     _logManager    = logManager;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuditableObjectContext"/> class.
 /// </summary>
 /// <param name="connectionString">The connection string.</param>
 /// <param name="defaultContainerName">Default name of the container.</param>
 /// <param name="userContext">The user context.</param>
 /// <param name="auditEventPublisher">The audit event publisher.</param>
 /// <param name="auditConfiguration">The audit configuration.</param>
 public AuditableObjectContext(string connectionString, string defaultContainerName, UserContext userContext, IAuditEventPublisher auditEventPublisher, IAuditConfiguration auditConfiguration)
     : base(connectionString, defaultContainerName)
 {
     Initialize(userContext, auditEventPublisher, auditConfiguration);
 }
示例#26
0
 public FileShareProvider(ILogManager logManager, IAuditConfiguration auditConfiguration)
 {
     _logManager         = logManager;
     _auditConfiguration = auditConfiguration;
 }
 public AuditManager(IAuditConfiguration config) {
     defaultAuditor = config.DefaultAuditor;
     namespaceAuditors = config.NamespaceAuditors.OrderByDescending(x => x.Key.Length).ToImmutableDictionary();
     Validate();
 }
示例#28
0
 public ConnectionFactory(IAuditConfiguration configuration)
 {
     _configuration = configuration;
 }
示例#29
0
 protected override IUnitOfWorkFactory CreateUnitOfWorkFactory(IAuditConfiguration auditConfiguration, IDateTime dateTime, IUserContext userContext)
 {
     return(Helper.CreateUnitOfWorkFactory(auditConfiguration: auditConfiguration, dateTime: dateTime, userContext: userContext));
 }
 public AuditManager(IAuditConfiguration config)
 {
     defaultAuditor    = config.DefaultAuditor;
     namespaceAuditors = config.NamespaceAuditors.OrderByDescending(x => x.Key.Length).ToImmutableDictionary();
     Validate();
 }
示例#31
0
 protected abstract IUnitOfWorkFactory CreateUnitOfWorkFactory(IAuditConfiguration auditConfiguration, IDateTime dateTime, IUserContext userContext);
示例#32
0
 public FtpProvider(IAuditConfiguration configuration, ILogManager logManager)
 {
     _logManager    = logManager;
     _configuration = configuration.FtpConfiguration;
 }
示例#33
0
 public ClientRepositoryV1(IConnectionFactory connectionFactory, ILogManager logManager, IAuditConfiguration auditConfiguration)
     : base(connectionFactory, logManager, new CarriersDto())
 {
     _auditConfiguration = auditConfiguration;
 }
 public FileShareProviderEgnyte(ILogManager logManager, IAuditConfiguration auditConfiguration)
 {
     _logManager         = logManager;
     _auditConfiguration = auditConfiguration;
     _client             = RestApiClientFactory.GetClient(auditConfiguration.ShareFileConfiguration.BaseUrl);
 }
示例#35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ObjectContextAuditor"/> class.
 /// </summary>
 /// <param name="auditContext">The audit context.</param>
 /// <param name="auditEventPublisher">The audit event publisher.</param>
 /// <param name="auditConfiguration">The audit configuration.</param>
 public ObjectContextAuditor(AuditContext auditContext, IAuditEventPublisher auditEventPublisher, IAuditConfiguration auditConfiguration)
 {
     _auditEvent = new TrackingAuditEvent(auditContext);
     _auditEventPublisher = auditEventPublisher;
     _auditConfiguration = auditConfiguration;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuditableEntityContext" /> class.
 /// </summary>
 /// <param name="nameOrConnectionString">The name or connection string.</param>
 /// <param name="userContext">The user context.</param>
 /// <param name="auditEventPublisher">The audit event publisher.</param>
 /// <param name="auditConfiguration">The audit configuration.</param>
 public AuditableEntityContext(string nameOrConnectionString, UserContext userContext, IAuditEventPublisher auditEventPublisher, IAuditConfiguration auditConfiguration)
     : base(nameOrConnectionString)
 {
     Initialize(userContext, auditEventPublisher, auditConfiguration);
 }