Development/F-57061/US-63667/T-62825
dotnet user-secrets set eip:clientId 248052cd-239b-4703-aa8f-a7aefcab2f2f dotnet user-secrets set eip:clientSecret baJ8Q~WIGVEdgQbIoZnCHExCl6wdqrl.ngfRrbst dotnet user-secrets set eip:scope api://248052cd-239b-4703-aa8f-a7aefcab2f2f/.default dotnet user-secrets set eip:authUrl https://login.microsoftonline.com/1cabd5e8-e68a-4ad8-9a69-7f5f24e92af2/oauth2/v2.0/token dotnet user-secrets set eip:url https://appgw-ag-uks-eip-tst.uksouth.cloudapp.azure.com
policy/outwardPolicies?policyId=AA03AA524L31 var clientId = Configuration["Authentication:ClientId"]; var clientSecret = Configuration["Authentication:ClientSecret"]; var scope = Configuration["Authentication:Scope"];
@echo off setlocal
:: Define your SQL Server connection details set ServerName=YourServerName set DatabaseName=YourDatabaseName set BacpacFilePath=Path\to\YourDatabase.bacpac
:: Define SQL Server authentication credentials set Username=YourUsername set Password=YourPassword
:: Define paths for SQL Server utilities (sqlcmd and SqlPackage) set SqlCmdPath="C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\sqlcmd.exe" set SqlPackagePath="C:\Program Files\Microsoft SQL Server\DAC\bin\SqlPackage.exe"
:: Delete the existing database %SqlCmdPath% -S %ServerName% -U %Username% -P %Password% -Q "USE master; DROP DATABASE IF EXISTS %DatabaseName%;"
:: Import the .bacpac file to create the new database %SqlPackagePath% /a:Import /sf:%BacpacFilePath% /tsn:%ServerName% /tdn:%DatabaseName% /tu:%Username% /tp:%Password%
endlocal
private void ValidatePolicyEntries() { var entries = ChangeTracker.Entries(); var policyGroups = entries .Where(e => e.State == EntityState.Added || e.State == EntityState.Modified) .GroupBy(e => e.Entity.PolicyReference);
foreach (var group in policyGroups)
{
var existingEntries = PolicyEntries
.Where(pe => pe.PolicyReference == group.Key && !group.Select(g => g.Entity.Id).Contains(pe.Id))
.ToList(); // Retrieve all relevant entries and sum them in memory
var totalSplitPct = existingEntries.Select(pe => pe.SplitPct).Sum() + group.Select(g => g.Entity.SplitPct).Sum();
if (totalSplitPct > 100M) // Assuming 100% is the maximum allowable threshold
{
throw new InvalidOperationException($"Total split percentage for policy reference {group.Key} exceeds allowable threshold.");
}
}
}
public override int SaveChanges() { ValidatePolicyEntries(); return base.SaveChanges(); }
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
{
ValidatePolicyEntries();
return base.SaveChangesAsync(cancellationToken);
}
private void ValidatePolicyEntries()
{
var entries = ChangeTracker.Entries<PolicyEntry>();
var policyGroups = entries
.Where(e => e.State == EntityState.Added || e.State == EntityState.Modified)
.GroupBy(e => e.Entity.PolicyReference);
foreach (var group in policyGroups)
{
var totalSplitPct = PolicyEntries
.Where(pe => pe.PolicyReference == group.Key && !group.Select(g => g.Entity.Id).Contains(pe.Id))
.Select(pe => pe.SplitPct)
.Sum();
totalSplitPct += group.Select(g => g.Entity.SplitPct).Sum();
if (totalSplitPct > 100) // Assuming 100% is the maximum allowable threshold
{
throw new InvalidOperationException($"Total split percentage for policy reference {group.Key} exceeds allowable threshold.");
}
}
}
}