Add files via upload

This commit is contained in:
Christian Wade 2017-01-11 18:27:38 -08:00 committed by GitHub
parent b78a0c88e4
commit 487372158a
93 changed files with 3018 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,55 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ASTrace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<ASTrace.Properties.Settings>
<setting name="AnalysisServerNames" serializeAs="String">
<value>localhost,localhost\tabular</value>
</setting>
<setting name="SQLServer" serializeAs="String">
<value>localhost</value>
</setting>
<setting name="SQLServerDatabase" serializeAs="String">
<value>TraceDB</value>
</setting>
<setting name="TraceTableName" serializeAs="String">
<value>ASTraceTable</value>
</setting>
<setting name="TraceDefinition" serializeAs="String">
<value>Standard.tdf</value>
</setting>
<setting name="PreserveHistory" serializeAs="String">
<value>True</value>
</setting>
<setting name="RestartRetries" serializeAs="String">
<value>3</value>
</setting>
<setting name="RestartDelayMinutes" serializeAs="String">
<value>5</value>
</setting>
</ASTrace.Properties.Settings>
</applicationSettings>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.ConnectionInfo" publicKeyToken="89845dcd8080cc91" />
<bindingRedirect oldVersion="10.0.0.0" newVersion="11.0.0.0" />
<publisherPolicy apply="no" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.ConnectionInfoExtended" publicKeyToken="89845dcd8080cc91" />
<bindingRedirect oldVersion="10.0.0.0" newVersion="11.0.0.0" />
<publisherPolicy apply="no" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,6 @@
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
</startup>
</configuration>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
cd /d "%~dp0"
InstallUtil.exe ASTrace.exe
pause

View File

@ -0,0 +1,3 @@
cd /d "%~dp0"
InstallUtil.exe /u ASTrace.exe
pause

View File

@ -0,0 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASTrace", "ASTrace\ASTrace.csproj", "{1B1359C0-AD58-4B92-966D-0110733AD0FF}"
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs02
SccLocalPath0 = .
SccProjectUniqueName1 = ASTrace\\ASTrace.csproj
SccProjectName1 = ASTrace
SccLocalPath1 = ASTrace
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}

View File

@ -0,0 +1,95 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1B1359C0-AD58-4B92-966D-0110733AD0FF}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ASTrace</RootNamespace>
<AssemblyName>ASTrace</AssemblyName>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<ApplicationRevision>0</ApplicationRevision>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</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>
<PlatformTarget>x86</PlatformTarget>
</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>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
<Reference Include="Microsoft.SqlServer.ConnectionInfoExtended, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Service1.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Service1.Designer.cs">
<DependentUpon>Service1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProjectInstaller.resx">
<SubType>Designer</SubType>
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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,16 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory>
</InstallUrlHistory>
<SupportUrlHistory>
</SupportUrlHistory>
<UpdateUrlHistory>
</UpdateUrlHistory>
<BootstrapperUrlHistory>
</BootstrapperUrlHistory>
<ApplicationRevision>0</ApplicationRevision>
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1B1359C0-AD58-4B92-966D-0110733AD0FF}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ASTrace</RootNamespace>
<AssemblyName>ASTrace</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation />
<TargetFrameworkProfile />
<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>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</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>
<PlatformTarget>x86</PlatformTarget>
</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>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.ConnectionInfoExtended, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfoExtended.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Service1.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Service1.Designer.cs">
<DependentUpon>Service1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProjectInstaller.resx">
<SubType>Designer</SubType>
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory />
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.ServiceProcess;
using System.Text;
namespace ASTrace
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = new ServiceBase[] {new ASTrace(), new MySecondUserService()};
//
ServicesToRun = new ServiceBase[] { new Trace() };
ServiceBase.Run(ServicesToRun);
}
}
}

View File

@ -0,0 +1,62 @@
namespace ASTrace
{
partial class ProjectInstaller
{
/// <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 Component 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.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
this.serviceProcessInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceProcessInstaller1_AfterInstall);
//
// serviceInstaller1
//
this.serviceInstaller1.Description = "Analysis Services Trace Sample Service";
this.serviceInstaller1.DisplayName = "ASTrace";
this.serviceInstaller1.ServiceName = "ASTrace";
this.serviceInstaller1.BeforeUninstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_BeforeUninstall);
this.serviceInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_AfterInstall);
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
namespace ASTrace
{
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
Microsoft.Win32.RegistryKey software, microsoft, astrace;
software = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE");
microsoft = software.OpenSubKey("Microsoft", true);
astrace = microsoft.CreateSubKey("ASTrace");
astrace.SetValue("path", Environment.CurrentDirectory);
}
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
}
private void serviceInstaller1_BeforeUninstall(object sender, InstallEventArgs e)
{
try
{
Microsoft.Win32.RegistryKey software, microsoft;
software = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE");
microsoft = software.OpenSubKey("Microsoft",true);
microsoft.DeleteSubKey("ASTrace");
}
catch { }
}
}
}

View File

