Skip to content

Commit

Permalink
Merge branch 'master' into release/v1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric L. Charlier committed Jul 11, 2015
2 parents 8acb514 + 0672ebe commit d3c9664
Show file tree
Hide file tree
Showing 27 changed files with 487 additions and 101 deletions.
96 changes: 48 additions & 48 deletions .hgignore → .gitignore
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
# Ignore file for Visual Studio 2008
# use glob syntax
syntax: glob
# Ignore Visual Studio 2008 files
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
[Ii]nspiration/
[Pp]ackages/
*.user.config
NUnit.exe.lnk
NBi.ncrunchsolution
[Dd]ocumentation*/
*.orig
*.dgml
.JustCode/
.nuget/[Nn]u[Gg]et.exe
*.vsp
*.psess
Thumbs.db
*.rej
# Ignore file for Visual Studio 2008

# use glob syntax
syntax: glob

# Ignore Visual Studio 2008 files
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
[Ii]nspiration/
[Pp]ackages/
*.user.config
NUnit.exe.lnk
NBi.ncrunchsolution
[Dd]ocumentation*/
*.orig
*.dgml
.JustCode/
.nuget/[Nn]u[Gg]et.exe
*.vsp
*.psess
Thumbs.db
*.rej
*.diff
9 changes: 3 additions & 6 deletions NBi.Core/NBi.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@
<Reference Include="Antlr4.StringTemplate">
<HintPath>..\packages\Antlr4.StringTemplate.4.0.6.9004\lib\net35\Antlr4.StringTemplate.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.AnalysisServices.DLL</HintPath>
</Reference>
<Reference Include="Microsoft.AnalysisServices.AdomdClient, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>../../../../../../../Program%20Files/Microsoft.NET/ADOMD.NET/100/Microsoft.AnalysisServices.AdomdClient.dll</HintPath>
<Reference Include="Microsoft.AnalysisServices.AdomdClient, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>../../../../../../../Program%20Files/Microsoft.NET/ADOMD.NET/120/Microsoft.AnalysisServices.AdomdClient.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.SqlServer.ConnectionInfo, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
2 changes: 1 addition & 1 deletion NBi.Core/Structure/Olap/OlapStructureDiscoveryFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public StructureDiscoveryCommand Instantiate(Target target, TargetType type, IEn
var description = new CommandDescription(target, filters);

OlapCommand command = null;
if ((target == Target.MeasureGroups && type == TargetType.Object) || target == Target.Schemas || target == Target.Perspectives)
if ((target == Target.MeasureGroups && type == TargetType.Object) || target == Target.Perspectives)
command = new DistinctOlapCommand(cmd, postFilters, description);
else if (target == Target.Dimensions && type == TargetType.Object)
command = new DimensionCommand(cmd, postFilters, description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public ColumnDiscoveryCommandBuilder()
protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionFilter> filters)
{
yield return new CommandFilter(string.Format("[table_schema]='{0}'"
, filters.Single(f => f.Target == Target.Schemas).Caption
, filters.Single(f => f.Target == Target.Perspectives).Caption
));

yield return new CommandFilter(string.Format("[table_name]='{0}'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public SchemaDiscoveryCommandBuilder()

protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionFilter> filters)
{
var filter = filters.SingleOrDefault(f => f.Target == Target.Schemas);
var filter = filters.SingleOrDefault(f => f.Target == Target.Perspectives);
if (filter != null)
yield return new CommandFilter(string.Format("[schema_name]='{0}'"
, filter.Caption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public TableDiscoveryCommandBuilder()
protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionFilter> filters)
{
yield return new CommandFilter(string.Format("[table_schema]='{0}'"
, filters.Single(f => f.Target == Target.Schemas).Caption
, filters.Single(f => f.Target == Target.Perspectives).Caption
));

var filter = filters.SingleOrDefault(f => f.Target == Target.Tables);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected virtual IDiscoveryCommandBuilder InstantiateBuilder(Target target)
{
switch (target)
{
case Target.Schemas:
case Target.Perspectives:
return new SchemaDiscoveryCommandBuilder();
case Target.Tables:
return new TableDiscoveryCommandBuilder();
Expand Down
58 changes: 50 additions & 8 deletions NBi.Core/Structure/StructureDiscoveryFactoryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
using System.Data.Odbc;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;

namespace NBi.Core.Structure
{
Expand Down Expand Up @@ -68,23 +70,63 @@ protected virtual string InquireFurtherAnalysisService(string connectionString)
{
try
{
var server = new Server();
server.Connect(connectionString);
switch (server.ServerMode)
var parsedMode = string.Empty;
using (var conn = new AdomdConnection(connectionString))
{
case ServerMode.Default: return Olap;
case ServerMode.Multidimensional: return Olap;
case ServerMode.SharePoint: return Tabular;
case ServerMode.Tabular: return Tabular;
conn.Open();
var restrictions = new AdomdRestrictionCollection();
restrictions.Add(new AdomdRestriction("ObjectExpansion", "ReferenceOnly"));
var ds = conn.GetSchemaDataSet("DISCOVER_XML_METADATA", restrictions);
var xml = ds.Tables[0].Rows[0].ItemArray[0].ToString();
var doc = new XmlDocument();
doc.LoadXml(xml);
parsedMode = ParseXmlaResponse(doc);
}


switch (parsedMode)
{
case "Default": return Olap;
case "Multidimensional": return Olap;
case "SharePoint": return Tabular;
case "Tabular": return Tabular;
}
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLineIf(NBiTraceSwitch.TraceWarning,"Can't detect server mode for SSAS, using Olap:" + ex.Message);
Trace.WriteLineIf(NBiTraceSwitch.TraceWarning,"Can't detect server mode for SSAS, using Olap. Initial message:" + ex.Message);
return Olap;
}
return Olap;

}

protected string ParseXmlaResponse(XmlDocument doc)
{
var root = doc.DocumentElement;

var nm = new XmlNamespaceManager(doc.NameTable);
nm.AddNamespace("ddl300", "http://schemas.microsoft.com/analysisservices/2011/engine/300");
nm.AddNamespace("default", "http://schemas.microsoft.com/analysisservices/2003/engine");
var serverModeNode = root.SelectSingleNode("//ddl300:ServerMode", nm);
if (serverModeNode == null)
{
Trace.WriteLineIf(NBiTraceSwitch.TraceVerbose, "Trying to detect the server mode for SSAS but the server doesn't return this information. Trying to get it from version.");
var versionNode = root.SelectSingleNode("//default:Version", nm);
if (versionNode != null)
{
var splitVersion = versionNode.InnerText.Split('.');
short releaseVersion = 0;
if (splitVersion.Count() >= 1)
if (short.TryParse(splitVersion[0], out releaseVersion))
if (releaseVersion < 11)
return "Multidimensional";
throw new ArgumentException(string.Format("Unable to locate the node for 'ServerMode' and can't guess based on node 'Version'. Value returned for version is '{0}'. Use AdomdClient 12.0 or higher.", versionNode.InnerText));
}
throw new ArgumentException("Unable to locate the node for 'ServerMode' or the node for 'Version'. Use AdomdClient 12.0 or higher.");
}

return serverModeNode.InnerText;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionF
{
yield return new CommandFilter("column_name<>'RowNumber'");

var filter = filters.SingleOrDefault(f => f.Target == Target.Schemas);
var filter = filters.SingleOrDefault(f => f.Target == Target.Perspectives);
if (filter != null)
yield return new CommandFilter(string.Format("[table_schema]='{0}'"
, filters.Single(f => f.Target == Target.Schemas).Caption
, filters.Single(f => f.Target == Target.Perspectives).Caption
));

yield return new CommandFilter(string.Format("[table_name]='${0}'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionF
yield return new CommandFilter("left(table_schema,1)<>'$'");


var filter = filters.SingleOrDefault(f => f.Target == Target.Schemas);
var filter = filters.SingleOrDefault(f => f.Target == Target.Perspectives);
if (filter != null)
yield return new CommandFilter(string.Format("[table_schema]='{0}'"
, filter.Caption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override IEnumerable<ICommandFilter> BuildFilters(IEnumerable<CaptionF
{
yield return new CommandFilter("left(table_name,1)<>'$'");

var filter = filters.SingleOrDefault(f => f.Target == Target.Schemas);
var filter = filters.SingleOrDefault(f => f.Target == Target.Perspectives);
if (filter != null)
yield return new CommandFilter(string.Format("[table_schema]='{0}'"
, filter.Caption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ protected override IDiscoveryCommandBuilder InstantiateBuilder(Target target, Ta
return new ColumnDiscoveryCommandBuilder();
case Target.Sets:
return new SetDiscoveryCommandBuilder();
case Target.Schemas:
return new SchemaDiscoveryCommandBuilder();
default:
throw new ArgumentOutOfRangeException();
}
Expand Down
3 changes: 1 addition & 2 deletions NBi.Core/Structure/Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public enum Target
Properties,
Tables,
Columns,
Sets,
Schemas
Sets
}
}
Loading

0 comments on commit d3c9664

Please sign in to comment.