This commit is contained in:
christianwade 2016-12-01 20:31:09 -08:00
commit 1ffaee6daa
57 changed files with 12266 additions and 2 deletions

7
.gitignore vendored
View File

@ -140,7 +140,7 @@ publish/
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Un-comment the next line if you do not want to checkin
# TODO: Un-comment the next line if you do not want to checkin
# your web deploy settings because they may include unencrypted
# passwords
#*.pubxml
@ -166,6 +166,9 @@ csx/
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
@ -239,4 +242,4 @@ ModelManifest.xml
.paket/paket.exe
# FAKE - F# Make
.fake/
.fake/

Binary file not shown.

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Development</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7274efcc-e7df-40ad-83df-1dfd5b954e67}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MyRootNamespace</RootNamespace>
<AssemblyName>MyAssemblyName</AssemblyName>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<OutputPath>bin\</OutputPath>
<Name>AsPartitionProcessing.AdventureWorks</Name>
<DeploymentServerName>localhost</DeploymentServerName>
<DeploymentServerEdition>Developer</DeploymentServerEdition>
<DeploymentServerVersion>Version_11_0</DeploymentServerVersion>
<DeploymentServerDatabase>AW Tabular Model SQL 2014</DeploymentServerDatabase>
<DeploymentServerCubeName>Model</DeploymentServerCubeName>
<DeploymentOptionProcessing>Default</DeploymentOptionProcessing>
<DeploymentOptionTransactionalDeployment>False</DeploymentOptionTransactionalDeployment>
<DeploymentOptionDirectQueryMode>InMemory</DeploymentOptionDirectQueryMode>
<DeploymentOptionQueryImpersonation>Default</DeploymentOptionQueryImpersonation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Development' ">
<OutputPath>bin\</OutputPath>
<DeploymentServerName>localhost</DeploymentServerName>
<DeploymentServerEdition>Developer</DeploymentServerEdition>
<DeploymentServerVersion>Version_11_0</DeploymentServerVersion>
<DeploymentServerDatabase>AdventureWorks</DeploymentServerDatabase>
<DeploymentServerCubeName>Model</DeploymentServerCubeName>
<DeploymentOptionProcessing>Default</DeploymentOptionProcessing>
<DeploymentOptionTransactionalDeployment>False</DeploymentOptionTransactionalDeployment>
<DeploymentOptionDirectQueryMode>InMemory</DeploymentOptionDirectQueryMode>
<DeploymentOptionQueryImpersonation>Default</DeploymentOptionQueryImpersonation>
</PropertyGroup>
<ItemGroup />
<ItemGroup>
<Compile Include="Model.bim">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Business Intelligence Semantic Model\1.0\Microsoft.AnalysisServices.VSHostBuilder.targets" />
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="AsPartitionProcessing.SampleClient.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
<userSettings>
<AsPartitionProcessing.SampleClient.Settings>
<setting name="ConfigServer" serializeAs="String">
<value>localhost</value>
</setting>
<setting name="ConfigDatabase" serializeAs="String">
<value>AsPartitionProcessing</value>
</setting>
<setting name="ConfigDatabaseIntegratedAuth" serializeAs="String">
<value>True</value>
</setting>
</AsPartitionProcessing.SampleClient.Settings>
</userSettings>
</configuration>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C45B329D-F606-4F89-A41A-785C247F24B2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AsPartitionProcessing.SampleClient</RootNamespace>
<AssemblyName>AsPartitionProcessing.SampleClient</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AnalysisServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.DLL</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices.Core, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Core.DLL</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices.Tabular, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Tabular.DLL</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AsPartitionProcessing\AsPartitionProcessing.csproj">
<Project>{fb937281-b06d-47fb-9846-e97b0287afce}</Project>
<Name>AsPartitionProcessing</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,248 @@
using System;
using System.Collections.Generic;
using Microsoft.AnalysisServices.Tabular;
namespace AsPartitionProcessing.SampleClient
{
class Program
{
const bool UseDatabase = true;
static void Main(string[] args)
{
try
{
List<ModelConfiguration> modelsConfig;
if (!UseDatabase)
{
modelsConfig = InitializeAdventureWorksInline();
}
else
{
modelsConfig = InitializeFromDatabase();
}
foreach (ModelConfiguration modelConfig in modelsConfig)
{
if (!modelConfig.IntegratedAuth) //For Azure AS
{
Console.WriteLine();
Console.Write("User name for AS server: ");
modelConfig.UserName = Console.ReadLine();
Console.Write("Password for AS server: ");
modelConfig.Password = ReadPassword();
}
//Most important method:
PartitionProcessor.PerformProcessing(modelConfig, LogMessage);
}
}
catch (Exception exc)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine();
Console.WriteLine(exc.Message, null);
}
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
private static List<ModelConfiguration> InitializeAdventureWorksInline()
{
ModelConfiguration partitionedModel = new ModelConfiguration(
modelConfigurationID: 1,
analysisServicesServer: "localhost",
analysisServicesDatabase: "AdventureWorks",
initialSetUp: true,
incrementalOnline: true,
incrementalParallelTables: true,
integratedAuth: true,
userName: "",
password: "",
tableConfigurations:
new List<TableConfiguration>
{
new TableConfiguration(
tableConfigurationID: 1,
analysisServicesTable: "Internet Sales",
partitioningConfigurations:
new List<PartitioningConfiguration>
{
new PartitioningConfiguration(
partitioningConfigurationID: 1,
granularity: Granularity.Monthly,
numberOfPartitionsFull: 12,
numberOfPartitionsForIncrementalProcess: 3,
maxDate: Convert.ToDateTime("2012-12-01"),
sourceTableName: "[dbo].[FactInternetSales]",
sourcePartitionColumn: "OrderDateKey"
)
}
),
new TableConfiguration(
tableConfigurationID: 2,
analysisServicesTable: "Reseller Sales",
partitioningConfigurations:
new List<PartitioningConfiguration>
{
new PartitioningConfiguration(
partitioningConfigurationID: 2,
granularity: Granularity.Yearly,
numberOfPartitionsFull: 3,
numberOfPartitionsForIncrementalProcess: 1,
maxDate: Convert.ToDateTime("2012-12-01"),
sourceTableName: "[dbo].[FactResellerSales]",
sourcePartitionColumn: "OrderDateKey"
)
}
)
}
);
#region Not needed as sample includes pre-prepared version of AdventureWorks
////This section not to be used normally - just to get started with AdventureWorks. It removes existing partitions that come in AdventureWorks and creates a template one to align with assumptions listed at top of PartitionProcessor.cs file.
//if (partitionedModel.InitialSetUp)
//{
// Console.WriteLine("Initialize AdventureWorks template partitions? [y/n]");
// if (Console.ReadLine().ToLower() == "y")
// InitializeAdventureWorksDatabase(partitionedModel);
//}
#endregion
return new List<ModelConfiguration> { partitionedModel };
}
private static List<ModelConfiguration> InitializeFromDatabase()
{
ConfigDatabaseConnectionInfo connectionInfo = new ConfigDatabaseConnectionInfo();
connectionInfo.Server = Settings.Default.ConfigServer;
connectionInfo.Database = Settings.Default.ConfigDatabase;
connectionInfo.IntegratedAuth = Settings.Default.ConfigDatabaseIntegratedAuth;
if (!Settings.Default.ConfigDatabaseIntegratedAuth)
{
Console.Write("User name for config database: ");
connectionInfo.UserName = Console.ReadLine();
Console.Write("Password for config database: ");
connectionInfo.Password = ReadPassword();
}
return ConfigDatabaseHelper.ReadConfig(connectionInfo);
}
private static void LogMessage(string message, ModelConfiguration partitionedModel)
{
//Can provide custom logger here
try
{
if (UseDatabase)
ConfigDatabaseHelper.LogMessage(message, partitionedModel);
Console.WriteLine(message);
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
Environment.Exit(0); //Avoid recursion if errored connecting to db
}
}
public static string ReadPassword()
{
string password = "";
ConsoleKeyInfo info = Console.ReadKey(true);
while (info.Key != ConsoleKey.Enter)
{
if (info.Key != ConsoleKey.Backspace)
{
Console.Write("*");
password += info.KeyChar;
}
else if (info.Key == ConsoleKey.Backspace)
{
if (!string.IsNullOrEmpty(password))
{
// remove one character from the list of password characters
password = password.Substring(0, password.Length - 1);
// get the location of the cursor
int pos = Console.CursorLeft;
// move the cursor to the left by one character
Console.SetCursorPosition(pos - 1, Console.CursorTop);
// replace it with space
Console.Write(" ");
// move the cursor to the left by one character again
Console.SetCursorPosition(pos - 1, Console.CursorTop);
}
}
info = Console.ReadKey(true);
}
// add a new line because user pressed enter at the end of password
Console.WriteLine();
return password;
}
#region Not needed as sample includes pre-prepared version of AdventureWorks
private static void InitializeAdventureWorksDatabase(ModelConfiguration parameters)
{
//In order to align with assumptions listed in PartitionProcessor.cs, need to:
//1. Delete existing partitions in InternetSales and ResellerSales
//2. Create template partition (again, see comments at top of PartitionProcessor.cs)
Console.WriteLine("Initializing AdventureWorks ...");
using (Server server = new Server())
{
//Connect and get main objects
string serverConnectionString;
if (parameters.IntegratedAuth)
serverConnectionString = $"Provider=MSOLAP;Data Source={parameters.AnalysisServicesServer};";
else
{
serverConnectionString = $"Provider=MSOLAP;Data Source={parameters.AnalysisServicesServer};User ID={parameters.UserName};Password={parameters.Password};Persist Security Info=True;Impersonation Level=Impersonate;";
}
server.Connect(serverConnectionString);
Database database = server.Databases.FindByName(parameters.AnalysisServicesDatabase);
if (database == null)
{
throw new Microsoft.AnalysisServices.ConnectionException($"Could not connect to database {parameters.AnalysisServicesDatabase}.");
}
InitializeAdventureWorksTable(database, "Internet Sales", "[dbo].[FactInternetSales]");
InitializeAdventureWorksTable(database, "Reseller Sales", "[dbo].[FactResellerSales]");
database.Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull);
server.Disconnect();
}
}
private static void InitializeAdventureWorksTable(Database database, string analysisServicesTableName, string sourceFactTableName)
{
Table table = database.Model.Tables.Find(analysisServicesTableName);
if (table == null)
{
throw new Microsoft.AnalysisServices.ConnectionException($"Could not connect to table {analysisServicesTableName}.");
}
table.Partitions.Clear();
Partition templatePartition = new Partition();
templatePartition.Name = analysisServicesTableName;
table.Partitions.Add(templatePartition);
templatePartition.Source = new QueryPartitionSource()
{
DataSource = database.Model.DataSources[0], //Assuming this is only data source (SqlServer localhost)
Query = $"SELECT * FROM {sourceFactTableName}"
};
}
#endregion
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AsPartitionProcessing.SampleClient")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("AsPartitionProcessing.SampleClient")]
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c45b329d-f606-4f89-a41a-785c247f24b2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AsPartitionProcessing.SampleClient {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("localhost")]
public string ConfigServer {
get {
return ((string)(this["ConfigServer"]));
}
set {
this["ConfigServer"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("AsPartitionProcessing")]
public string ConfigDatabase {
get {
return ((string)(this["ConfigDatabase"]));
}
set {
this["ConfigDatabase"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool ConfigDatabaseIntegratedAuth {
get {
return ((bool)(this["ConfigDatabaseIntegratedAuth"]));
}
set {
this["ConfigDatabaseIntegratedAuth"] = value;
}
}
}
}

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="AsPartitionProcessing.SampleClient" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ConfigServer" Type="System.String" Scope="User">
<Value Profile="(Default)">localhost</Value>
</Setting>
<Setting Name="ConfigDatabase" Type="System.String" Scope="User">
<Value Profile="(Default)">AsPartitionProcessing</Value>
</Setting>
<Setting Name="ConfigDatabaseIntegratedAuth" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,73 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsPartitionProcessing", "AsPartitionProcessing\AsPartitionProcessing.csproj", "{FB937281-B06D-47FB-9846-E97B0287AFCE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AsPartitionProcessing.SampleClient", "AsPartitionProcessing.SampleClient\AsPartitionProcessing.SampleClient.csproj", "{C45B329D-F606-4F89-A41A-785C247F24B2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0B23151E-8A6B-44AA-B670-797D1EB8B3C0}"
ProjectSection(SolutionItems) = preProject
AdventureWorksDW.bak = AdventureWorksDW.bak
CreateDatabaseObjects.sql = CreateDatabaseObjects.sql
SampleConfiguration.sql = SampleConfiguration.sql
EndProjectSection
EndProject
Project("{6870E480-7721-4708-BFB8-9AE898AA21B3}") = "AsPartitionProcessing.AdventureWorks", "AsPartitionProcessing.AdventureWorks\AsPartitionProcessing.AdventureWorks.smproj", "{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Development|Any CPU = Development|Any CPU
Development|x86 = Development|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Debug|x86.ActiveCfg = Debug|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Debug|x86.Build.0 = Debug|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Development|Any CPU.ActiveCfg = Debug|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Development|Any CPU.Build.0 = Debug|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Development|x86.ActiveCfg = Debug|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Development|x86.Build.0 = Debug|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Release|Any CPU.Build.0 = Release|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Release|x86.ActiveCfg = Release|Any CPU
{FB937281-B06D-47FB-9846-E97B0287AFCE}.Release|x86.Build.0 = Release|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Debug|x86.ActiveCfg = Debug|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Debug|x86.Build.0 = Debug|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Development|Any CPU.ActiveCfg = Debug|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Development|Any CPU.Build.0 = Debug|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Development|x86.ActiveCfg = Debug|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Development|x86.Build.0 = Debug|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Release|Any CPU.Build.0 = Release|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Release|x86.ActiveCfg = Release|Any CPU
{C45B329D-F606-4F89-A41A-785C247F24B2}.Release|x86.Build.0 = Release|Any CPU
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Debug|Any CPU.ActiveCfg = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Debug|Any CPU.Build.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Debug|Any CPU.Deploy.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Debug|x86.ActiveCfg = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Debug|x86.Build.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Debug|x86.Deploy.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Development|Any CPU.ActiveCfg = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Development|x86.ActiveCfg = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Development|x86.Build.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Development|x86.Deploy.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Release|Any CPU.ActiveCfg = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Release|Any CPU.Build.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Release|Any CPU.Deploy.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Release|x86.ActiveCfg = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Release|x86.Build.0 = Development|x86
{7274EFCC-E7DF-40AD-83DF-1DFD5B954E67}.Release|x86.Deploy.0 = Development|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FB937281-B06D-47FB-9846-E97B0287AFCE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AsPartitionProcessing</RootNamespace>
<AssemblyName>AsPartitionProcessing</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\AsPartitionProcessing.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AnalysisServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.DLL</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices.Core, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Core.DLL</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices.Tabular, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Tabular.DLL</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigDatabaseConnectionInfo.cs" />
<Compile Include="ModelConfiguration.cs" />
<Compile Include="ConfigDatabaseHelper.cs" />
<Compile Include="TableConfiguration.cs" />
<Compile Include="PartitioningConfiguration.cs" />
<Compile Include="PartitionProcessor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,35 @@
using System;
namespace AsPartitionProcessing
{
/// <summary>
/// Information required to connect to the configuration and logging database.
/// </summary>
public class ConfigDatabaseConnectionInfo
{
/// <summary>
/// Database server name.
/// </summary>
public string Server { get; set; }
/// <summary>
/// Name of the database.
/// </summary>
public string Database { get; set; }
/// <summary>
/// User name used for connection.
/// </summary>
public string UserName { get; set; }
/// <summary>
/// Password used for connection.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Whether connection to be made using integrated authentication or SQL authentication.
/// </summary>
public bool IntegratedAuth { get; set; }
}
}

View File

@ -0,0 +1,195 @@
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace AsPartitionProcessing
{
/// <summary>
/// Class containing helper methods for reading and writing to the configuration and logging database.
/// </summary>
public static class ConfigDatabaseHelper
{
/// <summary>
/// Read configuration information from the database.
/// </summary>
/// <param name="connectionInfo">Information required to connect to the configuration and logging database.</param>
/// <returns>Collection of partitioned models with configuration information.</returns>
public static List<ModelConfiguration> ReadConfig(ConfigDatabaseConnectionInfo connectionInfo)
{
using (SqlConnection connection = new SqlConnection(GetConnectionString(connectionInfo)))
{
connection.Open();
using (SqlCommand command = new SqlCommand())
{
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = @"
SELECT [ModelConfigurationID]
,[AnalysisServicesServer]
,[AnalysisServicesDatabase]
,[InitialSetUp]
,[IncrementalOnline]
,[IncrementalParallelTables]
,[IntegratedAuth]
,[TableConfigurationID]
,[AnalysisServicesTable]
,[Partitioned]
,[PartitioningConfigurationID]
,[Granularity]
,[NumberOfPartitionsFull]
,[NumberOfPartitionsForIncrementalProcess]
,[MaxDate]
,[SourceTableName]
,[SourcePartitionColumn]
FROM [dbo].[vPartitioningConfiguration]
ORDER BY
[ModelConfigurationID],
[TableConfigurationID],
[PartitioningConfigurationID];";
List<ModelConfiguration> modelConfigs = new List<ModelConfiguration>();
ModelConfiguration modelConfig = null;
int currentModelConfigurationID = -1;
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
TableConfiguration tableConfig = null;
int currentTableConfigurationID = -1;
if (modelConfig == null || currentModelConfigurationID != Convert.ToInt32(reader["ModelConfigurationID"]))
{
modelConfig = new ModelConfiguration();
modelConfig.TableConfigurations = new List<TableConfiguration>();
modelConfigs.Add(modelConfig);
modelConfig.ModelConfigurationID = Convert.ToInt32(reader["ModelConfigurationID"]);
modelConfig.AnalysisServicesServer = Convert.ToString(reader["AnalysisServicesServer"]);
modelConfig.AnalysisServicesDatabase = Convert.ToString(reader["AnalysisServicesDatabase"]);
modelConfig.InitialSetUp = Convert.ToBoolean(reader["InitialSetUp"]);
modelConfig.IncrementalOnline = Convert.ToBoolean(reader["IncrementalOnline"]);
modelConfig.IncrementalParallelTables = Convert.ToBoolean(reader["IncrementalParallelTables"]);
modelConfig.IntegratedAuth = Convert.ToBoolean(reader["IntegratedAuth"]);
modelConfig.ConfigDatabaseConnectionInfo = connectionInfo;
currentModelConfigurationID = modelConfig.ModelConfigurationID;
}
if (tableConfig == null || currentTableConfigurationID != Convert.ToInt32(reader["TableConfigurationID"]))
{
tableConfig = new TableConfiguration();
tableConfig.PartitioningConfigurations = new List<PartitioningConfiguration>();
modelConfig.TableConfigurations.Add(tableConfig);
tableConfig.TableConfigurationID = Convert.ToInt32(reader["TableConfigurationID"]);
tableConfig.AnalysisServicesTable = Convert.ToString(reader["AnalysisServicesTable"]);
currentTableConfigurationID = tableConfig.TableConfigurationID;
}
if (Convert.ToBoolean(reader["Partitioned"]))
{
tableConfig.PartitioningConfigurations.Add(
new PartitioningConfiguration(
Convert.ToInt32(reader["PartitioningConfigurationID"]),
(Granularity)Convert.ToInt32(reader["Granularity"]),
Convert.ToInt32(reader["NumberOfPartitionsFull"]),
Convert.ToInt32(reader["NumberOfPartitionsForIncrementalProcess"]),
Convert.ToDateTime(reader["MaxDate"]),
Convert.ToString(reader["SourceTableName"]),
Convert.ToString(reader["SourcePartitionColumn"])
)
);
}
}
return modelConfigs;
}
}
}
/// <summary>
/// Delete all existing logs from the database. Useful in demo scenarios to initialize the database.
/// </summary>
/// <param name="connectionInfo">Information required to connect to the configuration and logging database.</param>
public static void ClearLogTable(ConfigDatabaseConnectionInfo connectionInfo)
{
using (var connection = new SqlConnection(GetConnectionString(connectionInfo)))
{
connection.Open();
using (var command = new SqlCommand())
{
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = "DELETE FROM [dbo].[PartitionedModelLog];";
command.ExecuteNonQuery();
}
}
}
/// <summary>
/// Log a message to the databsae.
/// </summary>
/// <param name="message">Message to be logged.</param>
/// <param name="partitionedModel">Partitioned model with configuration information.</param>
public static void LogMessage(string message, ModelConfiguration partitionedModel)
{
using (var connection = new SqlConnection(GetConnectionString(partitionedModel.ConfigDatabaseConnectionInfo)))
{
connection.Open();
using (var command = new SqlCommand())
{
command.Connection = connection;
command.CommandType = CommandType.Text;
command.CommandText = @"
INSERT INTO [dbo].[PartitionedModelLog]
([ModelConfigurationID]
,[ExecutionID]
,[LogDateTime]
,[Message])
VALUES
(@ModelConfigurationID
,@ExecutionID
,@LogDateTime
,@Message);";
SqlParameter parameter;
parameter = new SqlParameter("@ModelConfigurationID", SqlDbType.Int);
parameter.Value = partitionedModel.ModelConfigurationID;
command.Parameters.Add(parameter);
parameter = new SqlParameter("@ExecutionID", SqlDbType.Char, 36);
parameter.Value = partitionedModel.ExecutionID;
command.Parameters.Add(parameter);
parameter = new SqlParameter("@LogDateTime", SqlDbType.DateTime);
parameter.Value = DateTime.Now;
command.Parameters.Add(parameter);
parameter = new SqlParameter("@Message", SqlDbType.VarChar, 4000);
parameter.Value = message;
command.Parameters.Add(parameter);
command.ExecuteNonQuery();
}
}
}
private static string GetConnectionString(ConfigDatabaseConnectionInfo connectionInfo)
{
string connectionString;
if (connectionInfo.IntegratedAuth)
{
connectionString = $"Server={connectionInfo.Server};Database={connectionInfo.Database};Integrated Security=SSPI;";
}
else
{
connectionString = $"Server={connectionInfo.Server};Database={connectionInfo.Database};User ID={connectionInfo.UserName};Password={connectionInfo.Password};";
}
return connectionString;
}
}
}

View File

@ -0,0 +1,14 @@
using System;
namespace AsPartitionProcessing
{
public class LogMessageEventArgs : EventArgs
{
public string Message { get; set; }
public LogMessageEventArgs(string message)
{
Message = message;
}
}
}

View File

@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
namespace AsPartitionProcessing
{
/// <summary>
/// Configuration information for a partitioned AS tabular model.
/// </summary>
public class ModelConfiguration
{
/// <summary>
/// ID of the ModelConfiguration table.
/// </summary>
public int ModelConfigurationID { get; set; }
/// <summary>
/// Name of the Analysis Services instance. Can be SSAS or an Azure AS URL.
/// </summary>
public string AnalysisServicesServer { get; set; }
/// <summary>
/// Name of the Analysis Services database.
/// </summary>
public string AnalysisServicesDatabase { get; set; }
/// <summary>
/// True for initial set up to create partitions and process them sequentially. False for incremental processing.
/// </summary>
public bool InitialSetUp { get; set; }
/// <summary>
/// When initialSetUp=false, determines if processing is performed as an online operation, which may require more memory, but users can still query the model.
/// </summary>
public bool IncrementalOnline { get; set; }
/// <summary>
/// When initialSetUp=false, determines if separate tables are processed in parallel. Partitions within a table are always processed in parallel.
/// </summary>
public bool IncrementalParallelTables { get; set; }
/// <summary>
/// Should always set to true for SSAS implementations that will run under the current process account. For Azure AS, normally set to false.
/// </summary>
public bool IntegratedAuth { get; set; }
/// <summary>
/// Only applies when integratedAuth=false. Used for Azure AD UPNs to connect to Azure AS.
/// </summary>
public string UserName { get; set; }
/// <summary>
/// Only applies when integratedAuth=false. Used for Azure AD UPNs to connect to Azure AS.
/// </summary>
public string Password { get; set; }
/// <summary>
/// Collection of partitioned tables containing configuration information.
/// </summary>
public List<TableConfiguration> TableConfigurations { get; set; }
/// <summary>
/// Connection information to connect to the configuration and logging database.
/// </summary>
public ConfigDatabaseConnectionInfo ConfigDatabaseConnectionInfo { get; set; }
/// <summary>
/// GUID generated to the execution run.
/// </summary>
public string ExecutionID { get; set; }
/// <summary>
/// Parameters normally from configuration database to determine partitioning ranges and design.
/// </summary>
/// <param name="modelConfigurationID">ID of the ModelConfiguration table.</param>
/// <param name="analysisServicesServer">Name of the Analysis Services instance. Can be SSAS or an Azure AS URL.</param>
/// <param name="analysisServicesDatabase">Name of the Analysis Services database.</param>
/// <param name="initialSetUp">True for initial set up to create partitions and process them sequentially. False for incremental processing.</param>
/// <param name="incrementalOnline">When initialSetUp=false, determines if processing is performed as an online operation, which may require more memory, but users can still query the model.</param>
/// <param name="incrementalParallelTables">When initialSetUp=false, determines if separate tables are processed in parallel. Partitions within a table are always processed in parallel.</param>
/// <param name="integratedAuth">Should always set to true for SSAS implementations that will run under the current process account. For Azure AS, normally set to false.</param>
/// <param name="userName">Only applies when integratedAuth=false. Used for Azure AD UPNs to connect to Azure AS.</param>
/// <param name="password">Only applies when integratedAuth=false. Used for Azure AD UPNs to connect to Azure AS.</param>
/// <param name="tableConfigurations">Collection of partitioned tables containing configuration information.</param>
public ModelConfiguration(
int modelConfigurationID,
string analysisServicesServer,
string analysisServicesDatabase,
bool initialSetUp,
bool incrementalOnline,
bool incrementalParallelTables,
bool integratedAuth,
string userName,
string password,
List<TableConfiguration> tableConfigurations
)
{
ModelConfigurationID = modelConfigurationID;
AnalysisServicesServer = analysisServicesServer;
AnalysisServicesDatabase = analysisServicesDatabase;
InitialSetUp = initialSetUp;
IncrementalOnline = incrementalOnline;
IncrementalParallelTables = incrementalParallelTables;
IntegratedAuth = integratedAuth;
UserName = userName;
Password = password;
TableConfigurations = tableConfigurations;
ExecutionID = Guid.NewGuid().ToString();
}
/// <summary>
/// Default constructor.
/// </summary>
public ModelConfiguration()
{
ExecutionID = Guid.NewGuid().ToString();
}
}
}

View File

@ -0,0 +1,367 @@
using System;
using System.Collections.Generic;
using Microsoft.AnalysisServices.Tabular;
//-----------
//ASSUMPTIONS
//Rolling window. Removes oldest partition on increment
//Depends on date keys in source to be integers formatted as yyyymmdd
//Source queries take the form "SELECT * FROM <SourceTable> WHERE FLOOR(<SourceColumn> / 100) = <yyyymm>" (monthly)
//Template partition exists with same name as table
//Non-template partitions have name of the format yyyy (yearly), yyyymm (monthly), yyyymmdd (daily)
//-----------
namespace AsPartitionProcessing
{
/// <summary>
/// Delegate to allow client to pass in a custom logging method
/// </summary>
/// <param name="message">The message to be logged</param>
/// <param name="modelConfiguration">Configuration info for the model</param>
public delegate void LogMessageDelegate(string message, ModelConfiguration modelConfiguration);
/// <summary>
/// Processor of partitions in AS tabular models
/// </summary>
public static class PartitionProcessor
{
private static ModelConfiguration _modelConfiguration;
private static LogMessageDelegate _messageLogger;
/// <summary>
/// Partitions tables in a tabular model based on configuration
/// </summary>
/// <param name="modelConfiguration">Configuration info for the model</param>
/// <param name="messageLogger">Pointer to logging method</param>
public static void PerformProcessing(ModelConfiguration modelConfiguration, LogMessageDelegate messageLogger)
{
_modelConfiguration = modelConfiguration;
_messageLogger = messageLogger;
Server server = new Server();
try
{
Database database;
Connect(server, out database);
Console.ForegroundColor = ConsoleColor.White;
LogMessage($"Start: {DateTime.Now.ToString("hh:mm:ss tt")}", false);
LogMessage($"Server: {_modelConfiguration.AnalysisServicesServer}", false);
LogMessage($"Database: {_modelConfiguration.AnalysisServicesDatabase}", false);
Console.ForegroundColor = ConsoleColor.Yellow;
foreach (TableConfiguration tableConfiguration in _modelConfiguration.TableConfigurations)
{
Table table = database.Model.Tables.Find(tableConfiguration.AnalysisServicesTable);
if (table == null)
{
throw new Microsoft.AnalysisServices.ConnectionException($"Could not connect to table {tableConfiguration.AnalysisServicesTable}.");
}
if (tableConfiguration.PartitioningConfigurations.Count == 0)
{
//Non-partitioned table. Process at table level.
LogMessage("", false);
LogMessage($"Non-partitioned processing for table {tableConfiguration.AnalysisServicesTable}", false);
LogMessage(new String('-', tableConfiguration.AnalysisServicesTable.Length + 37), false);
if (_modelConfiguration.IncrementalOnline)
{
LogMessage($"Process table {tableConfiguration.AnalysisServicesTable} /Full", true);
table.RequestRefresh(RefreshType.Full);
}
else
{
LogMessage($"Process table {tableConfiguration.AnalysisServicesTable} /DataOnly", true);
table.RequestRefresh(RefreshType.DataOnly);
}
}
else
{
//Non-partitioned table. Process based on partitioning configuration(s).
Partition templatePartition = table.Partitions.Find(tableConfiguration.AnalysisServicesTable);
if (templatePartition == null)
{
throw new Microsoft.AnalysisServices.ConnectionException($"Table {tableConfiguration.AnalysisServicesTable} does not contain a partition with the same name to act as the template partition.");
}
foreach (PartitioningConfiguration partitioningConfiguration in tableConfiguration.PartitioningConfigurations)
{
LogMessage("", false);
LogMessage($"Rolling-window partitioning for table {tableConfiguration.AnalysisServicesTable}", false);
LogMessage(new String('-', tableConfiguration.AnalysisServicesTable.Length + 38), false);
//Figure out what processing needs to be done
List<string> partitionKeysCurrent = GetPartitionKeysTable(table, partitioningConfiguration.Granularity);
List<string> partitionKeysNew = GetPartitionKeys(false, partitioningConfiguration, partitioningConfiguration.Granularity);
List<string> partitionKeysForProcessing = GetPartitionKeys(true, partitioningConfiguration, partitioningConfiguration.Granularity);
DisplayPartitionRange(partitionKeysCurrent, true, partitioningConfiguration.Granularity);
DisplayPartitionRange(partitionKeysNew, false, partitioningConfiguration.Granularity);
LogMessage("", false);
LogMessage("=>Actions & progress:", false);
//Check for old partitions that need to be removed
foreach (string partitionKey in partitionKeysCurrent)
{
if (Convert.ToInt32(partitionKey) < Convert.ToInt32(partitionKeysNew[0]))
{
LogMessage($"Remove old partition {DateFormatPartitionKey(partitionKey, partitioningConfiguration.Granularity)}", true);
table.Partitions.Remove(partitionKey);
}
}
//Process partitions
string selectQueryTemplate;
switch (partitioningConfiguration.Granularity)
{
case Granularity.Daily:
selectQueryTemplate = "SELECT * FROM {0} WHERE {1} = {2} ORDER BY {1}";
break;
case Granularity.Monthly:
selectQueryTemplate = "SELECT * FROM {0} WHERE FLOOR({1} / 100) = {2} ORDER BY {1}";
break;
default: //Granularity.Yearly:
selectQueryTemplate = "SELECT * FROM {0} WHERE FLOOR({1} / 10000) = {2} ORDER BY {1}";
break;
}
foreach (string partitionKey in partitionKeysForProcessing)
{
Partition partitionToProcess = table.Partitions.Find(partitionKey);
if (partitionToProcess == null)
{
//Doesn't exist so create it
partitionToProcess = new Partition();
templatePartition.CopyTo(partitionToProcess);
partitionToProcess.Name = partitionKey;
((QueryPartitionSource)partitionToProcess.Source).Query = String.Format(selectQueryTemplate, partitioningConfiguration.SourceTableName, partitioningConfiguration.SourcePartitionColumn, partitionKey);
table.Partitions.Add(partitionToProcess);
LogMessage($"Create new partition {DateFormatPartitionKey(partitionKey, partitioningConfiguration.Granularity)}", true);
if (!_modelConfiguration.InitialSetUp)
{
IncrementalProcessPartition(partitionKey, partitionToProcess, partitioningConfiguration.Granularity);
}
}
else if (!_modelConfiguration.InitialSetUp)
{
//Existing partition for processing
IncrementalProcessPartition(partitionKey, partitionToProcess, partitioningConfiguration.Granularity);
}
if (_modelConfiguration.InitialSetUp)
{
if (partitionToProcess.State != ObjectState.Ready)
{
//Process new partitions sequentially during initial setup so don't run out of memory
LogMessage($"Sequentially process {DateFormatPartitionKey(partitionKey, partitioningConfiguration.Granularity)} /DataOnly", true);
partitionToProcess.RequestRefresh(RefreshType.DataOnly);
database.Model.SaveChanges();
}
else
{
//Partition already exists during initial setup (and is fully processed), so ignore it
LogMessage($"Partition {DateFormatPartitionKey(partitionKey, partitioningConfiguration.Granularity)} already exists and is processed", true);
}
}
}
}
//Ensure template partition doesn't contain any data
if (_modelConfiguration.InitialSetUp)
{
((QueryPartitionSource)templatePartition.Source).Query = String.Format("SELECT * FROM {0} WHERE 0=1", tableConfiguration.PartitioningConfigurations[0].SourceTableName); //assuming the same for all partitioning configurations
templatePartition.RequestRefresh(RefreshType.DataOnly);
}
}
//If processing tables sequentially (but all partitions being done in parallel), then save changes now
if (!_modelConfiguration.IncrementalParallelTables)
{
LogMessage($"Save changes for table {tableConfiguration.AnalysisServicesTable} ...", true);
database.Model.SaveChanges();
}
}
//Commit the data changes, and bring model back online if necessary
LogMessage("", false);
LogMessage("Final operations", false);
LogMessage(new String('-', 16), false);
if (_modelConfiguration.IncrementalParallelTables)
{
LogMessage("Save changes ...", true);
database.Model.SaveChanges();
}
if (_modelConfiguration.InitialSetUp || (!_modelConfiguration.InitialSetUp && !_modelConfiguration.IncrementalOnline))
{
LogMessage("Recalc model to bring back online ...", true);
database.Model.RequestRefresh(RefreshType.Calculate);
database.Model.SaveChanges();
}
Console.ForegroundColor = ConsoleColor.White;
LogMessage("", false);
LogMessage("Finish: " + DateTime.Now.ToString("hh:mm:ss tt"), false);
}
catch (Exception exc)
{
Console.ForegroundColor = ConsoleColor.Red;
LogMessage("", false);
LogMessage($"Exception occurred: {DateTime.Now.ToString("hh:mm:ss tt")}", false);
LogMessage($"Exception message: {exc.Message}", false);
LogMessage($"Inner exception message: {exc.InnerException.Message}", false);
}
finally
{
try
{
_modelConfiguration = null;
_messageLogger = null;
if (server != null) server.Disconnect();
}
catch { }
}
}
private static void IncrementalProcessPartition(string partitionKey, Partition partitionToProcess, Granularity granularity)
{
if (_modelConfiguration.IncrementalOnline)
{
LogMessage($"Parallel process partition {DateFormatPartitionKey(partitionKey, granularity)} /Full", true);
partitionToProcess.RequestRefresh(RefreshType.Full);
}
else
{
LogMessage($"Parallel process partition {DateFormatPartitionKey(partitionKey, granularity)} /DataOnly", true);
partitionToProcess.RequestRefresh(RefreshType.DataOnly);
}
}
private static void LogMessage(string message, bool indented)
{
_messageLogger($"{(indented ? new String(' ', 3) : "")}{message}", _modelConfiguration);
}
private static string DateFormatPartitionKey(string partitionKey, Granularity granularity)
{
string returnVal = partitionKey.Substring(0, 4);
try
{
if (granularity == Granularity.Monthly || granularity == Granularity.Daily)
{
returnVal += "-" + partitionKey.Substring(4, 2);
}
if (granularity == Granularity.Daily)
{
returnVal += "-" + partitionKey.Substring(6, 2);
}
}
catch (ArgumentOutOfRangeException exc)
{
throw new InvalidOperationException($"Failed to derive date from partition key. Check the key {partitionKey} matches {Convert.ToString(granularity)} granularity.");
}
return returnVal;
}
private static void DisplayPartitionRange(List<string> partitionKeys, bool current, Granularity granularity)
{
LogMessage("", false);
if (partitionKeys.Count > 0)
{
LogMessage($"=>{(current ? "Current" : "New")} partition range ({Convert.ToString(granularity)}):", false);
LogMessage($"MIN partition: {DateFormatPartitionKey(partitionKeys[0], granularity)}", true);
LogMessage($"MAX partition: {DateFormatPartitionKey(partitionKeys[partitionKeys.Count - 1], granularity)}", true);
LogMessage($"Partition count: {partitionKeys.Count}", true);
}
else
{
LogMessage("=>Table not yet partitioned", false);
}
}
private static void Connect(Server server, out Database database)
{
//Connect and get main objects
string serverConnectionString;
if (_modelConfiguration.IntegratedAuth)
serverConnectionString = $"Provider=MSOLAP;Data Source={_modelConfiguration.AnalysisServicesServer};";
else
{
serverConnectionString = $"Provider=MSOLAP;Data Source={_modelConfiguration.AnalysisServicesServer};User ID={_modelConfiguration.UserName};Password={_modelConfiguration.Password};Persist Security Info=True;Impersonation Level=Impersonate;";
}
server.Connect(serverConnectionString);
database = server.Databases.FindByName(_modelConfiguration.AnalysisServicesDatabase);
if (database == null)
{
throw new Microsoft.AnalysisServices.ConnectionException($"Could not connect to database {_modelConfiguration.AnalysisServicesDatabase}.");
}
}
private static List<string> GetPartitionKeys(bool forProcessing, PartitioningConfiguration partitioningConfiguration, Granularity granularity)
{
//forProcessing: false to return complete target set of partitions, true to return partitons to be processed (may be less if incremental mode).
List<string> partitionKeys = new List<string>();
int numberOfPartitions = (forProcessing && !_modelConfiguration.InitialSetUp ? partitioningConfiguration.NumberOfPartitionsForIncrementalProcess : partitioningConfiguration.NumberOfPartitionsFull);
for (int i = numberOfPartitions - 1; i >= 0; i--)
{
DateTime periodToAdd;
switch (granularity)
{
case Granularity.Daily:
periodToAdd = partitioningConfiguration.MaxDate.AddDays(-i);
partitionKeys.Add(Convert.ToString((periodToAdd.Year * 100 + periodToAdd.Month) * 100 + periodToAdd.Day));
break;
case Granularity.Monthly:
periodToAdd = partitioningConfiguration.MaxDate.AddMonths(-i);
partitionKeys.Add(Convert.ToString(periodToAdd.Year * 100 + periodToAdd.Month));
break;
default: //Granularity.Yearly:
periodToAdd = partitioningConfiguration.MaxDate.AddYears(-i);
partitionKeys.Add(Convert.ToString(periodToAdd.Year));
break;
}
}
partitionKeys.Sort();
return partitionKeys;
}
private static List<string> GetPartitionKeysTable(Table table, Granularity granularity)
{
List<string> partitionKeysExisting = new List<string>();
foreach (Partition partition in table.Partitions)
{
//Ignore partitions that don't follow the convention yyyy, yyyymm or yyyymmdd
int partitionKey;
if (
( (partition.Name.Length == 4 && granularity == Granularity.Yearly) ||
(partition.Name.Length == 6 && granularity == Granularity.Monthly) ||
(partition.Name.Length == 8 && granularity == Granularity.Daily)
) && int.TryParse(partition.Name, out partitionKey)
)
{
partitionKeysExisting.Add(Convert.ToString(partitionKey));
}
}
partitionKeysExisting.Sort();
return partitionKeysExisting;
}
}
}

View File

@ -0,0 +1,85 @@
using System;
namespace AsPartitionProcessing
{
/// <summary>
/// Configuration information for partitioning of a table within an AS tabular model.
/// </summary>
public class PartitioningConfiguration
{
/// <summary>
/// ID of the PartitioningConfiguration table.
/// </summary>
public int PartitioningConfigurationID { get; set; }
/// <summary>
/// Partition granularity, which can be Yearly, Monthly or Daily.
/// </summary>
public Granularity Granularity { get; set; }
/// <summary>
/// Count of all partitions in the rolling window. For example, a rolling window of 10 years partitioned by month would result in 120 partitions.
/// </summary>
public int NumberOfPartitionsFull { get; set; }
/// <summary>
/// Count of “hot partitions” where the data can change. For example, it may be necessary to refresh the most recent 3 months of data every day. This only applies to the most recent partitions.
/// </summary>
public int NumberOfPartitionsForIncrementalProcess { get; set; }
/// <summary>
/// The maximum date that needs to be accounted for in the partitioned table. Represents the upper boundary of the rolling window.
/// </summary>
public DateTime MaxDate { get; set; }
/// <summary>
/// Name of the source table in the relational database.
/// </summary>
public string SourceTableName { get; set; }
/// <summary>
/// Name of the source column from the table in the relational database.
/// </summary>
public string SourcePartitionColumn { get; set; }
/// <summary>
/// Initialize partitioning configuration for partitioned table. Normally populated from a configuration database.
/// </summary>
/// <param name="model">Parent model.</param>
/// <param name="PartitioningConfigurationID">ID of the PartitioningConfiguration table.</param>
/// <param name="granularity">Partition granularity, which can be Yearly, Monthly or Daily.</param>
/// <param name="numberOfPartitionsFull">Count of all partitions in the rolling window. For example, a rolling window of 10 years partitioned by month would result in 120 partitions.</param>
/// <param name="numberOfPartitionsForIncrementalProcess">Count of “hot partitions” where the data can change. For example, it may be necessary to refresh the most recent 3 months of data every day. This only applies to the most recent partitions.</param>
/// <param name="maxDate">The maximum date that needs to be accounted for in the partitioned table. Represents the upper boundary of the rolling window.</param>
/// <param name="sourceTableName">Name of the source table in the relational database.</param>
/// <param name="sourcePartitionColumn">Name of the source column from the table in the relational database.</param>
public PartitioningConfiguration(
int partitioningConfigurationID,
Granularity granularity,
int numberOfPartitionsFull,
int numberOfPartitionsForIncrementalProcess,
DateTime maxDate,
string sourceTableName,
string sourcePartitionColumn
)
{
PartitioningConfigurationID = partitioningConfigurationID;
Granularity = granularity;
NumberOfPartitionsFull = numberOfPartitionsFull;
NumberOfPartitionsForIncrementalProcess = numberOfPartitionsForIncrementalProcess;
MaxDate = maxDate;
SourceTableName = sourceTableName;
SourcePartitionColumn = sourcePartitionColumn;
}
}
/// <summary>
/// Enumeration of supported partition granularities.
/// </summary>
public enum Granularity
{
Daily = 0,
Monthly = 1,
Yearly = 2
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AsPartitionProcessing")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("AsPartitionProcessing")]
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("fb937281-b06d-47fb-9846-e97b0287afce")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
namespace AsPartitionProcessing
{
/// <summary>
/// Configuration information for a table within an AS tabular model.
/// </summary>
public class TableConfiguration
{
/// <summary>
/// ID of the TableConfiguration table.
/// </summary>
public int TableConfigurationID { get; set; }
/// <summary>
/// Name of the partitioned table in the tabular model.
/// </summary>
public string AnalysisServicesTable { get; set; }
/// <summary>
/// Collection of partitioning configurations.
/// </summary>
public List<PartitioningConfiguration> PartitioningConfigurations { get; set; }
/// <summary>
/// Initialize configuration info for table. Normally populated from a configuration database.
/// </summary>
/// <param name="model">Parent model.</param>
/// <param name="tableConfigurationID">ID of the TableConfiguration table.</param>
/// <param name="analysisServicesTable">Name of the partitioned table in the tabular model.</param>
/// <param name="partitioningConfigurations">Collection of partitioning configurations.</param>
public TableConfiguration(
int tableConfigurationID,
string analysisServicesTable,
List<PartitioningConfiguration> partitioningConfigurations
)
{
TableConfigurationID = tableConfigurationID;
AnalysisServicesTable = analysisServicesTable;
PartitioningConfigurations = partitioningConfigurations;
}
/// <summary>
/// Default constructor.
/// </summary>
public TableConfiguration()
{
}
}
}

View File

@ -0,0 +1,126 @@
CREATE DATABASE [AsPartitionProcessing]
GO
USE [AsPartitionProcessing]
GO
CREATE TABLE [dbo].[ModelConfiguration](
[ModelConfigurationID] [int] NOT NULL,
[AnalysisServicesServer] [varchar](255) NOT NULL,
[AnalysisServicesDatabase] [varchar](255) NOT NULL,
[InitialSetUp] [bit] NOT NULL,
[IncrementalOnline] [bit] NOT NULL,
[IncrementalParallelTables] [bit] NOT NULL,
[IntegratedAuth] [bit] NOT NULL,
CONSTRAINT [PK_ModelConfiguration] PRIMARY KEY CLUSTERED
(
[ModelConfigurationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[PartitioningConfiguration](
[PartitioningConfigurationID] [int] NOT NULL,
[TableConfigurationID] [int] NOT NULL,
[Granularity] [tinyint] NOT NULL,
[NumberOfPartitionsFull] [int] NOT NULL,
[NumberOfPartitionsForIncrementalProcess] [int] NOT NULL,
[MaxDate] [date] NOT NULL,
[MinDate] AS (case when [Granularity]=(0) then dateadd(day,( -[NumberOfPartitionsFull])+(1),[MaxDate]) when [Granularity]=(1) then CONVERT([date],format(dateadd(month,( -[NumberOfPartitionsFull])+(1),[MaxDate]),'yyyy-MMM-01')) when [Granularity]=(2) then CONVERT([date],format(dateadd(year,( -[NumberOfPartitionsFull])+(1),[MaxDate]),'yyyy-01-01')) else [MaxDate] end),
[SourceTableName] [varchar](255) NOT NULL,
[SourcePartitionColumn] [varchar](255) NOT NULL,
CONSTRAINT [PK_PartitioningConfiguration] PRIMARY KEY CLUSTERED
(
[PartitioningConfigurationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[ProcessingLog](
[PartitioningLogID] [int] IDENTITY(1,1) NOT NULL,
[ModelConfigurationID] [int] NOT NULL,
[ExecutionID] [char](36) NOT NULL,
[LogDateTime] [datetime] NOT NULL,
[Message] [varchar](8000) NOT NULL,
CONSTRAINT [PK_ProcessingLog] PRIMARY KEY CLUSTERED
(
[PartitioningLogID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[TableConfiguration](
[TableConfigurationID] [int] NOT NULL,
[ModelConfigurationID] [int] NOT NULL,
[AnalysisServicesTable] [varchar](255) NOT NULL,
CONSTRAINT [PK_TableConfiguration] PRIMARY KEY CLUSTERED
(
[TableConfigurationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[PartitioningConfiguration] WITH CHECK ADD CONSTRAINT [FK_PartitioningConfiguration_TableConfiguration] FOREIGN KEY([TableConfigurationID])
REFERENCES [dbo].[TableConfiguration] ([TableConfigurationID])
GO
ALTER TABLE [dbo].[PartitioningConfiguration] CHECK CONSTRAINT [FK_PartitioningConfiguration_TableConfiguration]
GO
ALTER TABLE [dbo].[ProcessingLog] WITH CHECK ADD CONSTRAINT [FK_ProcessingLog_ModelConfiguration] FOREIGN KEY([ModelConfigurationID])
REFERENCES [dbo].[ModelConfiguration] ([ModelConfigurationID])
GO
ALTER TABLE [dbo].[ProcessingLog] CHECK CONSTRAINT [FK_ProcessingLog_ModelConfiguration]
GO
ALTER TABLE [dbo].[TableConfiguration] WITH CHECK ADD CONSTRAINT [FK_TableConfiguration_ModelConfiguration] FOREIGN KEY([ModelConfigurationID])
REFERENCES [dbo].[ModelConfiguration] ([ModelConfigurationID])
GO
ALTER TABLE [dbo].[TableConfiguration] CHECK CONSTRAINT [FK_TableConfiguration_ModelConfiguration]
GO
ALTER TABLE [dbo].[PartitioningConfiguration] WITH CHECK ADD CONSTRAINT [CK_PartitioningConfiguration_Granularity] CHECK (([Granularity]=(2) OR [Granularity]=(1) OR [Granularity]=(0)))
GO
ALTER TABLE [dbo].[PartitioningConfiguration] CHECK CONSTRAINT [CK_PartitioningConfiguration_Granularity]
GO
ALTER TABLE [dbo].[PartitioningConfiguration] WITH CHECK ADD CONSTRAINT [CK_PartitioningConfiguration_NumberOfPartitionsForIncrementalProcess] CHECK (([NumberOfPartitionsForIncrementalProcess]<=[NumberOfPartitionsFull]))
GO
ALTER TABLE [dbo].[PartitioningConfiguration] CHECK CONSTRAINT [CK_PartitioningConfiguration_NumberOfPartitionsForIncrementalProcess]
GO
CREATE VIEW [dbo].[vPartitioningConfiguration]
AS
SELECT m.[ModelConfigurationID]
,m.[AnalysisServicesServer]
,m.[AnalysisServicesDatabase]
,m.[InitialSetUp]
,m.[IncrementalOnline]
,m.[IncrementalParallelTables]
,m.[IntegratedAuth]
,t.[TableConfigurationID]
,t.[AnalysisServicesTable]
,CASE
WHEN p.[TableConfigurationID] IS NULL THEN 0
ELSE 1
END [Partitioned]
,p.[PartitioningConfigurationID]
,p.[Granularity]
,p.[NumberOfPartitionsFull]
,p.[NumberOfPartitionsForIncrementalProcess]
,p.[MaxDate]
,p.[MinDate]
,p.[SourceTableName]
,p.[SourcePartitionColumn]
FROM [dbo].[ModelConfiguration] m
INNER JOIN [dbo].[TableConfiguration] t ON m.[ModelConfigurationID] = t.[ModelConfigurationID]
LEFT JOIN [dbo].[PartitioningConfiguration] p ON t.[TableConfigurationID] = p.[TableConfigurationID]
GO

View File

@ -0,0 +1,8 @@
Microsoft BI technical whitepaper: [Automated Partition Management for Analysis Services Tabular Models](Automated%20Partition%20Management%20for%20Analysis%20Services%20Tabular%20Models.pdf)
Analysis Services tabular models can store data in a highly-compressed, in-memory cache for optimized query performance. This provides fast user interactivity over large data sets. Large datasets normally require table partitioning to accelerate and optimize the data-load process. Partitioning enables incremental loads, increases parallelization, and reduces memory consumption. The Tabular Object Model (TOM) serves as an API to create and manage partitions. Model Compatibility Level 1200 or above is required.
The AsPartitionProcessing TOM code sample is
* Intended to be generic and configuration driven requiring minimal code changes.
* Works for both Azure Analysis Services and SQL Server Analysis Services tabular models.
* Can be leveraged in many ways including from an SSIS script task, Azure Functions and others.

View File

@ -0,0 +1,44 @@
INSERT INTO [dbo].[ModelConfiguration]
VALUES(
1 --[ModelConfigurationID]
,'localhost' --[AnalysisServicesServer]
,'AdventureWorks' --[AnalysisServicesDatabase]
,1 --[InitialSetUp]
,1 --[IncrementalOnline]
,1 --[IncrementalParallelTables]
,1 --[IntegratedAuth]
);
INSERT INTO [dbo].[TableConfiguration]
VALUES(
1 --[TableConfigurationID]
,1 --[ModelConfigurationID]
,'Internet Sales' --[AnalysisServicesTable]
),
(
2 --[TableConfigurationID]
,1 --[ModelConfigurationID]
,'Reseller Sales' --[AnalysisServicesTable]
);
INSERT INTO [dbo].[PartitioningConfiguration]
VALUES(
1 --[PartitioningConfigurationID]
,1 --[TableConfigurationID]
,1 --[Granularity] 1=Monthly
,12 --[NumberOfPartitionsFull]
,3 --[NumberOfPartitionsForIncrementalProcess]
,'2012-12-01' --[MaxDate]
,'[dbo].[FactInternetSales]'--[SourceTableName]
,'OrderDateKey' --[SourcePartitionColumn]
),
(
2 --[PartitioningConfigurationID]
,2 --[TableConfigurationID]
,2 --[Granularity] 2=Yearly
,3 --[NumberOfPartitionsFull]
,1 --[NumberOfPartitionsForIncrementalProcess]
,'2012-12-01' --[MaxDate]
,'[dbo].[FactResellerSales]'--[SourceTableName]
,'OrderDateKey' --[SourcePartitionColumn]
);

22
AsPerfMon/ASPerfMon.sln Normal file
View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASPerfMon", "ASPerfMon\ASPerfMon.csproj", "{B2442578-2C46-47D2-B5FB-57096C234552}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B2442578-2C46-47D2-B5FB-57096C234552}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2442578-2C46-47D2-B5FB-57096C234552}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2442578-2C46-47D2-B5FB-57096C234552}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2442578-2C46-47D2-B5FB-57096C234552}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

BIN
AsPerfMon/AsPerfMon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

View File

@ -0,0 +1,94 @@
namespace ASPerfMon
{
partial class ASPerfMon
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ASPerfMon));
this.chartControl = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.btnConnect = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.chartControl)).BeginInit();
this.SuspendLayout();
//
// chartControl
//
chartArea1.Name = "ChartArea1";
this.chartControl.ChartAreas.Add(chartArea1);
this.chartControl.Dock = System.Windows.Forms.DockStyle.Fill;
legend1.Name = "Legend1";
this.chartControl.Legends.Add(legend1);
this.chartControl.Location = new System.Drawing.Point(0, 0);
this.chartControl.Name = "chartControl";
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
series1.Name = "Series1";
this.chartControl.Series.Add(series1);
this.chartControl.Size = new System.Drawing.Size(948, 645);
this.chartControl.TabIndex = 0;
this.chartControl.Text = "chart1";
this.chartControl.GetToolTipText += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ToolTipEventArgs>(this.chartControl_GetToolTipText);
//
// btnConnect
//
this.btnConnect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnConnect.Location = new System.Drawing.Point(788, 567);
this.btnConnect.Name = "btnConnect";
this.btnConnect.Size = new System.Drawing.Size(127, 44);
this.btnConnect.TabIndex = 6;
this.btnConnect.Text = "Connect";
this.btnConnect.UseVisualStyleBackColor = true;
this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
//
// ASPerfMon
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(948, 645);
this.Controls.Add(this.btnConnect);
this.Controls.Add(this.chartControl);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "ASPerfMon";
this.Text = "AS PerfMon";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ASPerfMon_FormClosing);
this.Load += new System.EventHandler(this.ASPerfMon_Load);
this.Shown += new System.EventHandler(this.ASPerfMon_Shown);
((System.ComponentModel.ISupportInitialize)(this.chartControl)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataVisualization.Charting.Chart chartControl;
private System.Windows.Forms.Button btnConnect;
}
}

View File

@ -0,0 +1,394 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using System.Timers;
using Microsoft.AnalysisServices;
using Tom = Microsoft.AnalysisServices.Tabular;
using System.Xml;
using System.Drawing;
namespace ASPerfMon
{
public partial class ASPerfMon : Form
{
public ASPerfMon()
{
InitializeComponent();
}
private Tom.Server _server = new Tom.Server();
private System.Timers.Timer _timer;
private const int _smallestFont = 12;
private string _serverConnectionString;
private DateTime _connectionTime;
//--------------------------------------------------
//120 X axis markers, one for each array item.
//Each item holds a dictionary with lookup key of series name (e.g. database name), which returns a SeriesPoint object.
Dictionary<string, SeriesPoint>[] _seriesData = new Dictionary<string, SeriesPoint>[120];
class SeriesPoint
{
public string XAxisLabel;
public long MemoryUsedBytes;
public long MemoryUsedMegabytes
{
get
{
return MemoryUsedBytes / 1024 / 1024;
}
}
public SeriesPoint(string xAxisCategoryName)
{
this.XAxisLabel = xAxisCategoryName;
this.MemoryUsedBytes = 0;
}
}
private void ASPerfMon_Load(object sender, EventArgs e)
{
InitializeChart(false);
}
private void InitializeChart(bool withSampleSeries)
{
chartControl.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
chartControl.ChartAreas[0].AxisX.Interval = 5;
chartControl.ChartAreas[0].AxisY.IsMarksNextToAxis = true;
chartControl.ChartAreas[0].AxisY.LabelStyle.Format = "{0:n0}";
chartControl.ChartAreas[0].AxisY.Title = "Memory Usage MB";
chartControl.Palette = ChartColorPalette.Pastel;
chartControl.ChartAreas[0].AxisY.TitleFont = new Font(Font.FontFamily, _smallestFont + 2);
chartControl.Legends[0].Font = new Font(Font.FontFamily, _smallestFont);
chartControl.Legends[0].LegendItemOrder = LegendItemOrder.ReversedSeriesOrder;
//initialize the chart with blanks
Dictionary<string, SeriesPoint> pointsSample;
if (withSampleSeries)
pointsSample = GetNewXAxisMarkerPointsFromAs();
else
{
pointsSample = new Dictionary<string, SeriesPoint>();
}
chartControl.Series.Clear();
if (withSampleSeries)
{
for (int i = _seriesData.Length - 1; i >= 0; i--)
{
foreach (KeyValuePair<string, SeriesPoint> entry in pointsSample)//to get series
{
entry.Value.XAxisLabel = " ";
entry.Value.MemoryUsedBytes = 0;
//add the series if not there yet
if (chartControl.Series.FindByName(entry.Key) == null)
{
Series series = new Series(entry.Key);
chartControl.Series.Add(series);
}
chartControl.Series[entry.Key].Points.AddXY(" ", 0);
}
_seriesData[i] = pointsSample;
}
PaintChart();
}
else
{
chartControl.Series.Add("");
for (int i = 0; i < _seriesData.Length; i++)
{
chartControl.Series[0].Points.AddXY(" ", 0);
}
chartControl.Invalidate();
}
_timer = new System.Timers.Timer(Settings.Default.SampleInterval);
_timer.Elapsed += OnTimedEvent;
_timer.AutoReset = true;
}
private void PaintChart()
{
//set dynamic scale
long maxValue = 0;
for (int i = _seriesData.Length - 1; i >= 0; i--)
{
long pointsStack = 0;
foreach (SeriesPoint point in _seriesData[i].Values)
{
pointsStack += Math.Abs(point.MemoryUsedMegabytes);
}
if (pointsStack > maxValue)
maxValue = pointsStack;
}
chartControl.ChartAreas[0].AxisY.IsStartedFromZero = true;
chartControl.ChartAreas[0].AxisY.Minimum = double.NaN;
chartControl.ChartAreas[0].AxisY.Maximum = double.NaN;
chartControl.ChartAreas[0].RecalculateAxesScale();
chartControl.Invalidate();
}
delegate void SetTimerCallback(Object source, ElapsedEventArgs e);
private void OnTimedEvent(Object source, ElapsedEventArgs e)
{
try
{
if (chartControl.InvokeRequired)
{
SetTimerCallback callback = new SetTimerCallback(OnTimedEvent);
//todo safer invoke look up bism
try
{
Invoke(callback, new object[] { source, e });
}
catch { }
}
else
{
//Todo delete this once http stability fix is done
if ((DateTime.Now - _connectionTime).TotalMinutes > 8)
{
_server.Disconnect();
_server.Connect(_serverConnectionString);
_connectionTime = DateTime.Now;
}
_seriesData[0] = GetNewXAxisMarkerPointsFromAs();
//rebind
chartControl.Series.Clear();
//for each X axis marker
for (int i = _seriesData.Length - 1; i > 0; i--)
{
//push back one category
_seriesData[i] = _seriesData[i - 1];
//foreach series for the X axis marker we are populating: ...
foreach (KeyValuePair<string, SeriesPoint> entry in _seriesData[i])
{
//add the series if not there yet
if (chartControl.Series.FindByName(entry.Key) == null)
{
Series series = new Series(entry.Key);
series.ChartType = SeriesChartType.StackedColumn;
chartControl.Series.Add(series);
}
//add the data point for the series
DataPoint point = new DataPoint();
point.SetValueXY(entry.Value.XAxisLabel, entry.Value.MemoryUsedMegabytes);
point.ToolTip = string.Format($"{entry.Value.XAxisLabel} - {entry.Key}: {string.Format("{0:#,###0}", entry.Value.MemoryUsedMegabytes)} MB");
chartControl.Series[entry.Key].Points.Add(point);
}
}
PaintChart();
}
}
catch (Exception exc)
{
//Workaround for timeout over HTTP. Try to reconnect - todo delete
try
{
System.Diagnostics.Debug.WriteLine($"Exception occurred at {DateTime.Now}: {exc.Message}");
_server.Disconnect();
_server.Connect(_serverConnectionString);
_connectionTime = DateTime.Now;
}
catch
{
_timer.Enabled = false;
MessageBox.Show($"Error: {exc.Message}", "AS PerfMon", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private Dictionary<string, SeriesPoint> GetNewXAxisMarkerPointsFromAs()
{
Dictionary<string, SeriesPoint> points = new Dictionary<string, SeriesPoint>();
string xAxisLabel = DateTime.Now.ToString("hh:mm:ss tt");
string commandStatement = String.Format("SELECT [OBJECT_PARENT_PATH], [OBJECT_MEMORY_NONSHRINKABLE] FROM $SYSTEM.DISCOVER_OBJECT_MEMORY_USAGE");
XmlNodeList rows = ExecuteXmlaCommand(_server, commandStatement);
foreach (XmlNode row in rows)
{
long result, label;
if (long.TryParse(row.LastChild.InnerText, out result) && result > 0)
{
string objectName = "";
string[] pathMembers = row.ChildNodes[0].InnerText.Split('.');
if (pathMembers.Length > 2 && _server.Databases.ContainsName(pathMembers[2]))
{
//Database name identified
objectName = pathMembers[2];
}
else
{
string firstMember = row.ChildNodes[0].InnerText;
//Ignore if number or blank. Assuming this is a double counted, shared allocation.
if (!long.TryParse(firstMember, out label) && firstMember != "")
{
objectName = firstMember;
}
}
if (objectName != "" && objectName != "Global") //todo: delete global condition
{
if (!points.ContainsKey(objectName))
points.Add(objectName, new SeriesPoint(xAxisLabel));
points[objectName].MemoryUsedBytes += Math.Abs(result);
}
}
else if (result > 0)
{
System.Diagnostics.Debug.WriteLine("We have a problem parsing");
}
}
return points;
}
public static XmlNodeList ExecuteXmlaCommand(Microsoft.AnalysisServices.Core.Server amoServer, string commandStatement)
{
XmlWriter xmlWriter = amoServer.StartXmlaRequest(XmlaRequestType.Undefined);
WriteSoapEnvelopeWithCommandStatement(xmlWriter, amoServer.SessionID, commandStatement);
System.Xml.XmlReader xmlReader = amoServer.EndXmlaRequest();
xmlReader.MoveToContent();
string fullEnvelopeResponseFromServer = xmlReader.ReadOuterXml();
xmlReader.Close();
XmlDocument documentResponse = new XmlDocument();
documentResponse.LoadXml(fullEnvelopeResponseFromServer);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(documentResponse.NameTable);
nsmgr.AddNamespace("myns1", "urn:schemas-microsoft-com:xml-analysis");
nsmgr.AddNamespace("myns2", "urn:schemas-microsoft-com:xml-analysis:rowset");
XmlNodeList rows = documentResponse.SelectNodes("//myns1:ExecuteResponse/myns1:return/myns2:root/myns2:row", nsmgr);
return rows;
}
public static void WriteSoapEnvelopeWithCommandStatement(XmlWriter xmlWriter, string sessionId, string commandStatement)
{
//--------------------------------------------------------------------------------
// This is a sample of the XMLA request we'll write:
//
// <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
// <Header>
// <Session soap:mustUnderstand="1" SessionId="THE SESSION ID HERE" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:schemas-microsoft-com:xml-analysis" />
// </Header>
// <Body>
// <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">
// <Command>
// <Statement>
// ...
// </Statement>
// </Command>
// <Properties/>
// </Execute>
// </Body>
// </Envelope>
//--------------------------------------------------------------------------------
xmlWriter.WriteStartElement("Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
xmlWriter.WriteStartElement("Header");
if (sessionId != null)
{
xmlWriter.WriteStartElement("Session", "urn:schemas-microsoft-com:xml-analysis");
xmlWriter.WriteAttributeString("soap", "mustUnderstand", "http://schemas.xmlsoap.org/soap/envelope/", "1");
xmlWriter.WriteAttributeString("SessionId", sessionId);
xmlWriter.WriteEndElement(); // </Session>
}
xmlWriter.WriteEndElement(); // </Header>
xmlWriter.WriteStartElement("Body");
xmlWriter.WriteStartElement("Execute", "urn:schemas-microsoft-com:xml-analysis");
xmlWriter.WriteStartElement("Command");
xmlWriter.WriteElementString("Statement", commandStatement);
xmlWriter.WriteEndElement(); // </Command>
xmlWriter.WriteStartElement("Properties");
xmlWriter.WriteEndElement(); // </Properties>
xmlWriter.WriteEndElement(); // </Execute>
xmlWriter.WriteEndElement(); // </Body>
xmlWriter.WriteEndElement(); // </Envelope>
}
private void btnConnect_Click(object sender, EventArgs e)
{
Connect();
}
private void Connect()
{
try
{
Connect connForm = new Connect();
connForm.StartPosition = FormStartPosition.CenterParent;
connForm.ShowDialog();
if (connForm.DialogResult == DialogResult.OK)
{
_timer.Enabled = false;
if (connForm.IntegratedAuth)
_serverConnectionString = $"Provider=MSOLAP;Data Source={connForm.ServerName};";
else
_serverConnectionString = $"Provider=MSOLAP;Data Source={connForm.ServerName};User ID={connForm.UserName};Password={connForm.Passwrod};Persist Security Info=True;Impersonation Level=Impersonate;";
_server = new Tom.Server();
_server.Connect(_serverConnectionString);
_connectionTime = DateTime.Now;
if (_server.ServerProperties.Count == 0)
{
throw new ConnectionException("User is not AS admin.");
}
chartControl.Titles.Clear();
chartControl.Titles.Add(connForm.ServerName);
chartControl.Titles[0].Font = new Font(Font.FontFamily, _smallestFont + 4);
InitializeChart(true);
_timer.Interval = connForm.SampleInterval;
_timer.Enabled = true;
Settings.Default.ServerName = connForm.ServerName;
Settings.Default.UserName = connForm.UserName;
Settings.Default.SampleInterval = connForm.SampleInterval;
Settings.Default.IntegratedAuth = connForm.IntegratedAuth;
Settings.Default.Save();
}
}
catch (Exception exc)
{
MessageBox.Show($"Cannot connect.\n{exc.Message}", "AS PerfMon", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ASPerfMon_FormClosing(object sender, FormClosingEventArgs e)
{
Disconnect();
}
private void Disconnect()
{
try
{
if (_server != null) _server.Disconnect();
}
catch { }
}
private void chartControl_GetToolTipText(object sender, ToolTipEventArgs e)
{
//Event handler has to be hooked up in order to display tooltip (!)
}
private void ASPerfMon_Shown(object sender, EventArgs e)
{
Connect();
}
}
}

View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B2442578-2C46-47D2-B5FB-57096C234552}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ASPerfMon</RootNamespace>
<AssemblyName>ASPerfMon</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Chart.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AnalysisServices, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.DLL</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices.Core, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Core.DLL</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices.Tabular, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Tabular.DLL</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices.Tabular.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.AnalysisServices.Tabular.Json.DLL</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms.DataVisualization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ASPerfMon.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ASPerfMon.Designer.cs">
<DependentUpon>ASPerfMon.cs</DependentUpon>
</Compile>
<Compile Include="Connect.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Connect.Designer.cs">
<DependentUpon>Connect.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<EmbeddedResource Include="ASPerfMon.resx">
<DependentUpon>ASPerfMon.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Connect.resx">
<DependentUpon>Connect.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<None Include="Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Chart.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ASPerfMon.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<ASPerfMon.Settings>
<setting name="ServerName" serializeAs="String">
<value />
</setting>
<setting name="UserName" serializeAs="String">
<value />
</setting>
<setting name="SampleInterval" serializeAs="String">
<value>2500</value>
</setting>
<setting name="IntegratedAuth" serializeAs="String">
<value>False</value>
</setting>
</ASPerfMon.Settings>
</userSettings>
</configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

210
AsPerfMon/AsPerfMon/Connect.Designer.cs generated Normal file
View File

@ -0,0 +1,210 @@
namespace ASPerfMon
{
partial class Connect
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.txtUserName = new System.Windows.Forms.TextBox();
this.txtServer = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.chkIntegratedAuth = new System.Windows.Forms.CheckBox();
this.txtPassword = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtSampleInterval = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOK.Location = new System.Drawing.Point(264, 179);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 0;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(345, 179);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
//
// txtUserName
//
this.txtUserName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtUserName.Location = new System.Drawing.Point(111, 62);
this.txtUserName.Name = "txtUserName";
this.txtUserName.Size = new System.Drawing.Size(310, 20);
this.txtUserName.TabIndex = 10;
//
// txtServer
//
this.txtServer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtServer.Location = new System.Drawing.Point(111, 13);
this.txtServer.Name = "txtServer";
this.txtServer.Size = new System.Drawing.Size(310, 20);
this.txtServer.TabIndex = 1;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 65);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(63, 13);
this.label3.TabIndex = 8;
this.label3.Text = "User Name:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 13);
this.label1.TabIndex = 6;
this.label1.Text = "Server:";
//
// chkIntegratedAuth
//
this.chkIntegratedAuth.AutoSize = true;
this.chkIntegratedAuth.Location = new System.Drawing.Point(111, 39);
this.chkIntegratedAuth.Name = "chkIntegratedAuth";
this.chkIntegratedAuth.Size = new System.Drawing.Size(145, 17);
this.chkIntegratedAuth.TabIndex = 2;
this.chkIntegratedAuth.Text = "Integrated Authentication";
this.chkIntegratedAuth.UseVisualStyleBackColor = true;
this.chkIntegratedAuth.CheckedChanged += new System.EventHandler(this.chkIntegratedAuth_CheckedChanged);
//
// txtPassword
//
this.txtPassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtPassword.Location = new System.Drawing.Point(111, 88);
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.Size = new System.Drawing.Size(310, 20);
this.txtPassword.TabIndex = 13;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 91);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 13);
this.label2.TabIndex = 12;
this.label2.Text = "Password:";
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.txtUserName);
this.groupBox1.Controls.Add(this.txtPassword);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.chkIntegratedAuth);
this.groupBox1.Controls.Add(this.txtServer);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(427, 123);
this.groupBox1.TabIndex = 14;
this.groupBox1.TabStop = false;
//
// txtSampleInterval
//
this.txtSampleInterval.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtSampleInterval.Location = new System.Drawing.Point(123, 141);
this.txtSampleInterval.Name = "txtSampleInterval";
this.txtSampleInterval.Size = new System.Drawing.Size(310, 20);
this.txtSampleInterval.TabIndex = 15;
this.txtSampleInterval.Text = "1000";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(18, 144);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(105, 13);
this.label4.TabIndex = 14;
this.label4.Text = "Sample Interval (ms):";
//
// Connect
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(450, 219);
this.Controls.Add(this.txtSampleInterval);
this.Controls.Add(this.label4);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Connect";
this.ShowIcon = false;
this.Text = "Connect";
this.Load += new System.EventHandler(this.Connect_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.TextBox txtUserName;
private System.Windows.Forms.TextBox txtServer;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox chkIntegratedAuth;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox txtSampleInterval;
private System.Windows.Forms.Label label4;
}
}

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ASPerfMon
{
public partial class Connect : Form
{
public string ServerName { get; set; }
public bool IntegratedAuth { get; set; }
public string UserName { get; set; }
public string Passwrod { get; set; }
public int SampleInterval { get; set; }
public Connect()
{
InitializeComponent();
}
private void Connect_Load(object sender, EventArgs e)
{
this.txtServer.Text = Settings.Default.ServerName;
this.chkIntegratedAuth.Checked = Settings.Default.IntegratedAuth;
this.txtUserName.Text = Settings.Default.UserName;
this.txtSampleInterval.Text = Settings.Default.SampleInterval.ToString();
this.txtServer.MouseDown += new System.Windows.Forms.MouseEventHandler(this.txt_MouseDown);
this.txtUserName.MouseDown += new System.Windows.Forms.MouseEventHandler(this.txt_MouseDown);
this.txtPassword.MouseDown += new System.Windows.Forms.MouseEventHandler(this.txt_MouseDown);
this.txtSampleInterval.MouseDown += new System.Windows.Forms.MouseEventHandler(this.txt_MouseDown);
}
private void chkIntegratedAuth_CheckedChanged(object sender, EventArgs e)
{
txtUserName.Enabled = !chkIntegratedAuth.Checked;
txtPassword.Enabled = !chkIntegratedAuth.Checked;
}
private void btnOK_Click(object sender, EventArgs e)
{
int sampleInterval;
if (!int.TryParse(txtSampleInterval.Text, out sampleInterval))
{
MessageBox.Show("Sample Interval must be a positive integer", "AS PerfMon", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
this.ServerName = txtServer.Text;
this.IntegratedAuth = chkIntegratedAuth.Checked;
this.UserName = txtUserName.Text;
this.Passwrod = txtPassword.Text;
this.SampleInterval = sampleInterval;
this.DialogResult = DialogResult.OK;
}
private void txt_MouseDown(object sender, MouseEventArgs e)
{
TextBox textBox = (TextBox)sender;
textBox.SelectAll();
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ASPerfMon
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new ASPerfMon());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ASPerfMon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("ASPerfMon")]
[assembly: AssemblyCopyright("Copyright © Microsoft Corporation 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b2442578-2c46-47d2-b5fb-57096c234552")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ASPerfMon.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ASPerfMon.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ASPerfMon.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

74
AsPerfMon/AsPerfMon/Settings.Designer.cs generated Normal file
View File

@ -0,0 +1,74 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ASPerfMon {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ServerName {
get {
return ((string)(this["ServerName"]));
}
set {
this["ServerName"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string UserName {
get {
return ((string)(this["UserName"]));
}
set {
this["UserName"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("2500")]
public int SampleInterval {
get {
return ((int)(this["SampleInterval"]));
}
set {
this["SampleInterval"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool IntegratedAuth {
get {
return ((bool)(this["IntegratedAuth"]));
}
set {
this["IntegratedAuth"] = value;
}
}
}
}

View File

@ -0,0 +1,18 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ASPerfMon" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ServerName" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="UserName" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="SampleInterval" Type="System.Int32" Scope="User">
<Value Profile="(Default)">2500</Value>
</Setting>
<Setting Name="IntegratedAuth" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ASPerfMon.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<ASPerfMon.Settings>
<setting name="ServerName" serializeAs="String">
<value />
</setting>
<setting name="UserName" serializeAs="String">
<value />
</setting>
<setting name="SampleInterval" serializeAs="String">
<value>2500</value>
</setting>
<setting name="IntegratedAuth" serializeAs="String">
<value>False</value>
</setting>
</ASPerfMon.Settings>
</userSettings>
</configuration>

Binary file not shown.

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ASPerfMon.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<ASPerfMon.Settings>
<setting name="ServerName" serializeAs="String">
<value />
</setting>
<setting name="UserName" serializeAs="String">
<value />
</setting>
<setting name="SampleInterval" serializeAs="String">
<value>2500</value>
</setting>
<setting name="IntegratedAuth" serializeAs="String">
<value>False</value>
</setting>
</ASPerfMon.Settings>
</userSettings>
</configuration>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1 @@
C:\Users\ChWade\Source\Repos\Analysis-Services\AsPerfMon\ASPerfMon\bin\Debug\ASPerfMon.exe.config

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AnalysisServices.AdomdClient" version="12.0.2000.8" targetFramework="net452" />
</packages>

4
AsPerfMon/README.md Normal file
View File

@ -0,0 +1,4 @@
Monitor Analysis Services memory usage broken out by database and other high-level allocations in a stacked bar that increments at set interval. Useful during processing especially with multiple databases on same server.
![alt text](AsPerfMon.png "Stacked bar by memory allocation")

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

16
README.md Normal file
View File

@ -0,0 +1,16 @@
# Analysis Services
Git repo for Analysis Services samples and community projects
## [AsPartitionProcessing](https://github.com/Microsoft/Analysis-Services/tree/master/AsPartitionProcessing)
Automated partition management of Azure Analysis Services tabular models
## [AsPerfMon](https://github.com/Microsoft/Analysis-Services/tree/master/AsPerfMon)
Real-time monitoring of Analysis Services memory usage broken out by database
## Code of Conduct
This project has adopted the [Microsoft Open Source Code of
Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct
FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com)
with any additional questions or comments.