コード例 #1
0
 public IdempotentMessageConsumer(ZaminConfigurationOptions zaminConfigurations, IEventDispatcher eventDispatcher, IJsonSerializer jsonSerializer, ICommandDispatcher commandDispatcher, IMessageInboxItemRepository messageInboxItemRepository)
 {
     _zaminConfigurations        = zaminConfigurations;
     _eventDispatcher            = eventDispatcher;
     _jsonSerializer             = jsonSerializer;
     _commandDispatcher          = commandDispatcher;
     _messageInboxItemRepository = messageInboxItemRepository;
     LoadMessageMap();
 }
コード例 #2
0
ファイル: Startup.cs プロジェクト: sajad-mirzaei/Zamin
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                       ZaminConfigurationOptions zaminConfigurations)
 {
     app.UseZaminMvcConfigure(endpoints =>
     {
         endpoints.MapControllerRoute(
             name: "default",
             pattern: "{controller=Home}/{action=Index}/{id?}");
     }, zaminConfigurations, env);
 }
コード例 #3
0
        public ParrotTranslator(ZaminConfigurationOptions configuration)
        {
#if NET451
            _currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
#elif NET46
            _currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
#else
            _currentCulture = CultureInfo.CurrentCulture.ToString();
#endif
            _localizer = new ParrotDataWrapper(configuration);
        }
コード例 #4
0
        public ParrotDataWrapper(ZaminConfigurationOptions configuration)
        {
            _configuration = configuration;
            _dbConnection  = new SqlConnection(configuration.Translator.Parrottranslator.ConnectionString);
            if (_configuration.Translator.Parrottranslator.AutoCreateSqlTable)
            {
                CreateTableIfNeeded();
            }
            SelectCommand = string.Format(SelectCommand, configuration.Translator.Parrottranslator.SchemaName, configuration.Translator.Parrottranslator.TableName);

            InsertCommand = string.Format(InsertCommand, configuration.Translator.Parrottranslator.SchemaName, configuration.Translator.Parrottranslator.TableName);

            _localizationRecords = _dbConnection.Query <LocalizationRecord>(SelectCommand, commandType: CommandType.Text).ToList();
        }
コード例 #5
0
        public RabbitMqMessageBus(ZaminConfigurationOptions configuration, IJsonSerializer jsonSerializer, IMessageConsumer messageConsumer)
        {
            _configuration   = configuration;
            _jsonSerializer  = jsonSerializer;
            _messageConsumer = messageConsumer;
            var connectionFactory = new ConnectionFactory
            {
                Uri = configuration.MessageBus.RabbitMq.Uri
            };

            _connection = connectionFactory.CreateConnection();
            var channel = _connection.CreateModel();

            channel.ExchangeDeclare(configuration.MessageBus.RabbitMq.ExchangeName, ExchangeType.Topic, configuration.MessageBus.RabbitMq.ExchangeDurable, configuration.MessageBus.RabbitMq.ExchangeAutoDeleted);
            ReveiveMessages();
        }
コード例 #6
0
        public static void UseZaminApiConfigure(this IApplicationBuilder app, ZaminConfigurationOptions configuration, IWebHostEnvironment env)
        {
            app.UseApiExceptionHandler(options =>
            {
                options.AddResponseDetails = (context, ex, error) =>
                {
                    if (ex.GetType().Name == typeof(SqlException).Name)
                    {
                        error.Detail = "Exception was a database exception!";
                    }
                };
                options.DetermineLogLevel = ex =>
                {
                    if (ex.Message.StartsWith("cannot open database", StringComparison.InvariantCultureIgnoreCase) ||
                        ex.Message.StartsWith("a network-related", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(LogLevel.Critical);
                    }
                    return(LogLevel.Error);
                };
            });

            app.UseStatusCodePages();
            if (configuration.Swagger != null && configuration.Swagger.SwaggerDoc != null)
            {
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint(configuration.Swagger.SwaggerDoc.URL, configuration.Swagger.SwaggerDoc.Title);
                    c.RoutePrefix = string.Empty;
                });
            }

            app.UseCors(builder =>
            {
                builder.AllowAnyOrigin();
                builder.AllowAnyHeader();
                builder.AllowAnyMethod();
            });
            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
コード例 #7
0
        public static IServiceCollection AddZaminMvcServices(this IServiceCollection services,
                                                             IConfiguration configuration)
        {
            var _zaminConfigurations = new ZaminConfigurationOptions();

            configuration.GetSection(_zaminConfigurations.SectionName).Bind(_zaminConfigurations);
            services.AddSingleton(_zaminConfigurations);
            services.AddControllersWithViews(options =>
            {
                options.Filters.Add(typeof(TrackActionPerformanceFilter));
            }).AddRazorRuntimeCompilation()
            .AddFluentValidation();

            services.AddZaminDependencies(_zaminConfigurations.AssmblyNameForLoad.Split(','));

            return(services);
        }
コード例 #8
0
        public static IServiceCollection AddZaminApiServices(this IServiceCollection services,
                                                             IConfiguration configuration)
        {
            var _zaminConfigurations = new ZaminConfigurationOptions();

            configuration.GetSection(_zaminConfigurations.SectionName).Bind(_zaminConfigurations);
            services.AddSingleton(_zaminConfigurations);
            services.AddScoped <ValidateModelStateAttribute>();
            services.AddControllers(options =>
            {
                options.Filters.AddService <ValidateModelStateAttribute>();
                options.Filters.Add(typeof(TrackActionPerformanceFilter));
            }).AddFluentValidation();

            services.AddZaminDependencies(_zaminConfigurations.AssmblyNameForLoad.Split(','));

            AddSwagger(services);
            return(services);
        }
コード例 #9
0
 public PoolingPublisherHostedService(ZaminConfigurationOptions configuration, IOutBoxEventItemRepository outBoxEventItemRepository, IMessageBus messageBus)
 {
     _configuration             = configuration;
     _outBoxEventItemRepository = outBoxEventItemRepository;
     _messageBus = messageBus;
 }
コード例 #10
0
ファイル: Startup.cs プロジェクト: sajad-mirzaei/Zamin
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
                       ZaminConfigurationOptions zaminConfigurations)
 {
     app.UseZaminApiConfigure(zaminConfigurations, env);
 }
コード例 #11
0
 public SqlMessageInboxItemRepository(ZaminConfigurationOptions configurations)
 {
     _connectionString = configurations.Messageconsumer.SqlMessageInboxStore.ConnectionString;
 }
コード例 #12
0
        public static void UseZaminMvcConfigure(this IApplicationBuilder app, Action <IEndpointRouteBuilder> configur, ZaminConfigurationOptions configuration, IWebHostEnvironment env)
        {
            app.UseApiExceptionHandler(options =>
            {
                options.AddResponseDetails = (context, ex, error) =>
                {
                    if (ex.GetType().Name == typeof(SqlException).Name)
                    {
                        error.Detail = "Exception was a database exception!";
                    }
                };
                options.DetermineLogLevel = ex =>
                {
                    if (ex.Message.StartsWith("cannot open database", StringComparison.InvariantCultureIgnoreCase) ||
                        ex.Message.StartsWith("a network-related", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(LogLevel.Critical);
                    }
                    return(LogLevel.Error);
                };
            });

            app.UseStatusCodePages();
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthorization();

            if (configuration?.Session?.Enable == true)
            {
                app.UseSession();
            }

            app.UseEndpoints(configur);
        }
コード例 #13
0
 public SqlOutBoxEventItemRepository(ZaminConfigurationOptions configurations)
 {
     _configurations = configurations;
 }