aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Publisher/App.xaml
blob: 582bd00348b3a0be9d73697ae68d820b200caa14 (plain)
1
2
3
4
5
6
7
8
9
<Application x:Class="Tango.MachineStudio.Publisher.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:Tango.MachineStudio.Publisher"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
         
    </Application.Resources>
</Application>
n>Microsoft.IdentityModel.Clients.ActiveDirectory; using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Tango.Web.SQLServer { public class SQLServerManager { private String _service_root = $"https://login.microsoftonline.com/{WebConfig.TENANT_ID}"; public AuthenticationResult GetAccessToken() { var authContext = new AuthenticationContext(_service_root); authContext.TokenCache.Clear(); ClientCredential clientCredentials = new ClientCredential(WebConfig.CLIENT_ID, WebConfig.APP_SECRET); AuthenticationResult authResult = authContext.AcquireTokenAsync("https://database.windows.net/", clientCredentials).Result; return authResult; } public SqlConnection CreateSqlConnection(String accessToken, String catalog) { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); builder.DataSource = "twine.database.windows.net"; builder.InitialCatalog = catalog; builder.MultipleActiveResultSets = true; builder.ApplicationName = "EntityFramework"; SqlConnection sqlConnection = new SqlConnection(builder.ConnectionString); sqlConnection.AccessToken = accessToken; return sqlConnection; } } }