Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Msalem/fix scheduler button #570

Closed
wants to merge 13 commits into from
3 changes: 1 addition & 2 deletions deployment/Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Param(
[string][Parameter()]$LogoURLpng, # URL for Publisher .png logo
[string][Parameter()]$LogoURLico, # URL for Publisher .ico logo
[string][Parameter()]$KeyVault, # Name of KeyVault
[switch][Parameter()]$MeteredSchedulerSupport, # Add this key like -MeteredSchedulerSupport to the command to enable Metered Scheduler Support
[switch][Parameter()]$Quiet #if set, only show error / warning output from script commands
)

Expand Down Expand Up @@ -333,7 +332,7 @@ Write-host " ➡️ Setup access to KeyVault"
az keyvault set-policy --name $KeyVault --object-id $WebAppNameAdminId --secret-permissions get list --key-permissions get list --output $azCliOutput
Write-host " ➡️ Set Configuration"
az webapp config connection-string set -g $ResourceGroupForDeployment -n $WebAppNameAdmin -t SQLAzure --output $azCliOutput --settings DefaultConnection=$DefaultConnectionKeyVault
az webapp config appsettings set -g $ResourceGroupForDeployment -n $WebAppNameAdmin --output $azCliOutput --settings KnownUsers=$PublisherAdminUsers SaaSApiConfiguration__AdAuthenticationEndPoint=https://login.microsoftonline.com SaaSApiConfiguration__ClientId=$ADApplicationID SaaSApiConfiguration__ClientSecret=$ADApplicationSecretKeyVault SaaSApiConfiguration__FulFillmentAPIBaseURL=https://marketplaceapi.microsoft.com/api SaaSApiConfiguration__FulFillmentAPIVersion=2018-08-31 SaaSApiConfiguration__GrantType=client_credentials SaaSApiConfiguration__MTClientId=$ADMTApplicationID SaaSApiConfiguration__Resource=20e940b3-4c77-4b0b-9a53-9e16a1b010a7 SaaSApiConfiguration__TenantId=$TenantID SaaSApiConfiguration__SignedOutRedirectUri=https://$WebAppNamePrefix-portal.azurewebsites.net/Home/Index/ SaaSApiConfiguration__SupportmeteredBilling=$MeteredSchedulerSupport SaaSApiConfiguration_CodeHash=$SaaSApiConfiguration_CodeHash
az webapp config appsettings set -g $ResourceGroupForDeployment -n $WebAppNameAdmin --output $azCliOutput --settings KnownUsers=$PublisherAdminUsers SaaSApiConfiguration__AdAuthenticationEndPoint=https://login.microsoftonline.com SaaSApiConfiguration__ClientId=$ADApplicationID SaaSApiConfiguration__ClientSecret=$ADApplicationSecretKeyVault SaaSApiConfiguration__FulFillmentAPIBaseURL=https://marketplaceapi.microsoft.com/api SaaSApiConfiguration__FulFillmentAPIVersion=2018-08-31 SaaSApiConfiguration__GrantType=client_credentials SaaSApiConfiguration__MTClientId=$ADMTApplicationID SaaSApiConfiguration__Resource=20e940b3-4c77-4b0b-9a53-9e16a1b010a7 SaaSApiConfiguration__TenantId=$TenantID SaaSApiConfiguration__SignedOutRedirectUri=https://$WebAppNamePrefix-portal.azurewebsites.net/Home/Index/ SaaSApiConfiguration_CodeHash=$SaaSApiConfiguration_CodeHash
az webapp config set -g $ResourceGroupForDeployment -n $WebAppNameAdmin --always-on true --output $azCliOutput

