public ConfigModel() { /// all the objects in the class have been initialized with an empty object to avoid /// throwing Object reference error even in all circumstances. /// these objects SHOULD be initialized with some default values - possibly from web.config for worst case scenarios. ConfigSettings = new List <ConfigSettingModel>(); BasketSettings = new BasketSettings(); B2BSettings = new B2BSettings(); CatalogSettings = new CatalogSettings(); DomainSettings = new DomainSettings(); OrderSettings = new OrderSettings(); SearchSettings = new SearchSettings(); SeoSettings = new SeoSettings(); ShippingSettings = new ShippingSettings(); SocialSettings = new SocialSettings(); RecommendationSettings = new RecommendationSettings(); Currencies = new List <CurrencyModel>(); ShippingCountries = new List <CountryModel>(); BillingCountries = new List <CountryModel>(); Languages = new List <LanguageModel>(); RegionalSettings = new RegionalSettings(); ReviewSettings = new List <ProductReviewSection>(); GeoLocators = new List <GeoLocatorModel>(); Snippets = new List <SnippetModel>(); FeatureToggles = new FeatureToggleSettings(); }
public UpkManagerController(UpkManagerViewModel ViewModel, MainMenuViewModel MenuViewModel, IMessenger Messenger, ISettingsRepository SettingsRepository, IExceptionRepository ExceptionRepository, IMapper Mapper) { if (Application.Current != null) { Application.Current.DispatcherUnhandledException += onCurrentDispatcherUnhandledException; } AppDomain.CurrentDomain.UnhandledException += onDomainUnhandledException; Dispatcher.CurrentDispatcher.UnhandledException += onCurrentDispatcherUnhandledException; TaskScheduler.UnobservedTaskException += onUnobservedTaskException; System.Windows.Forms.Application.ThreadException += onThreadException; viewModel = ViewModel; menuViewModel = MenuViewModel; messenger = Messenger; settingsRepository = SettingsRepository; exceptionRepository = ExceptionRepository; mapper = Mapper; settings = Task.Run(() => settingsRepository.LoadSettingsAsync()).Result; viewModel.Settings = mapper.Map <SettingsWindowViewEntity>(settings); registerMessages(); registerCommands(); }
public async Task <DomainSettings> LoadSettingsAsync() { DomainSettings settings; if (await Task.Run(() => File.Exists(Filename))) { settings = await Task.Run(() => JsonConvert.DeserializeObject <DomainSettings>(File.ReadAllText(Filename))); if (settings.WindowW.EqualInPercentRange(0)) { settings.WindowW = 1280; settings.WindowH = 720; settings.WindowX = 100; settings.WindowY = 100; } } else { settings = new DomainSettings { WindowW = 1280, WindowH = 720, WindowX = 100, WindowY = 100 } }; return(settings); }
private void onApplicationLoaded(AppLoadedMessage message) { settings = message.Settings; loadExportFiles(); setupWatchers(); }
private void ConfigureSettings(IServiceCollection services) { var settings = new DomainSettings( Configuration.GetValue <string>("Domain:Copyright"), Configuration.GetValue <string>("Domain:CopyrightYear")); services.AddSingleton(settings); }
public ProjectSettings( InfrastuctureSettings infrastuctureSettings, DomainSettings domainSettings, ApplicationSettings applicationSettings) { this.infrastuctureSettings = infrastuctureSettings; this.domainSettings = domainSettings; this.applicationSettings = applicationSettings; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var domainSettings = new DomainSettings(); var section = Configuration.GetSection(nameof(DomainSettings)); section.Bind(domainSettings); services.Configure <DomainSettings>(options => section.Bind(options)); services.AddMvc(options => options.SslPort = _sslPort); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); services.AddAuthentication( options => { options.DefaultScheme = "Cookies"; options.DefaultChallengeScheme = "oidc"; }) .AddCookie("Cookies") .AddOpenIdConnect("oidc", options => { options.SignInScheme = "Cookies"; options.Authority = domainSettings.Auth.Url; options.RequireHttpsMetadata = false; options.ClientId = domainSettings.Client.Id; options.ClientSecret = domainSettings.Client.Secret; options.SaveTokens = true; options.ResponseType = "code id_token"; options.Scope.Add(IdentityServerConstants.StandardScopes.Email); options.Scope.Add(IdentityServerConstants.StandardScopes.OpenId); options.Scope.Add(IdentityServerConstants.StandardScopes.OfflineAccess); options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true; options.TokenValidationParameters = new TokenValidationParameters { NameClaimType = "name", RoleClaimType = "role" }; options.Scope.Add(domainSettings.Api.Id); options.Scope.Add("internal_auth_api"); options.Scope.Add(DomainScopes.Roles); options.Scope.Add(DomainScopes.MvcClientUser); //options.Scope.Add(DomainScopes.ApiKeys); options.Events = new OpenIdConnectEvents { OnRemoteFailure = context => { Console.WriteLine(context.Failure.Message + " Failiure during authentication - Remote failure."); return(Task.FromResult(0)); } }; }); }
public async Task InitializeAsync() { settings = await settingsRepository.LoadSettingsAsync(); viewModel.Settings = mapper.Map <SettingsWindowViewEntity>(settings); registerMessages(); registerCommands(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { string connectionString = Configuration.GetConnectionString("DefaultConnection"); var domainSettings = new DomainSettings(); var section = Configuration.GetSection(nameof(DomainSettings)); section.Bind(domainSettings); services.Configure <DomainSettings>(options => section.Bind(options)); services.AddApplicationInsightsTelemetry(Configuration); services.AddMvcCore(options => { options.SslPort = _sslPort; }) .AddAuthorization() .AddJsonFormatters() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = domainSettings.Auth.Url; options.RequireHttpsMetadata = false; options.ApiName = domainSettings.Api.Name; options.ApiSecret = domainSettings.Api.Secret; }); services.AddCors(options => { options.AddPolicy("default", policy => { policy.WithOrigins(domainSettings.Client.Url) .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddAuthorization(options => { options.AddPolicy(DomainPolicies.NormalUser, policy => policy.RequireClaim(JwtClaimTypes.Scope, DomainScopes.MvcClientUser)); options.AddPolicy(DomainPolicies.SuperAdmin, policy => policy.RequireClaim(JwtClaimTypes.Role, DomainRoles.SuperAdmin)); options.AddPolicy(DomainPolicies.Admin, policy => policy.RequireClaim(JwtClaimTypes.Role, DomainRoles.Admin)); }); services.AddDbContext <IdentityContext>(options => options.UseSqlServer(connectionString)); services.AddTransient <EntityManager>(); services.AddTransient <IUnitOfWork, SiUnitOfWork>(); }
public MailDispatcherTests(ITestOutputHelper output) { _queue = new MockMailQueue(); _transfer = new MockMailTransferQueue(); _mailbox = new MockMailboxStore(); _domainSettings = new DomainSettings( new[] { new DistributionList( "*****@*****.**", "Internal only list", new[] { "*****@*****.**" }, new[] { "*****@*****.**", "*****@*****.**" }, false, true ), new DistributionList( "*****@*****.**", "Disabled list", new[] { "*****@*****.**" }, new[] { "*****@*****.**", "*****@*****.**" } ), new DistributionList( "*****@*****.**", "External list", new[] { "*****@*****.**" }, new[] { "*****@*****.**", "*****@*****.**", "*****@*****.**", "*****@*****.**" }, true, true ) }, new Dictionary <string, string> { { "*****@*****.**", "*****@*****.**" } }); AgentSettings settings = TestHelpers.MakeSettings( "example.com", new[] { new SmtpAcceptDomain("example.com") }, relayDomains: new[] { new SmtpRelayDomain("relay.example.com", "relay.example.com") }, idleDelay: 1); _dispatcher = new MailDispatcher( _queue, _mailbox, _transfer, new TestOutputLogger(output), new MockDomainResolver(_domainSettings), null, new MockVolatile <AgentSettings>(settings)); }
public void TryExtractInt_ThrowsExceptionStringIsNotConvertableToint() { // Arrange // Act var exp = Assert.Throws <Exception>(() => DomainSettings.TryExtractInt("i'm words", "SomeNameId")); // Assert Assert.That(exp.Message, Is.EqualTo("SomeNameId in DomainSettings is missing or has an invalid value! String value: i'm words")); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var domainSettings = new DomainSettings(); Configuration.GetSection(nameof(DomainSettings)).Bind(domainSettings); services.Configure <DomainSettings>(options => Configuration.GetSection(nameof(DomainSettings)).Bind(options)); var appSettings = new AppSettings(); Configuration.GetSection(nameof(AppSettings)).Bind(appSettings); var connectionString = appSettings.ConnectionStrings.AuthContext; var migrationsAssembly = typeof(DataModule).GetTypeInfo().Assembly.GetName().Name; services.AddDbContext <IdentityContext>(o => o.UseSqlServer(connectionString, optionsBuilder => optionsBuilder.MigrationsAssembly(migrationsAssembly))); services.AddIdentity <ApplicationUser, IdentityRole>(options => { options.Password.RequireDigit = false; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; options.Password.RequiredLength = 6; }) .AddEntityFrameworkStores <IdentityContext>() .AddDefaultTokenProviders(); services.AddMvc(options => { //options.Filters.Add(new RequireHttpsAttribute()); options.SslPort = _sslPort; }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddIdentityServer(options => { options.UserInteraction.LoginUrl = "/Account/login"; options.UserInteraction.LogoutUrl = "/Account/logout"; }) // Replace with your certificate's thumbPrint, path, and password .AddInMemoryApiResources(Domain.Authentication.Resources.GetApis(domainSettings.Api)) .AddInMemoryIdentityResources(Domain.Authentication.Resources.GetIdentityResources()) .AddOperationalStore(options => { options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)); // this enables automatic token cleanup. this is optional. options.EnableTokenCleanup = true; options.TokenCleanupInterval = 30; // interval in seconds }) .AddAspNetIdentity <ApplicationUser>() ; }
public async Task SaveSettings(DomainSettings Settings) { string json = await Task.Run(() => JsonConvert.SerializeObject(Settings, Formatting.Indented)); if (!await Task.Run(() => File.Exists(Filename))) { await Task.Run(() => Directory.CreateDirectory(Path.GetDirectoryName(Filename))); } await Task.Run(() => File.WriteAllText(Filename, json)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var domainSettings = new DomainSettings(); var section = Configuration.GetSection(nameof(DomainSettings)); section.Bind(domainSettings); services.Configure <DomainSettings>(options => section.Bind(options)); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); services.AddAuthentication( options => { options.DefaultScheme = "Cookies"; options.DefaultChallengeScheme = "oidc"; }) .AddCookie("Cookies") .AddOpenIdConnect("oidc", options => { options.SignInScheme = "Cookies"; options.Authority = domainSettings.Auth.Url; options.RequireHttpsMetadata = false; options.ClientId = domainSettings.Client.Id; options.ClientSecret = domainSettings.Client.Secret; options.SaveTokens = true; options.ResponseType = "code id_token"; options.Scope.Add(IdentityServerConstants.StandardScopes.Email); options.Scope.Add(IdentityServerConstants.StandardScopes.OpenId); options.Scope.Add(IdentityServerConstants.StandardScopes.OfflineAccess); options.GetClaimsFromUserInfoEndpoint = true; options.Scope.Add(domainSettings.Api.Id); options.Scope.Add(DomainScopes.Roles); options.Scope.Add(DomainScopes.MvcClientUser); options.Scope.Add(DomainScopes.ApiKeys); options.Events = new OpenIdConnectEvents { OnRemoteFailure = context => { Console.WriteLine(context.Failure.Message + " Failure during authentication - Remote failure."); return(Task.FromResult(0)); } }; }); }
private async Task onApplicationLoaded(AppLoadedMessage message) { settings = message.Settings; oldPathToGame = settings.PathToGame; viewModel.SelectedType = ObjectTypes.Texture2D.ToString(); viewModel.IsShowFilesWithType = true; await loadAllFiles(); }
private void Verify(DomainSettings settings) { Assert.NotNull(settings.Resolver); Assert.Null(Record.Exception(() => settings.Validate())); DomainServiceResolverSettings serviceResolverSettings = settings.Resolver as DomainServiceResolverSettings; if (serviceResolverSettings != null) { Assert.True(serviceResolverSettings.AgentName == "Agent1"); Assert.True(serviceResolverSettings.ClientSettings.Url == "http://localhost/ConfigService/DomainManagerService.svc/Domains"); } }
private void Verify(DomainSettings settings) { Assert.NotNull(settings.Resolver); Assert.DoesNotThrow(() => settings.Validate()); DomainServiceResolverSettings serviceResolverSettings = settings.Resolver as DomainServiceResolverSettings; if (serviceResolverSettings != null) { Assert.True(serviceResolverSettings.AgentName == "Agent1"); Assert.True(serviceResolverSettings.ClientSettings.Url == "http://localhost:6692/DomainManagerService.svc/Domains"); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var domainSettings = new DomainSettings(); var section = Configuration.GetSection(nameof(DomainSettings)); section.Bind(domainSettings); services.Configure <DomainSettings>(options => section.Bind(options)); services.AddApplicationInsightsTelemetry(Configuration); services.AddMvcCore(options => { // options.Conventions.Insert(0, new ModeRouteConvention()); // options.Filters.Add(new RequireHttpsAttribute()); options.SslPort = _sslPort; }) .AddAuthorization() .AddJsonFormatters(); services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = domainSettings.Auth.Url; options.RequireHttpsMetadata = false; options.ApiName = domainSettings.Api.Id; options.ApiSecret = domainSettings.Api.Secret; }); services.AddCors(options => { options.AddPolicy("default", policy => { policy.WithOrigins(domainSettings.Client.Url) .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddAuthorization(options => { options.AddPolicy(DomainPolicies.NormalUser, policy => policy.RequireClaim(JwtClaimTypes.Scope, DomainScopes.MvcClientUser)); options.AddPolicy(DomainPolicies.Admin, policy => policy.RequireClaim(JwtClaimTypes.Role, DomainRoles.Admin)); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var domainSettings = new DomainSettings(); var section = Configuration.GetSection(nameof(DomainSettings)); section.Bind(domainSettings); services.Configure <DomainSettings>(options => section.Bind(options)); services .AddMvcCore() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddAuthorization() .AddJsonFormatters() ; services.AddAuthentication("Bearer") .AddIdentityServerAuthentication(options => { options.Authority = domainSettings.Auth.Url; options.RequireHttpsMetadata = false; options.ApiName = domainSettings.Api.Id; options.ApiSecret = domainSettings.Api.Secret; }); services.AddCors(options => { options.AddPolicy("default", policy => { policy.WithOrigins(domainSettings.Client.Url) .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddAuthorization(options => { options.AddPolicy(DomainPolicies.NormalUser, policy => policy.RequireClaim(JwtClaimTypes.Scope, DomainScopes.MvcClientUser)); options.AddPolicy(DomainPolicies.Admin, policy => policy.RequireClaim(JwtClaimTypes.Role, DomainRoles.Admin)); }); }
public DomainSetting GetDomainSetting(string hostWithPort) { DomainSetting domainSetting = null; try { domainSetting = DomainSettings.FirstOrDefault( domainsetting => domainsetting.Domain.Equals(hostWithPort, StringComparison.InvariantCultureIgnoreCase)); if (domainSetting == null) { domainSetting = DomainSettings.First( domainsetting => domainsetting.Domain.Equals("default", StringComparison.InvariantCultureIgnoreCase));; } } catch (Exception ex) { Log.Error("GetDomainSetting throw exception, might forget to set domain default", ex); } return(domainSetting); }
public CombatService(IQuotesProxy quotesProxy, DomainSettings settings) { this.quotesProxy = quotesProxy; this.settings = settings; }
public static async Task <ActivityResponse> QueryOutputProcessorOrchestrator( [OrchestrationTrigger] DurableOrchestrationContext context, Microsoft.Extensions.Logging.ILogger log) { ActivityResponse response = new ActivityResponse() { FunctionName = "QueryOutputProcessorOrchestrator" }; // Get the Query_Outputs_Request from the context... Query_Outputs_Request request = context.GetInput <Query_Outputs_Request>(); if (null != request) { // Read the outputs for the given query Guid queryGuid; if (Guid.TryParse(request.UniqueIdentifier, out queryGuid)) { // Get the current state of the query... Projection getQueryState = new Projection(Constants.Domain_Query, request.QueryName, queryGuid.ToString(), nameof(Query_Summary_Projection)); if (null != getQueryState) { // Get all the output targets Query_Outputs_Projection qryOutputs = new Query_Outputs_Projection(log); await getQueryState.Process(qryOutputs); if ((qryOutputs.CurrentSequenceNumber > 0) || (qryOutputs.ProjectionValuesChanged())) { #region Logging if (null != log) { log.LogDebug($"Sending results to output targets from {request.QueryName} : {request.UniqueIdentifier} "); } #endregion List <Task <ActivityResponse> > allOutputTasks = new List <Task <ActivityResponse> >(); if (null != request.Results) { // Create a QueryOutputRecord<object> QueryOutputRecord <object> outputRequest = QueryOutputRecord <object> .Create(request.Results, @"", request.QueryName, queryGuid); foreach (string location in qryOutputs.WebhookTargets) { #region Logging if (null != log) { log.LogDebug($"Target : { location} - being sent by webhook in OutputResultsGetLeagueSummaryQuery"); } #endregion outputRequest.Target = location; // add a task to ouputit it via webhook.... allOutputTasks.Add(context.CallActivityWithRetryAsync <ActivityResponse>("QueryOutputToWebhookActivity", DomainSettings.QueryRetryOptions(), outputRequest)); } foreach (string location in qryOutputs.BlobTargets) { #region Logging if (null != log) { log.LogDebug($"Target : { location} - being persisted to a Blob in {response.FunctionName}"); } #endregion outputRequest.Target = location; // add a task to ouputit it via webhook.... allOutputTasks.Add(context.CallActivityWithRetryAsync <ActivityResponse>("QueryOutputToBlobActivity", DomainSettings.QueryRetryOptions(), outputRequest)); } foreach (string location in qryOutputs.ServiceBusTargets) { #region Logging if (null != log) { log.LogDebug($"Target : { location} - being sent out via service bus in {response.FunctionName}"); } #endregion outputRequest.Target = location; // add a task to ouputit it via service bus.... allOutputTasks.Add(context.CallActivityWithRetryAsync <ActivityResponse>("QueryOutputToServiceBusActivity", DomainSettings.QueryRetryOptions(), outputRequest)); } //EventGridTargets foreach (string location in qryOutputs.EventGridTargets) { #region Logging if (null != log) { log.LogDebug($"Target : { location} - being sent out via event grid in {response.FunctionName}"); } #endregion outputRequest.Target = location; // add a task to ouputit it via event grid.... allOutputTasks.Add(context.CallActivityWithRetryAsync <ActivityResponse>("QueryOutputToEventGridActivity", DomainSettings.QueryRetryOptions(), outputRequest)); } foreach (string location in qryOutputs.SignalRTargets) { #region Logging if (null != log) { log.LogDebug($"Target : { location} - being sent out via SignalR in {response.FunctionName}"); } #endregion outputRequest.Target = location; // add a task to ouputit it via SignalR.... allOutputTasks.Add(context.CallActivityWithRetryAsync <ActivityResponse>("QueryOutputToSignalRActivity", DomainSettings.QueryRetryOptions(), outputRequest)); } // TODO: All the other output methods } // Await for all the outputs to have run in parallel... await Task.WhenAll(allOutputTasks); foreach (var returnedResponse in allOutputTasks) { if (returnedResponse.Result.FatalError) { response.FatalError = true; response.Message = returnedResponse.Result.Message; } #region Logging if (null != log) { log.LogDebug($"Sent results to output targets from {returnedResponse.Result.FunctionName} : {returnedResponse.Result.Message } "); } #endregion context.SetCustomStatus(returnedResponse.Result); } } } } } else { response.Message = $"Unable to get outputs request details in sub orchestration {context.InstanceId} "; response.FatalError = true; } return(response); }
private void onSettingsChanged(SettingsChangedMessage message) { settings = message.Settings; }
private void onApplicationLoaded(AppLoadedMessage message) { settings = message.Settings; }
private void onSettingsChanged(SettingsChangedMessage message) { settings = message.Settings; setupWatchers(); }
public static async Task <Get_League_Summary_Definition_Return> OnGetLeagueSummaryQueryHandlerOrchestrator ([OrchestrationTrigger] DurableOrchestrationContext context, Microsoft.Extensions.Logging.ILogger log) { // Get the query definition form the context... QueryRequest <Get_League_Summary_Definition> queryRequest = context.GetInput <QueryRequest <Get_League_Summary_Definition> >(); try { if (null != queryRequest) { if (string.IsNullOrWhiteSpace(queryRequest.QueryName)) { queryRequest.QueryName = "Get League Summary"; } // Log the query request in its own own query event stream Guid queryId = await context.CallActivityWithRetryAsync <Guid>("GetLeagueSummaryCreateQueryRequestActivity", DomainSettings.QueryRetryOptions(), queryRequest); if (queryId.Equals(Guid.Empty)) { #region Logging if (null != log) { // Unable to get the request details from the orchestration log.LogError("OnGetLeagueSummaryQueryHandlerOrchestrator : Unable to create the query event stream"); } #endregion return(null); } else { queryRequest.QueryUniqueIdentifier = queryId; // Save the parameters to the event stream ActivityResponse resp = null; resp = await context.CallActivityWithRetryAsync <ActivityResponse>("GetLeagueSummaryLogParametersActivity", DomainSettings.QueryRetryOptions(), queryRequest); #region Logging if (null != log) { if (null != resp) { log.LogInformation($"{resp.FunctionName} complete: {resp.Message } "); } } #endregion if (null != resp) { context.SetCustomStatus(resp); } // next validate the query bool valid = false; try { valid = await context.CallActivityWithRetryAsync <bool>("GetLeagueSummaryValidateActivity", DomainSettings.QueryRetryOptions(), queryRequest); } catch (FunctionFailedException ffs) { if (null == resp) { resp = new ActivityResponse() { FunctionName = "QueryProjectionProcessorOrchestrator" }; } resp.Message = ffs.Message; resp.FatalError = true; } if (!valid) { #region Logging if (null != log) { // Could not run the query as the parameters don't make sense log.LogError($"OnGetLeagueSummaryQueryHandlerOrchestrator : Query parameters are invalid {queryId}"); } #endregion return(null); } else { try { // Request all the projections needed to answer this query resp = await context.CallActivityWithRetryAsync <ActivityResponse>("GetLeagueSummaryQueryProjectionRequestActivity", DomainSettings.QueryRetryOptions(), queryRequest); } catch (FunctionFailedException ffs) { if (null == resp) { resp = new ActivityResponse() { FunctionName = "QueryProjectionProcessorOrchestrator" }; } resp.Message = ffs.Message; resp.FatalError = true; } if (null != resp) { #region Logging if (null != log) { if (null != resp) { log.LogInformation($"{resp.FunctionName} complete: {resp.Message } "); } } #endregion context.SetCustomStatus(resp); if (resp.FatalError) { #region Logging if (null != log) { log.LogError($"Fatal error in {resp.FunctionName} - {resp.Message} "); } #endregion return(null); } } // Get all the outstanding projection requests by calling a sub-orchestrator Query_Projections_Projection_Request projectionQueryRequest = new Query_Projections_Projection_Request() { UniqueIdentifier = queryRequest.QueryUniqueIdentifier.ToString(), QueryName = queryRequest.QueryName }; try { resp = await context.CallSubOrchestratorWithRetryAsync <ActivityResponse>("QueryProjectionProcessorOrchestrator", DomainSettings.QueryRetryOptions(), projectionQueryRequest); } catch (FunctionFailedException ffs) { if (null == resp) { resp = new ActivityResponse() { FunctionName = "QueryProjectionProcessorOrchestrator" }; } resp.Message = ffs.Message; resp.FatalError = true; } if (null != resp) { #region Logging if (null != log) { if (null != resp) { log.LogInformation($"{resp.FunctionName} complete: {resp.Message } "); } } #endregion context.SetCustomStatus(resp); if (resp.FatalError) { #region Logging if (null != log) { log.LogError($"Fatal error in {resp.FunctionName} - {resp.Message} "); } #endregion return(null); } } try { // Output the results resp = await context.CallActivityWithRetryAsync <ActivityResponse>("GetLeagueSummaryOutputResultsActivity", DomainSettings.QueryRetryOptions(), queryRequest); } catch (FunctionFailedException ffs) { if (null == resp) { resp = new ActivityResponse() { FunctionName = "QueryProjectionProcessorOrchestrator" }; } resp.Message = ffs.Message; resp.FatalError = true; } #region Logging if (null != log) { if (null != resp) { log.LogInformation($"{resp.FunctionName} complete: {resp.Message } "); } } #endregion if (null != resp) { context.SetCustomStatus(resp); if (resp.FatalError) { #region Logging if (null != log) { log.LogError($"Fatal error in {resp.FunctionName} - {resp.Message} "); } #endregion return(null); } } // Get the results for ourselves to return...to do this the query must be complete... Get_League_Summary_Definition_Return ret = await context.CallActivityWithRetryAsync <Get_League_Summary_Definition_Return>("GetLeagueSummaryGetResultsActivity", DomainSettings.QueryRetryOptions(), queryRequest); return(ret); } } } else { if (null != log) { // Unable to get the request details from the orchestration log.LogError("OnGetLeagueSummaryQueryHandlerOrchestrator : Unable to get the query request from the context"); string contextAsString = context.GetInput <string>(); if (!string.IsNullOrWhiteSpace(contextAsString)) { log.LogError($"Context was {contextAsString} "); } else { log.LogError($"Context was blank "); } } return(null); } } catch (Exception ex) { #region Logging if (null != log) { // Error running thew orchestration log.LogError($"OnGetLeagueSummaryQueryHandlerOrchestrator : Error {ex.Message}"); } #endregion if (null != context) { context.SetCustomStatus($"OnGetLeagueSummaryQueryHandlerOrchestrator : Error {ex.Message}"); } throw; } }
public ClientStore(IdentityContext context, IOptions <DomainSettings> domainSettings) { _context = context; _domainSettings = domainSettings.Value; }
public static async Task <ActivityResponse> CommandNotificationOrchestrator( [OrchestrationTrigger] DurableOrchestrationContext context, Microsoft.Extensions.Logging.ILogger log) { ActivityResponse <Command_Notification_Response> response = new ActivityResponse <Command_Notification_Response>() { FunctionName = "CommandNotificationOrchestrator" }; Command_Get_Notifications_Request request = context.GetInput <Command_Get_Notifications_Request>(); if (null != request) { Guid UniqueIdentifierGuid; if (Guid.TryParse(request.CommandUniqueIdentifier, out UniqueIdentifierGuid)) { // run the [Command_Notifications_Projection].. response = await context.CallActivityAsync <ActivityResponse <Command_Notification_Response> >("GetCommandNotificationsActivity", request); if (null != response) { if ((!response.FatalError) && (!response.StepFailure)) { if (null != response.ReturnedData) { List <Task <ActivityResponse> > allNotificationTasks = new List <Task <ActivityResponse> >(); // Only process the notifications that match the state of the command... IEnumerable <ReturnHookAdded> notificationHooks = null; if (response.ReturnedData.InError) { notificationHooks = response.ReturnedData.NotificationTargetHooks.ForErrors(); } else { if (response.ReturnedData.Completed) { notificationHooks = response.ReturnedData.NotificationTargetHooks.ForCompleteCommands(); } else { notificationHooks = response.ReturnedData.NotificationTargetHooks.ForStepComplete(); } } // fire off all the notifications in parrallel foreach (var notificationTarget in notificationHooks) { foreach (var notifyEntity in response.ReturnedData.ImpactedEntities) { // create an individual notification request Command_Notification_Request notifyRequest = new Command_Notification_Request() { CommandName = request.CommandName, CommandNotificationType = Command_Notification_Request.NotificationType.StepComplete, HookAddress = notificationTarget.HookAddress, HookType = notificationTarget.HookType, ImpactedEntity = notifyEntity }; if (response.ReturnedData.InError) { notifyRequest.CommandNotificationType = Command_Notification_Request.NotificationType.Error; } else { if (response.ReturnedData.Completed) { notifyRequest.CommandNotificationType = Command_Notification_Request.NotificationType.CommandComplete; } } if (notificationTarget.HookType == CommandNotificationTarget.NotificationTargetType.CustomEventGridTopic) { // RunCustomEventGridTopicNotificationActivity allNotificationTasks.Add(context.CallActivityWithRetryAsync <ActivityResponse>("RunCustomEventGridTopicNotificationActivity", DomainSettings.CommandRetryOptions(), notifyRequest)); } if (notificationTarget.HookType == CommandNotificationTarget.NotificationTargetType.WebHook) { // RunWebHookNotificationActivity allNotificationTasks.Add(context.CallActivityWithRetryAsync <ActivityResponse>("RunWebHookNotificationActivity", DomainSettings.CommandRetryOptions(), notifyRequest)); } if (notificationTarget.HookType == CommandNotificationTarget.NotificationTargetType.SignalR) { //RunSignalRNotificationActivity allNotificationTasks.Add(context.CallActivityWithRetryAsync <ActivityResponse>("RunSignalRNotificationActivity", DomainSettings.CommandRetryOptions(), notifyRequest)); } } } // Run the projections in parallel... await Task.WhenAll(allNotificationTasks); } } else { #region Logging if (null != log) { log.LogError($"{response.FunctionName} error - no data returned - {response.Message} "); } #endregion } } } else { response.FatalError = true; response.Message = $"Unable to get command unique identifier for {request.CommandName} {request.CommandUniqueIdentifier } as a GUID "; } } return(response); }
public ClientStore(IOptions <DomainSettings> domainSettings) { _domainSettings = domainSettings.Value; }
public static async Task <ActivityResponse> QueryProjectionProcessorOrchestrator( [OrchestrationTrigger] DurableOrchestrationContext context, Microsoft.Extensions.Logging.ILogger log) { ActivityResponse response = new ActivityResponse() { FunctionName = "QueryProjectionProcessorOrchestrator" }; Query_Projections_Projection_Request request = context.GetInput <Query_Projections_Projection_Request>(); if (null != request) { Guid UniqueIdentifierGuid; if (!Guid.TryParse(request.UniqueIdentifier, out UniqueIdentifierGuid)) { if (!Guid.TryParse(request.CallbackOrchestrationIdentifier, out UniqueIdentifierGuid)) { if (!Guid.TryParse(context.ParentInstanceId, out UniqueIdentifierGuid)) { if (!Guid.TryParse(context.InstanceId, out UniqueIdentifierGuid)) { UniqueIdentifierGuid = Guid.NewGuid(); } } } } // get all the projection requests for the query List <Query_Projections_Projection_Return> allProjections = await context.CallActivityWithRetryAsync <List <Query_Projections_Projection_Return> >("GetQueryProjectionsStatusProjectionActivity", DomainSettings.QueryRetryOptions(), request); if (null != allProjections) { #region Logging if (null != log) { log.LogInformation($"Query {request.QueryName}.{request.UniqueIdentifier} has {allProjections.Count} projections total "); } #endregion // Run them - This should be done by fan-out/fan-in List <Task <ProjectionResultsRecord <object> > > allProjectionTasks = new List <Task <ProjectionResultsRecord <object> > >(); // run all the outstanding projections in parallel foreach (Query_Projections_Projection_Return projectionRequest in allProjections) { if (projectionRequest.ProjectionState == Query_Projections_Projection_Return.QueryProjectionState.Queued) { ProjectionRequest projRequest = new ProjectionRequest() { ParentRequestName = request.QueryName, CorrelationIdentifier = UniqueIdentifierGuid, DomainName = projectionRequest.Projection.DomainName, AggregateTypeName = projectionRequest.Projection.AggregateTypeName, AggregateInstanceUniqueIdentifier = projectionRequest.Projection.InstanceKey, AsOfDate = request.AsOfDate, ProjectionName = projectionRequest.Projection.ProjectionTypeName }; if (null != projRequest) { context.SetCustomStatus(projRequest); } // mark it as in-flight response = await context.CallActivityWithRetryAsync <ActivityResponse>("LogQueryProjectionInFlightActivity", DomainSettings.QueryRetryOptions(), projRequest); if (null != response) { context.SetCustomStatus(response); } } } // Now start them running using a fan-out/fan in pattern foreach (Query_Projections_Projection_Return projectionRequest in allProjections) { if (projectionRequest.ProjectionState == Query_Projections_Projection_Return.QueryProjectionState.Queued) { ProjectionRequest projRequest = new ProjectionRequest() { ParentRequestName = request.QueryName, CorrelationIdentifier = UniqueIdentifierGuid, DomainName = projectionRequest.Projection.DomainName, AggregateTypeName = projectionRequest.Projection.AggregateTypeName, AggregateInstanceUniqueIdentifier = projectionRequest.Projection.InstanceKey, AsOfDate = request.AsOfDate, ProjectionName = projectionRequest.Projection.ProjectionTypeName }; // and start running it... allProjectionTasks.Add(context.CallActivityWithRetryAsync <ProjectionResultsRecord <object> >("RunProjectionActivity", DomainSettings.QueryRetryOptions(), projRequest)); } } // Run the projections in parallel... await Task.WhenAll(allProjectionTasks); // and save their results to the query foreach (var returnValue in allProjectionTasks) { ProjectionResultsRecord <object> result = returnValue.Result; if (null != result) { if (!result.Error) { response = await context.CallActivityWithRetryAsync <ActivityResponse>("LogQueryProjectionResultActivity", DomainSettings.QueryRetryOptions(), result); } else { #region Logging if (null != log) { log.LogError($"Error running projection {result.ProjectionName} - {result.StatusMessage} "); } #endregion response.Message = $"Error running projection {result.ProjectionName} - {result.StatusMessage} "; } if (null != response) { context.SetCustomStatus(response); } } else { #region Logging if (null != log) { log.LogError($"Projection {returnValue.Id} did not return any values : {returnValue.Exception}"); } #endregion } } } // when all done - trigger the calling orchestration to come out of hibernation if (!string.IsNullOrWhiteSpace(request.CallbackOrchestrationIdentifier)) { } } else { response.Message = $"Unable to read projection request data from context {context.InstanceId}"; response.FatalError = true; } return(response); }