@ -0,0 +1,129 @@
<?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=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>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 11</value>
</metadata>
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>221, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -0,0 +1,36 @@
using System;
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("ASTrace")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ASTrace")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[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)]
[assembly: CLSCompliant(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("49f2e12f-ed21-4372-9097-ee25cb7318ff")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]

View File

@ -0,0 +1,116 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.5466
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ASTrace.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.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.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string AnalysisServerName {
get {
return ((string)(this["AnalysisServerName"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("localhost")]
public string SQLServer {
get {
return ((string)(this["SQLServer"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("TraceDB")]
public string SQLServerDatabase {
get {
return ((string)(this["SQLServerDatabase"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("ASTraceTable")]
public string TraceTableName {
get {
return ((string)(this["TraceTableName"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Standard.tdf")]
public string TraceDefinition {
get {
return ((string)(this["TraceDefinition"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool PreserveHistory {
get {
return ((bool)(this["PreserveHistory"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string AnalysisServerNames {
get {
return ((string)(this["AnalysisServerNames"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool AppendDateToSQLTable {
get {
return ((bool)(this["AppendDateToSQLTable"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("3")]
public int RestartRetries {
get {
return ((int)(this["RestartRetries"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("5")]
public int RestartDelayMinutes {
get {
return ((int)(this["RestartDelayMinutes"]));
}
}
}
}

View File

@ -0,0 +1,36 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ASTrace.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="AnalysisServerName" Type="System.String" Scope="Application">
<Value Profile="(Default)" />
</Setting>
<Setting Name="SQLServer" Type="System.String" Scope="Application">
<Value Profile="(Default)">localhost</Value>
</Setting>
<Setting Name="SQLServerDatabase" Type="System.String" Scope="Application">
<Value Profile="(Default)">TraceDB</Value>
</Setting>
<Setting Name="TraceTableName" Type="System.String" Scope="Application">
<Value Profile="(Default)">ASTraceTable</Value>
</Setting>
<Setting Name="TraceDefinition" Type="System.String" Scope="Application">
<Value Profile="(Default)">Standard.tdf</Value>
</Setting>
<Setting Name="PreserveHistory" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="AnalysisServerNames" Type="System.String" Scope="Application">
<Value Profile="(Default)" />
</Setting>
<Setting Name="AppendDateToSQLTable" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="RestartRetries" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">3</Value>
</Setting>
<Setting Name="RestartDelayMinutes" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">5</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,37 @@
namespace ASTrace
{
partial class Trace
{
/// <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 Component 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()
{
components = new System.ComponentModel.Container();
this.ServiceName = "ASTrace";
}
#endregion
}
}

View File

@ -0,0 +1,442 @@
/*============================================================================
File: Service1.cs
Summary: Contains class implementiong ASTrace service
Part of ASTrace
Date: January 2007
------------------------------------------------------------------------------
This file is part of the Microsoft SQL Server Code Samples.
Copyright (C) Microsoft Corporation. All rights reserved.
This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation. See these other
materials for detailed information regarding Microsoft code samples.
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
============================================================================*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.IO;
using Microsoft.SqlServer.Management.Trace;
using Microsoft.SqlServer.Management.Common;
namespace ASTrace
{
public partial class Trace : ServiceBase
{
List<Thread> workers = new List<Thread>();
string localPath;
List<string> _ServernamesList;
int _NumInstance;
TextWriter writer;
List<TraceServer> traceServers = new List<TraceServer>();
public Trace()
{
//Have seen errors here, normally when configuring for first time
//Note, the eventlog will need to create a source the very first time it runs and that needs admin privs.
try
{
InitializeComponent();
// Read registry to find out where the service executable is installed
Microsoft.Win32.RegistryKey software, microsoft, astrace;
software = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE");
microsoft = software.OpenSubKey("Microsoft");
astrace = microsoft.OpenSubKey("ASTrace");
localPath = (string)astrace.GetValue("path");
writer = new StreamWriter(localPath + "\\ASTraceService.log", true);
WriteLog(DateTime.Now.ToString() + ": Service Started in '" + localPath + "'");
}
catch (Exception ex)
{
StringBuilder messageText = new StringBuilder();
messageText.Append("Failed to write to log file ").AppendLine();
messageText.Append("Error: " + ex.Message).AppendLine();
while (ex.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(ex.InnerException.Message).AppendLine();
messageText.Append(ex.InnerException.StackTrace).AppendLine();
ex = ex.InnerException;
}
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Error);
}
}
protected override void OnStart(string[] args)
{
if (Properties.Settings.Default.AppendDateToSQLTable && Properties.Settings.Default.PreserveHistory)
{
StringBuilder messageText = new StringBuilder();
messageText.Append(DateTime.Now.ToString() + ": Both AppendDateToSQLTable and PreserveHistory cannot be true!");
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Error);
WriteLog(messageText.ToString());
Stop();
return;
}
//Initial startup so get the server list
string sServerNames = Properties.Settings.Default.AnalysisServerName + "," + Properties.Settings.Default.AnalysisServerNames;
_ServernamesList = new List<string>(sServerNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
//Get the number of servers so we can maintain legacy behaviour
_NumInstance = _ServernamesList.Count;
foreach (string SSASserver in _ServernamesList)
{
//Spin up a thread to write the trace to SQL
Thread worker = new Thread(DoWork);
workers.Add(worker);
//Start the tracing and pass SSAS Server name so we can handle retries
worker.Start(SSASserver);
}
}
bool ConnectOlap(out TraceServer traceServer, string SSASserver)
{
OlapConnectionInfo ci = new OlapConnectionInfo();
traceServer = new TraceServer();
StringBuilder messageText = new StringBuilder();
try
{
ci.UseIntegratedSecurity = true;
ci.ServerName = SSASserver;
string tracetemplate = localPath + "\\" + Properties.Settings.Default.TraceDefinition;
traceServer.InitializeAsReader(ci, tracetemplate);
lock (traceServers)
{
traceServers.Add(traceServer);
}
messageText.Append(
DateTime.Now.ToString()
+ ": Created trace for Analysis Server : '"
+ SSASserver
+ "'");
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Information);
return true;
}
catch (Exception e)
{
messageText.Append(DateTime.Now.ToString() + ": Cannot start Analysis Server trace: ").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Analysis Server name: '" + SSASserver + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Trace definition : '" + localPath + "\\" + Properties.Settings.Default.TraceDefinition + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Error: " + e.Message).AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Stack Trace: " + e.StackTrace).AppendLine();
while (e.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(e.InnerException.Message).AppendLine();
messageText.Append(e.InnerException.StackTrace).AppendLine();
e = e.InnerException;
}
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Error);
return false;
}
}
bool ConnectSQL(ref TraceServer traceServer, out TraceTable tableWriter, string SSASserver)
{
SqlConnectionInfo connInfo = new SqlConnectionInfo(Properties.Settings.Default.SQLServer);
StringBuilder messageText = new StringBuilder();
string _AppendInst = "_" + SSASserver;
string _SQLTable;
string _AppendDate;
//Maintains legacy logic where by a server with single instance does not have any inst names appended.
if (_NumInstance == 1)
_AppendInst = "";
//Append data to end of SQL table. Useful as an alternative to preserver SQL but data only survives 1 restart a day and you need cleanup logic in SQL Server
if (Properties.Settings.Default.AppendDateToSQLTable)
_AppendDate = "_" + DateTime.Now.ToString("yyyyMMdd");
else
_AppendDate = "";
_SQLTable =
Properties.Settings.Default.TraceTableName
+ _AppendInst
+ _AppendDate;
if (Properties.Settings.Default.PreserveHistory)
PreserveSQLHistory(ref _SQLTable);
tableWriter = new TraceTable();
try
{
connInfo.DatabaseName = Properties.Settings.Default.SQLServerDatabase;
tableWriter.InitializeAsWriter(traceServer, connInfo, _SQLTable);
messageText.Append(DateTime.Now.ToString() + ": Created Analysis Server trace table: '" + _SQLTable + "' on SQL Server: '" + Properties.Settings.Default.SQLServer
+ "' in database: " + Properties.Settings.Default.SQLServerDatabase + "'");
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Information);
return true;
}
catch (Exception e)
{
messageText.Append(DateTime.Now.ToString() + ": Cannot create Analysis Server trace table: '" + SSASserver + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": SQL Server Name: '" + Properties.Settings.Default.SQLServer + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": SQL Server Database : '" + Properties.Settings.Default.SQLServerDatabase + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": SQL Server Table : '" + _SQLTable + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Error: " + e.Message).AppendLine();
while (e.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(e.InnerException.Message).AppendLine();
messageText.Append(e.InnerException.StackTrace.ToString()).AppendLine();
e = e.InnerException;
}
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Error);
return false;
}
}
void PreserveSQLHistory(ref string _SQLTable)
{
string sHistorySuffix = "History";
if (_NumInstance > 1)
{
sHistorySuffix = "_History";
}
StringBuilder messageText = new StringBuilder();
try
{
SqlConnectionInfo connInfo = new SqlConnectionInfo(Properties.Settings.Default.SQLServer);
IDbConnection conn = connInfo.CreateConnectionObject();
conn.Open();
conn.ChangeDatabase(Properties.Settings.Default.SQLServerDatabase);
string sSQL = @"if object_id('[" + _SQLTable.Replace("'", "''") + @"]') is not null
select top 1 * from [" + _SQLTable.Replace("]", "]]") + "]";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sSQL, (System.Data.SqlClient.SqlConnection)conn);
cmd.CommandTimeout = 0;
System.Data.SqlClient.SqlDataReader datareader = cmd.ExecuteReader();
string sColumns = "";
for (int i = 0; i < datareader.FieldCount; i++)
{
if (!string.IsNullOrEmpty(sColumns)) sColumns += ", ";
sColumns += "[" + datareader.GetName(i) + "]";
}
datareader.Close();
if (sColumns != "")
{
sSQL = @"
if object_id('[" + _SQLTable.Replace("'", "''") + @"]') is not null
begin
if object_id('[" + _SQLTable.Replace("'", "''") + sHistorySuffix + @"]') is null
begin
select * into [" + _SQLTable.Replace("]", "]]") + sHistorySuffix + "] from [" + _SQLTable.Replace("]", "]]") + @"]
end
else
begin
SET IDENTITY_INSERT [" + _SQLTable.Replace("]", "]]") + sHistorySuffix + @"] ON
insert into [" + _SQLTable.Replace("]", "]]") + sHistorySuffix + "] (" + sColumns + @")
select * from [" + _SQLTable.Replace("]", "]]") + @"]
SET IDENTITY_INSERT [" + _SQLTable.Replace("]", "]]") + sHistorySuffix + @"] OFF
end
end
";
cmd.CommandText = sSQL;
int iRowsPreserved = cmd.ExecuteNonQuery();
messageText.Append(DateTime.Now.ToString() + ": Successfully preserved " + iRowsPreserved + " rows of history to table: " + _SQLTable + sHistorySuffix);
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Information);
}
conn.Close();
conn.Dispose();
}
catch (Exception ex)
{
messageText.Append(DateTime.Now.ToString() + ": Cannot preserve history of trace table. ").AppendLine();
messageText.Append("Error: " + ex.Message).AppendLine();
messageText.Append(ex.StackTrace).AppendLine();
while (ex.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(ex.InnerException.Message).AppendLine();
messageText.Append(ex.InnerException.StackTrace).AppendLine();
ex = ex.InnerException;
}
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Warning);
}
}
void DoWork(object SSAS)
{
string SSASserver = (string)SSAS;
TraceTable _SQLDestTableWriter = null;
TraceServer _SSASSourceTraceServer = null;
int _RetryCounter = 0;
bool bFirstLoop = true;
while (bFirstLoop || _RetryCounter < Properties.Settings.Default.RestartRetries)
{
bFirstLoop = false;
try
{
//Grab connection to SSAS
bool bSuccess = ConnectOlap(out _SSASSourceTraceServer, SSASserver);
if (bSuccess)
{
//Grab connection to SQL and connect it with the SSAS trace
bSuccess = ConnectSQL(ref _SSASSourceTraceServer, out _SQLDestTableWriter, SSASserver);
if (bSuccess)
{
_RetryCounter = 0;
while (_SQLDestTableWriter.Write())
{
if (_SQLDestTableWriter.IsClosed)
throw new Exception("SQL connection closed unexpectedly.");
if (_SSASSourceTraceServer.IsClosed)
throw new Exception("SSAS connection closed unexpectedly.");
}
}
}
}
catch (Exception ex)
{
StringBuilder messageText = new StringBuilder();
messageText.Append(DateTime.Now.ToString() + ": Error reading trace: " + ex.Message).AppendLine();
messageText.Append(ex.StackTrace).AppendLine();
while (ex.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(ex.InnerException.Message).AppendLine();
messageText.Append(ex.InnerException.StackTrace).AppendLine();
ex = ex.InnerException;
}
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Warning);
}
try
{
_SSASSourceTraceServer.Stop();
_SSASSourceTraceServer.Close();
}
catch { }
try
{
_SQLDestTableWriter.Close();
}
catch { }
_RetryCounter++;
if (_RetryCounter < Properties.Settings.Default.RestartRetries)
{
StringBuilder messageText2 = new StringBuilder();
messageText2.Append(DateTime.Now.ToString() + ": Exception caught tracing server: " + SSASserver + ", retry " + _RetryCounter + " of " + Properties.Settings.Default.RestartRetries
+ ". Pausing for " + Properties.Settings.Default.RestartDelayMinutes + " minute(s) then restarting automatically"
).AppendLine();
WriteLog(messageText2.ToString());
EventLog.WriteEntry(this.ServiceName, messageText2.ToString(), EventLogEntryType.Warning);
System.Threading.Thread.Sleep(new TimeSpan(0, Properties.Settings.Default.RestartDelayMinutes, 0));
}
else
{
WriteLog(DateTime.Now.ToString() + ": Exceeded the number of allowed retries for server: " + SSASserver);
}
}
//if this one trace exceeded the number of retries so stop the service and stop all traces
Stop();
}
protected override void OnStop()
{
try
{
WriteLog(DateTime.Now.ToString() + ": Stopping");
writer.Close();
writer.Dispose();
}
catch { }
try
{
foreach (TraceServer ts in traceServers)
{
try
{
ts.Stop();
ts.Close();
ts.Dispose();
}
catch { }
}
}
catch { }
}
private void WriteLog(string sMessage)
{
lock (writer)
{
try
{
writer.WriteLine(sMessage);
writer.Flush();
}
catch { }
}
}
}
}

View File

@ -0,0 +1,28 @@
namespace ASTrace.Properties {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ASTrace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<ASTrace.Properties.Settings>
<setting name="AnalysisServerName" serializeAs="String">
<value />
</setting>
<setting name="SQLServer" serializeAs="String">
<value>localhost</value>
</setting>
<setting name="SQLServerDatabase" serializeAs="String">
<value>TraceDB</value>
</setting>
<setting name="TraceTableName" serializeAs="String">
<value>ASTraceTable</value>
</setting>
<setting name="TraceDefinition" serializeAs="String">
<value>Standard.tdf</value>
</setting>
<setting name="PreserveHistory" serializeAs="String">
<value>True</value>
</setting>
<setting name="AnalysisServerNames" serializeAs="String">
<value />
</setting>
<setting name="AppendDateToSQLTable" serializeAs="String">
<value>False</value>
</setting>
<setting name="RestartRetries" serializeAs="String">
<value>3</value>
</setting>
<setting name="RestartDelayMinutes" serializeAs="String">
<value>5</value>
</setting>
</ASTrace.Properties.Settings>
</applicationSettings>
</configuration>

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ASTrace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<ASTrace.Properties.Settings>
<setting name="AnalysisServerName" serializeAs="String">
<value />
</setting>
<setting name="SQLServer" serializeAs="String">
<value>localhost</value>
</setting>
<setting name="SQLServerDatabase" serializeAs="String">
<value>TraceDB</value>
</setting>
<setting name="TraceTableName" serializeAs="String">
<value>ASTraceTable</value>
</setting>
<setting name="TraceDefinition" serializeAs="String">
<value>Standard.tdf</value>
</setting>
<setting name="PreserveHistory" serializeAs="String">
<value>True</value>
</setting>
<setting name="AnalysisServerNames" serializeAs="String">
<value />
</setting>
<setting name="AppendDateToSQLTable" serializeAs="String">
<value>False</value>
</setting>
<setting name="RestartRetries" serializeAs="String">
<value>3</value>
</setting>
<setting name="RestartDelayMinutes" serializeAs="String">
<value>5</value>
</setting>
</ASTrace.Properties.Settings>
</applicationSettings>
</configuration>

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ASTrace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<ASTrace.Properties.Settings>
<setting name="AnalysisServerName" serializeAs="String">
<value />
</setting>
<setting name="SQLServer" serializeAs="String">
<value>localhost</value>
</setting>
<setting name="SQLServerDatabase" serializeAs="String">
<value>TraceDB</value>
</setting>
<setting name="TraceTableName" serializeAs="String">
<value>ASTraceTable</value>
</setting>
<setting name="TraceDefinition" serializeAs="String">
<value>Standard.tdf</value>
</setting>
<setting name="PreserveHistory" serializeAs="String">
<value>True</value>
</setting>
<setting name="AnalysisServerNames" serializeAs="String">
<value />
</setting>
<setting name="AppendDateToSQLTable" serializeAs="String">
<value>False</value>
</setting>
<setting name="RestartRetries" serializeAs="String">
<value>3</value>
</setting>
<setting name="RestartDelayMinutes" serializeAs="String">
<value>5</value>
</setting>
</ASTrace.Properties.Settings>
</applicationSettings>
</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,8 @@
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.exe.config
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.exe
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.pdb
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace2012.csprojResolveAssemblyReference.cache
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.ProjectInstaller.resources
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace2012.csproj.GenerateResource.Cache
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.exe
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.pdb

View File

@ -0,0 +1,8 @@
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.exe.config
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.exe
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.pdb
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace2014.csprojResolveAssemblyReference.cache
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.ProjectInstaller.resources
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace2014.csproj.GenerateResource.Cache
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.exe
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.pdb

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}

View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASTrace2014", "ASTrace\ASTrace2014.csproj", "{1B1359C0-AD58-4B92-966D-0110733AD0FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASTrace", "ASTrace\ASTrace.csproj", "{1B1359C0-AD58-4B92-966D-0110733AD0FF}"
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs02
SccLocalPath0 = .
SccProjectUniqueName1 = ASTrace\\ASTrace.csproj
SccProjectName1 = ASTrace
SccLocalPath1 = ASTrace
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}

View File

@ -0,0 +1,95 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1B1359C0-AD58-4B92-966D-0110733AD0FF}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ASTrace</RootNamespace>
<AssemblyName>ASTrace</AssemblyName>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<ApplicationRevision>0</ApplicationRevision>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</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>
<PlatformTarget>x86</PlatformTarget>
</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>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
<Reference Include="Microsoft.SqlServer.ConnectionInfoExtended, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Service1.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Service1.Designer.cs">
<DependentUpon>Service1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProjectInstaller.resx">
<SubType>Designer</SubType>
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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,16 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory>
</InstallUrlHistory>
<SupportUrlHistory>
</SupportUrlHistory>
<UpdateUrlHistory>
</UpdateUrlHistory>
<BootstrapperUrlHistory>
</BootstrapperUrlHistory>
<ApplicationRevision>0</ApplicationRevision>
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1B1359C0-AD58-4B92-966D-0110733AD0FF}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ASTrace</RootNamespace>
<AssemblyName>ASTrace</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation />
<TargetFrameworkProfile />
<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>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</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>
<PlatformTarget>x86</PlatformTarget>
</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>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll</HintPath>
</Reference>
<Reference Include="Microsoft.SqlServer.ConnectionInfoExtended, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Program Files\Microsoft SQL Server\130\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfoExtended.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Service1.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Service1.Designer.cs">
<DependentUpon>Service1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProjectInstaller.resx">
<SubType>Designer</SubType>
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory />
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.ServiceProcess;
using System.Text;
namespace ASTrace
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = new ServiceBase[] {new ASTrace(), new MySecondUserService()};
//
ServicesToRun = new ServiceBase[] { new Trace() };
ServiceBase.Run(ServicesToRun);
}
}
}

View File

@ -0,0 +1,62 @@
namespace ASTrace
{
partial class ProjectInstaller
{
/// <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 Component 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.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
this.serviceProcessInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceProcessInstaller1_AfterInstall);
//
// serviceInstaller1
//
this.serviceInstaller1.Description = "Analysis Services Trace Sample Service";
this.serviceInstaller1.DisplayName = "ASTrace";
this.serviceInstaller1.ServiceName = "ASTrace";
this.serviceInstaller1.BeforeUninstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_BeforeUninstall);
this.serviceInstaller1.AfterInstall += new System.Configuration.Install.InstallEventHandler(this.serviceInstaller1_AfterInstall);
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
namespace ASTrace
{
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
Microsoft.Win32.RegistryKey software, microsoft, astrace;
software = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE");
microsoft = software.OpenSubKey("Microsoft", true);
astrace = microsoft.CreateSubKey("ASTrace");
astrace.SetValue("path", Environment.CurrentDirectory);
}
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
}
private void serviceInstaller1_BeforeUninstall(object sender, InstallEventArgs e)
{
try
{
Microsoft.Win32.RegistryKey software, microsoft;
software = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE");
microsoft = software.OpenSubKey("Microsoft",true);
microsoft.DeleteSubKey("ASTrace");
}
catch { }
}
}
}

View File

@ -0,0 +1,129 @@
<?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=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>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 11</value>
</metadata>
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>221, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -0,0 +1,36 @@
using System;
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("ASTrace")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ASTrace")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[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)]
[assembly: CLSCompliant(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("49f2e12f-ed21-4372-9097-ee25cb7318ff")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]

View File

@ -0,0 +1,116 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.5466
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ASTrace.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.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.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string AnalysisServerName {
get {
return ((string)(this["AnalysisServerName"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("localhost")]
public string SQLServer {
get {
return ((string)(this["SQLServer"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("TraceDB")]
public string SQLServerDatabase {
get {
return ((string)(this["SQLServerDatabase"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("ASTraceTable")]
public string TraceTableName {
get {
return ((string)(this["TraceTableName"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Standard.tdf")]
public string TraceDefinition {
get {
return ((string)(this["TraceDefinition"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool PreserveHistory {
get {
return ((bool)(this["PreserveHistory"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string AnalysisServerNames {
get {
return ((string)(this["AnalysisServerNames"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool AppendDateToSQLTable {
get {
return ((bool)(this["AppendDateToSQLTable"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("3")]
public int RestartRetries {
get {
return ((int)(this["RestartRetries"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("5")]
public int RestartDelayMinutes {
get {
return ((int)(this["RestartDelayMinutes"]));
}
}
}
}

View File

@ -0,0 +1,36 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ASTrace.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="AnalysisServerName" Type="System.String" Scope="Application">
<Value Profile="(Default)" />
</Setting>
<Setting Name="SQLServer" Type="System.String" Scope="Application">
<Value Profile="(Default)">localhost</Value>
</Setting>
<Setting Name="SQLServerDatabase" Type="System.String" Scope="Application">
<Value Profile="(Default)">TraceDB</Value>
</Setting>
<Setting Name="TraceTableName" Type="System.String" Scope="Application">
<Value Profile="(Default)">ASTraceTable</Value>
</Setting>
<Setting Name="TraceDefinition" Type="System.String" Scope="Application">
<Value Profile="(Default)">Standard.tdf</Value>
</Setting>
<Setting Name="PreserveHistory" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="AnalysisServerNames" Type="System.String" Scope="Application">
<Value Profile="(Default)" />
</Setting>
<Setting Name="AppendDateToSQLTable" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="RestartRetries" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">3</Value>
</Setting>
<Setting Name="RestartDelayMinutes" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">5</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,37 @@
namespace ASTrace
{
partial class Trace
{
/// <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 Component 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()
{
components = new System.ComponentModel.Container();
this.ServiceName = "ASTrace";
}
#endregion
}
}

View File

@ -0,0 +1,442 @@
/*============================================================================
File: Service1.cs
Summary: Contains class implementiong ASTrace service
Part of ASTrace
Date: January 2007
------------------------------------------------------------------------------
This file is part of the Microsoft SQL Server Code Samples.
Copyright (C) Microsoft Corporation. All rights reserved.
This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation. See these other
materials for detailed information regarding Microsoft code samples.
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
============================================================================*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.IO;
using Microsoft.SqlServer.Management.Trace;
using Microsoft.SqlServer.Management.Common;
namespace ASTrace
{
public partial class Trace : ServiceBase
{
List<Thread> workers = new List<Thread>();
string localPath;
List<string> _ServernamesList;
int _NumInstance;
TextWriter writer;
List<TraceServer> traceServers = new List<TraceServer>();
public Trace()
{
//Have seen errors here, normally when configuring for first time
//Note, the eventlog will need to create a source the very first time it runs and that needs admin privs.
try
{
InitializeComponent();
// Read registry to find out where the service executable is installed
Microsoft.Win32.RegistryKey software, microsoft, astrace;
software = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE");
microsoft = software.OpenSubKey("Microsoft");
astrace = microsoft.OpenSubKey("ASTrace");
localPath = (string)astrace.GetValue("path");
writer = new StreamWriter(localPath + "\\ASTraceService.log", true);
WriteLog(DateTime.Now.ToString() + ": Service Started in '" + localPath + "'");
}
catch (Exception ex)
{
StringBuilder messageText = new StringBuilder();
messageText.Append("Failed to write to log file ").AppendLine();
messageText.Append("Error: " + ex.Message).AppendLine();
while (ex.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(ex.InnerException.Message).AppendLine();
messageText.Append(ex.InnerException.StackTrace).AppendLine();
ex = ex.InnerException;
}
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Error);
}
}
protected override void OnStart(string[] args)
{
if (Properties.Settings.Default.AppendDateToSQLTable && Properties.Settings.Default.PreserveHistory)
{
StringBuilder messageText = new StringBuilder();
messageText.Append(DateTime.Now.ToString() + ": Both AppendDateToSQLTable and PreserveHistory cannot be true!");
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Error);
WriteLog(messageText.ToString());
Stop();
return;
}
//Initial startup so get the server list
string sServerNames = Properties.Settings.Default.AnalysisServerName + "," + Properties.Settings.Default.AnalysisServerNames;
_ServernamesList = new List<string>(sServerNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
//Get the number of servers so we can maintain legacy behaviour
_NumInstance = _ServernamesList.Count;
foreach (string SSASserver in _ServernamesList)
{
//Spin up a thread to write the trace to SQL
Thread worker = new Thread(DoWork);
workers.Add(worker);
//Start the tracing and pass SSAS Server name so we can handle retries
worker.Start(SSASserver);
}
}
bool ConnectOlap(out TraceServer traceServer, string SSASserver)
{
OlapConnectionInfo ci = new OlapConnectionInfo();
traceServer = new TraceServer();
StringBuilder messageText = new StringBuilder();
try
{
ci.UseIntegratedSecurity = true;
ci.ServerName = SSASserver;
string tracetemplate = localPath + "\\" + Properties.Settings.Default.TraceDefinition;
traceServer.InitializeAsReader(ci, tracetemplate);
lock (traceServers)
{
traceServers.Add(traceServer);
}
messageText.Append(
DateTime.Now.ToString()
+ ": Created trace for Analysis Server : '"
+ SSASserver
+ "'");
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Information);
return true;
}
catch (Exception e)
{
messageText.Append(DateTime.Now.ToString() + ": Cannot start Analysis Server trace: ").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Analysis Server name: '" + SSASserver + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Trace definition : '" + localPath + "\\" + Properties.Settings.Default.TraceDefinition + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Error: " + e.Message).AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Stack Trace: " + e.StackTrace).AppendLine();
while (e.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(e.InnerException.Message).AppendLine();
messageText.Append(e.InnerException.StackTrace).AppendLine();
e = e.InnerException;
}
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Error);
return false;
}
}
bool ConnectSQL(ref TraceServer traceServer, out TraceTable tableWriter, string SSASserver)
{
SqlConnectionInfo connInfo = new SqlConnectionInfo(Properties.Settings.Default.SQLServer);
StringBuilder messageText = new StringBuilder();
string _AppendInst = "_" + SSASserver;
string _SQLTable;
string _AppendDate;
//Maintains legacy logic where by a server with single instance does not have any inst names appended.
if (_NumInstance == 1)
_AppendInst = "";
//Append data to end of SQL table. Useful as an alternative to preserver SQL but data only survives 1 restart a day and you need cleanup logic in SQL Server
if (Properties.Settings.Default.AppendDateToSQLTable)
_AppendDate = "_" + DateTime.Now.ToString("yyyyMMdd");
else
_AppendDate = "";
_SQLTable =
Properties.Settings.Default.TraceTableName
+ _AppendInst
+ _AppendDate;
if (Properties.Settings.Default.PreserveHistory)
PreserveSQLHistory(ref _SQLTable);
tableWriter = new TraceTable();
try
{
connInfo.DatabaseName = Properties.Settings.Default.SQLServerDatabase;
tableWriter.InitializeAsWriter(traceServer, connInfo, _SQLTable);
messageText.Append(DateTime.Now.ToString() + ": Created Analysis Server trace table: '" + _SQLTable + "' on SQL Server: '" + Properties.Settings.Default.SQLServer
+ "' in database: " + Properties.Settings.Default.SQLServerDatabase + "'");
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Information);
return true;
}
catch (Exception e)
{
messageText.Append(DateTime.Now.ToString() + ": Cannot create Analysis Server trace table: '" + SSASserver + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": SQL Server Name: '" + Properties.Settings.Default.SQLServer + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": SQL Server Database : '" + Properties.Settings.Default.SQLServerDatabase + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": SQL Server Table : '" + _SQLTable + "'").AppendLine();
messageText.Append(DateTime.Now.ToString() + ": Error: " + e.Message).AppendLine();
while (e.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(e.InnerException.Message).AppendLine();
messageText.Append(e.InnerException.StackTrace.ToString()).AppendLine();
e = e.InnerException;
}
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Error);
return false;
}
}
void PreserveSQLHistory(ref string _SQLTable)
{
string sHistorySuffix = "History";
if (_NumInstance > 1)
{
sHistorySuffix = "_History";
}
StringBuilder messageText = new StringBuilder();
try
{
SqlConnectionInfo connInfo = new SqlConnectionInfo(Properties.Settings.Default.SQLServer);
IDbConnection conn = connInfo.CreateConnectionObject();
conn.Open();
conn.ChangeDatabase(Properties.Settings.Default.SQLServerDatabase);
string sSQL = @"if object_id('[" + _SQLTable.Replace("'", "''") + @"]') is not null
select top 1 * from [" + _SQLTable.Replace("]", "]]") + "]";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sSQL, (System.Data.SqlClient.SqlConnection)conn);
cmd.CommandTimeout = 0;
System.Data.SqlClient.SqlDataReader datareader = cmd.ExecuteReader();
string sColumns = "";
for (int i = 0; i < datareader.FieldCount; i++)
{
if (!string.IsNullOrEmpty(sColumns)) sColumns += ", ";
sColumns += "[" + datareader.GetName(i) + "]";
}
datareader.Close();
if (sColumns != "")
{
sSQL = @"
if object_id('[" + _SQLTable.Replace("'", "''") + @"]') is not null
begin
if object_id('[" + _SQLTable.Replace("'", "''") + sHistorySuffix + @"]') is null
begin
select * into [" + _SQLTable.Replace("]", "]]") + sHistorySuffix + "] from [" + _SQLTable.Replace("]", "]]") + @"]
end
else
begin
SET IDENTITY_INSERT [" + _SQLTable.Replace("]", "]]") + sHistorySuffix + @"] ON
insert into [" + _SQLTable.Replace("]", "]]") + sHistorySuffix + "] (" + sColumns + @")
select * from [" + _SQLTable.Replace("]", "]]") + @"]
SET IDENTITY_INSERT [" + _SQLTable.Replace("]", "]]") + sHistorySuffix + @"] OFF
end
end
";
cmd.CommandText = sSQL;
int iRowsPreserved = cmd.ExecuteNonQuery();
messageText.Append(DateTime.Now.ToString() + ": Successfully preserved " + iRowsPreserved + " rows of history to table: " + _SQLTable + sHistorySuffix);
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Information);
}
conn.Close();
conn.Dispose();
}
catch (Exception ex)
{
messageText.Append(DateTime.Now.ToString() + ": Cannot preserve history of trace table. ").AppendLine();
messageText.Append("Error: " + ex.Message).AppendLine();
messageText.Append(ex.StackTrace).AppendLine();
while (ex.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(ex.InnerException.Message).AppendLine();
messageText.Append(ex.InnerException.StackTrace).AppendLine();
ex = ex.InnerException;
}
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Warning);
}
}
void DoWork(object SSAS)
{
string SSASserver = (string)SSAS;
TraceTable _SQLDestTableWriter = null;
TraceServer _SSASSourceTraceServer = null;
int _RetryCounter = 0;
bool bFirstLoop = true;
while (bFirstLoop || _RetryCounter < Properties.Settings.Default.RestartRetries)
{
bFirstLoop = false;
try
{
//Grab connection to SSAS
bool bSuccess = ConnectOlap(out _SSASSourceTraceServer, SSASserver);
if (bSuccess)
{
//Grab connection to SQL and connect it with the SSAS trace
bSuccess = ConnectSQL(ref _SSASSourceTraceServer, out _SQLDestTableWriter, SSASserver);
if (bSuccess)
{
_RetryCounter = 0;
while (_SQLDestTableWriter.Write())
{
if (_SQLDestTableWriter.IsClosed)
throw new Exception("SQL connection closed unexpectedly.");
if (_SSASSourceTraceServer.IsClosed)
throw new Exception("SSAS connection closed unexpectedly.");
}
}
}
}
catch (Exception ex)
{
StringBuilder messageText = new StringBuilder();
messageText.Append(DateTime.Now.ToString() + ": Error reading trace: " + ex.Message).AppendLine();
messageText.Append(ex.StackTrace).AppendLine();
while (ex.InnerException != null)
{
messageText.Append("INNER EXCEPTION: ");
messageText.Append(ex.InnerException.Message).AppendLine();
messageText.Append(ex.InnerException.StackTrace).AppendLine();
ex = ex.InnerException;
}
WriteLog(messageText.ToString());
EventLog.WriteEntry(this.ServiceName, messageText.ToString(), EventLogEntryType.Warning);
}
try
{
_SSASSourceTraceServer.Stop();
_SSASSourceTraceServer.Close();
}
catch { }
try
{
_SQLDestTableWriter.Close();
}
catch { }
_RetryCounter++;
if (_RetryCounter < Properties.Settings.Default.RestartRetries)
{
StringBuilder messageText2 = new StringBuilder();
messageText2.Append(DateTime.Now.ToString() + ": Exception caught tracing server: " + SSASserver + ", retry " + _RetryCounter + " of " + Properties.Settings.Default.RestartRetries
+ ". Pausing for " + Properties.Settings.Default.RestartDelayMinutes + " minute(s) then restarting automatically"
).AppendLine();
WriteLog(messageText2.ToString());
EventLog.WriteEntry(this.ServiceName, messageText2.ToString(), EventLogEntryType.Warning);
System.Threading.Thread.Sleep(new TimeSpan(0, Properties.Settings.Default.RestartDelayMinutes, 0));
}
else
{
WriteLog(DateTime.Now.ToString() + ": Exceeded the number of allowed retries for server: " + SSASserver);
}
}
//if this one trace exceeded the number of retries so stop the service and stop all traces
Stop();
}
protected override void OnStop()
{
try
{
WriteLog(DateTime.Now.ToString() + ": Stopping");
writer.Close();
writer.Dispose();
}
catch { }
try
{
foreach (TraceServer ts in traceServers)
{
try
{
ts.Stop();
ts.Close();
ts.Dispose();
}
catch { }
}
}
catch { }
}
private void WriteLog(string sMessage)
{
lock (writer)
{
try
{
writer.WriteLine(sMessage);
writer.Flush();
}
catch { }
}
}
}
}

View File

@ -0,0 +1,28 @@
namespace ASTrace.Properties {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ASTrace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<ASTrace.Properties.Settings>
<setting name="AnalysisServerName" serializeAs="String">
<value />
</setting>
<setting name="SQLServer" serializeAs="String">
<value>localhost</value>
</setting>
<setting name="SQLServerDatabase" serializeAs="String">
<value>TraceDB</value>
</setting>
<setting name="TraceTableName" serializeAs="String">
<value>ASTraceTable</value>
</setting>
<setting name="TraceDefinition" serializeAs="String">
<value>Standard.tdf</value>
</setting>
<setting name="PreserveHistory" serializeAs="String">
<value>True</value>
</setting>
<setting name="AnalysisServerNames" serializeAs="String">
<value />
</setting>
<setting name="AppendDateToSQLTable" serializeAs="String">
<value>False</value>
</setting>
<setting name="RestartRetries" serializeAs="String">
<value>3</value>
</setting>
<setting name="RestartDelayMinutes" serializeAs="String">
<value>5</value>
</setting>
</ASTrace.Properties.Settings>
</applicationSettings>
</configuration>

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ASTrace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<ASTrace.Properties.Settings>
<setting name="AnalysisServerName" serializeAs="String">
<value />
</setting>
<setting name="SQLServer" serializeAs="String">
<value>localhost</value>
</setting>
<setting name="SQLServerDatabase" serializeAs="String">
<value>TraceDB</value>
</setting>
<setting name="TraceTableName" serializeAs="String">
<value>ASTraceTable</value>
</setting>
<setting name="TraceDefinition" serializeAs="String">
<value>Standard.tdf</value>
</setting>
<setting name="PreserveHistory" serializeAs="String">
<value>True</value>
</setting>
<setting name="AnalysisServerNames" serializeAs="String">
<value />
</setting>
<setting name="AppendDateToSQLTable" serializeAs="String">
<value>False</value>
</setting>
<setting name="RestartRetries" serializeAs="String">
<value>3</value>
</setting>
<setting name="RestartDelayMinutes" serializeAs="String">
<value>5</value>
</setting>
</ASTrace.Properties.Settings>
</applicationSettings>
</configuration>

View File

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ASTrace.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<ASTrace.Properties.Settings>
<setting name="AnalysisServerName" serializeAs="String">
<value />
</setting>
<setting name="SQLServer" serializeAs="String">
<value>localhost</value>
</setting>
<setting name="SQLServerDatabase" serializeAs="String">
<value>TraceDB</value>
</setting>
<setting name="TraceTableName" serializeAs="String">
<value>ASTraceTable</value>
</setting>
<setting name="TraceDefinition" serializeAs="String">
<value>Standard.tdf</value>
</setting>
<setting name="PreserveHistory" serializeAs="String">
<value>True</value>
</setting>
<setting name="AnalysisServerNames" serializeAs="String">
<value />
</setting>
<setting name="AppendDateToSQLTable" serializeAs="String">
<value>False</value>
</setting>
<setting name="RestartRetries" serializeAs="String">
<value>3</value>
</setting>
<setting name="RestartDelayMinutes" serializeAs="String">
<value>5</value>
</setting>
</ASTrace.Properties.Settings>
</applicationSettings>
</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,8 @@
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.exe.config
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.exe
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.pdb
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace2012.csprojResolveAssemblyReference.cache
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.ProjectInstaller.resources
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace2012.csproj.GenerateResource.Cache
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.exe
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.pdb

View File

@ -0,0 +1,16 @@
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.exe.config
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.exe
C:\ASTrace\CS\ASTrace\bin\Debug\ASTrace.pdb
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace2014.csprojResolveAssemblyReference.cache
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.ProjectInstaller.resources
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace2014.csproj.GenerateResource.Cache
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.exe
C:\ASTrace\CS\ASTrace\obj\Debug\ASTrace.pdb
C:\ASTrace\CS - 2016\ASTrace\bin\Debug\ASTrace.exe.config
C:\ASTrace\CS - 2016\ASTrace\obj\Debug\ASTrace.exe
C:\ASTrace\CS - 2016\ASTrace\obj\Debug\ASTrace.pdb
C:\ASTrace\CS - 2016\ASTrace\bin\Debug\ASTrace.exe
C:\ASTrace\CS - 2016\ASTrace\bin\Debug\ASTrace.pdb
C:\ASTrace\CS - 2016\ASTrace\obj\Debug\ASTrace2014.csprojResolveAssemblyReference.cache
C:\ASTrace\CS - 2016\ASTrace\obj\Debug\ASTrace.ProjectInstaller.resources
C:\ASTrace\CS - 2016\ASTrace\obj\Debug\ASTrace2014.csproj.GenerateResource.Cache

View File

@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT"
}

Binary file not shown.

View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASTrace2016", "ASTrace\ASTrace2016.csproj", "{1B1359C0-AD58-4B92-966D-0110733AD0FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B1359C0-AD58-4B92-966D-0110733AD0FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

Binary file not shown.

Binary file not shown.

21
AsTrace/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 karanspeaks
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.

2
AsTrace/README.md Normal file
View File

@ -0,0 +1,2 @@
# SQL-Server-Analysis-Services-Community-Samples
This project contains SQL Server Analysis Services samples.