Write-host " 🔵 Customer Portal WebApp"
Expand Down
1 change: 0 additions & 1 deletion docs/Advanced-Instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
| SQLAdminLoginPassword | SQL Admin password. Default: secure random password. |
| LogoURLpng | The url of the company logo image in .png format with a size of 96x96 to be used on the website |
| LogoURLico | The url of the company logo image in .ico format |
| MeteredSchedulerSupport | Enable the metered scheduler. This is deployed by default. Use **true** to enable the feature. More information [here](https://github.com/Azure/Commercial-Marketplace-SaaS-Accelerator/blob/main/docs/Metered-Scheduler-Manager-Instruction.md).
| Quiet | Disable verbose output when running the script


Expand Down
2 changes: 0 additions & 2 deletions docs/Installation-Instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ The script above will perform the following actions.
-ADMTApplicationID "xxxx-xxx-xxx-xxx-xxxx" `
-LogoURLpng "https://company_com/company_logo.png" `
-LogoURLico "https://company_com/company_logo.ico" `
-MeteredSchedulerSupport
-Quiet
```

Expand Down Expand Up @@ -103,7 +102,6 @@ cd ./Commercial-Marketplace-SaaS-Accelerator/deployment; `
| SQLAdminLoginPassword | SQL Admin password. Default: secure random password. |
| LogoURLpng | The url of the company logo image in .png format with a size of 96x96 to be used on the website |
| LogoURLico | The url of the company logo image in .ico format |
| MeteredSchedulerSupport | Enable the metered scheduler. This is deployed by default. Use **true** to enable the feature. More information [here](https://github.com/Azure/Commercial-Marketplace-SaaS-Accelerator/blob/main/docs/Metered-Scheduler-Manager-Instruction.md).
| Quiet | Disable verbose output when running the script

## Setting up a development environment
Expand Down
7 changes: 2 additions & 5 deletions docs/Metered-Scheduler-Manager-Instruction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ Metered Scheduler Manager is a feature where Publisher can schedule **FIX Quanti
1. Monthly
1. Yearly
1. OneTime
## Enable and Disable Metered Scheduler Manager Feature During Installation
By default, this feature is disabled during the installation. Publisher can enable this feature during the installion process by passing an optional parameter **MeteredSchedulerSupport**. Please refer to the installation steps [here](./Installation-Instructions.md)


## Enable and Disable Metered Scheduler Manager Feature Post Installation
Publisher can active the **Metered Scheduler** feature by updating Admin portal web configuration and set **SaaSApiConfiguration__SupportmeteredBilling** to **true**
Publisher can active the **Metered Scheduler** feature by updating Admin portal App Setting and set **IsMeteredBillingEnabled** to **true**
![home](./images/scheduler-config.png)

Publisher can disable the feature by feature by updating Admin portal web configuration and set **SaaSApiConfiguration__SupportmeteredBilling** to **false**
Publisher can disable the feature by feature by updating Admin portal web configuration and set **IsMeteredBillingEnabled** to **false**

## IMPORTANT: Enable Scheduler Frequencies
Publisher must enable scheduler Frequencies before start scheduling tasks. From **App Config**, publisher can enable or disable available frequencies per business needs. Without enable the frequencies, Publisher will not able to add tasks also the scheduler engine will skip any disabled frequencies.
Expand Down
Binary file modified docs/images/scheduler-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions src/AdminSite/Controllers/ApplicationConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using System.Web;
using Marketplace.SaaS.Accelerator.DataAccess.Contracts;
using Marketplace.SaaS.Accelerator.DataAccess.Entities;
using Marketplace.SaaS.Accelerator.DataAccess.Services;
using Marketplace.SaaS.Accelerator.Services.Configurations;
using Marketplace.SaaS.Accelerator.Services.Services;
using Marketplace.SaaS.Accelerator.Services.Utilities;
using Microsoft.AspNetCore.Http;
Expand All @@ -30,9 +32,10 @@ public class ApplicationConfigController : BaseController
/// </summary>
private readonly IEmailTemplateRepository emailTemplateRepository;

public ApplicationConfigController(
ApplicationConfigService appConfigService,
IEmailTemplateRepository emailTemplateRepository, SaaSClientLogger<ApplicationConfigController> logger)
public ApplicationConfigController(ApplicationConfigService appConfigService,
IEmailTemplateRepository emailTemplateRepository,
SaaSClientLogger<ApplicationConfigController> logger,
IApplicationConfigRepository appConfigRepository) : base(appConfigRepository)
{
this.appConfigService = appConfigService;
this.emailTemplateRepository = emailTemplateRepository;
Expand All @@ -46,7 +49,7 @@ public ApplicationConfigController(
[ServiceFilter(typeof(ExceptionHandlerAttribute))]
public IActionResult Index()
{
var getAllAppConfigData = this.appConfigService.GetAllApplicationConfiguration();
var getAllAppConfigData = this.appConfigService.GetAllApplicationConfiguration();
return this.View(getAllAppConfigData);
}

Expand Down
6 changes: 5 additions & 1 deletion src/AdminSite/Controllers/ApplicationLogController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Text.RegularExpressions;
using Marketplace.SaaS.Accelerator.DataAccess.Contracts;
using Marketplace.SaaS.Accelerator.DataAccess.Entities;
using Marketplace.SaaS.Accelerator.DataAccess.Services;
using Marketplace.SaaS.Accelerator.Services.Configurations;
using Marketplace.SaaS.Accelerator.Services.Services;
using Marketplace.SaaS.Accelerator.Services.Utilities;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -20,7 +22,9 @@ public class ApplicationLogController : BaseController

private readonly IApplicationLogRepository appLogRepository;

public ApplicationLogController(IApplicationLogRepository applicationLogRepository, SaaSClientLogger<ApplicationLogController> logger)
public ApplicationLogController(IApplicationLogRepository applicationLogRepository,
SaaSClientLogger<ApplicationLogController> logger,
IApplicationConfigRepository applicationConfigRepository) : base(applicationConfigRepository)
{
this.appLogRepository = applicationLogRepository;
this.logger = logger;
Expand Down
28 changes: 27 additions & 1 deletion src/AdminSite/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using System.Linq;
using System.Web;
using Marketplace.SaaS.Accelerator.DataAccess.Contracts;
using Marketplace.SaaS.Accelerator.Services.Models;
using Marketplace.SaaS.Accelerator.Services.Services;
using Marketplace.SaaS.Accelerator.Services.Utilities;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace Marketplace.SaaS.Accelerator.AdminSite.Controllers;

Expand All @@ -18,11 +21,32 @@ public class BaseController : Controller
/// Initializes a new instance of the <see cref="BaseController" /> class.
/// </summary>
///
public BaseController()
private readonly IApplicationConfigRepository applicationConfigRepository;
private readonly ApplicationConfigService applicationConfigService;
public BaseController(IApplicationConfigRepository applicationConfigRepository)
{
this.applicationConfigRepository = applicationConfigRepository;
this.applicationConfigService = new ApplicationConfigService(this.applicationConfigRepository);
this.CheckAuthentication();
}

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (TempData is not null)
{
bool.TryParse(this.applicationConfigService.GetValueByName("IsMeteredBillingEnabled"), out bool supportMeteredBilling);
if (supportMeteredBilling)
{
TempData["SupportMeteredBilling"] = "1";
}
else
{
TempData["SupportMeteredBilling"] = "0";
}
}

base.OnActionExecuting(filterContext);
}
/// <summary>
/// Gets Current Logged in User Email Address.
/// </summary>
Expand Down Expand Up @@ -64,6 +88,8 @@ public PartnerDetailViewModel GetCurrentUserDetail()
return new PartnerDetailViewModel();
}



/// <summary>
/// Checks the authentication.
/// </summary>
Expand Down
27 changes: 20 additions & 7 deletions src/AdminSite/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,26 @@ public class HomeController : BaseController
/// <param name="offersRepository">The offers repository.</param>
/// <param name="offersAttributeRepository">The offers attribute repository.</param>
public HomeController(
IUsersRepository usersRepository, IMeteredBillingApiService billingApiService, ISubscriptionsRepository subscriptionRepo, IPlansRepository planRepository, ISubscriptionUsageLogsRepository subscriptionUsageLogsRepository, IMeteredDimensionsRepository dimensionsRepository, ISubscriptionLogRepository subscriptionLogsRepo, IApplicationConfigRepository applicationConfigRepository, IUsersRepository userRepository, IFulfillmentApiService fulfillApiService, IApplicationLogRepository applicationLogRepository, IEmailTemplateRepository emailTemplateRepository, IPlanEventsMappingRepository planEventsMappingRepository, IEventsRepository eventsRepository, SaaSApiClientConfiguration saaSApiClientConfiguration, ILoggerFactory loggerFactory, IEmailService emailService, IOffersRepository offersRepository, IOfferAttributesRepository offersAttributeRepository, SaaSClientLogger<HomeController> logger)
IUsersRepository usersRepository,
IMeteredBillingApiService billingApiService,
ISubscriptionsRepository subscriptionRepo,
IPlansRepository planRepository,
ISubscriptionUsageLogsRepository subscriptionUsageLogsRepository,
IMeteredDimensionsRepository dimensionsRepository,
ISubscriptionLogRepository subscriptionLogsRepo,
IApplicationConfigRepository applicationConfigRepository,
IUsersRepository userRepository,
IFulfillmentApiService fulfillApiService,
IApplicationLogRepository applicationLogRepository,
IEmailTemplateRepository emailTemplateRepository,
IPlanEventsMappingRepository planEventsMappingRepository,
IEventsRepository eventsRepository,
SaaSApiClientConfiguration saaSApiClientConfiguration,
ILoggerFactory loggerFactory,
IEmailService emailService,
IOffersRepository offersRepository,
IOfferAttributesRepository offersAttributeRepository,
SaaSClientLogger<HomeController> logger):base(applicationConfigRepository)
{
this.billingApiService = billingApiService;
this.subscriptionRepo = subscriptionRepo;
Expand Down Expand Up @@ -212,12 +231,6 @@ public IActionResult Index()
this.applicationConfigService.SaveFileToDisk("FaviconFile", "favicon.ico");

var userId = this.userService.AddUser(this.GetCurrentUserDetail());

if (this.saaSApiClientConfiguration.SupportMeteredBilling)
{
this.TempData.Add("SupportMeteredBilling", "1");
this.HttpContext.Session.SetString("SupportMeteredBilling", "1");
}
return this.View();
}
catch (Exception ex)
Expand Down
7 changes: 6 additions & 1 deletion src/AdminSite/Controllers/KnownUsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using System.Web;
using Marketplace.SaaS.Accelerator.DataAccess.Contracts;
using Marketplace.SaaS.Accelerator.DataAccess.Entities;
using Marketplace.SaaS.Accelerator.DataAccess.Services;
using Marketplace.SaaS.Accelerator.Services.Configurations;
using Marketplace.SaaS.Accelerator.Services.Services;
using Marketplace.SaaS.Accelerator.Services.Utilities;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand All @@ -24,7 +27,9 @@ public class KnownUsersController : BaseController
/// <param name = "knownUsersRepository" > The known users repository.</param>
/// <param name="logger">The logger.</param>

public KnownUsersController(IKnownUsersRepository knownUsersRepository, SaaSClientLogger<KnownUsersController> logger)
public KnownUsersController(IKnownUsersRepository knownUsersRepository,
SaaSClientLogger<KnownUsersController> logger,
IApplicationConfigRepository applicationConfigRepository) : base(applicationConfigRepository)
{
this.knownUsersRepository = knownUsersRepository;
this.logger = logger;
Expand Down
3 changes: 2 additions & 1 deletion src/AdminSite/Controllers/OffersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public OffersController(
IApplicationConfigRepository applicationConfigRepository,
IUsersRepository usersRepository,
IValueTypesRepository valueTypesRepository,
IOfferAttributesRepository offersAttributeRepository, SaaSClientLogger<OffersController> logger)
IOfferAttributesRepository offersAttributeRepository,
SaaSClientLogger<OffersController> logger) : base(applicationConfigRepository)
{
this.applicationConfigRepository = applicationConfigRepository;
this.usersRepository = usersRepository;
Expand Down
8 changes: 7 additions & 1 deletion src/AdminSite/Controllers/PlansController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ public class PlansController : BaseController
/// <param name="offerAttributeRepository">The offer attribute repository.</param>
/// <param name="offerRepository">The offer repository.</param>
/// <param name="logger">The logger.</param>
public PlansController(ISubscriptionsRepository subscriptionRepository, IUsersRepository usersRepository, IApplicationConfigRepository applicationConfigRepository, IPlansRepository plansRepository, IOfferAttributesRepository offerAttributeRepository, IOffersRepository offerRepository, SaaSClientLogger<PlansController> logger)
public PlansController(ISubscriptionsRepository subscriptionRepository,
IUsersRepository usersRepository,
IApplicationConfigRepository applicationConfigRepository,
IPlansRepository plansRepository,
IOfferAttributesRepository offerAttributeRepository,
IOffersRepository offerRepository,
SaaSClientLogger<PlansController> logger) : base(applicationConfigRepository)
{
this.subscriptionRepository = subscriptionRepository;
this.usersRepository = usersRepository;
Expand Down
Loading
Loading