Exemplo n.º 1
0
        /// <summary>
        /// Tries to establish a connection to the wordclock
        /// </summary>
        /// <returns></returns>
        async Task ConnectToWordclock()
        {
            bool isInputValid = await ValidateUserInput();

            if (isInputValid)
            {
                IsBusy = true;
                Connect.ChangeCanExecute();

                var isConnectionEstablished = false;

                try
                {
                    EndpointConfigurationFactory.Initialize(_server, _port);
                    isConnectionEstablished = await Task.Run(() => _connectionService.IsConnectionEstablished());
                }
                catch (Exception ex)
                {
                    await _dialogService.ShowError(ex);
                }
                finally
                {
                    IsBusy = false;
                    Connect.ChangeCanExecute();
                }

                if (isConnectionEstablished)
                {
                    SaveConnectionInformation();

                    //Use absolute Uri to reset the navigation stack. So it is not possible to navigate to the ConnectPage anymore
                    await _navigationService.NavigateAsync(new Uri("/MenuPage", UriKind.Absolute));
                }
            }
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            var serviceFabricHostMarker = Environment.GetEnvironmentVariable("ServiceFabricHostMarker");

            services.AddDbContext <PaymentDbContext>(
                options => options.UseSqlServer(this.Configuration.GetConnectionString("PaymentDbContext")));

            services.AddSingleton(res => this.Configuration);
            services.AddScoped <DbContext, PaymentDbContext>();
            services.AddScoped <IPaymentService, PaymentService>();

            services.AddEventManagementAuthentication(new DefaultEventManagementTokenValidationParameters(this.Configuration));
            services.AddMvc();

            var builder = new ContainerBuilder();

            builder.Populate(services);

            // Add NServiceBus Handlers
            EndpointConfiguration endpointConfiguration = null;

            if (!this.CurrentEnvironment.IsEnvironment("IntegrationTest"))
            {
                endpointConfiguration = EndpointConfigurationFactory.ConfigureEndpoint(PaymentEndpoint.Name, true)
                                        .ConfigureSqlPersistence(
                    this.Configuration.GetConnectionString("PaymentDbContext"),
                    1,
                    this.CurrentEnvironment.IsDevelopment() && serviceFabricHostMarker == null).ConfigureSqlTransport(
                    this.Configuration.GetConnectionString("TransportDbContext"),
                    (routing) =>
                {
                    routing.RegisterPublisher(typeof(RequestPayment), RegistrationEndpoint.Name);
                    routing.RegisterPublisher(typeof(CompletePayment), PaymentEndpoint.Name);
                    routing.RegisterPublisher(typeof(CancelPayment), PaymentEndpoint.Name);
                });
                endpointConfiguration.LicensePath("License.xml");
            }

            builder.Register(x => MessageSession).As <IMessageSession>();

            // Build container
            this.applicationContainer = builder.Build();

            // Add NServiceBus
            if (!this.CurrentEnvironment.IsEnvironment("IntegrationTest"))
            {
                endpointConfiguration.UseContainer <AutofacBuilder>(
                    customizations => { customizations.ExistingLifetimeScope(this.applicationContainer); });
                MessageSession = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();
            }

            return(new AutofacServiceProvider(this.applicationContainer));
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            var serviceFabricHostMarker = Environment.GetEnvironmentVariable("ServiceFabricHostMarker");

            services.AddDbContext <ResourcesDbContext>(
                options => options.UseSqlServer(this.Configuration.GetConnectionString("ResourcesDbContext")));

            services.AddSingleton(res => this.Configuration);
            services.AddScoped <DbContext, ResourcesDbContext>();
            services.AddScoped <IEventService, EventService>();
            services.AddScoped <IResourceService, ResourceService>();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Contacts API", Version = "v1"
                });
            });

            services.AddCors();
            services.AddMvc();
            services.AddEventManagementAuthentication(new DefaultEventManagementTokenValidationParameters(this.Configuration));

            var builder = new ContainerBuilder();

            builder.Populate(services);

            // Add NServiceBus Handlers
            EndpointConfiguration endpointConfiguration = null;

            if (!this.CurrentEnvironment.IsEnvironment("IntegrationTest"))
            {
                endpointConfiguration = EndpointConfigurationFactory.ConfigureEndpoint(ResouresEndpoint.Name, true)
                                        .ConfigureSqlPersistence(
                    this.Configuration.GetConnectionString("ResourcesDbContext"),
                    1,
                    this.CurrentEnvironment.IsDevelopment() && serviceFabricHostMarker == null).ConfigureSqlTransport(
                    this.Configuration.GetConnectionString("TransportDbContext"),
                    (routing) =>
                {
                    // TODO: Mapp app service bus nodes
                    // if (Convert.ToBoolean(this.Configuration.GetSection("ServiceBusNodes")["SomeNode"]))
                    // {
                    // routing.RegisterPublisher(typeof(SomeMessage), EndpointName);
                    // }
                });
                endpointConfiguration.LicensePath("License.xml");
            }

            builder.Register(x => MessageSession).As <IMessageSession>();

            // Build container
            this.applicationContainer = builder.Build();

            // Add NServiceBus
            if (!this.CurrentEnvironment.IsEnvironment("IntegrationTest"))
            {
                endpointConfiguration.UseContainer <AutofacBuilder>(
                    customizations => { customizations.ExistingLifetimeScope(this.applicationContainer); });
                MessageSession = Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();
            }

            return(new AutofacServiceProvider(this.applicationContainer));
        }